Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: scaling factors for TPXO9-atlas currents for #241 #243

Merged
merged 2 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=================
check_tide_points
=================
============
check_points
============

- Check if points are within a tide model domain
- Can check OTIS format tidal solutions provided by Ohio State University and ESR
Expand All @@ -12,12 +12,11 @@ Calling Sequence

.. code-block:: python

from pyTMD.check_tide_points import check_tide_points
valid = check_tide_points(x, y, DIRECTORY=DIRECTORY,
MODEL=MODEL, EPSG=3031)
import pyTMD
valid = pyTMD.check_points(x, y, DIRECTORY=DIRECTORY, MODEL=MODEL, EPSG=3031)

`Source code`__

.. __: https://github.com/tsutterley/pyTMD/blob/main/pyTMD/check_tide_points.py
.. __: https://github.com/tsutterley/pyTMD/blob/main/pyTMD/check_points.py

.. autofunction:: pyTMD.check_tide_points
.. autofunction:: pyTMD.check_points
7 changes: 4 additions & 3 deletions doc/source/api_reference/compute_tide_corrections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ Calling Sequence

.. code-block:: python

from pyTMD.compute_tide_corrections import compute_tide_corrections
tide = compute_tide_corrections(x, y, delta_time, DIRECTORY=DIRECTORY,
MODEL=MODEL, EPOCH=(2000,1,1,0,0,0), EPSG=3031, TYPE='drift')
import pyTMD
tide = pyTMD.compute_tide_corrections(x, y, delta_time,
DIRECTORY=DIRECTORY, MODEL=MODEL, EPOCH=(2000,1,1,0,0,0),
EPSG=3031, TYPE='drift')

`Source code`__

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
=============
tidal_ellipse
=============
=======
ellipse
=======

- Expresses the amplitudes and phases for the `u` and `v` components in terms of four ellipse parameters using `Foreman's formula <https://www.sciencedirect.com/science/article/pii/0309170889900171>`_

Expand All @@ -9,11 +9,11 @@ Calling Sequence

.. code-block:: python

from pyTMD.tidal_ellipse import tidal_ellipse
umajor,uminor,uincl,uphase = tidal_ellipse(u,v)
import pyTMD
umajor,uminor,uincl,uphase = pyTMD.ellipse(u,v)

`Source code`__

.. __: https://github.com/tsutterley/pyTMD/blob/main/pyTMD/tidal_ellipse.py
.. __: https://github.com/tsutterley/pyTMD/blob/main/pyTMD/ellipse.py

.. autofunction:: pyTMD.tidal_ellipse
.. autofunction:: pyTMD.ellipse
19 changes: 0 additions & 19 deletions doc/source/api_reference/load_constituent.rst

This file was deleted.

2 changes: 2 additions & 0 deletions doc/source/api_reference/predict.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Calling Sequence

.. autofunction:: pyTMD.predict.solid_earth_tide

.. autofunction:: pyTMD.predict._constituent_parameters

.. autofunction:: pyTMD.predict._out_of_phase_diurnal

.. autofunction:: pyTMD.predict._out_of_phase_semidiurnal
Expand Down
5 changes: 2 additions & 3 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ ocean, load, solid Earth and pole tides

api_reference/arguments.rst
api_reference/astro.rst
api_reference/check_tide_points.rst
api_reference/check_points.rst
api_reference/compute_tide_corrections.rst
api_reference/constants.rst
api_reference/convert_crs.rst
api_reference/ellipse.rst
api_reference/eop.rst
api_reference/interpolate.rst
api_reference/io/ATLAS.rst
Expand All @@ -44,10 +45,8 @@ ocean, load, solid Earth and pole tides
api_reference/io/constituents.rst
api_reference/io/model.rst
api_reference/io/ocean_pole_tide.rst
api_reference/load_constituent.rst
api_reference/predict.rst
api_reference/spatial.rst
api_reference/tidal_ellipse.rst
api_reference/time.rst
api_reference/utilities.rst

