@@ -44,9 +44,10 @@ class Grid:
4444
4545 def __init__ (
4646 self ,
47- lon : npt .NDArray ,
47+ time : npt .NDArray ,
48+ depth : npt .NDArray ,
4849 lat : npt .NDArray ,
49- time : npt .NDArray | None ,
50+ lon : npt .NDArray ,
5051 time_origin : TimeConverter | None ,
5152 mesh : Mesh ,
5253 ):
@@ -71,6 +72,7 @@ def __init__(
7172
7273 self ._lon = lon
7374 self ._lat = lat
75+ self ._depth = depth
7476 self .time = time
7577 self .time_full = self .time # needed for deferred_loaded Fields
7678 self ._time_origin = TimeConverter () if time_origin is None else time_origin
@@ -98,7 +100,7 @@ def __repr__(self):
98100 with np .printoptions (threshold = 5 , suppress = True , linewidth = 120 , formatter = {"float" : "{: 0.2f}" .format }):
99101 return (
100102 f"{ type (self ).__name__ } ("
101- f"lon={ self .lon !r} , lat={ self .lat !r} , time={ self .time !r} , "
103+ f"lon={ self .lon !r} , lat={ self .lat !r} , time={ self .time !r} , depth= { self . depth !r } , "
102104 f"time_origin={ self .time_origin !r} , mesh={ self .mesh !r} )"
103105 )
104106
@@ -195,10 +197,10 @@ def load_chunk(self):
195197
196198 @staticmethod
197199 def create_grid (
198- lon : npt .ArrayLike ,
200+ time : npt .ArrayLike ,
201+ depth : npt .ArrayLike ,
199202 lat : npt .ArrayLike ,
200- depth ,
201- time ,
203+ lon : npt .ArrayLike ,
202204 time_origin ,
203205 mesh : Mesh ,
204206 ** kwargs ,
@@ -211,14 +213,14 @@ def create_grid(
211213
212214 if len (lon .shape ) <= 1 :
213215 if depth is None or len (depth .shape ) <= 1 :
214- return RectilinearZGrid (lon , lat , depth , time , time_origin = time_origin , mesh = mesh , ** kwargs )
216+ return RectilinearZGrid (time , depth , lat , lon , time_origin = time_origin , mesh = mesh , ** kwargs )
215217 else :
216- return RectilinearSGrid (lon , lat , depth , time , time_origin = time_origin , mesh = mesh , ** kwargs )
218+ return RectilinearSGrid (time , depth , lat , lon , time_origin = time_origin , mesh = mesh , ** kwargs )
217219 else :
218220 if depth is None or len (depth .shape ) <= 1 :
219- return CurvilinearZGrid (lon , lat , depth , time , time_origin = time_origin , mesh = mesh , ** kwargs )
221+ return CurvilinearZGrid (time , depth , lat , lon , time_origin = time_origin , mesh = mesh , ** kwargs )
220222 else :
221- return CurvilinearSGrid (lon , lat , depth , time , time_origin = time_origin , mesh = mesh , ** kwargs )
223+ return CurvilinearSGrid (time , depth , lat , lon , time_origin = time_origin , mesh = mesh , ** kwargs )
222224
223225 @property
224226 def ctypes_struct (self ):
@@ -461,14 +463,14 @@ class RectilinearGrid(Grid):
461463
462464 """
463465
464- def __init__ (self , lon , lat , time , time_origin , mesh : Mesh ):
466+ def __init__ (self , time , depth , lat , lon , time_origin , mesh : Mesh ):
465467 assert isinstance (lon , np .ndarray ) and len (lon .shape ) <= 1 , "lon is not a numpy vector"
466468 assert isinstance (lat , np .ndarray ) and len (lat .shape ) <= 1 , "lat is not a numpy vector"
467469 assert isinstance (time , np .ndarray ) or not time , "time is not a numpy array"
468470 if isinstance (time , np .ndarray ):
469471 assert len (time .shape ) == 1 , "time is not a vector"
470472
471- super ().__init__ (lon , lat , time , time_origin , mesh )
473+ super ().__init__ (time , depth , lat , lon , time_origin , mesh )
472474 self .tdim = self .time .size
473475
474476 if self .ydim > 1 and self .lat [- 1 ] < self .lat [0 ]:
@@ -559,8 +561,8 @@ class RectilinearZGrid(RectilinearGrid):
559561 2. flat: No conversion, lat/lon are assumed to be in m.
560562 """
561563
562- def __init__ (self , lon , lat , depth = None , time = None , time_origin = None , mesh : Mesh = "flat" ):
563- super ().__init__ (lon , lat , time , time_origin , mesh )
564+ def __init__ (self , time , depth , lat , lon , time_origin = None , mesh : Mesh = "flat" ):
565+ super ().__init__ (time , depth , lat , lon , time_origin , mesh )
564566 if isinstance (depth , np .ndarray ):
565567 assert len (depth .shape ) <= 1 , "depth is not a vector"
566568
@@ -592,7 +594,7 @@ class RectilinearSGrid(RectilinearGrid):
592594 which are s-coordinates.
593595 s-coordinates can be terrain-following (sigma) or iso-density (rho) layers,
594596 or any generalised vertical discretisation.
595- The depth of each node depends then on the horizontal position (lon, lat ),
597+ The depth of each node depends then on the horizontal position (lat, lon ),
596598 the number of the layer and the time is depth is a 4D array.
597599 depth array is either a 4D array[xdim][ydim][zdim][tdim] or a 3D array[xdim][ydim[zdim].
598600 time :
@@ -610,14 +612,14 @@ class RectilinearSGrid(RectilinearGrid):
610612
611613 def __init__ (
612614 self ,
613- lon : npt .NDArray ,
614- lat : npt .NDArray ,
615+ time : npt .NDArray ,
615616 depth : npt .NDArray ,
616- time : npt .NDArray | None = None ,
617+ lat : npt .NDArray ,
618+ lon : npt .NDArray ,
617619 time_origin : TimeConverter | None = None ,
618620 mesh : Mesh = "flat" ,
619621 ):
620- super ().__init__ (lon , lat , time , time_origin , mesh )
622+ super ().__init__ (time , depth , lat , lon , time_origin , mesh )
621623 assert isinstance (depth , np .ndarray ) and len (depth .shape ) in [3 , 4 ], "depth is not a 3D or 4D numpy array"
622624
623625 self ._gtype = GridType .RectilinearSGrid
@@ -656,9 +658,10 @@ def zdim(self):
656658class CurvilinearGrid (Grid ):
657659 def __init__ (
658660 self ,
659- lon : npt .NDArray ,
661+ time : npt .NDArray ,
662+ depth : npt .NDArray ,
660663 lat : npt .NDArray ,
661- time : npt .NDArray | None = None ,
664+ lon : npt .NDArray ,
662665 time_origin : TimeConverter | None = None ,
663666 mesh : Mesh = "flat" ,
664667 ):
@@ -670,7 +673,7 @@ def __init__(
670673
671674 lon = lon .squeeze ()
672675 lat = lat .squeeze ()
673- super ().__init__ (lon , lat , time , time_origin , mesh )
676+ super ().__init__ (time , None , lat , lon , time_origin , mesh )
674677 self .tdim = self .time .size
675678
676679 @property
@@ -770,14 +773,14 @@ class CurvilinearZGrid(CurvilinearGrid):
770773
771774 def __init__ (
772775 self ,
773- lon : npt .NDArray ,
776+ time : npt .NDArray ,
777+ depth : npt .NDArray ,
774778 lat : npt .NDArray ,
775- depth : npt .NDArray | None = None ,
776- time : npt .NDArray | None = None ,
779+ lon : npt .NDArray ,
777780 time_origin : TimeConverter | None = None ,
778781 mesh : Mesh = "flat" ,
779782 ):
780- super ().__init__ (lon , lat , time , time_origin , mesh )
783+ super ().__init__ (time , depth , lat , lon , time_origin , mesh )
781784 if isinstance (depth , np .ndarray ):
782785 assert len (depth .shape ) == 1 , "depth is not a vector"
783786
@@ -808,7 +811,7 @@ class CurvilinearSGrid(CurvilinearGrid):
808811 which are s-coordinates.
809812 s-coordinates can be terrain-following (sigma) or iso-density (rho) layers,
810813 or any generalised vertical discretisation.
811- The depth of each node depends then on the horizontal position (lon, lat ),
814+ The depth of each node depends then on the horizontal position (lat, lon ),
812815 the number of the layer and the time is depth is a 4D array.
813816 depth array is either a 4D array[xdim][ydim][zdim][tdim] or a 3D array[xdim][ydim[zdim].
814817 time :
@@ -826,14 +829,14 @@ class CurvilinearSGrid(CurvilinearGrid):
826829
827830 def __init__ (
828831 self ,
829- lon : npt .NDArray ,
830- lat : npt .NDArray ,
832+ time : npt .NDArray ,
831833 depth : npt .NDArray ,
832- time : npt .NDArray | None = None ,
834+ lat : npt .NDArray ,
835+ lon : npt .NDArray ,
833836 time_origin : TimeConverter | None = None ,
834837 mesh : Mesh = "flat" ,
835838 ):
836- super ().__init__ (lon , lat , time , time_origin , mesh )
839+ super ().__init__ (time , depth , lat , lon , time_origin , mesh )
837840 assert isinstance (depth , np .ndarray ) and len (depth .shape ) in [3 , 4 ], "depth is not a 4D numpy array"
838841
839842 self ._gtype = GridType .CurvilinearSGrid
0 commit comments