77import numpy .typing as npt
88
99from parcels ._typing import Mesh , UpdateStatus , assert_valid_mesh
10- from parcels .tools .converters import Geographic , GeographicPolar , TimeConverter , UnitConverter
10+ from parcels .tools .converters import Geographic , GeographicPolar , UnitConverter
1111from parcels .tools .warnings import FieldSetWarning
1212
1313__all__ = [
@@ -46,7 +46,6 @@ def __init__(
4646 lon : npt .NDArray ,
4747 lat : npt .NDArray ,
4848 time : npt .NDArray | None ,
49- time_origin : TimeConverter | None ,
5049 mesh : Mesh ,
5150 ):
5251 self ._ti = - 1
@@ -62,18 +61,11 @@ def __init__(
6261 lon = lon .astype (np .float32 )
6362 if not lat .dtype == np .float32 :
6463 lat = lat .astype (np .float32 )
65- if not time .dtype == np .float64 :
66- assert isinstance (
67- time [0 ], (np .integer , np .floating , float , int )
68- ), "Time vector must be an array of int or floats"
69- time = time .astype (np .float64 )
7064
7165 self ._lon = lon
7266 self ._lat = lat
7367 self .time = time
7468 self .time_full = self .time # needed for deferred_loaded Fields
75- self ._time_origin = TimeConverter () if time_origin is None else time_origin
76- assert isinstance (self .time_origin , TimeConverter ), "time_origin needs to be a TimeConverter object"
7769 assert_valid_mesh (mesh )
7870 self ._mesh = mesh
7971 self ._cstruct = None
@@ -98,7 +90,7 @@ def __repr__(self):
9890 return (
9991 f"{ type (self ).__name__ } ("
10092 f"lon={ self .lon !r} , lat={ self .lat !r} , time={ self .time !r} , "
101- f"time_origin= { self . time_origin !r } , mesh={ self .mesh !r} )"
93+ f"mesh={ self .mesh !r} )"
10294 )
10395
10496 @property
@@ -132,10 +124,6 @@ def meridional_halo(self):
132124 def lonlat_minmax (self ):
133125 return self ._lonlat_minmax
134126
135- @property
136- def time_origin (self ):
137- return self ._time_origin
138-
139127 @property
140128 def zonal_periodic (self ):
141129 return self ._zonal_periodic
@@ -158,7 +146,6 @@ def create_grid(
158146 lat : npt .ArrayLike ,
159147 depth ,
160148 time ,
161- time_origin ,
162149 mesh : Mesh ,
163150 ** kwargs ,
164151 ):
@@ -170,14 +157,14 @@ def create_grid(
170157
171158 if len (lon .shape ) <= 1 :
172159 if depth is None or len (depth .shape ) <= 1 :
173- return RectilinearZGrid (lon , lat , depth , time , time_origin = time_origin , mesh = mesh , ** kwargs )
160+ return RectilinearZGrid (lon , lat , depth , time , mesh = mesh , ** kwargs )
174161 else :
175- return RectilinearSGrid (lon , lat , depth , time , time_origin = time_origin , mesh = mesh , ** kwargs )
162+ return RectilinearSGrid (lon , lat , depth , time , mesh = mesh , ** kwargs )
176163 else :
177164 if depth is None or len (depth .shape ) <= 1 :
178- return CurvilinearZGrid (lon , lat , depth , time , time_origin = time_origin , mesh = mesh , ** kwargs )
165+ return CurvilinearZGrid (lon , lat , depth , time , mesh = mesh , ** kwargs )
179166 else :
180- return CurvilinearSGrid (lon , lat , depth , time , time_origin = time_origin , mesh = mesh , ** kwargs )
167+ return CurvilinearSGrid (lon , lat , depth , time , mesh = mesh , ** kwargs )
181168
182169 @property
183170 def ctypes_struct (self ):
@@ -378,14 +365,14 @@ class RectilinearGrid(Grid):
378365
379366 """
380367
381- def __init__ (self , lon , lat , time , time_origin , mesh : Mesh ):
368+ def __init__ (self , lon , lat , time , mesh : Mesh ):
382369 assert isinstance (lon , np .ndarray ) and len (lon .shape ) <= 1 , "lon is not a numpy vector"
383370 assert isinstance (lat , np .ndarray ) and len (lat .shape ) <= 1 , "lat is not a numpy vector"
384371 assert isinstance (time , np .ndarray ) or not time , "time is not a numpy array"
385372 if isinstance (time , np .ndarray ):
386373 assert len (time .shape ) == 1 , "time is not a vector"
387374
388- super ().__init__ (lon , lat , time , time_origin , mesh )
375+ super ().__init__ (lon , lat , time , mesh )
389376 self .tdim = self .time .size
390377
391378 if self .ydim > 1 and self .lat [- 1 ] < self .lat [0 ]:
@@ -465,8 +452,6 @@ class RectilinearZGrid(RectilinearGrid):
465452 The depth of the different layers is thus constant.
466453 time :
467454 Vector containing the time coordinates of the grid
468- time_origin : parcels.tools.converters.TimeConverter
469- Time origin of the time axis
470455 mesh : str
471456 String indicating the type of mesh coordinates and
472457 units used during velocity interpolation:
@@ -476,8 +461,8 @@ class RectilinearZGrid(RectilinearGrid):
476461 2. flat: No conversion, lat/lon are assumed to be in m.
477462 """
478463
479- def __init__ (self , lon , lat , depth = None , time = None , time_origin = None , mesh : Mesh = "flat" ):
480- super ().__init__ (lon , lat , time , time_origin , mesh )
464+ def __init__ (self , lon , lat , depth = None , time = None , mesh : Mesh = "flat" ):
465+ super ().__init__ (lon , lat , time , mesh )
481466 if isinstance (depth , np .ndarray ):
482467 assert len (depth .shape ) <= 1 , "depth is not a vector"
483468
@@ -514,8 +499,6 @@ class RectilinearSGrid(RectilinearGrid):
514499 depth array is either a 4D array[xdim][ydim][zdim][tdim] or a 3D array[xdim][ydim[zdim].
515500 time :
516501 Vector containing the time coordinates of the grid
517- time_origin : parcels.tools.converters.TimeConverter
518- Time origin of the time axis
519502 mesh : str
520503 String indicating the type of mesh coordinates and
521504 units used during velocity interpolation:
@@ -531,10 +514,9 @@ def __init__(
531514 lat : npt .NDArray ,
532515 depth : npt .NDArray ,
533516 time : npt .NDArray | None = None ,
534- time_origin : TimeConverter | None = None ,
535517 mesh : Mesh = "flat" ,
536518 ):
537- super ().__init__ (lon , lat , time , time_origin , mesh )
519+ super ().__init__ (lon , lat , time , mesh )
538520 assert isinstance (depth , np .ndarray ) and len (depth .shape ) in [3 , 4 ], "depth is not a 3D or 4D numpy array"
539521
540522 self ._gtype = GridType .RectilinearSGrid
@@ -576,7 +558,6 @@ def __init__(
576558 lon : npt .NDArray ,
577559 lat : npt .NDArray ,
578560 time : npt .NDArray | None = None ,
579- time_origin : TimeConverter | None = None ,
580561 mesh : Mesh = "flat" ,
581562 ):
582563 assert isinstance (lon , np .ndarray ) and len (lon .squeeze ().shape ) == 2 , "lon is not a 2D numpy array"
@@ -587,7 +568,7 @@ def __init__(
587568
588569 lon = lon .squeeze ()
589570 lat = lat .squeeze ()
590- super ().__init__ (lon , lat , time , time_origin , mesh )
571+ super ().__init__ (lon , lat , time , mesh )
591572 self .tdim = self .time .size
592573
593574 @property
@@ -630,8 +611,6 @@ class CurvilinearZGrid(CurvilinearGrid):
630611 The depth of the different layers is thus constant.
631612 time :
632613 Vector containing the time coordinates of the grid
633- time_origin : parcels.tools.converters.TimeConverter
634- Time origin of the time axis
635614 mesh : str
636615 String indicating the type of mesh coordinates and
637616 units used during velocity interpolation:
@@ -647,10 +626,9 @@ def __init__(
647626 lat : npt .NDArray ,
648627 depth : npt .NDArray | None = None ,
649628 time : npt .NDArray | None = None ,
650- time_origin : TimeConverter | None = None ,
651629 mesh : Mesh = "flat" ,
652630 ):
653- super ().__init__ (lon , lat , time , time_origin , mesh )
631+ super ().__init__ (lon , lat , time , mesh )
654632 if isinstance (depth , np .ndarray ):
655633 assert len (depth .shape ) == 1 , "depth is not a vector"
656634
@@ -686,8 +664,6 @@ class CurvilinearSGrid(CurvilinearGrid):
686664 depth array is either a 4D array[xdim][ydim][zdim][tdim] or a 3D array[xdim][ydim[zdim].
687665 time :
688666 Vector containing the time coordinates of the grid
689- time_origin : parcels.tools.converters.TimeConverter
690- Time origin of the time axis
691667 mesh : str
692668 String indicating the type of mesh coordinates and
693669 units used during velocity interpolation:
@@ -703,10 +679,9 @@ def __init__(
703679 lat : npt .NDArray ,
704680 depth : npt .NDArray ,
705681 time : npt .NDArray | None = None ,
706- time_origin : TimeConverter | None = None ,
707682 mesh : Mesh = "flat" ,
708683 ):
709- super ().__init__ (lon , lat , time , time_origin , mesh )
684+ super ().__init__ (lon , lat , time , mesh )
710685 assert isinstance (depth , np .ndarray ) and len (depth .shape ) in [3 , 4 ], "depth is not a 4D numpy array"
711686
712687 self ._gtype = GridType .CurvilinearSGrid
0 commit comments