Skip to content

Commit

Permalink
fix: default direction is FORWARD
Browse files Browse the repository at this point in the history
  • Loading branch information
tsutterley committed Jul 18, 2024
1 parent c3ff7c1 commit 5710c70
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 1 addition & 3 deletions pyTMD/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,7 @@ def direction(self):
``pyproj`` direction of the coordinate transform
"""
# convert from input coordinates to model coordinates
if self._direction is None:
return None
elif (self._direction.upper() == 'F'):
if (self._direction is None) or (self._direction.upper() == 'F'):
return pyproj.enums.TransformDirection.FORWARD
# convert from model coordinates to coordinates
elif (self._direction.upper() == 'B'):
Expand Down
10 changes: 5 additions & 5 deletions pyTMD/io/ATLAS.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,18 @@ def extract_constants(
xmin, xmax = np.min(ilon), np.max(ilon)
ymin, ymax = np.min(ilat), np.max(ilat)
kwargs.setdefault('bounds', [xmin, xmax, ymin, ymax])
# grid step size of tide model
dlon = lon[1] - lon[0]
# if global: extend limits
is_global = False

# crop bathymetry data to (buffered) bounds
# or adjust longitudinal convention to fit tide model
if kwargs['crop'] and np.any(kwargs['bounds']):
mlon, mlat = np.copy(lon), np.copy(lat)
bathymetry, lon, lat = _crop(bathymetry, mlon, mlat,
bounds=kwargs['bounds'],
buffer=5
buffer=4.0*dlon
)
elif (np.min(ilon) < 0.0) & (np.max(lon) > 180.0):
# input points convention (-180:180)
Expand All @@ -232,10 +236,6 @@ def extract_constants(
# tide model convention (-180:180)
ilon[ilon > 180.0] -= 360.0

# grid step size of tide model
dlon = lon[1] - lon[0]
# if global: extend limits
is_global = False
# replace original values with extend arrays/matrices
if np.isclose(lon[-1] - lon[0], 360.0 - dlon):
lon = _extend_array(lon, dlon)
Expand Down
6 changes: 3 additions & 3 deletions pyTMD/io/OTIS.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ def interpolate_constants(
ilat = np.atleast_1d(np.copy(ilat))
# run wrapper function to convert coordinate systems of input lat/lon
transformer = pyTMD.crs().get(EPSG)
x,y = transformer.transform(ilon, ilat, direction='FORWARD')
x,y = transformer.transform(ilon, ilat)
is_geographic = transformer.is_geographic
# adjust longitudinal convention of input latitude and longitude
# to fit tide model convention
Expand Down Expand Up @@ -1972,8 +1972,8 @@ def _crop(
ymin = bounds[2] - buffer
ymax = bounds[3] + buffer
# find indices for cropping
yind = np.flatnonzero((ilat >= ymin) & (ilat <= ymax))
xind = np.flatnonzero((ilon >= xmin) & (ilon <= xmax))
yind = np.flatnonzero((iy >= ymin) & (iy <= ymax))
xind = np.flatnonzero((ix >= xmin) & (ix <= xmax))
# slices for cropping axes
rows = slice(yind[0], yind[-1]+1)
cols = slice(xind[0], xind[-1]+1)
Expand Down

0 comments on commit 5710c70

Please sign in to comment.