Expand Down
1 change: 0 additions & 1 deletion notebooks/Plot Antarctic Tidal Currents.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"- `arguments.py`: load the nodal corrections for tidal constituents \n",
"- `astro.py`: computes the basic astronomical mean longitudes \n",
"- `convert_crs.py`: convert points to and from Coordinates Reference Systems \n",
"- `load_constituent.py`: loads parameters for a given tidal constituent \n",
"- `io.model.py`: retrieves tide model parameters for named tide models\n",
"- `io.OTIS.py`: extract tidal harmonic constants from OTIS tide models \n",
"- `io.ATLAS.py`: extract tidal harmonic constants from ATLAS netcdf models \n",
Expand Down
1 change: 0 additions & 1 deletion notebooks/Plot Arctic Ocean Map.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"- `arguments.py`: load the nodal corrections for tidal constituents \n",
"- `astro.py`: computes the basic astronomical mean longitudes \n",
"- `convert_crs.py`: convert points to and from Coordinates Reference Systems \n",
"- `load_constituent.py`: loads parameters for a given tidal constituent \n",
"- `io.model.py`: retrieves tide model parameters for named tide models \n",
"- `io.OTIS.py`: extract tidal harmonic constants from OTIS tide models \n",
"- `io.ATLAS.py`: extract tidal harmonic constants from ATLAS netcdf models \n",
Expand Down
1 change: 0 additions & 1 deletion notebooks/Plot Ross Ice Shelf Map.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"- `arguments.py`: load the nodal corrections for tidal constituents \n",
"- `astro.py`: computes the basic astronomical mean longitudes \n",
"- `convert_crs.py`: convert points to and from Coordinates Reference Systems \n",
"- `load_constituent.py`: loads parameters for a given tidal constituent \n",
"- `io.model.py`: retrieves tide model parameters for named tide models\n",
"- `io.OTIS.py`: extract tidal harmonic constants from OTIS tide models \n",
"- `io.ATLAS.py`: extract tidal harmonic constants from ATLAS netcdf models \n",
Expand Down
1 change: 0 additions & 1 deletion notebooks/Plot Tide Forecasts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"- `arguments.py`: load the nodal corrections for tidal constituents \n",
"- `astro.py`: computes the basic astronomical mean longitudes \n",
"- `convert_crs.py`: convert points to and from Coordinates Reference Systems \n",
"- `load_constituent.py`: loads parameters for a given tidal constituent \n",
"- `io.model.py`: retrieves tide model parameters for named tide models\n",
"- `io.OTIS.py`: extract tidal harmonic constants from OTIS tide models \n",
"- `io.ATLAS.py`: extract tidal harmonic constants from ATLAS netCDF4 tide models \n",
Expand Down
5 changes: 2 additions & 3 deletions pyTMD/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import pyTMD.version
from pyTMD import io
from pyTMD.arguments import arguments
from pyTMD.check_tide_points import check_tide_points
from pyTMD.check_points import check_points
from pyTMD.compute_tide_corrections import (
compute_corrections,
compute_tide_corrections,
Expand All @@ -36,8 +36,7 @@
_ellipsoids
)
from pyTMD.convert_crs import convert_crs
from pyTMD.load_constituent import load_constituent
from pyTMD.tidal_ellipse import tidal_ellipse
from pyTMD.ellipse import ellipse

