From 995a0bf0ae8f7e397579afd5b813a147ca225ee6 Mon Sep 17 00:00:00 2001 From: Katelyn FitzGerald <7872563+kafitzgerald@users.noreply.github.com> Date: Wed, 9 Oct 2024 17:33:27 -0600 Subject: [PATCH] Address SciPy interp2d deprecation (#615) * use xarray's interp instead * remove env pin --- Gallery/Vectors/NCL_vector_5.py | 12 ++++-------- conda_environment.yml | 5 ++--- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Gallery/Vectors/NCL_vector_5.py b/Gallery/Vectors/NCL_vector_5.py index fb38aec7e..67e1c2a7c 100644 --- a/Gallery/Vectors/NCL_vector_5.py +++ b/Gallery/Vectors/NCL_vector_5.py @@ -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, diff --git a/conda_environment.yml b/conda_environment.yml index 769d05b90..ec0bfbe9b 100644 --- a/conda_environment.yml +++ b/conda_environment.yml @@ -19,7 +19,7 @@ dependencies: - pillow - pip - scikit-learn - - scipy<1.14 + - scipy - sphinx<7 - sphinx-book-theme - sphinx-design @@ -27,5 +27,4 @@ dependencies: - xarray - dask - wrf-python - - pip: - - pre-commit + - pre-commit