You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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 )
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.
@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
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.
Activity
deeplycloudy commentedon Jul 1, 2016
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
sgdecker commentedon Sep 26, 2016
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.
dopplershift commentedon Apr 18, 2017
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 )
deeplycloudy commentedon Apr 24, 2017
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.
dopplershift commentedon Apr 24, 2017
I agree, but I can't help but think of this:
deeplycloudy commentedon Apr 24, 2017
I believe that's called Mathematica
laufers commentedon Apr 25, 2017
lesserwhirls commentedon Apr 25, 2017
...a few of us resemble that remark...
10 remaining items
dopplershift commentedon Sep 21, 2017
Not sure, but numpy/numpy#9408 (for 1.13.2) may restore the variable differences.
eric-wieser commentedon Sep 21, 2017
@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
dopplershift commentedon Sep 21, 2017
Good to know, thx.
sgdecker commentedon Oct 25, 2017
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.
dopplershift commentedon Oct 25, 2017
Thanks @sgdecker ! We'll have a look.
dopplershift commentedon Dec 13, 2017
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.
dopplershift commentedon Jan 25, 2018
Re-opening to remind us to tackle the coordinate system issues.
dopplershift commentedon Jul 31, 2018
We can continue to talk about the map projection issues in #893.