@@ -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 )
@@ -931,13 +931,13 @@ def temporal_interpolate_fullfield(self, ti, time):
931931 f1 = self .data [ti + 1 , :]
932932 return f0 + (f1 - f0 ) * ((time - t0 ) / (t1 - t0 ))
933933
934- def _spatial_interpolation (self , ti , z , y , x , time , particle = None ):
935- """Interpolate horizontal field values using a SciPy interpolator ."""
934+ def _spatial_interpolation (self , time , z , y , x , ti , particle = None ):
935+ """Interpolate spatial field values."""
936936 try :
937937 if self .grid .zdim == 1 :
938- val = self ._interpolator2D (ti , z , y , x , particle = particle )
938+ val = self ._interpolator2D (time , z , y , x , ti , particle = particle )
939939 else :
940- val = self ._interpolator3D (ti , z , y , x , time , particle = particle )
940+ val = self ._interpolator3D (time , z , y , x , ti , particle = particle )
941941
942942 if np .isnan (val ):
943943 # Detect Out-of-bounds sampling and raise exception
@@ -1002,16 +1002,16 @@ def eval(self, time, z, y, x, particle=None, applyConversion=True):
10021002 if self .gridindexingtype == "croco" and self not in [self .fieldset .H , self .fieldset .Zeta ]:
10031003 z = _croco_from_z_to_sigma_scipy (self .fieldset , time , z , y , x , particle = particle )
10041004 if ti < self .grid .tdim - 1 and time > self .grid .time [ti ]:
1005- f0 = self ._spatial_interpolation (ti , z , y , x , time , particle = particle )
1006- f1 = self ._spatial_interpolation (ti + 1 , z , y , x , time , particle = particle )
1005+ f0 = self ._spatial_interpolation (time , z , y , x , ti , particle = particle )
1006+ f1 = self ._spatial_interpolation (time , z , y , x , ti + 1 , particle = particle )
10071007 t0 = self .grid .time [ti ]
10081008 t1 = self .grid .time [ti + 1 ]
10091009 value = f0 + (f1 - f0 ) * ((time - t0 ) / (t1 - t0 ))
10101010 else :
10111011 # Skip temporal interpolation if time is outside
10121012 # of the defined time range or if we have hit an
10131013 # exact value in the time array.
1014- value = self ._spatial_interpolation (ti , z , y , x , self . grid . time [ ti ] , particle = particle )
1014+ value = self ._spatial_interpolation (self . grid . time [ ti ] , z , y , x , ti , particle = particle )
10151015
10161016 if applyConversion :
10171017 return self .units .to_target (value , z , y , x )
0 commit comments