@@ -877,15 +877,15 @@ def cell_areas(self):
877877 """
878878 return _calc_cell_areas (self .grid )
879879
880- def _search_indices (self , time , z , y , x , ti = - 1 , particle = None , search2D = False ):
880+ def _search_indices (self , time , z , y , x , ti , particle = None , search2D = False ):
881881 if self .grid ._gtype in [GridType .RectilinearSGrid , GridType .RectilinearZGrid ]:
882882 return _search_indices_rectilinear (self , time , z , y , x , ti , particle = particle , search2D = search2D )
883883 else :
884884 return _search_indices_curvilinear (self , time , z , y , x , ti , particle = particle , search2D = search2D )
885885
886- def _interpolator2D (self , ti , z , y , x , particle = None ):
886+ def _interpolator2D (self , time , z , y , x , ti , particle = None ):
887887 """Impelement 2D interpolation with coordinate transformations as seen in Delandmeter and Van Sebille (2019), 10.5194/gmd-12-3571-2019.."""
888- (_ , eta , xsi , _ , yi , xi ) = self ._search_indices (- 1 , z , y , x , particle = particle )
888+ (_ , eta , xsi , _ , yi , xi ) = self ._search_indices (time , z , y , x , ti , particle = particle )
889889 ctx = InterpolationContext2D (self .data , eta , xsi , ti , yi , xi )
890890
891891 try :
@@ -899,7 +899,7 @@ def _interpolator2D(self, ti, z, y, x, particle=None):
899899 raise RuntimeError (self .interp_method + " is not implemented for 2D grids" )
900900 return f (ctx )
901901
902- def _interpolator3D (self , ti , z , y , x , time , particle = None ):
902+ def _interpolator3D (self , time , z , y , x , ti , particle = None ):
903903 """Impelement 3D interpolation with coordinate transformations as seen in Delandmeter and Van Sebille (2019), 10.5194/gmd-12-3571-2019.."""
904904 (zeta , eta , xsi , zi , yi , xi ) = self ._search_indices (time , z , y , x , ti , particle = particle )
905905 ctx = InterpolationContext3D (self .data , zeta , eta , xsi , ti , zi , yi , xi , self .gridindexingtype )
@@ -910,13 +910,13 @@ def _interpolator3D(self, ti, z, y, x, time, particle=None):
910910 raise RuntimeError (self .interp_method + " is not implemented for 3D grids" )
911911 return f (ctx )
912912
913- def _spatial_interpolation (self , ti , z , y , x , time , particle = None ):
914- """Interpolate horizontal field values using a SciPy interpolator ."""
913+ def _spatial_interpolation (self , time , z , y , x , ti , particle = None ):
914+ """Interpolate spatial field values."""
915915 try :
916916 if self .grid .zdim == 1 :
917- val = self ._interpolator2D (ti , z , y , x , particle = particle )
917+ val = self ._interpolator2D (time , z , y , x , ti , particle = particle )
918918 else :
919- val = self ._interpolator3D (ti , z , y , x , time , particle = particle )
919+ val = self ._interpolator3D (time , z , y , x , ti , particle = particle )
920920
921921 if np .isnan (val ):
922922 # Detect Out-of-bounds sampling and raise exception
@@ -980,16 +980,16 @@ def eval(self, time, z, y, x, particle=None, applyConversion=True):
980980 if self .gridindexingtype == "croco" and self not in [self .fieldset .H , self .fieldset .Zeta ]:
981981 z = _croco_from_z_to_sigma_scipy (self .fieldset , time , z , y , x , particle = particle )
982982 if ti < self .grid .tdim - 1 and time > self .grid .time [ti ]:
983- f0 = self ._spatial_interpolation (ti , z , y , x , time , particle = particle )
984- f1 = self ._spatial_interpolation (ti + 1 , z , y , x , time , particle = particle )
983+ f0 = self ._spatial_interpolation (time , z , y , x , ti , particle = particle )
984+ f1 = self ._spatial_interpolation (time , z , y , x , ti + 1 , particle = particle )
985985 t0 = self .grid .time [ti ]
986986 t1 = self .grid .time [ti + 1 ]
987987 value = f0 + (f1 - f0 ) * ((time - t0 ) / (t1 - t0 ))
988988 else :
989989 # Skip temporal interpolation if time is outside
990990 # of the defined time range or if we have hit an
991991 # exact value in the time array.
992- value = self ._spatial_interpolation (ti , z , y , x , self . grid . time [ ti ] , particle = particle )
992+ value = self ._spatial_interpolation (self . grid . time [ ti ] , z , y , x , ti , particle = particle )
993993
994994 if applyConversion :
995995 return self .units .to_target (value , z , y , x )
0 commit comments