Skip to content

Add custom gradient function #174

Closed
Closed

Description

@dopplershift

It seems np.gradient doesn't support arrays for dx, etc. For a case where we want to compute the geostrophic wind on a lat/lon grid (like GFS), we have a varying dx. Time for our own I guess.

Activity

  1. deeplycloudy commented on Jul 1, 2016

    @deeplycloudy
    Contributor

    A while ago I wrote a 4th order accurate gradient and third order accurate second derivative (along each axis) function. From a quick glance at it, it looks like it might adapt trivially to arrays of dx. I put it in a gist, which you're free to use.

    https://gist.github.com/deeplycloudy/1b9fa46d5290314d9be02a5156b48741

  2. sgdecker commented on Sep 26, 2016

    @sgdecker
    Contributor

    I believe this issue explains why the geostrophic winds in the example at https://github.com/Unidata/notebook-gallery/blob/master/notebooks/Geostrophic_Wind_Example.ipynb are close to but not exactly parallel to the height contours.

  3. modified the milestone: on Mar 10, 2017
  4. modified the milestones: , on Apr 18, 2017
  5. dopplershift commented on Apr 18, 2017

    @dopplershift
    MemberAuthor

    Move up in priority since numpy 1.12 has broken the ability to pass arrays for dx/dy. We just need to move to our own, likely based on @deeplycloudy 's implementation. (cc @kgoebber )

  6. deeplycloudy commented on Apr 24, 2017

    @deeplycloudy
    Contributor

    It's mentioned in the comment at the top of the gist, but my implementation should drop in easily, since it was based on the version in numpy. It's worth noting that the implementation extends easily to vectorizing other derivative stencils of various orders of accuracy.

  7. dopplershift commented on Apr 24, 2017

    @dopplershift
    MemberAuthor

    I agree, but I can't help but think of this:

    xkcd 974

  8. deeplycloudy commented on Apr 24, 2017

    @deeplycloudy
    Contributor

    I believe that's called Mathematica

  9. laufers commented on Apr 25, 2017

    @laufers
  10. lesserwhirls commented on Apr 25, 2017

    @lesserwhirls
    Member

    ...a few of us resemble that remark...

  11. removed this from the 0.6 milestone on Jul 19, 2017
  12. 10 remaining items

  13. dopplershift commented on Sep 21, 2017

    @dopplershift
    MemberAuthor

    Not sure, but numpy/numpy#9408 (for 1.13.2) may restore the variable differences.

  14. eric-wieser commented on Sep 21, 2017

    @eric-wieser

    @dopplershift: Passing anything other than 1D arrays was never supported, and computed incorrect results. 1.13.2 just raises an error in those cases instead

  15. dopplershift commented on Sep 21, 2017

    @dopplershift
    MemberAuthor

    Good to know, thx.

  16. sgdecker commented on Oct 25, 2017

    @sgdecker
    Contributor

    The following reference (especially the first three equations) might have some useful info for computing the gradient (and other quantities that involve the del operator like divergence) properly on non-uniform grids:
    http://www1.arl.noaa.gov/documents/reports/cmapf.pdf
    Looks like the routines still exist at https://www.arl.noaa.gov/HYSPLIT_cmapf.php as well.

  17. dopplershift commented on Oct 25, 2017

    @dopplershift
    MemberAuthor

    Thanks @sgdecker ! We'll have a look.

  18. modified the milestones: Fall 2017, on Oct 26, 2017
  19. self-assigned this
    on Dec 7, 2017
  20. dopplershift commented on Dec 13, 2017

    @dopplershift
    MemberAuthor

    Here's an updated link for the NOAA stuff: https://www.arl.noaa.gov/hysplit/cmapf-mapping-routines/

    I think we'll defer on the issues with projected coordinate systems in the short term, but I should get in a PR in a bit that tackles the non-uniform issue.

  21. dopplershift commented on Jan 25, 2018

    @dopplershift
    MemberAuthor

    Re-opening to remind us to tackle the coordinate system issues.

  22. removed this from the 0.7 milestone on Jan 25, 2018
  23. dopplershift commented on Jul 31, 2018

    @dopplershift
    MemberAuthor

    We can continue to talk about the map projection issues in #893.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: CalcPertains to calculationsType: EnhancementEnhancement to existing functionality

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions