Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address SciPy interp2d deprecation #615

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading