Skip to content

Commit f7ac168

Browse files
authored
Merge pull request #97 from kthyng/xesmf
small changes so that using xESMF as horizontal interpolator works
2 parents 7070404 + 22af9c6 commit f7ac168

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

docs/whats_new.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
:mod:`What's New`
22
-----------------
33

4+
v1.4.0 (November 6, 2023)
5+
=========================
6+
* small changes so that using xESMF as horizontal interpolator works
7+
48
v1.3.0 (October 11, 2023)
59
=========================
610
* Incorporated `locstreamT` and `locstreamZ` to standardize the options available to user in `em.select()`.

extract_model/extract_model.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ def make_output_ds(longitude, latitude, locstream=False):
174174
elif latitude.ndim == 2:
175175
ds_out = xr.Dataset(
176176
{
177+
"X": ("X", np.arange(longitude.shape[1]), {"axis": "X"}),
178+
"Y": ("Y", np.arange(longitude.shape[0]), {"axis": "Y"}),
177179
"lat": (
178180
["Y", "X"],
179181
latitude,
@@ -186,8 +188,6 @@ def make_output_ds(longitude, latitude, locstream=False):
186188
),
187189
}
188190
)
189-
ds_out["X"].attrs["axis"] = "X"
190-
ds_out["Y"].attrs["axis"] = "Y"
191191
else:
192192
raise IndexError(f"{latitude.ndim}D latitude/longitude arrays not supported.")
193193

@@ -392,7 +392,11 @@ def select(
392392
weights=weights,
393393
)
394394
kwargs_out["weights"] = weights
395-
395+
kwargs_out["interp_coords"] = {}
396+
elif not XESMF_AVAILABLE and horizontal_interp_code == "xesmf":
397+
raise ModuleNotFoundError(
398+
"xESMF is not available so horizontal interpolation in 2D cannot be performed."
399+
)
396400
elif horizontal_interp_code == "delaunay":
397401

398402
# This might be faster for interpolation between a few points and many points
@@ -542,11 +546,8 @@ def pt_in_itriangle_proj(ix, iy):
542546
# interp_coords are the coords and indices that went into the interpolation
543547
da, interp_coords = interp_with_barycentric(da, ixs, iys, lam)
544548
kwargs_out["interp_coords"] = interp_coords
545-
546549
else:
547-
raise ModuleNotFoundError(
548-
"xESMF is not available so horizontal interpolation in 2D cannot be performed."
549-
)
550+
raise RuntimeError("Horizontal interpolation cannot be run.")
550551

551552
end_time = time()
552553
print("time: ", end_time - start_time)

0 commit comments

Comments
 (0)