From 5c4bca1c61ac26fa8cd1c2e4f5f1447090833823 Mon Sep 17 00:00:00 2001 From: Tyler Sutterley Date: Wed, 30 Oct 2024 12:12:54 -0700 Subject: [PATCH] fix: remove default `bounds` being `None` for #356 (#357) --- pyTMD/io/model.py | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/pyTMD/io/model.py b/pyTMD/io/model.py index d8f0ef62..14cdcd9e 100644 --- a/pyTMD/io/model.py +++ b/pyTMD/io/model.py @@ -13,6 +13,7 @@ UPDATE HISTORY: Updated 10/2024: add wrapper functions to read and interpolate constants add functions to append node tide equilibrium values to amplitudes + remove redundant default keyword arguments to readers and interpolators Updated 09/2024: use JSON database for known model parameters drop support for the ascii definition file format add file_format and nodal correction attributes @@ -997,12 +998,7 @@ def extract_constants(self, # set default keyword arguments kwargs.setdefault('type', self.type) kwargs.setdefault('append_node', False) - kwargs.setdefault('crop', False) - kwargs.setdefault('bounds', None) - kwargs.setdefault('method', 'spline') - kwargs.setdefault('extrapolate', False) - kwargs.setdefault('cutoff', None) - kwargs.setdefault('apply_flexure', False) + kwargs.setdefault('scale', self.scale) # read tidal constants and interpolate to grid points if self.format in ('OTIS', 'ATLAS-compact', 'TMD3'): # extract model file in case of currents @@ -1023,14 +1019,13 @@ def extract_constants(self, model_file = self.model_file # extract tidal constants for model type amp,ph,D,c = ATLAS.extract_constants(lon, lat, - self.grid_file, model_file, scale=self.scale, + self.grid_file, model_file, compressed=self.compressed, **kwargs) elif self.format in ('GOT-ascii', 'GOT-netcdf'): # extract tidal constants for model type amp,ph,c = GOT.extract_constants(lon, lat, self.model_file, grid=self.file_format, - scale=self.scale, compressed=self.compressed, - **kwargs) + compressed=self.compressed, **kwargs) elif self.format in ('FES-ascii', 'FES-netcdf'): # extract model file in case of currents if isinstance(self.model_file, dict): @@ -1041,8 +1036,7 @@ def extract_constants(self, # extract tidal constants for model type amp,ph = FES.extract_constants(lon, lat, self.model_file, version=self.version, - scale=self.scale, compressed=self.compressed, - **kwargs) + compressed=self.compressed, **kwargs) # available model constituents c = self.constituents # append node equilibrium tide if not in constituents list @@ -1073,9 +1067,6 @@ def read_constants(self, **kwargs): # set default keyword arguments kwargs.setdefault('type', self.type) kwargs.setdefault('append_node', False) - kwargs.setdefault('crop', False) - kwargs.setdefault('bounds', None) - kwargs.setdefault('apply_flexure', False) # read tidal constants if self.format in ('OTIS','ATLAS-compact','TMD3'): # extract model file in case of currents @@ -1159,9 +1150,7 @@ def interpolate_constants(self, from pyTMD.io import OTIS, ATLAS, GOT, FES # set default keyword arguments kwargs.setdefault('type', self.type) - kwargs.setdefault('method', 'spline') - kwargs.setdefault('extrapolate', False) - kwargs.setdefault('cutoff', 10.0) + kwargs.setdefault('scale', self.scale) # verify constituents have been read if not hasattr(self, '_constituents'): self.read_constants(**kwargs) @@ -1171,16 +1160,13 @@ def interpolate_constants(self, self._constituents, **kwargs) elif self.format in ('ATLAS-netcdf',): amp,ph,D = ATLAS.interpolate_constants(lon, lat, - self._constituents, scale=self.scale, - **kwargs) + self._constituents, **kwargs) elif self.format in ('GOT-ascii','GOT-netcdf'): amp,ph = GOT.interpolate_constants(lon, lat, - self._constituents, scale=self.scale, - **kwargs) + self._constituents, **kwargs) elif self.format in ('FES-ascii','FES-netcdf'): amp,ph = FES.interpolate_constants(lon, lat, - self._constituents, scale=self.scale, - **kwargs) + self._constituents, **kwargs) # return the amplitude and phase return (amp, ph) @@ -1272,12 +1258,6 @@ def extract_constants(lon: np.ndarray, lat: np.ndarray, m, **kwargs): assert isinstance(m, model) # set default keyword arguments kwargs.setdefault('type', m.type) - kwargs.setdefault('crop', False) - kwargs.setdefault('bounds', None) - kwargs.setdefault('method', 'spline') - kwargs.setdefault('extrapolate', False) - kwargs.setdefault('cutoff', None) - kwargs.setdefault('apply_flexure', False) # extract tidal constants amp, ph, c = m.extract_constants(lon, lat, **kwargs) # return the amplitude, phase, and constituents @@ -1303,9 +1283,6 @@ def read_constants(m, **kwargs): assert isinstance(m, model) # set default keyword arguments kwargs.setdefault('type', m.type) - kwargs.setdefault('crop', False) - kwargs.setdefault('bounds', None) - kwargs.setdefault('apply_flexure', False) # read tidal constants m.read_constants(**kwargs) # return the tidal constituents @@ -1333,10 +1310,6 @@ def interpolate_constants(lon: np.ndarray, lat: np.ndarray, m, **kwargs): ph: np.ndarray Tidal phase in degrees """ - # set default keyword arguments - kwargs.setdefault('method', 'spline') - kwargs.setdefault('extrapolate', False) - kwargs.setdefault('cutoff', None) # extract tidal constants amp, ph = m.interpolate_constants(lon, lat, **kwargs) # return the amplitude and phase