From 3842531b62c3f7d58023402e3b872a1a17b6810f Mon Sep 17 00:00:00 2001 From: tsutterley Date: Thu, 14 Sep 2023 13:41:52 -0700 Subject: [PATCH] fix: prevent overwriting ATLAS compact x and y coordinates to address #238 ci: update versions to prevent deprecations --- .github/workflows/auto-update-bulletin-a.yml | 4 +- .github/workflows/auto-update-files.yml | 4 +- .github/workflows/python-publish.yml | 4 +- .github/workflows/python-request.yml | 4 +- doc/source/release_notes/release-v2.0.8.rst | 11 ++++ pyTMD/calc_astrol_longitudes.py | 2 - pyTMD/convert_ll_xy.py | 2 - pyTMD/io/OTIS.py | 68 ++++++++------------ pyTMD/load_nodal_corrections.py | 2 - scripts/usap_cats_tides.py | 2 - 10 files changed, 46 insertions(+), 57 deletions(-) create mode 100644 doc/source/release_notes/release-v2.0.8.rst diff --git a/.github/workflows/auto-update-bulletin-a.yml b/.github/workflows/auto-update-bulletin-a.yml index 37bc6f3f..4c3a4e6e 100644 --- a/.github/workflows/auto-update-bulletin-a.yml +++ b/.github/workflows/auto-update-bulletin-a.yml @@ -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: @@ -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" diff --git a/.github/workflows/auto-update-files.yml b/.github/workflows/auto-update-files.yml index ee55fa73..1264ee35 100644 --- a/.github/workflows/auto-update-files.yml +++ b/.github/workflows/auto-update-files.yml @@ -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: @@ -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" diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index ef4ad928..2c2e5b03 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -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 diff --git a/.github/workflows/python-request.yml b/.github/workflows/python-request.yml index ad05d3f3..0da4be2f 100644 --- a/.github/workflows/python-request.yml +++ b/.github/workflows/python-request.yml @@ -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: @@ -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 diff --git a/doc/source/release_notes/release-v2.0.8.rst b/doc/source/release_notes/release-v2.0.8.rst new file mode 100644 index 00000000..f150b34c --- /dev/null +++ b/doc/source/release_notes/release-v2.0.8.rst @@ -0,0 +1,11 @@ +################## +`Release v2.0.8`__ +################## + +* ``feat``: add option to run with parquet tabular files (`#236 `_) +* ``feat``: add function to invert field mapping keys and values (`#235 `_) +* ``fix``: prevent overwriting ATLAS compact x and y coordinates to address `#238 `_ (`#240 `_) +* ``docs``: use micromamba for builds (`#235 `_) +* ``ci``: bump versions of imports to prevent deprecation errors (`#235 `_) + +.. __: https://github.com/tsutterley/pyTMD/releases/tag/2.0.8 diff --git a/pyTMD/calc_astrol_longitudes.py b/pyTMD/calc_astrol_longitudes.py index d7ec06f3..2284e5e9 100644 --- a/pyTMD/calc_astrol_longitudes.py +++ b/pyTMD/calc_astrol_longitudes.py @@ -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) diff --git a/pyTMD/convert_ll_xy.py b/pyTMD/convert_ll_xy.py index 289c5c80..7c5b17f7 100644 --- a/pyTMD/convert_ll_xy.py +++ b/pyTMD/convert_ll_xy.py @@ -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) diff --git a/pyTMD/io/OTIS.py b/pyTMD/io/OTIS.py index 4ef5066b..b29ccfdc 100644 --- a/pyTMD/io/OTIS.py +++ b/pyTMD/io/OTIS.py @@ -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 @@ -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 @@ -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') @@ -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') @@ -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') @@ -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 @@ -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 |= mz.astype(bool) + # append extended constituent + constituents.append(c, hc) # return the complex form of the model constituents return constituents diff --git a/pyTMD/load_nodal_corrections.py b/pyTMD/load_nodal_corrections.py index b103ff3a..8941316a 100755 --- a/pyTMD/load_nodal_corrections.py +++ b/pyTMD/load_nodal_corrections.py @@ -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 @@ -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) diff --git a/scripts/usap_cats_tides.py b/scripts/usap_cats_tides.py index 1d972fba..58c9360c 100644 --- a/scripts/usap_cats_tides.py +++ b/scripts/usap_cats_tides.py @@ -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: