@@ -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