# Deprecated functions
from pyTMD.calc_astrol_longitudes import calc_astrol_longitudes
Expand Down
4 changes: 2 additions & 2 deletions pyTMD/check_tide_points.py → pyTMD/check_points.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
u"""
check_tide_points.py
check_points.py
Written by Tyler Sutterley (04/2023)
Check if points are within a tide model domain

Expand Down Expand Up @@ -82,11 +82,11 @@
# attempt imports
try:
import pyproj
except (AttributeError, ImportError, ModuleNotFoundError) as exc:

Check warning on line 85 in pyTMD/check_points.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/check_points.py#L85

Added line #L85 was not covered by tests
logging.debug("pyproj not available")

# PURPOSE: compute tides at points and times using tide model algorithms
def check_tide_points(x: np.ndarray, y: np.ndarray,
def check_points(x: np.ndarray, y: np.ndarray,
DIRECTORY: str | pathlib.Path | None = None,
MODEL: str | None = None,
ATLAS_FORMAT: str = 'netcdf',
Expand Down
1 change: 0 additions & 1 deletion pyTMD/compute_tide_corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
arguments.py: load the nodal corrections for tidal constituents
astro.py: computes the basic astronomical mean longitudes
convert_crs.py: convert points to and from Coordinates Reference Systems
load_constituent.py: loads parameters for a given tidal constituent
predict.py: predict tide values using harmonic constants
io/model.py: retrieves tide model parameters for named tide models
io/OTIS.py: extract tidal harmonic constants from OTIS tide models
Expand Down Expand Up @@ -118,7 +117,7 @@
# attempt imports
try:
import pyproj
except (AttributeError, ImportError, ModuleNotFoundError) as exc:

Check warning on line 120 in pyTMD/compute_tide_corrections.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/compute_tide_corrections.py#L120

Added line #L120 was not covered by tests
logging.critical("pyproj not available")

# PURPOSE: wrapper function for computing corrections
Expand Down
7 changes: 4 additions & 3 deletions pyTMD/tidal_ellipse.py → pyTMD/ellipse.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env python
u"""
tidal_ellipse.py (03/2023)
ellipse.py (03/2023)
Expresses the amplitudes and phases for the u and v components in terms of
four ellipse parameters using Foreman's formula

CALLING SEQUENCE:
umajor,uminor,uincl,uphase = tidal_ellipse(u,v)
umajor,uminor,uincl,uphase = ellipse(u,v)

INPUTS:
u: zonal current (EW)
Expand All @@ -24,6 +24,7 @@
https://doi.org/10.1016/0309-1708(89)90017-1

UPDATE HISTORY:
Updated 09/2023: renamed to ellipse.py (from tidal_ellipse.py)
Updated 03/2023: add basic variable typing to function inputs
Updated 04/2022: updated docstrings to numpy documentation format
Written 07/2020
Expand All @@ -32,7 +33,7 @@

import numpy as np

