4646 DeferredNetcdfFileBuffer ,
4747 NetcdfFileBuffer ,
4848)
49- from .grid import Grid , GridType , _calc_cell_areas
49+ from .grid import Grid , GridType
5050
5151if TYPE_CHECKING :
5252 from parcels .fieldset import FieldSet
@@ -325,10 +325,6 @@ def depth(self):
325325 """Depth defined on the Grid object"""
326326 return self .grid .depth
327327
328- @property
329- def cell_edge_sizes (self ):
330- return self .grid .cell_edge_sizes
331-
332328 @property
333329 def interp_method (self ):
334330 return self ._interp_method
@@ -837,22 +833,15 @@ def set_depth_from_field(self, field):
837833 if self .grid != field .grid :
838834 field .grid .depth_field = field
839835
840- def cell_areas (self ):
841- """Method to calculate cell sizes based on cell_edge_sizes.
842-
843- Only works for Rectilinear Grids
844- """
845- return _calc_cell_areas (self .grid )
846-
847- def _search_indices (self , time , z , y , x , ti = - 1 , particle = None , search2D = False ):
836+ def _search_indices (self , time , z , y , x , ti , particle = None , search2D = False ):
848837 if self .grid ._gtype in [GridType .RectilinearSGrid , GridType .RectilinearZGrid ]:
849838 return _search_indices_rectilinear (self , time , z , y , x , ti , particle = particle , search2D = search2D )
850839 else :
851840 return _search_indices_curvilinear (self , time , z , y , x , ti , particle = particle , search2D = search2D )
852841
853- def _interpolator2D (self , ti , z , y , x , particle = None ):
842+ def _interpolator2D (self , time , z , y , x , ti , particle = None ):
854843 """Impelement 2D interpolation with coordinate transformations as seen in Delandmeter and Van Sebille (2019), 10.5194/gmd-12-3571-2019.."""
855- (_ , eta , xsi , _ , yi , xi ) = self ._search_indices (- 1 , z , y , x , particle = particle )
844+ (_ , eta , xsi , _ , yi , xi ) = self ._search_indices (time , z , y , x , ti , particle = particle )
856845 ctx = InterpolationContext2D (self .data , eta , xsi , ti , yi , xi )
857846
858847 try :
@@ -866,7 +855,7 @@ def _interpolator2D(self, ti, z, y, x, particle=None):
866855 raise RuntimeError (self .interp_method + " is not implemented for 2D grids" )
867856 return f (ctx )
868857
869- def _interpolator3D (self , ti , z , y , x , time , particle = None ):
858+ def _interpolator3D (self , time , z , y , x , ti , particle = None ):
870859 """Impelement 3D interpolation with coordinate transformations as seen in Delandmeter and Van Sebille (2019), 10.5194/gmd-12-3571-2019.."""
871860 (zeta , eta , xsi , zi , yi , xi ) = self ._search_indices (time , z , y , x , ti , particle = particle )
872861 ctx = InterpolationContext3D (self .data , zeta , eta , xsi , ti , zi , yi , xi , self .gridindexingtype )
@@ -877,34 +866,13 @@ def _interpolator3D(self, ti, z, y, x, time, particle=None):
877866 raise RuntimeError (self .interp_method + " is not implemented for 3D grids" )
878867 return f (ctx )
879868
880- def temporal_interpolate_fullfield (self , ti , time ):
881- """Calculate the data of a field between two snapshots using linear interpolation.
882-
883- Parameters
884- ----------
885- ti :
886- Index in time array associated with time (via :func:`time_index`)
887- time :
888- Time to interpolate to
889- """
890- t0 = self .grid .time [ti ]
891- if time == t0 :
892- return self .data [ti , :]
893- elif ti + 1 >= len (self .grid .time ):
894- raise TimeExtrapolationError (time , field = self )
895- else :
896- t1 = self .grid .time [ti + 1 ]
897- f0 = self .data [ti , :]
898- f1 = self .data [ti + 1 , :]
899- return f0 + (f1 - f0 ) * ((time - t0 ) / (t1 - t0 ))
900-
901- def _spatial_interpolation (self , ti , z , y , x , time , particle = None ):
902- """Interpolate horizontal field values using a SciPy interpolator."""
869+ def _spatial_interpolation (self , time , z , y , x , ti , particle = None ):
870+ """Interpolate spatial field values."""
903871 try :
904872 if self .grid .zdim == 1 :
905- val = self ._interpolator2D (ti , z , y , x , particle = particle )
873+ val = self ._interpolator2D (time , z , y , x , ti , particle = particle )
906874 else :
907- val = self ._interpolator3D (ti , z , y , x , time , particle = particle )
875+ val = self ._interpolator3D (time , z , y , x , ti , particle = particle )
908876
909877 if np .isnan (val ):
910878 # Detect Out-of-bounds sampling and raise exception
@@ -966,16 +934,16 @@ def eval(self, time, z, y, x, particle=None, applyConversion=True):
966934 if self .gridindexingtype == "croco" and self not in [self .fieldset .H , self .fieldset .Zeta ]:
967935 z = _croco_from_z_to_sigma_scipy (self .fieldset , time , z , y , x , particle = particle )
968936 if ti < self .grid .tdim - 1 and time > self .grid .time [ti ]:
969- f0 = self ._spatial_interpolation (ti , z , y , x , time , particle = particle )
970- f1 = self ._spatial_interpolation (ti + 1 , z , y , x , time , particle = particle )
937+ f0 = self ._spatial_interpolation (time , z , y , x , ti , particle = particle )
938+ f1 = self ._spatial_interpolation (time , z , y , x , ti + 1 , particle = particle )
971939 t0 = self .grid .time [ti ]
972940 t1 = self .grid .time [ti + 1 ]
973941 value = f0 + (f1 - f0 ) * ((time - t0 ) / (t1 - t0 ))
974942 else :
975943 # Skip temporal interpolation if time is outside
976944 # of the defined time range or if we have hit an
977945 # exact value in the time array.
978- value = self ._spatial_interpolation (ti , z , y , x , self . grid . time [ ti ] , particle = particle )
946+ value = self ._spatial_interpolation (self . grid . time [ ti ] , z , y , x , ti , particle = particle )
979947
980948 if applyConversion :
981949 return self .units .to_target (value , z , y , x )
0 commit comments