Skip to content

Commit

Permalink
fix: keep prime nomenclature for 3rd degree tides
Browse files Browse the repository at this point in the history
fix: revert OTIS crop change and assume  bounds are projected
  • Loading branch information
tsutterley committed Aug 5, 2024
1 parent 64e0303 commit 8f2d65a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pyTMD/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def arguments(
fargs = np.c_[tau, s, h, p, n, pp, k]
arg = np.dot(fargs, _arguments_table(**kwargs))

# determine nodal corrections f and u
# trigonometric factors for nodal corrections
sinn = np.sin(n*dtr)
cosn = np.cos(n*dtr)
sin2n = np.sin(2.0*n*dtr)
Expand Down
14 changes: 6 additions & 8 deletions pyTMD/io/OTIS.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
u"""
OTIS.py
Written by Tyler Sutterley (07/2024)
Written by Tyler Sutterley (08/2024)
Reads files for a tidal model and makes initial calculations to run tide program
Includes functions to extract tidal harmonic constants from OTIS tide models for
Expand Down Expand Up @@ -59,6 +59,7 @@
interpolate.py: interpolation routines for spatial data
UPDATE HISTORY:
Updated 08/2024: revert change and assume crop bounds are projected
Updated 07/2024: added crop and bounds keywords for trimming model data
convert the crs of bounds when cropping model data
Updated 06/2024: change int32 to int to prevent overflows with numpy 2.0
Expand Down Expand Up @@ -565,15 +566,11 @@ def read_constants(
# crop mask and bathymetry data to (buffered) bounds
# or adjust longitudinal convention to fit tide model
if kwargs['crop'] and np.any(kwargs['bounds']):
# convert coordinate systems of input bounding box
xbox, ybox = np.meshgrid(kwargs['bounds'][:2], kwargs['bounds'][2:])
x, y = transformer.transform(xbox, ybox, direction='FORWARD')
bounds = np.array([x.min(), x.max(), y.min(), y.max()])
# crop tide model data
mx, my = np.copy(xi), np.copy(yi)
mz, xi, yi = _crop(mz, mx, my, bounds=bounds,
mz, xi, yi = _crop(mz, mx, my, bounds=kwargs['bounds'],
is_geographic=is_geographic)
hz, xi, yi = _crop(hz, mx, my, bounds=bounds,
hz, xi, yi = _crop(hz, mx, my, bounds=kwargs['bounds'],
is_geographic=is_geographic)

# replace original values with extend arrays/matrices
Expand Down Expand Up @@ -677,7 +674,8 @@ def read_constants(
# crop tide model data to (buffered) bounds
if kwargs['crop'] and np.any(kwargs['bounds']):
hc, _, _ = _crop(hc, mx, my,

Check warning on line 676 in pyTMD/io/OTIS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/OTIS.py#L676

Added line #L676 was not covered by tests
bounds=bounds, is_geographic=is_geographic)
bounds=kwargs['bounds'],
is_geographic=is_geographic)
# replace original values with extend matrices
if is_global:
hc = _extend_matrix(hc)
Expand Down
8 changes: 5 additions & 3 deletions pyTMD/io/constituents.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
u"""
constituents.py
Written by Tyler Sutterley (07/2024)
Written by Tyler Sutterley (08/2024)
Basic tide model constituent class
PYTHON DEPENDENCIES:
Expand All @@ -10,6 +10,7 @@
https://numpy.org/doc/stable/user/numpy-for-matlab-users.html
UPDATE HISTORY:
Updated 08/2024: add GOT prime nomenclature for 3rd degree constituents
Updated 07/2024: add function to parse tidal constituents from strings
Updated 05/2024: make subscriptable and allow item assignment
Updated 01/2024: added properties for Doodson and Cartwright numbers
Expand Down Expand Up @@ -213,10 +214,11 @@ def parse(constituent: str) -> str:
'ms4','mk4',r'(?<!m)s4','s5','m6','s6','s7','s8','m8','mks2',
'msqm','mtm',r'(?<!m)n4','eps2','z0']
# compile regular expression
rx = re.compile(r'(' + '|'.join(cindex) + r')', re.IGNORECASE)
# adding GOT prime nomenclature for 3rd degree constituents
rx = re.compile(r'(' + '|'.join(cindex) + r')(\')?', re.IGNORECASE)
# check if tide model is a simple regex case
if rx.search(constituent):
return rx.findall(constituent)[0].lower()
return "".join(rx.findall(constituent)[0]).lower()
# known remapped cases
mapping = [('2n','2n2'), ('e2','eps2'), ('la2','lambda2'),
('sig1','sigma1')]
Expand Down
6 changes: 3 additions & 3 deletions scripts/gsfc_got_tides.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
u"""
gsfc_got_tides.py
Written by Tyler Sutterley (07/2024)
Written by Tyler Sutterley (08/2024)
Download GSFC Global Ocean Tide (GOT) models
CALLING SEQUENCE:
Expand Down Expand Up @@ -31,6 +31,7 @@
utilities.py: download and management utilities for syncing files
UPDATE HISTORY:
Updated 08/2024: keep prime nomenclature for 3rd degree tides
Written 07/2024
"""
from __future__ import print_function, annotations
Expand Down Expand Up @@ -90,8 +91,7 @@ def gsfc_got_tides(MODEL: str,
elif re.match(r'^._', posixpath.basename(m.name)):
continue
# output file name
member = m.name.replace("'","")
output = f'{member}.gz' if sfx in ('.d','.nc') and GZIP else member
output = f'{m.name}.gz' if sfx in ('.d','.nc') and GZIP else m.name
local_file = DIRECTORY.joinpath(*posixpath.split(output))
# check if the local file exists
if local_file.exists() and newer(m.mtime, local_file.stat().st_mtime):
Expand Down

0 comments on commit 8f2d65a

Please sign in to comment.