def tidal_ellipse(u: np.ndarray, v: np.ndarray):
def ellipse(u: np.ndarray, v: np.ndarray):
"""
Expresses the amplitudes and phases for the u and v components in terms of
four ellipse parameters using Foreman's formula [1]_
Expand Down
1 change: 0 additions & 1 deletion pyTMD/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def bilinear(
# return interpolated values
return data


def spline(
ilon: np.ndarray,
ilat: np.ndarray,
Expand Down
36 changes: 18 additions & 18 deletions pyTMD/io/ATLAS.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
# attempt imports
try:
import netCDF4
except (AttributeError, ImportError, ModuleNotFoundError) as exc:

Check warning on line 109 in pyTMD/io/ATLAS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/ATLAS.py#L109

Added line #L109 was not covered by tests
logging.critical("netCDF4 not available")

# PURPOSE: extract harmonic constants from tide models at coordinates
Expand Down Expand Up @@ -911,11 +911,11 @@
nc['lat_u'] = fileID.createVariable('lat_u', lat_u.dtype, ('ny',))
nc['lon_v'] = fileID.createVariable('lon_v', lon_v.dtype, ('nx',))
nc['lat_v'] = fileID.createVariable('lat_v', lat_v.dtype, ('ny',))
nc['hz'] = fileID.createVariable('hz', hz.dtype, ('ny','nx',),
nc['hz'] = fileID.createVariable('hz', hz.dtype, ('nx','ny',),

Check warning on line 914 in pyTMD/io/ATLAS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/ATLAS.py#L914

Added line #L914 was not covered by tests
fill_value=0, zlib=True)
nc['hu'] = fileID.createVariable('hu', hu.dtype, ('ny','nx',),
nc['hu'] = fileID.createVariable('hu', hu.dtype, ('nx','ny',),

Check warning on line 916 in pyTMD/io/ATLAS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/ATLAS.py#L916

Added line #L916 was not covered by tests
fill_value=0, zlib=True)
nc['hv'] = fileID.createVariable('hv', hv.dtype, ('ny','nx',),
nc['hv'] = fileID.createVariable('hv', hv.dtype, ('nx','ny',),

Check warning on line 918 in pyTMD/io/ATLAS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/ATLAS.py#L918

Added line #L918 was not covered by tests
fill_value=0, zlib=True)
# filling the NetCDF variables
nc['lon_z'][:] = lon_z[:]
Expand All @@ -924,9 +924,9 @@
nc['lat_u'][:] = lat_u[:]
nc['lon_v'][:] = lon_v[:]
nc['lat_v'][:] = lat_v[:]
nc['hz'][:] = hz[:]
nc['hu'][:] = hu[:]
nc['hv'][:] = hv[:]
nc['hz'][:] = hz[:].T
nc['hu'][:] = hu[:].T
nc['hv'][:] = hv[:].T

Check warning on line 929 in pyTMD/io/ATLAS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/ATLAS.py#L927-L929

Added lines #L927 - L929 were not covered by tests
# define variable attributes
for TYPE in ('z','u','v'):
# set variable attributes for coordinates
Expand Down Expand Up @@ -992,15 +992,15 @@
nc = {}
nc['lon_z'] = fileID.createVariable('lon_z', lon_z.dtype, ('nx',))
nc['lat_z'] = fileID.createVariable('lat_z', lat_z.dtype, ('ny',))
nc['hRe'] = fileID.createVariable('hRe', h.real.dtype, ('ny','nx',),
nc['hRe'] = fileID.createVariable('hRe', h.real.dtype, ('nx','ny',),

Check warning on line 995 in pyTMD/io/ATLAS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/ATLAS.py#L995

Added line #L995 was not covered by tests
fill_value=0, zlib=True)
nc['hIm'] = fileID.createVariable('hIm', h.imag.dtype, ('ny','nx',),
nc['hIm'] = fileID.createVariable('hIm', h.imag.dtype, ('nx','ny',),

Check warning on line 997 in pyTMD/io/ATLAS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/ATLAS.py#L997

Added line #L997 was not covered by tests
fill_value=0, zlib=True)
# filling the NetCDF variables
nc['lon_z'][:] = lon_z[:]
nc['lat_z'][:] = lat_z[:]
nc['hRe'][:] = h.real[:]
nc['hIm'][:] = h.imag[:]
nc['hRe'][:] = h.real[:].T
nc['hIm'][:] = h.imag[:].T

Check warning on line 1003 in pyTMD/io/ATLAS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/ATLAS.py#L1002-L1003

Added lines #L1002 - L1003 were not covered by tests
# define variable attributes
complexpart = dict(Re='Real part', Im='Imag part')
# set variable attributes for coordinates
Expand Down Expand Up @@ -1087,23 +1087,23 @@
nc['lat_u'] = fileID.createVariable('lat_u', lat_u.dtype, ('ny',))
nc['lon_v'] = fileID.createVariable('lon_v', lon_v.dtype, ('nx',))
nc['lat_v'] = fileID.createVariable('lat_v', lat_v.dtype, ('ny',))
nc['uRe'] = fileID.createVariable('uRe', u.real.dtype, ('ny','nx',),
nc['uRe'] = fileID.createVariable('uRe', u.real.dtype, ('nx','ny',),

Check warning on line 1090 in pyTMD/io/ATLAS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/ATLAS.py#L1090

Added line #L1090 was not covered by tests
fill_value=0, zlib=True)
nc['uIm'] = fileID.createVariable('uIm', u.imag.dtype, ('ny','nx',),
nc['uIm'] = fileID.createVariable('uIm', u.imag.dtype, ('nx','ny',),

Check warning on line 1092 in pyTMD/io/ATLAS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/ATLAS.py#L1092

Added line #L1092 was not covered by tests
fill_value=0, zlib=True)
nc['vRe'] = fileID.createVariable('vRe', v.real.dtype, ('ny','nx',),
nc['vRe'] = fileID.createVariable('vRe', v.real.dtype, ('nx','ny',),

Check warning on line 1094 in pyTMD/io/ATLAS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/ATLAS.py#L1094

Added line #L1094 was not covered by tests
fill_value=0, zlib=True)
nc['vIm'] = fileID.createVariable('vIm', v.imag.dtype, ('ny','nx',),
nc['vIm'] = fileID.createVariable('vIm', v.imag.dtype, ('nx','ny',),

Check warning on line 1096 in pyTMD/io/ATLAS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/ATLAS.py#L1096

Added line #L1096 was not covered by tests
fill_value=0, zlib=True)
# filling the NetCDF variables
nc['lon_u'][:] = lon_u[:]
nc['lat_u'][:] = lat_u[:]
nc['lon_v'][:] = lon_v[:]
nc['lat_v'][:] = lat_v[:]
nc['uRe'][:] = u.real[:]
nc['uIm'][:] = u.imag[:]
nc['vRe'][:] = v.real[:]
nc['vIm'][:] = v.imag[:]
nc['uRe'][:] = u.real[:].T
nc['uIm'][:] = u.imag[:].T
nc['vRe'][:] = v.real[:].T
nc['vIm'][:] = v.imag[:].T

Check warning on line 1106 in pyTMD/io/ATLAS.py

View check run for this annotation

Codecov / codecov/patch

pyTMD/io/ATLAS.py#L1103-L1106

Added lines #L1103 - L1106 were not covered by tests
# define variable attributes
direction = dict(u='WE', v='SN')
complexpart = dict(Re='Real part', Im='Imag part')
Expand Down
13 changes: 7 additions & 6 deletions pyTMD/io/model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env python
u"""
model.py
Written by Tyler Sutterley (08/2023)
Written by Tyler Sutterley (09/2023)
Retrieves tide model parameters for named tide models and
from model definition files

