Skip to content

Commit

Permalink
refactor: create database from providers
Browse files Browse the repository at this point in the history
refactor: drop support for the ascii definition file format
  • Loading branch information
tsutterley committed Sep 5, 2024
1 parent 3906e29 commit 40a9bb4
Show file tree
Hide file tree
Showing 37 changed files with 2,308 additions and 720 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ prune run*
prune test*
exclude *.cfg
exclude *.yml
include requirements.txt
2 changes: 2 additions & 0 deletions doc/source/api_reference/io/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ Retrieves tide model parameters for named tide models and from model definition
General Attributes and Methods
==============================

.. autofunction:: pyTMD.io.load_database

.. autoclass:: pyTMD.io.model
:members:
14 changes: 4 additions & 10 deletions doc/source/getting_started/Getting-Started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Directories

``pyTMD`` uses a tree structure for storing the tidal constituent data.
This structure was chosen based on the different formats of each tide model.
Presently, the following models and their directories parameterized within ``pyTMD``.
Presently, the following models and their directories are parameterized within ``pyTMD`` in a JSON database.

- Circum-Antarctic Tidal Simulations [Padman2008]_

Expand Down Expand Up @@ -133,15 +133,9 @@ elevations or currents (zonal and meridional) for each point.
Definition Files
################

For models not parameterized within ``pyTMD``, the parameters can be set with a model definition file.
There are two types of definition files currently supported by ``pyTMD`` (``ascii`` and ``json``).

The tab-delimited text format (``ascii``) consists of two separate columns (parameter names and parameter values).
These definition files are read line by line to fill a python dictionary mapping the names with their values.
For parameters consisting of lists, the parameter values can be separated by spaces or commas.
For FES-type models of currents, the two lists of model files (``u`` and ``v``) should be separated in the list with a semi-colon.

The JSON format (``json``) directly maps the parameter names with their values stored in the appropriate data type (strings, lists, numbers, booleans, etc).
For models within the ``pyTMD`` database, the parameters can be set with a model definition file in JSON format.
The JSON definition files follow a similar structure as the main ``pyTMD`` database, but for individual entries.
The JSON format directly maps the parameter names with their values stored in the appropriate data type (strings, lists, numbers, booleans, etc).
For FES-type models of currents, the two lists of model files (``u`` and ``v``) are stored in a name-value pair objects (similar to a python dictionary).
While still human readable, the JSON format is both interoperable and more easily machine readable.

