Skip to content

Commit

Permalink
fix: prevent overwriting ATLAS compact x and y coordinates to address #…
Browse files Browse the repository at this point in the history
…238 (#240)

ci: update versions to prevent deprecations
  • Loading branch information
tsutterley committed Sep 14, 2023
1 parent efa9002 commit d430c90
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/auto-update-bulletin-a.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
shell: bash -l {0}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up mamba ${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
with:
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
python -c "import pyTMD.time; pyTMD.time.append_delta_time(verbose=True)"
- name: Create pull request
if: steps.changes.outputs.DETECTED == 'true'
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v5
with:
assignees: ${{ github.actor }}
title: "data: automatic bulletin updates"
4 changes: 2 additions & 2 deletions .github/workflows/auto-update-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
shell: bash -l {0}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up mamba ${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
with:
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
fi
- name: Create pull request
if: steps.changes.outputs.DETECTED == 'true'
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v5
with:
assignees: ${{ github.actor }}
title: "data: automatic time updates"
4 changes: 2 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
shell: bash -l {0}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up mamba ${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
with:
Expand All @@ -52,7 +52,7 @@ jobs:
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Checkout Matlab TMD Toolbox
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: tsutterley/TMD_Matlab_Toolbox_v2.5
path: TMD_Matlab_Toolbox
Expand Down
11 changes: 11 additions & 0 deletions doc/source/release_notes/release-v2.0.8.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
##################
`Release v2.0.8`__
##################

* ``feat``: add option to run with parquet tabular files (`#236 <https://github.com/tsutterley/pyTMD/pull/236>`_)
* ``feat``: add function to invert field mapping keys and values (`#235 <https://github.com/tsutterley/pyTMD/pull/235>`_)
* ``fix``: prevent overwriting ATLAS compact x and y coordinates to address `#238 <https://github.com/tsutterley/pyTMD/issues/238>`_ (`#240 <https://github.com/tsutterley/pyTMD/pull/240>`_)
* ``docs``: use micromamba for builds (`#235 <https://github.com/tsutterley/pyTMD/pull/235>`_)
* ``ci``: bump versions of imports to prevent deprecation errors (`#235 <https://github.com/tsutterley/pyTMD/pull/235>`_)

.. __: https://github.com/tsutterley/pyTMD/releases/tag/2.0.8
2 changes: 0 additions & 2 deletions pyTMD/calc_astrol_longitudes.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ def calc_astrol_longitudes(*args, **kwargs):
----------
.. [1] J. Meeus, *Astronomical Algorithms*, 2nd edition, 477 pp., (1998).
"""
warnings.filterwarnings("module")
warnings.warn("Deprecated. Please use pyTMD.astro instead",
DeprecationWarning)
warnings.filterwarnings("ignore")
# call updated function to not break current workflows
return pyTMD.astro.mean_longitudes(*args, **kwargs)
2 changes: 0 additions & 2 deletions pyTMD/convert_ll_xy.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ def convert_ll_xy(*args, **kwargs):
o2: float
Projected y-coordinates (``'F'``) or latitude (``'B``')
"""
warnings.filterwarnings("module")
warnings.warn("Deprecated. Please use pyTMD.convert_crs instead",
DeprecationWarning)
warnings.filterwarnings("ignore")
# call updated function to not break current workflows
return pyTMD.convert_crs(*args, **kwargs)
68 changes: 27 additions & 41 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 (08/2023)
Written by Tyler Sutterley (09/2023)
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 09/2023: prevent overwriting ATLAS compact x and y coordinates
Updated 08/2023: changed ESR netCDF4 format to TMD3 format
Updated 04/2023: using pathlib to define and expand tide model paths
Updated 03/2023: add basic variable typing to function inputs
Expand Down Expand Up @@ -353,7 +354,7 @@ def extract_constants(
# read z constituent from elevation file
if (kwargs['grid'] == 'ATLAS'):
z0,zlocal = read_atlas_elevation(model_file, i, c)
xi,yi,hc = combine_atlas_model(x0, y0, z0, pmask, zlocal,
_,_,hc = combine_atlas_model(x0, y0, z0, pmask, zlocal,
variable='z')
elif (kwargs['grid'] == 'TMD3'):
hc = read_netcdf_file(model_file, i, variable='z')
Expand All @@ -368,7 +369,7 @@ def extract_constants(
# read u constituent from transport file
if (kwargs['grid'] == 'ATLAS'):
u0,v0,uvlocal = read_atlas_transport(model_file, i, c)
xi,yi,hc = combine_atlas_model(x0, y0, u0, pmask, uvlocal,
_,_,hc = combine_atlas_model(x0, y0, u0, pmask, uvlocal,
variable='u')
elif (kwargs['grid'] == 'TMD3'):
hc = read_netcdf_file(model_file, i, variable='u')
Expand All @@ -380,7 +381,7 @@ def extract_constants(
# read v constituent from transport file
if (kwargs['grid'] == 'ATLAS'):
u0,v0,uvlocal = read_atlas_transport(model_file, i, c)
xi,yi,hc = combine_atlas_model(x0, y0, v0, pmask, uvlocal,
_,_,hc = combine_atlas_model(x0, y0, v0, pmask, uvlocal,
variable='v')
elif (kwargs['grid'] == 'TMD3'):
hc = read_netcdf_file(model_file, i, type='v')
Expand All @@ -392,7 +393,7 @@ def extract_constants(
# replace original values with extend matrices
if global_grid:
hc = extend_matrix(hc)
# copy mask to elevation
# copy mask to constituent
hc.mask |= bathymetry.mask

# interpolate amplitude and phase of the constituent
Expand Down Expand Up @@ -587,64 +588,49 @@ def read_constants(
# read constituent from elevation file
if (kwargs['grid'] == 'ATLAS'):
z0,zlocal = read_atlas_elevation(model_file, i, c)
xi,yi,z = combine_atlas_model(x0, y0, z0, pmask, zlocal,
_,_,hc = combine_atlas_model(x0, y0, z0, pmask, zlocal,
variable='z')
elif (kwargs['grid'] == 'TMD3'):
z = read_netcdf_file(model_file, i, variable='z')
hc = read_netcdf_file(model_file, i, variable='z')
# apply flexure scaling
if kwargs['apply_flexure']:
z *= sf
hc *= sf
elif isinstance(model_file,list):
z = read_otis_elevation(model_file[i], 0)
hc = read_otis_elevation(model_file[i], 0)
else:
z = read_otis_elevation(model_file, i)
# replace original values with extend matrices
if global_grid:
z = extend_matrix(z)
# copy mask to elevation
z.mask |= mz.astype(bool)
# append extended constituent
constituents.append(c, z)

hc = read_otis_elevation(model_file, i)
elif kwargs['type'] in ('U','u'):
# read constituent from transport file
if (kwargs['grid'] == 'ATLAS'):
u0,v0,uvlocal = read_atlas_transport(model_file, i, c)
xi,yi,u = combine_atlas_model(x0, y0, u0, pmask, uvlocal,
_,_,hc = combine_atlas_model(x0, y0, u0, pmask, uvlocal,
variable='u')
elif (kwargs['grid'] == 'TMD3'):
u = read_netcdf_file(model_file, i, variable='u')
hc = read_netcdf_file(model_file, i, variable='u')
elif isinstance(model_file,list):
u,v = read_otis_transport(model_file[i], 0)
hc,v = read_otis_transport(model_file[i], 0)
else:
u,v = read_otis_transport(model_file, i)
# replace original values with extend matrices
if global_grid:
u = extend_matrix(u)
# copy mask to u transports
u.mask |= mu.astype(bool)
# append extended constituent
constituents.append(c, u)

hc,v = read_otis_transport(model_file, i)
elif kwargs['type'] in ('V','v'):
# read constituent from transport file
if (kwargs['grid'] == 'ATLAS'):
u0,v0,uvlocal = read_atlas_transport(model_file, i, c)
xi,yi,v = combine_atlas_model(x0, y0, v0, pmask, uvlocal,
_,_,hc = combine_atlas_model(x0, y0, v0, pmask, uvlocal,
variable='v')
elif (kwargs['grid'] == 'TMD3'):
v = read_netcdf_file(model_file, i, type='v')
hc = read_netcdf_file(model_file, i, type='v')
elif isinstance(model_file,list):
u,v = read_otis_transport(model_file[i], 0)
u,hc = read_otis_transport(model_file[i], 0)
else:
u,v = read_otis_transport(model_file, i)
# replace original values with extend matrices
if global_grid:
v = extend_matrix(v)
# copy mask to v transports
v.mask |= mv.astype(bool)
# append extended constituent
constituents.append(c, v)
u,hc = read_otis_transport(model_file, i)

# replace original values with extend matrices
if global_grid:
hc = extend_matrix(hc)
# copy mask to constituent
hc.mask |= bathymetry.mask
# append extended constituent
constituents.append(c, hc)

# return the complex form of the model constituents
return constituents
Expand Down
2 changes: 0 additions & 2 deletions pyTMD/load_nodal_corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ def load_nodal_corrections(*args, **kwargs):
.. __: https://doi.org/10.1175/1520-0426(2002)019<0183:EIMOBO>2.0.CO;2
"""
# raise warning for deprecated function call
warnings.filterwarnings("module")
warnings.warn("Deprecated. Please use pyTMD.arguments instead",
DeprecationWarning)
# raise warnings for deprecated keyword arguments
Expand All @@ -116,6 +115,5 @@ def load_nodal_corrections(*args, **kwargs):
Changed to '{new}'""", DeprecationWarning)
# set renamed argument to not break workflows
kwargs[new] = copy.copy(kwargs[old])
warnings.filterwarnings("ignore")
# call updated function to not break current workflows
return pyTMD.arguments(*args, **kwargs)
2 changes: 0 additions & 2 deletions scripts/usap_cats_tides.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ def main():
args,_ = parser.parse_known_args()

# warn user that USAP requires a reCAPTCHA check
warnings.filterwarnings("module")
warnings.warn("Deprecated. USAP now requires captcha", DeprecationWarning)
warnings.filterwarnings("ignore")
# check internet connection before attempting to run program
if pyTMD.utilities.check_connection('https://www.usap-dc.org'):
for m in args.tide:
Expand Down

0 comments on commit d430c90

Please sign in to comment.