From 238ad59754d30c7087223cefc1650b567f6a2bff Mon Sep 17 00:00:00 2001 From: tsutterley Date: Thu, 17 Aug 2023 13:08:16 -0700 Subject: [PATCH] refactor: place PyYAML behind try/except statement to reduce build size --- doc/source/release_notes/release-v1.0.2.7.rst | 2 +- doc/source/release_notes/release-v1.0.2.9.rst | 4 +-- doc/source/release_notes/release-v1.0.5.rst | 2 +- doc/source/release_notes/release-v1.0.7.rst | 2 +- doc/source/release_notes/release-v1.1.3.rst | 2 +- doc/source/release_notes/release-v2.0.0.rst | 4 +-- doc/source/release_notes/release-v2.0.1.rst | 28 +++++++++---------- doc/source/release_notes/release-v2.0.2.rst | 2 +- doc/source/release_notes/release-v2.0.3.rst | 4 +-- doc/source/release_notes/release-v2.0.4.rst | 2 +- doc/source/release_notes/release-v2.0.5.rst | 2 +- doc/source/release_notes/release-v2.0.7.rst | 5 ++-- pyTMD/spatial.py | 6 +++- requirements.txt | 1 - 14 files changed, 35 insertions(+), 31 deletions(-) diff --git a/doc/source/release_notes/release-v1.0.2.7.rst b/doc/source/release_notes/release-v1.0.2.7.rst index 3e2bf474..c6b3957e 100644 --- a/doc/source/release_notes/release-v1.0.2.7.rst +++ b/doc/source/release_notes/release-v1.0.2.7.rst @@ -2,7 +2,7 @@ `Release v1.0.2.7`__ #################### -- Added download CATS2008 and read program check +- Added download `CATS2008` and read program check - Added comparison with Antarctic tide gauges (AntTG) and RMS values from `King et al. (2011) `_ - Updated testing suite to directly call Matlab program through ``octave`` (and ``oct2py``) - Will compare the python and matlab versions for most Antarctic station sites diff --git a/doc/source/release_notes/release-v1.0.2.9.rst b/doc/source/release_notes/release-v1.0.2.9.rst index 457e8b60..c51fbbf6 100644 --- a/doc/source/release_notes/release-v1.0.2.9.rst +++ b/doc/source/release_notes/release-v1.0.2.9.rst @@ -2,8 +2,8 @@ `Release v1.0.2.9`__ #################### -- added test for GOT models using perth3 outputs from GOT4.7 -- GOT4.7 tide model data is stored on s3 +- added test for GOT models using perth3 outputs from `GOT4.7` +- `GOT4.7` tide model data is stored on s3 - convert times for FES models to Dynamic time (`TT`) - add equilibrium tide program - add program for calculating equilibrium tides for Operation IceBridge diff --git a/doc/source/release_notes/release-v1.0.5.rst b/doc/source/release_notes/release-v1.0.5.rst index 38fa6bad..b895c27c 100644 --- a/doc/source/release_notes/release-v1.0.5.rst +++ b/doc/source/release_notes/release-v1.0.5.rst @@ -6,7 +6,7 @@ - ``fix``: Operation IceBridge functions for geotrajectory outputs - ``feat``: try to get grid mapping attributes from netCDF4 and HDF5 - ``refactor``: adjust longitude convention based on model longitude -- ``feat``: add TPXO9-atlas-v5 to standard models +- ``feat``: add `TPXO9-atlas-v5` to standard models - ``feat``: add tide program for ATL10 freeboard files - ``feat``: added function to calculate a tidal time series diff --git a/doc/source/release_notes/release-v1.0.7.rst b/doc/source/release_notes/release-v1.0.7.rst index 514cc950..6073052f 100644 --- a/doc/source/release_notes/release-v1.0.7.rst +++ b/doc/source/release_notes/release-v1.0.7.rst @@ -8,7 +8,7 @@ - ``feat``: added Greenland 1km model (`Gr1kmTM`) to list of models - ``feat``: added field_mapping options to netCDF4 and HDF5 reads - ``refactor``: changed keyword arguments to camel case -- ``refactor``: use pypi versions of ICESat-2 and ATM1b tools +- ``refactor``: use ``pypi`` versions of ICESat-2 and ATM1b tools - ``docs``: add paragraph about delta times .. __: https://github.com/tsutterley/pyTMD/releases/tag/1.0.7 diff --git a/doc/source/release_notes/release-v1.1.3.rst b/doc/source/release_notes/release-v1.1.3.rst index c7650f4b..2c174c46 100644 --- a/doc/source/release_notes/release-v1.1.3.rst +++ b/doc/source/release_notes/release-v1.1.3.rst @@ -2,7 +2,7 @@ `Release v1.1.3`__ ################## -- ``docs``: use sphinx-argparse v0.4.0 +- ``docs``: use ``sphinx-argparse`` v0.4.0 - ``refactor``: use f-strings for ascii and verbose output - ``chore``: automatic time and bulletin updates diff --git a/doc/source/release_notes/release-v2.0.0.rst b/doc/source/release_notes/release-v2.0.0.rst index c49d3e7f..dc89f34b 100644 --- a/doc/source/release_notes/release-v2.0.0.rst +++ b/doc/source/release_notes/release-v2.0.0.rst @@ -2,7 +2,7 @@ `Release v2.0.0`__ ################## -- ``refactor``: single implicit import of pyTMD tools (`#130 `_) +- ``refactor``: single implicit import of ``pyTMD`` tools (`#130 `_) - ``refactor``: reorganization of tide model readers under ``io`` (`#132 `_) - ``refactor``: placed interpolation routines into new module (`#141 `_) - ``refactor``: move ``model`` class to ``io`` @@ -15,7 +15,7 @@ - ``docs``: update documentation for new structure - ``docs``: standardized citation format throughout docstrings - ``docs``: add release notes for all prior public releases -- ``docs``: add new pyTMD logo +- ``docs``: add new ``pyTMD`` logo - ``test``: read header from OPT test file and compare more variables - ``test``: add tests for ``io`` methods diff --git a/doc/source/release_notes/release-v2.0.1.rst b/doc/source/release_notes/release-v2.0.1.rst index de4db3a5..2625f0c2 100644 --- a/doc/source/release_notes/release-v2.0.1.rst +++ b/doc/source/release_notes/release-v2.0.1.rst @@ -2,19 +2,19 @@ `Release v2.0.1`__ ################## -* feat: default geotiff output as cog -* feat: added default field mapping for reading from netCDF4/HDF5 (`#152 `_) -* feat: split netCDF4 output for ``grid`` and ``drift`` types to address `#154 `_ (`#159 `_) -* feat: use debug level logging instead of import warnings in ``tools.py`` to address `#156 `_ (`#159 `_) -* feat: add ``time series`` type to address `#153 `_ (`#162 `_) -* fix: verify warnings have type and only show once `#146 `_ (`#147 `_) -* fix: pin ``scipy`` to 1.9.3 for `scipy/scipy#17716 `_ (`#147 `_) -* fix: use default context from ``utilities`` module (`#147 `_) -* fix: include more possible dimension names for ``grid`` and ``time series`` outputs (`#163 `_) -* test: add default field mapping test (`#152 `_) -* test: validate gridded and time series netCDF/HDF5 io (`#163 `_) -* docs: update documentation colors to match new logo -* docs: don't have metavar for ``--tide`` to address `#155 `_ (`#159 `_) -* docs: updated v2 link for Arc2km to address `#157 `_ (`#159 `_) +* ``feat``: default geotiff output as cog +* ``feat``: added default field mapping for reading from netCDF4/HDF5 (`#152 `_) +* ``feat``: split netCDF4 output for ``grid`` and ``drift`` types to address `#154 `_ (`#159 `_) +* ``feat``: use debug level logging instead of import warnings in ``tools.py`` to address `#156 `_ (`#159 `_) +* ``feat``: add ``time series`` type to address `#153 `_ (`#162 `_) +* ``fix``: verify warnings have type and only show once `#146 `_ (`#147 `_) +* ``fix``: pin ``scipy`` to 1.9.3 for `scipy/scipy#17716 `_ (`#147 `_) +* ``fix``: use default context from ``utilities`` module (`#147 `_) +* ``fix``: include more possible dimension names for ``grid`` and ``time series`` outputs (`#163 `_) +* ``test``: add default field mapping test (`#152 `_) +* ``test``: validate gridded and time series netCDF/HDF5 io (`#163 `_) +* ``docs``: update documentation colors to match new logo +* ``docs``: don't have metavar for ``--tide`` to address `#155 `_ (`#159 `_) +* ``docs``: updated v2 link for Arc2km to address `#157 `_ (`#159 `_) .. __: https://github.com/tsutterley/pyTMD/releases/tag/2.0.1 diff --git a/doc/source/release_notes/release-v2.0.2.rst b/doc/source/release_notes/release-v2.0.2.rst index fa214904..6544522f 100644 --- a/doc/source/release_notes/release-v2.0.2.rst +++ b/doc/source/release_notes/release-v2.0.2.rst @@ -2,7 +2,7 @@ `Release v2.0.2`__ ################## -* ``chore``: bump scipy pin to 1.10.1 to address `#148 `_ (`#167 `_) +* ``chore``: bump ``scipy`` pin to 1.10.1 to address `#148 `_ (`#167 `_) * ``refactor``: remove deprecated functions (`#171 `_) .. __: https://github.com/tsutterley/pyTMD/releases/tag/2.0.2 diff --git a/doc/source/release_notes/release-v2.0.3.rst b/doc/source/release_notes/release-v2.0.3.rst index 37cc8099..597d94dc 100644 --- a/doc/source/release_notes/release-v2.0.3.rst +++ b/doc/source/release_notes/release-v2.0.3.rst @@ -7,7 +7,7 @@ * ``feat``: added option to change IERS mean or secular pole convention (`#176 `_) * ``feat``: added 2018 IERS secular pole convention (`#176 `_) * ``feat``: set ellipsoid name and output units as ``constants`` attributes (`#176 `_) -* ``feat``: add ``'HAMTIDE11'`` model to address `#179 `_ (`#180 `_) +* ``feat``: add `HAMTIDE11` model to address `#179 `_ (`#180 `_) * ``feat``: adding work for computing solid earth tides (`#186 `_) * ``feat``: add solid Earth tide (SET) correction program for files (`#186 `_) * ``feat``: add function for phase angles (`#186 `_) @@ -15,7 +15,7 @@ * ``refactor``: renamed coordinate reference system conversion functions (`#174 `_) * ``refactor``: mapping notebooks for matplotlib 3.5 (`#182 `_) * ``fix``: setting directories for ``FES`` currents within ``model`` class (`#182 `_) -* ``fix``: check if datetime before converting to seconds (`#186 `_) +* ``fix``: check if ``datetime`` before converting to seconds (`#186 `_) * ``fix``: copy inputs in cartesian to not modify original arrays (`#186 `_) * ``docs``: remove deprecated ``.rst`` files (`#174 `_) * ``docs``: update documentation to denote new solid Earth tide (SET) functionality (`#186 `_) diff --git a/doc/source/release_notes/release-v2.0.4.rst b/doc/source/release_notes/release-v2.0.4.rst index 31b9fcb5..51d1281b 100644 --- a/doc/source/release_notes/release-v2.0.4.rst +++ b/doc/source/release_notes/release-v2.0.4.rst @@ -40,7 +40,7 @@ * ``test``: add test for more derived attributes in model (`#188 `_) * ``test``: parse all multiple file types for constituent names (`#190 `_) * ``test``: test permanent tide conversion in solid earth (`#190 `_) -* ``test``: get IODEM3 from AWS s3 (NSIDC is currently down) (`#192 `_) +* ``test``: get `IODEM3` from AWS s3 (NSIDC is currently down) (`#192 `_) * ``test``: add ``timescale`` checks for conversions and constants (`#198 `_) * ``test``: add test for leap seconds in ``timescale`` (`#198 `_) diff --git a/doc/source/release_notes/release-v2.0.5.rst b/doc/source/release_notes/release-v2.0.5.rst index cc1195f6..48771470 100644 --- a/doc/source/release_notes/release-v2.0.5.rst +++ b/doc/source/release_notes/release-v2.0.5.rst @@ -8,7 +8,7 @@ * ``feat``: add functions to retrieve and revoke Earthdata tokens (`#209 `_) * ``fix``: don't set a default directory in ``tools`` for `#202 `_ (`#203 `_) * ``fix``: setting path to output file in scripts where not defined as an argument -* ``fix``: extract variables for FES2012 ocean tide (`#212 `_) +* ``fix``: extract variables for `FES2012` ocean tide (`#212 `_) * ``docs``: update solid earth section (`#205 `_) * ``test``: add a time zone case to parsing (`#203 `_) diff --git a/doc/source/release_notes/release-v2.0.7.rst b/doc/source/release_notes/release-v2.0.7.rst index 5bdc64f8..245f6367 100644 --- a/doc/source/release_notes/release-v2.0.7.rst +++ b/doc/source/release_notes/release-v2.0.7.rst @@ -2,8 +2,9 @@ `Release v2.0.7`__ ################## -* ``feat``: added model parameters for CATS2008-v2023 (`#229 `_) -* ``refactor``: changed ESR netCDF4 format to TMD3 format (`#229 `_) +* ``feat``: added model parameters for `CATS2008-v2023` (`#229 `_) +* ``refactor``: changed ``ESR`` netCDF4 format to ``TMD3`` format (`#229 `_) +* ``refactor``: place more imports behind try/except statements to reduce RTD build size (`#230 `_) * ``fix``: remove possible `crs` variables from output netCDF4 fields list (`#229 `_) * ``ci``: bump actions to python 3.11 (`#229 `_) * ``docs``: `switch to RTD `_ ``build.os`` configuration (`#230 `_) diff --git a/pyTMD/spatial.py b/pyTMD/spatial.py index 4549dbc2..e5fbea1b 100644 --- a/pyTMD/spatial.py +++ b/pyTMD/spatial.py @@ -23,6 +23,7 @@ UPDATE HISTORY: Updated 08/2023: remove possible crs variables from output fields list + place PyYAML behind try/except statement to reduce build size Updated 05/2023: use datetime parser within pyTMD.time module Updated 04/2023: copy inputs in cartesian to not modify original arrays added iterative methods for converting from cartesian to geodetic @@ -70,7 +71,6 @@ import copy import gzip import uuid -import yaml import logging import pathlib import datetime @@ -91,6 +91,10 @@ import netCDF4 except (ImportError, ModuleNotFoundError) as exc: logging.debug("netCDF4 not available") +try: + import yaml +except (ImportError, ModuleNotFoundError) as exc: + logging.debug("PyYAML not available") def case_insensitive_filename(filename: str | pathlib.Path): """ diff --git a/requirements.txt b/requirements.txt index 378807cc..11623e1f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,5 @@ netCDF4 numpy pyproj python-dateutil -pyyaml scipy>=1.10.1 setuptools_scm