@@ -289,22 +289,13 @@ def search(self, z, y, x, ei=None):
289289 else :
290290 zi , zeta = np .zeros (z .shape , dtype = int ), np .zeros (z .shape , dtype = float )
291291
292- if ds .lon .ndim == 1 :
293- yi , eta = _search_1d_array (ds .lat .values , y )
294- xi , xsi = _search_1d_array (ds .lon .values , x )
295- return {
296- "Z" : {"index" : zi , "bcoord" : zeta },
297- "Y" : {"index" : yi , "bcoord" : eta },
298- "X" : {"index" : xi , "bcoord" : xsi },
299- }
292+ if "X" in self .axes and "Y" in self .axes and ds .lon .ndim == 2 :
293+ yi , xi = None , None
294+ if ei is not None :
295+ axis_indices = self .unravel_index (ei )
296+ xi = axis_indices .get ("X" )
297+ yi = axis_indices .get ("Y" )
300298
301- yi , xi = None , None
302- if ei is not None :
303- axis_indices = self .unravel_index (ei )
304- xi = axis_indices .get ("X" )
305- yi = axis_indices .get ("Y" )
306-
307- if ds .lon .ndim == 2 :
308299 yi , eta , xi , xsi = _search_indices_curvilinear_2d (self , y , x , yi , xi )
309300
310301 return {
@@ -313,7 +304,24 @@ def search(self, z, y, x, ei=None):
313304 "X" : {"index" : xi , "bcoord" : xsi },
314305 }
315306
316- raise NotImplementedError ("Searching in >2D lon/lat arrays is not implemented yet." )
307+ if "X" in self .axes and ds .lon .ndim > 2 :
308+ raise NotImplementedError ("Searching in >2D lon/lat arrays is not implemented yet." )
309+
310+ if "Y" in self .axes :
311+ yi , eta = _search_1d_array (ds .lat .values , y )
312+ else :
313+ yi , eta = np .zeros (y .shape , dtype = int ), np .zeros (y .shape , dtype = float )
314+
315+ if "X" in self .axes :
316+ xi , xsi = _search_1d_array (ds .lon .values , x )
317+ else :
318+ xi , xsi = np .zeros (x .shape , dtype = int ), np .zeros (x .shape , dtype = float )
319+
320+ return {
321+ "Z" : {"index" : zi , "bcoord" : zeta },
322+ "Y" : {"index" : yi , "bcoord" : eta },
323+ "X" : {"index" : xi , "bcoord" : xsi },
324+ }
317325
318326 @cached_property
319327 def _fpoint_info (self ):
0 commit comments