11from __future__ import annotations
22
3+ from typing import Literal
4+
35import numpy as np
46import uxarray as ux
57from uxarray .grid .neighbors import _barycentric_coordinates
810
911from .basegrid import BaseGrid
1012
13+ _UXGRID_AXES = Literal ["Z" , "CELL" ]
14+
1115
1216class UxGrid (BaseGrid ):
1317 """
@@ -49,9 +53,7 @@ def depth(self):
4953 return np .zeros (1 )
5054 return self .z .values
5155
52- def search (
53- self , z : float , y : float , x : float , ei : int | None = None , search2D : bool = False
54- ) -> tuple [np .ndarray , int ]:
56+ def search (self , z , y , x , ei = None ):
5557 tol = 1e-10
5658
5759 def try_face (fid ):
@@ -61,18 +63,15 @@ def try_face(fid):
6163 return None , None
6264
6365 def find_vertical_index () -> int :
64- if search2D :
66+ nz = self .z .shape [0 ]
67+ if nz == 1 :
6568 return 0
66- else :
67- nz = self .z .shape [0 ]
68- if nz == 1 :
69- return 0
70- zf = self .z .values
71- # Return zi such that zf[zi] <= z < zf[zi+1]
72- zi = np .searchsorted (zf , z , side = "right" ) - 1 # Search assumes that z is positive and increasing with i
73- if zi < 0 or zi >= nz - 1 :
74- raise FieldOutOfBoundError (z , y , x )
75- return zi
69+ zf = self .z .values
70+ # Return zi such that zf[zi] <= z < zf[zi+1]
71+ zi = np .searchsorted (zf , z , side = "right" ) - 1 # Search assumes that z is positive and increasing with i
72+ if zi < 0 or zi >= nz - 1 :
73+ raise FieldOutOfBoundError (z , y , x )
74+ return zi
7675
7776 zi = find_vertical_index () # Find the vertical cell center nearest to z
7877
0 commit comments