Skip to content

Commit

Permalink
Address SciPy interp2d deprecation (#615)
Browse files Browse the repository at this point in the history
* use xarray's interp instead

* remove env pin
  • Loading branch information
kafitzgerald authored Oct 9, 2024
1 parent 957aeb0 commit 995a0bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
12 changes: 4 additions & 8 deletions Gallery/Vectors/NCL_vector_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,15 @@

# We attempt to recreate curly vectors with Matplotlib's streamplot function.
# streamplot requires the input parameter x, y to be evenly spaced strictly increasing arrays.
# Therefore we interpolate the original dataset onto an manually set, evenly spaced grid.
# There are probably more suitable interpolation routines than scipy's interp2d,
# but we do not have a standardized procedure for interpolation for streamplot as of this point.
# Therefore we interpolate the original dataset onto an evenly spaced grid that we generate below.

# regularly spaced grid spanning the domain of x and y
xi = np.linspace(T['lat'].min(), T['lat'].max(), T['lat'].size)
yi = np.linspace(T['plev'].min(), T['plev'].max(), T['plev'].size)

# interp2d function creates interpolator classes
u_func = interp2d(T['lat'], T['plev'], V)
v_func = interp2d(T['lat'], T['plev'], wscale)
uCi = u_func(xi, yi)
vCi = v_func(xi, yi)
# use xarray's interp to interpolate onto the new grid
uCi = V.interp(lat=xi, plev=yi)
vCi = wscale.interp(lat=xi, plev=yi)

# Use streamplot to match curly vector
ax.streamplot(xi,
Expand Down
5 changes: 2 additions & 3 deletions conda_environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ dependencies:
- pillow
- pip
- scikit-learn
- scipy<1.14
- scipy
- sphinx<7
- sphinx-book-theme
- sphinx-design
- sphinx-gallery
- xarray
- dask
- wrf-python
- pip:
- pre-commit
- pre-commit

0 comments on commit 995a0bf

Please sign in to comment.