UPDATE HISTORY:
Updated 09/2023: fix scale values for TPXO9-atlas currents
Updated 08/2023: changed ESR netCDF4 format to TMD3 format
updated filenames for CATS2008-v2023 to final version
Updated 06/2023: remap FES2012 e2 constituent to eps2
Expand Down Expand Up @@ -726,7 +727,7 @@ def current(self, m: str):
self.model_file = dict(u=self.pathfinder(model_files),
v=self.pathfinder(model_files))
self.projection = '4326'
self.scale = 1.0/100.0
self.scale = 1e-4
self.version = 'v1'
# model description and references
self.reference = ('http://volkov.oce.orst.edu/tides/'
Expand All @@ -743,7 +744,7 @@ def current(self, m: str):
self.model_file = dict(u=self.pathfinder(model_files),
v=self.pathfinder(model_files))
self.projection = '4326'
self.scale = 1.0/100.0
self.scale = 1e-4
self.version = 'v2'
# model description and references
self.reference = 'https://www.tpxo.net/global/tpxo9-atlas'
Expand All @@ -760,7 +761,7 @@ def current(self, m: str):
self.model_file = dict(u=self.pathfinder(model_files),
v=self.pathfinder(model_files))
self.projection = '4326'
self.scale = 1.0/100.0
self.scale = 1e-4
self.version = 'v3'
# model description and references
self.reference = 'https://www.tpxo.net/global/tpxo9-atlas'
Expand All @@ -777,7 +778,7 @@ def current(self, m: str):
self.model_file = dict(u=self.pathfinder(model_files),
v=self.pathfinder(model_files))
self.projection = '4326'
self.scale = 1.0/100.0
self.scale = 1e-4
self.version = 'v4'
# model description and references
self.reference = 'https://www.tpxo.net/global/tpxo9-atlas'
Expand All @@ -795,7 +796,7 @@ def current(self, m: str):
self.model_file = dict(u=self.pathfinder(model_files),
v=self.pathfinder(model_files))
self.projection = '4326'
self.scale = 1.0/100.0
self.scale = 1e-4
self.version = 'v5'
# model description and references
self.reference = 'https://www.tpxo.net/global/tpxo9-atlas'
Expand Down
Loading
Loading