Skip to content

Commit

Permalink
Merge branch 'main' into fix_extrapolate_water
Browse files Browse the repository at this point in the history
  • Loading branch information
SorooshMani-NOAA authored Aug 13, 2024
2 parents 12fa952 + 2cd962e commit f66f9c4
Show file tree
Hide file tree
Showing 79 changed files with 1,610 additions and 952 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install Poetry
uses: abatilo/actions-poetry@v2.1.3
uses: abatilo/actions-poetry@v3
- name: install Dunamai
run: pip install dunamai
- name: extract version from VCS
Expand Down
34 changes: 20 additions & 14 deletions .github/workflows/quick_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: clone repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: load cached Python installation
id: cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: lint-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
Expand All @@ -40,19 +42,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: clone repository
uses: actions/checkout@v2
- name: install Python
uses: actions/setup-python@v2
# due to coupledmodeldriver dependency python 3.10 cannot be supported
with:
python-version: 3.9
- name: load cached Python installation
id: cache
uses: actions/cache@v2
uses: actions/checkout@v4
- name: conda virtual environment
uses: mamba-org/setup-micromamba@v1
with:
path: ${{ env.pythonLocation }}
key: test-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
init-shell: bash
environment-name: ci-env
create-args: >-
python=3.9
libnetcdf
hdf5
udunits2
- name: install dependencies
run: pip install ".[testing]"
shell: micromamba-shell {0}
- name: rebuild netcdf from source
run: pip install --upgrade --force-reinstall --no-deps --no-cache-dir netcdf4 --no-binary netcdf4
shell: micromamba-shell {0}
- name: run tests
run: pytest --numprocesses auto
shell: micromamba-shell {0}
65 changes: 38 additions & 27 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: clone repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: load cached Python installation
id: cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: lint-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
Expand All @@ -44,51 +46,60 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
# due to coupledmodeldriver dependency python 3.10 cannot be supported
python-version: [ '3.8', '3.9' ]
python-version: [ '3.9', '3.10', '3.11' ]
steps:
- name: clone repository
uses: actions/checkout@v2
- name: install Python
uses: actions/setup-python@v2
uses: actions/checkout@v4
- name: conda virtual environment
uses: mamba-org/setup-micromamba@v1
with:
python-version: ${{ matrix.python-version }}
- name: load cached Python installation
id: cache
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: test-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
init-shell: bash
environment-name: ci-env
create-args: >-
python=${{ matrix.python-version }}
libnetcdf
hdf5
udunits2
- name: install dependencies
run: pip install ".[testing]"
shell: micromamba-shell {0}
- name: rebuild netcdf from source
run: pip install --upgrade --force-reinstall --no-deps --no-cache-dir netcdf4 --no-binary netcdf4
shell: micromamba-shell {0}
- name: run tests
run: pytest --numprocesses auto
shell: micromamba-shell {0}
test_with_coverage:
needs: [ lint, test ]
name: test with coverage
runs-on: ubuntu-latest
steps:
- name: clone repository
uses: actions/checkout@v2
- name: install Python
uses: actions/setup-python@v2
# due to coupledmodeldriver dependency python 3.10 cannot be supported
with:
python-version: 3.9
- name: load cached Python installation
id: cache
uses: actions/cache@v2
uses: actions/checkout@v4
- name: conda virtual environment
uses: mamba-org/setup-micromamba@v1
with:
path: ${{ env.pythonLocation }}
key: test-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
init-shell: bash
environment-name: ci-env
create-args: >-
python=3.9
libnetcdf
hdf5
udunits2
- name: install dependencies
run: pip install ".[testing]"
shell: micromamba-shell {0}
- name: rebuild netcdf from source
run: pip install --upgrade --force-reinstall --no-deps --no-cache-dir netcdf4 --no-binary netcdf4
shell: micromamba-shell {0}
- name: run tests with coverage
run: pytest --numprocesses auto --cov . --cov-report xml:coverage.xml
shell: micromamba-shell {0}
- name: show coverage report
run: coverage report
shell: micromamba-shell {0}
- name: upload coverage to Codecov
uses: codecov/codecov-action@v2.1.0
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
Expand Down
2 changes: 1 addition & 1 deletion ensembleperturbation/client/perturb_tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def main():
else:
for forcing in arguments['forcings']:
if isinstance(forcing, BestTrackForcingJSON):
storm = forcing.adcircpy_forcing.nhc_code
storm = forcing.pyschism_forcing.nhc_code
break
else:
raise ValueError('no best track forcing specified')
Expand Down
3 changes: 0 additions & 3 deletions ensembleperturbation/client/plot_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from matplotlib import pyplot
import pandas
from pandas import DataFrame
import tables


def main():
Expand All @@ -23,8 +22,6 @@ def main():
)
output_dataframe: DataFrame = pandas.read_hdf(combined_results_filename, key='zeta_max')

combined_results = tables.open_file(combined_results_filename)

# just get standard deviation of the outputs
output_standard_deviation = output_dataframe.std(axis=1, skipna=True)

Expand Down
16 changes: 15 additions & 1 deletion ensembleperturbation/parsing/adcirc.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,20 @@ def combine_outputs(
if elevation_selection is not None:
elevation_subset = subset

if 'element' in file_data:
# keep only elements where all nodes are present
elements = file_data['element'].values
element_mask = numpy.isin(elements, file_data['node'].values).all(axis=1)
elements = elements[element_mask]
# map nodes in element table to local numbering system (start at 0)
node_mapper = numpy.zeros(file_data['node'].max().values + 1, dtype=int)
node_index = numpy.arange(len(file_data['node']))
node_mapper[file_data['node'].values] = node_index
elements = node_mapper[elements]
# update element table in dataset
ele_da = DataArray(data=elements, dims=['nele', 'nvertex'])
file_data = file_data.drop('element').assign_coords({'element': ele_da})

output_data[basename] = file_data

for basename, file_data in output_data.items():
Expand Down Expand Up @@ -832,7 +846,7 @@ def subset_dataset(
elements = node_mapper[elements]
# update element table in dataset
ele_da = DataArray(data=elements, dims=['nele', 'nvertex'])
subset = subset.assign_coords({'element': ele_da})
subset = subset.drop('element').assign_coords({'element': ele_da})
try:
subset = subset.drop_sel(run='original')
except:
Expand Down
Loading

0 comments on commit f66f9c4

Please sign in to comment.