diff --git a/doc/source/getting_started/Getting-Started.rst b/doc/source/getting_started/Getting-Started.rst index 51116c9f..0bed3c8d 100644 --- a/doc/source/getting_started/Getting-Started.rst +++ b/doc/source/getting_started/Getting-Started.rst @@ -31,7 +31,6 @@ Presently, the following models and their directories parameterized within ``pyT * CATS0201: ``/cats0201_tmd/`` * `CATS2008 `_: ``/CATS2008/`` * CATS2008_load: ``/CATS2008a_SPOTL_Load/`` - * CATS2022: ``/CATS2022/`` - Arctic Ocean and Greenland Coast Tidal Simulations [Padman2004]_ diff --git a/doc/source/getting_started/Overview.rst b/doc/source/getting_started/Overview.rst index fe2f91fd..af5c48ab 100644 --- a/doc/source/getting_started/Overview.rst +++ b/doc/source/getting_started/Overview.rst @@ -19,19 +19,54 @@ the output ocean, load, solid Earth and pole tide variables as shown in the flow :align: center digraph { - S [label="Spatial Coordinates" shape=box style="filled" color="#7570b3"] - E [label="Temporal Values" shape=box style="filled" color="#7570b3"] - M [label="Tide Model" shape=box style="filled" color="#7570b3"] - T [label="pyTMD" shape=box style="filled" color="gray"] - P [label="Tide Predictions" shape=box style="filled" color="#1b9e77"] - H [label="Tide Heights" shape=box style="filled" color="#1b9e77"] - C [label="Average Tidal Currents" shape=box style="filled" color="#1b9e77"] - S -> T - E -> T - M -> T - T -> P - T -> H - T -> C + S [label="Spatial Coordinates" + fontname="Lato" + fontsize=11 + shape=box + style="filled" + color="#7570b3"] + E [label="Temporal Values" + fontname="Lato" + fontsize=11 + shape=box + style="filled" + color="#7570b3"] + M [label="Tide Model" + fontname="Lato" + fontsize=11 + shape=box + style="filled" + color="#7570b3"] + T [label="pyTMD" + fontname="Lato" + fontsize=11 + shape=box + style="filled" + color="gray"] + P [label="Tide Predictions" + fontname="Lato" + fontsize=11 + shape=box + style="filled" + color="#1b9e77"] + H [label="Tide Heights" + fontname="Lato" + fontsize=11 + shape=box + style="filled" + color="#1b9e77"] + C [label="Average Tidal Currents" + fontname="Lato" + fontsize=11 + shape=box + style="filled" + color="#1b9e77"] + S -> T [arrowsize=0.8] + E -> T [arrowsize=0.8] + M -> T [arrowsize=0.8] + T -> P [arrowsize=0.8] + T -> H [arrowsize=0.8] + T -> C [arrowsize=0.8] } .. graphviz:: @@ -39,13 +74,38 @@ the output ocean, load, solid Earth and pole tide variables as shown in the flow :align: center digraph { - S [label="Spatial Coordinates" shape=box style="filled" color="#7570b3"] - E [label="Temporal Values" shape=box style="filled" color="#7570b3"] - T [label="pyTMD" shape=box style="filled" color="gray"] - D [label="Solid Earth Displacements" shape=box style="filled" color="#1b9e77"] - P [label="Pole Tide Displacements" shape=box style="filled" color="#1b9e77"] - S -> T - E -> T - T -> D - T -> P + S [label="Spatial Coordinates" + fontname="Lato" + fontsize=11 + shape=box + style="filled" + color="#7570b3"] + E [label="Temporal Values" + fontname="Lato" + fontsize=11 + shape=box + style="filled" + color="#7570b3"] + T [label="pyTMD" + fontname="Lato" + fontsize=11 + shape=box + style="filled" + color="gray"] + D [label="Solid Earth Displacements" + fontname="Lato" + fontsize=11 + shape=box + style="filled" + color="#1b9e77"] + P [label="Pole Tide Displacements" + fontname="Lato" + fontsize=11 + shape=box + style="filled" + color="#1b9e77"] + S -> T [arrowsize=0.8] + E -> T [arrowsize=0.8] + T -> D [arrowsize=0.8] + T -> P [arrowsize=0.8] } diff --git a/pyTMD/check_tide_points.py b/pyTMD/check_tide_points.py index 9be791d8..9c4b6d0d 100644 --- a/pyTMD/check_tide_points.py +++ b/pyTMD/check_tide_points.py @@ -68,8 +68,8 @@ """ from __future__ import print_function, annotations +import logging import pathlib -import warnings import numpy as np import scipy.interpolate @@ -82,10 +82,7 @@ try: import pyproj except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("pyproj not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + 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, diff --git a/pyTMD/compute_tide_corrections.py b/pyTMD/compute_tide_corrections.py index a6bf330b..4301b6e1 100644 --- a/pyTMD/compute_tide_corrections.py +++ b/pyTMD/compute_tide_corrections.py @@ -101,8 +101,8 @@ """ from __future__ import print_function, annotations +import logging import pathlib -import warnings import numpy as np import scipy.interpolate import pyTMD.constants @@ -118,10 +118,7 @@ try: import pyproj except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("pyproj not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.critical("pyproj not available") # PURPOSE: wrapper function for computing corrections def compute_corrections( diff --git a/pyTMD/convert_crs.py b/pyTMD/convert_crs.py index 5c43e65b..0119b5d2 100644 --- a/pyTMD/convert_crs.py +++ b/pyTMD/convert_crs.py @@ -47,17 +47,14 @@ """ from __future__ import annotations -import warnings +import logging import numpy as np # attempt imports try: import pyproj except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("pyproj not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.critical("pyproj not available") def convert_crs( i1: np.ndarray, diff --git a/pyTMD/io/ATLAS.py b/pyTMD/io/ATLAS.py index 96217471..4a7743ae 100644 --- a/pyTMD/io/ATLAS.py +++ b/pyTMD/io/ATLAS.py @@ -107,10 +107,7 @@ try: import netCDF4 except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("netCDF4 not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.critical("netCDF4 not available") # PURPOSE: extract harmonic constants from tide models at coordinates def extract_constants( diff --git a/pyTMD/io/FES.py b/pyTMD/io/FES.py index 71274b92..da9c5b31 100644 --- a/pyTMD/io/FES.py +++ b/pyTMD/io/FES.py @@ -107,10 +107,7 @@ try: import netCDF4 except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("netCDF4 not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.critical("netCDF4 not available") # PURPOSE: extract harmonic constants from tide models at coordinates def extract_constants( diff --git a/pyTMD/io/GOT.py b/pyTMD/io/GOT.py index e7292364..5cd16960 100644 --- a/pyTMD/io/GOT.py +++ b/pyTMD/io/GOT.py @@ -98,10 +98,7 @@ try: import netCDF4 except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("netCDF4 not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.debug("netCDF4 not available") # PURPOSE: extract harmonic constants from tide models at coordinates def extract_constants( diff --git a/pyTMD/io/OTIS.py b/pyTMD/io/OTIS.py index 6b5324ff..77cb39a6 100644 --- a/pyTMD/io/OTIS.py +++ b/pyTMD/io/OTIS.py @@ -112,6 +112,7 @@ import copy import struct +import logging import pathlib import warnings import numpy as np @@ -124,10 +125,7 @@ try: import netCDF4 except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("netCDF4 not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.debug("netCDF4 not available") # PURPOSE: extract harmonic constants from tide models at coordinates def extract_constants( diff --git a/pyTMD/spatial.py b/pyTMD/spatial.py index 782f3022..d7b3f9db 100644 --- a/pyTMD/spatial.py +++ b/pyTMD/spatial.py @@ -54,7 +54,7 @@ Updated 07/2021: added function for determining input variable type Updated 03/2021: added polar stereographic area scale calculation add routines for converting to and from cartesian coordinates - eplaced numpy bool/int to prevent deprecation warnings + replaced numpy bool/int to prevent deprecation warnings Updated 01/2021: add streaming from bytes for ascii, netCDF4, HDF5, geotiff set default time for geotiff files to 0 Updated 12/2020: added module for converting ellipsoids @@ -73,7 +73,6 @@ import logging import pathlib import datetime -import warnings import numpy as np import pyTMD.time from pyTMD.constants import constants @@ -82,20 +81,15 @@ try: import osgeo.gdal, osgeo.osr, osgeo.gdalconst except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("GDAL not available", ImportWarning) + logging.debug("GDAL not available") try: import h5py except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("h5py not available", ImportWarning) + logging.debug("h5py not available") try: import netCDF4 except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("netCDF4 not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.debug("netCDF4 not available") def case_insensitive_filename(filename: str | pathlib.Path): """ @@ -1604,8 +1598,8 @@ def _zhu_closed_form( def scale_areas( lat: np.ndarray, - flat: float=_wgs84.flat, - ref: float=70.0 + flat: float = _wgs84.flat, + ref: float = 70.0 ): """ Calculates area scaling factors for a polar stereographic projection diff --git a/pyTMD/time.py b/pyTMD/time.py index 0bd4ddb2..3e03466c 100644 --- a/pyTMD/time.py +++ b/pyTMD/time.py @@ -1,7 +1,7 @@ #!/usr/bin/env python u""" time.py -Written by Tyler Sutterley (05/2023) +Written by Tyler Sutterley (06/2023) Utilities for calculating time operations PYTHON DEPENDENCIES: @@ -16,6 +16,7 @@ utilities.py: download and management utilities for syncing files UPDATE HISTORY: + Updated 06/2023: improve conversion of timescale to datetime arrays Updated 05/2023: add timescale class for converting between time scales added timescale to_datetime function to create datetime arrays allow epoch arguments to be numpy datetime64 variables or strings @@ -135,7 +136,7 @@ def parse_date_string(date_string: str): # return the epoch (as list) return (datetime_to_list(epoch), 0.0) # split the date string into units and epoch - units,epoch = split_date_string(date_string) + units, epoch = split_date_string(date_string) if units not in _to_sec.keys(): raise ValueError(f'Invalid units: {units}') # return the epoch (as list) and the time unit conversion factors @@ -193,7 +194,7 @@ def calendar_days(year: int | float | np.ndarray) -> np.ndarray: Returns ------- - dpm: list + dpm: np.ndarray number of days for each month """ # Rules in the Gregorian calendar for a year to be a leap year: @@ -255,9 +256,9 @@ def convert_delta_time( ---------- delta_time: np.ndarray seconds since epoch1 - epoch1: tuple or NoneType, default None + epoch1: str, tuple, list or NoneType, default None epoch for input ``delta_time`` - epoch2: tuple or NoneType, default None + epoch2: str, tuple, list or NoneType, default None epoch for output ``delta_time`` scale: float, default 1.0 scaling factor for converting time to output units @@ -289,7 +290,7 @@ def convert_calendar_dates( scale: float = 1.0 ) -> np.ndarray: """ - Calculate the time in time units since ``epoch`` from calendar dates + Calculate the time in units since ``epoch`` from calendar dates Parameters ---------- @@ -759,7 +760,7 @@ def to_datetime(self): # use nanoseconds to keep as much precision as possible delta_time = np.atleast_1d(self.MJD*self.day*1e9).astype(np.int64) # return the datetime array - return np.array([epoch + np.timedelta64(s, 'ns') for s in delta_time]) + return np.array(epoch + delta_time.astype('timedelta64[ns]')) # PURPOSE: calculate the sum of a polynomial function of time def polynomial_sum(self, coefficients: list | np.ndarray, t: np.ndarray): diff --git a/scripts/compute_LPET_elevations.py b/scripts/compute_LPET_elevations.py index 287b6409..3992ebcd 100644 --- a/scripts/compute_LPET_elevations.py +++ b/scripts/compute_LPET_elevations.py @@ -88,7 +88,6 @@ import sys import logging import pathlib -import warnings import argparse import numpy as np import pyTMD @@ -97,10 +96,7 @@ try: import pyproj except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("pyproj not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.critical("pyproj not available") # PURPOSE: try to get the projection information for the input file def get_projection(attributes, PROJECTION): diff --git a/scripts/compute_LPT_displacements.py b/scripts/compute_LPT_displacements.py index 4f824535..a25d7b3f 100644 --- a/scripts/compute_LPT_displacements.py +++ b/scripts/compute_LPT_displacements.py @@ -106,7 +106,6 @@ import sys import logging import pathlib -import warnings import argparse import numpy as np import pyTMD @@ -115,10 +114,7 @@ try: import pyproj except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("pyproj not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.critical("pyproj not available") # PURPOSE: try to get the projection information for the input file def get_projection(attributes, PROJECTION): diff --git a/scripts/compute_OPT_displacements.py b/scripts/compute_OPT_displacements.py index 0bcc6d41..0e04a66e 100644 --- a/scripts/compute_OPT_displacements.py +++ b/scripts/compute_OPT_displacements.py @@ -122,7 +122,6 @@ import sys import logging import pathlib -import warnings import argparse import numpy as np import scipy.interpolate @@ -132,10 +131,7 @@ try: import pyproj except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("pyproj not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.critical("pyproj not available") # PURPOSE: try to get the projection information for the input file def get_projection(attributes, PROJECTION): diff --git a/scripts/compute_SET_displacements.py b/scripts/compute_SET_displacements.py index 791185d6..9315a7a1 100644 --- a/scripts/compute_SET_displacements.py +++ b/scripts/compute_SET_displacements.py @@ -101,7 +101,6 @@ import sys import logging import pathlib -import warnings import argparse import numpy as np import pyTMD @@ -110,10 +109,7 @@ try: import pyproj except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("pyproj not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.critical("pyproj not available") # PURPOSE: try to get the projection information for the input file def get_projection(attributes, PROJECTION): diff --git a/scripts/compute_tidal_currents.py b/scripts/compute_tidal_currents.py index f73965a8..0a2f7fd6 100755 --- a/scripts/compute_tidal_currents.py +++ b/scripts/compute_tidal_currents.py @@ -137,7 +137,6 @@ import sys import logging import pathlib -import warnings import argparse import numpy as np import pyTMD @@ -146,10 +145,7 @@ try: import pyproj except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("pyproj not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.critical("pyproj not available") # PURPOSE: try to get the projection information for the input file def get_projection(attributes, PROJECTION): diff --git a/scripts/compute_tidal_elevations.py b/scripts/compute_tidal_elevations.py index 0c80239c..9b98a141 100755 --- a/scripts/compute_tidal_elevations.py +++ b/scripts/compute_tidal_elevations.py @@ -142,7 +142,6 @@ import sys import logging import pathlib -import warnings import argparse import numpy as np import pyTMD @@ -151,10 +150,7 @@ try: import pyproj except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("pyproj not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.critical("pyproj not available") # PURPOSE: try to get the projection information for the input file def get_projection(attributes, PROJECTION): diff --git a/scripts/reduce_OTIS_files.py b/scripts/reduce_OTIS_files.py index 788d38e7..9320b9ec 100644 --- a/scripts/reduce_OTIS_files.py +++ b/scripts/reduce_OTIS_files.py @@ -50,8 +50,8 @@ from __future__ import print_function import sys +import logging import pathlib -import warnings import argparse import numpy as np import pyTMD.io @@ -62,10 +62,7 @@ try: import pyproj except (ImportError, ModuleNotFoundError) as exc: - warnings.filterwarnings("module") - warnings.warn("pyproj not available", ImportWarning) -# ignore warnings -warnings.filterwarnings("ignore") + logging.critical("pyproj not available") # PURPOSE: try to get the projection information for the input file def get_projection(PROJECTION):