@@ -238,6 +238,7 @@ def _model_tides(
238
238
time ,
239
239
directory ,
240
240
crs ,
241
+ crop ,
241
242
method ,
242
243
extrapolate ,
243
244
cutoff ,
@@ -278,6 +279,15 @@ def _model_tides(
278
279
# Convert datetime
279
280
timescale = pyTMD .time .timescale ().from_datetime (time .flatten ())
280
281
282
+ # Calculate bounds for cropping
283
+ buffer = 1 # one degree on either side
284
+ bounds = [
285
+ lon .min () - buffer ,
286
+ lon .max () + buffer ,
287
+ lat .min () - buffer ,
288
+ lat .max () + buffer ,
289
+ ]
290
+
281
291
# Read tidal constants and interpolate to grid points
282
292
if pytmd_model .format in ("OTIS" , "ATLAS" , "TMD3" ):
283
293
amp , ph , D , c = pyTMD .io .OTIS .extract_constants (
@@ -287,6 +297,8 @@ def _model_tides(
287
297
pytmd_model .model_file ,
288
298
pytmd_model .projection ,
289
299
type = pytmd_model .type ,
300
+ crop = crop ,
301
+ bounds = bounds ,
290
302
method = method ,
291
303
extrapolate = extrapolate ,
292
304
cutoff = cutoff ,
@@ -303,6 +315,8 @@ def _model_tides(
303
315
pytmd_model .grid_file ,
304
316
pytmd_model .model_file ,
305
317
type = pytmd_model .type ,
318
+ crop = crop ,
319
+ bounds = bounds ,
306
320
method = method ,
307
321
extrapolate = extrapolate ,
308
322
cutoff = cutoff ,
@@ -318,6 +332,8 @@ def _model_tides(
318
332
lon ,
319
333
lat ,
320
334
pytmd_model .model_file ,
335
+ crop = crop ,
336
+ bounds = bounds ,
321
337
method = method ,
322
338
extrapolate = extrapolate ,
323
339
cutoff = cutoff ,
@@ -335,6 +351,8 @@ def _model_tides(
335
351
pytmd_model .model_file ,
336
352
type = pytmd_model .type ,
337
353
version = pytmd_model .version ,
354
+ crop = crop ,
355
+ bounds = bounds ,
338
356
method = method ,
339
357
extrapolate = extrapolate ,
340
358
cutoff = cutoff ,
@@ -584,6 +602,7 @@ def model_tides(
584
602
model = "FES2014" ,
585
603
directory = None ,
586
604
crs = "EPSG:4326" ,
605
+ crop = True ,
587
606
method = "spline" ,
588
607
extrapolate = True ,
589
608
cutoff = None ,
@@ -674,6 +693,10 @@ def model_tides(
674
693
crs : str, optional
675
694
Input coordinate reference system for x and y coordinates.
676
695
Defaults to "EPSG:4326" (WGS84; degrees latitude, longitude).
696
+ crop : bool optional
697
+ Whether to crop tide model constituent files on-the-fly to
698
+ improve performance. Cropping will be performed based on a
699
+ 1 degree buffer around all input points. Defaults to True.
677
700
method : string, optional
678
701
Method used to interpolate tidal constituents
679
702
from model files. Options include:
@@ -831,6 +854,7 @@ def model_tides(
831
854
_model_tides ,
832
855
directory = directory ,
833
856
crs = crs ,
857
+ crop = crop ,
834
858
method = method ,
835
859
extrapolate = extrapolate ,
836
860
cutoff = np .inf if cutoff is None else cutoff ,
0 commit comments