diff --git a/.github/workflows/update-provider-database.yml b/.github/workflows/update-provider-database.yml new file mode 100644 index 00000000..9d339c41 --- /dev/null +++ b/.github/workflows/update-provider-database.yml @@ -0,0 +1,68 @@ +# This workflow will install Python dependencies and update database from the provider files + +name: Update provider database on pull request + +on: + pull_request: + +jobs: + build: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python-version: [3.11] + env: + OS: ${{ matrix.os }} + PYTHON: ${{ matrix.python-version }} + defaults: + run: + shell: bash -l {0} + + steps: + - uses: actions/checkout@v4 + - name: Set up mamba ${{ matrix.python-version }} + uses: mamba-org/setup-micromamba@v1 + with: + micromamba-version: 'latest' + environment-file: environment.yml + init-shell: bash + environment-name: pyTMD + cache-environment: true + post-cleanup: 'all' + create-args: >- + python=${{ matrix.python-version }} + flake8 + gh + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # 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: Merge Providers + run: | + pip install --no-deps --editable . + python providers/_providers_to_database.py --pretty -vv + - name: Check for changes + id: changes + run: | + if [ -n "$(git status --porcelain)" ] ; then + echo "DETECTED=true" >> $GITHUB_OUTPUT; + echo "::debug::Changes detected"; + else + echo "DETECTED=false" >> $GITHUB_OUTPUT; + echo "::debug::No changes detected"; + fi + - name: Checkout PR and Push Changes + if: steps.changes.outputs.DETECTED == 'true' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr checkout ${{ github.event.pull_request.number }} + git add -A + git config user.name ${{ github.actor }} + git config user.email ${{ github.actor }}@users.noreply.github.com + git commit -m "Update provider database" + git push diff --git a/providers/GSFC.json b/providers/GSFC.json index 8fefd895..3472b1f1 100644 --- a/providers/GSFC.json +++ b/providers/GSFC.json @@ -179,6 +179,34 @@ "type": "z", "variable": "tide_load", "version": "5.5" + }, + "GOT5.5D": { + "format": "GOT-netcdf", + "name": "GOT5.5D", + "model_file": [ + "GOT5.5/ocean_tides/2n2.nc", + "GOT5.5/ocean_tides/j1.nc", + "GOT5.5D/ocean_tides/k1_5.5D.nc", + "GOT5.5/ocean_tides/k2.nc", + "GOT5.5D/ocean_tides/m2_5.5D.nc", + "GOT5.5/ocean_tides/m4.nc", + "GOT5.5/ocean_tides/ms4.nc", + "GOT5.5/ocean_tides/mu2.nc", + "GOT5.5/ocean_tides/n2.nc", + "GOT5.5/ocean_tides/o1.nc", + "GOT5.5/ocean_tides/oo1.nc", + "GOT5.5D/ocean_tides/p1_5.5D.nc", + "GOT5.5/ocean_tides/q1.nc", + "GOT5.5D/ocean_tides/s1_5.5D.nc", + "GOT5.5D/ocean_tides/s2_5.5D.nc", + "GOT5.5/ocean_tides/sig1.nc" + ], + "type": "z", + "variable": "tide_ocean", + "version": "5.5", + "scale": 0.01, + "compressed": false, + "reference": "https://ntrs.nasa.gov/citations/19990089548" } } } \ No newline at end of file diff --git a/pyTMD/data/database.json b/pyTMD/data/database.json index c0a217dd..a4329442 100644 --- a/pyTMD/data/database.json +++ b/pyTMD/data/database.json @@ -1457,6 +1457,34 @@ "variable": "tide_ocean", "version": "5.5" }, + "GOT5.5D": { + "compressed": false, + "format": "GOT-netcdf", + "model_file": [ + "GOT5.5/ocean_tides/2n2.nc", + "GOT5.5/ocean_tides/j1.nc", + "GOT5.5D/ocean_tides/k1_5.5D.nc", + "GOT5.5/ocean_tides/k2.nc", + "GOT5.5D/ocean_tides/m2_5.5D.nc", + "GOT5.5/ocean_tides/m4.nc", + "GOT5.5/ocean_tides/ms4.nc", + "GOT5.5/ocean_tides/mu2.nc", + "GOT5.5/ocean_tides/n2.nc", + "GOT5.5/ocean_tides/o1.nc", + "GOT5.5/ocean_tides/oo1.nc", + "GOT5.5D/ocean_tides/p1_5.5D.nc", + "GOT5.5/ocean_tides/q1.nc", + "GOT5.5D/ocean_tides/s1_5.5D.nc", + "GOT5.5D/ocean_tides/s2_5.5D.nc", + "GOT5.5/ocean_tides/sig1.nc" + ], + "name": "GOT5.5D", + "reference": "https://ntrs.nasa.gov/citations/19990089548", + "scale": 0.01, + "type": "z", + "variable": "tide_ocean", + "version": "5.5" + }, "GOT5.5_load": { "format": "GOT-netcdf", "model_file": [ diff --git a/pyTMD/io/model.py b/pyTMD/io/model.py index 7c35647f..509d1b55 100644 --- a/pyTMD/io/model.py +++ b/pyTMD/io/model.py @@ -368,7 +368,7 @@ def formats() -> list: parameters = load_database() # extract all known formats format_list = [] - for type, models in parameters.items(): + for variable, models in parameters.items(): for model, val in models.items(): format_list.append(val['format']) # return unique list of formats @@ -872,23 +872,6 @@ def parse_file( else: return None - @staticmethod - def to_bool(val: str) -> bool: - """ - Converts strings of True/False to a boolean values - - Parameters - ---------- - val: str - string for converting to True/False - """ - if val.lower() in ('y', 'yes', 't', 'true', '1'): - return True - elif val.lower() in ('n', 'no', 'f', 'false', '0'): - return False - else: - raise ValueError(f'Invalid boolean string {val}') - def __str__(self): """String representation of the ``io.model`` object """