Expand Down
2 changes: 1 addition & 1 deletion notebooks/Check Tide Map.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
" format=TMDwidgets.atlas.value,\n",
" compressed=TMDwidgets.compress.value\n",
" ).elevation(TMDwidgets.model.value)\n",
" \n",
"\n",
"# read tidal constants and interpolate to grid points\n",
"if model.format in ('OTIS','ATLAS-compact','TMD3'):\n",
" # if reading a single OTIS solution\n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/Plot Antarctic Tidal Currents.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"outputs": [],
"source": [
"# available model list\n",
"model_list = sorted(pyTMD.io.model.global_current() + pyTMD.io.model.antarctic_current())\n",
"model_list = sorted(pyTMD.io.model.ocean_current())\n",
"# display widgets for setting directory and model\n",
"TMDwidgets = pyTMD.tools.widgets()\n",
"TMDwidgets.model.options = model_list\n",
Expand Down Expand Up @@ -287,7 +287,7 @@
"ttl = fig.suptitle(None, y=0.97, fontsize=13)\n",
"# adjust subplot within figure\n",
"fig.subplots_adjust(left=0.02,right=0.98,bottom=0.1,top=0.98,wspace=0.04)\n",
" \n",
"\n",
"# animate each map\n",
"def animate_maps(hour):\n",
" # set map data iterating over u and v currents\n",
Expand Down
4 changes: 2 additions & 2 deletions notebooks/Plot Antarctic Tide Range.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"outputs": [],
"source": [
"# available model list\n",
"model_list = sorted(pyTMD.io.model.global_ocean() + pyTMD.io.model.antarctic_ocean())\n",
"model_list = sorted(pyTMD.io.model.ocean_elevation())\n",
"# display widgets for setting directory and model\n",
"TMDwidgets = pyTMD.tools.widgets()\n",
"TMDwidgets.model.options = model_list\n",
Expand Down Expand Up @@ -165,7 +165,7 @@
"source": [
"def infer_minor_amplitudes(zmajor,constituents):\n",
" # number of constituents\n",
" npts,nc = np.shape(zmajor) \n",
" npts,nc = np.shape(zmajor)\n",
" cindex = ['q1','o1','p1','k1','n2','m2','s2','k2']\n",
" # re-order zmajor to correspond to cindex\n",
" z8 = np.ma.zeros((npts,8))\n",
Expand Down
8 changes: 4 additions & 4 deletions notebooks/Plot Arctic Ocean Map.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"outputs": [],
"source": [
"# available model list\n",
"model_list = sorted(pyTMD.io.model.global_ocean() + pyTMD.io.model.arctic_ocean())\n",
"model_list = sorted(pyTMD.io.model.ocean_elevation())\n",
"# display widgets for setting directory and model\n",
"TMDwidgets = pyTMD.tools.widgets()\n",
"TMDwidgets.model.options = model_list\n",
Expand Down Expand Up @@ -207,12 +207,12 @@
" c = model.constituents\n",
" # delta time (TT - UT1)\n",
" DELTAT = ts.tt_ut1\n",
" \n",
"\n",
"# calculate complex phase in radians for Euler's\n",
"cph = -1j*ph*np.pi/180.0\n",
"# calculate constituent oscillation\n",
"hc = amp*np.exp(cph)\n",
" \n",
"\n",
"# allocate for tide map calculated every hour\n",
"tide_cm = np.ma.zeros((ny,nx,24))\n",
"for hour in range(24):\n",
Expand Down Expand Up @@ -280,7 +280,7 @@
"ax.spines['geo'].set_capstyle('projecting')\n",
"# adjust subplot within figure\n",
"fig.subplots_adjust(left=0.02,right=0.98,bottom=0.05,top=0.95)\n",
" \n",
"\n",
"# animate each map\n",
"def animate_maps(hour):\n",
" # set map data\n",
Expand Down
8 changes: 4 additions & 4 deletions notebooks/Plot Ross Ice Shelf Map.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"outputs": [],
"source": [
"# available model list\n",
"model_list = sorted(pyTMD.io.model.global_ocean() + pyTMD.io.model.antarctic_ocean())\n",
"model_list = sorted(pyTMD.io.model.ocean_elevation())\n",
"# display widgets for setting directory and model\n",
"TMDwidgets = pyTMD.tools.widgets()\n",
"TMDwidgets.model.options = model_list\n",
Expand Down Expand Up @@ -207,12 +207,12 @@
" c = model.constituents\n",
" # delta time (TT - UT1)\n",
" DELTAT = ts.tt_ut1\n",
" \n",
"\n",
"# calculate complex phase in radians for Euler's\n",
"cph = -1j*ph*np.pi/180.0\n",
"# calculate constituent oscillation\n",
"hc = amp*np.exp(cph)\n",
" \n",
"\n",
"# allocate for tide map calculated every hour\n",
"tide_cm = np.ma.zeros((ny,nx,24))\n",
"for hour in range(24):\n",
Expand Down Expand Up @@ -280,7 +280,7 @@
"ax.spines['geo'].set_capstyle('projecting')\n",
"# adjust subplot within figure\n",
"fig.subplots_adjust(left=0.02,right=0.98,bottom=0.05,top=0.98)\n",
" \n",
"\n",
"# animate each map\n",
"def animate_maps(hour):\n",
" # set map data\n",
Expand Down
Loading

0 comments on commit 40a9bb4

Please sign in to comment.