diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml index 96aaea347..a022a6634 100644 --- a/.github/workflows/black.yml +++ b/.github/workflows/black.yml @@ -8,17 +8,27 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v4 + uses: actions/checkout@v6 + + - name: Get changed Python files + id: changed-py-files + uses: tj-actions/changed-files@v47 + with: + files: | + **.py - name: Set up Python - uses: actions/setup-python@v2 + if: steps.changed-py-files.outputs.any_changed == 'true' + uses: actions/setup-python@v6 with: python-version: "3.11" - name: Install Black + if: steps.changed-py-files.outputs.any_changed == 'true' run: | python -m pip install --upgrade pip pip install black - name: Check Black Formatting - run: black --check . + if: steps.changed-py-files.outputs.any_changed == 'true' + run: black --check ${{ steps.changed-py-files.outputs.all_changed_files }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ba7925a8f..7ca82b44d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Py 3.10, 3.11, 3.12 | Windows Mac Linux +name: Py 3.10, 3.11, 3.12, 3.13 | Windows Mac Linux on: pull_request: @@ -10,7 +10,25 @@ on: - main - develop +# Global configuration for all jobs. Can be overridden at the job level if needed. +env: + # Conda channels: Set conda forge as only channel and disable defaults channel + CONDA_MINICONDA_VERSION: latest + CONDA_AUTO_UPDATE_CONDA: true + CONDA_CHANNELS: conda-forge + CONDA_REMOVE_DEFAULTS: true + CONDA_USE_ONLY_TAR_BZ2: false + CONDA_ENVIRONMENT_FILE: environment-dev.yml + CONDA_ENVIRONMENT_NAME: mhkit-dev-env + # Coveralls: Set to false to ignore upload failures during outages. + # Check status: https://status.coveralls.io/ + COVERALLS_FAIL_ON_ERROR: true + jobs: + # Set the operating system matrix for the following jobs/tests + # conda-forge-build + # pip-build + # hindcast-calls set-os: runs-on: ubuntu-latest outputs: @@ -24,6 +42,8 @@ jobs: echo "matrix_os=[\"windows-latest\", \"ubuntu-latest\", \"macos-latest\"]" >> $GITHUB_OUTPUT fi + + # This job decides if the hindcast test suite should run. check-changes: runs-on: ubuntu-latest outputs: @@ -31,11 +51,11 @@ jobs: should-run-hindcast: ${{ steps.hindcast-logic.outputs.should-run-hindcast }} steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Check for changes in wave/io/hindcast id: changes - uses: dorny/paths-filter@v3 + uses: dorny/paths-filter@v4 with: filters: | wave_io_hindcast: @@ -56,45 +76,39 @@ jobs: PYTHON_VER: 3.11 steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v3 + uses: conda-incubator/setup-miniconda@v4 with: - miniconda-version: 'latest' - auto-update-conda: true - python-version: ${{ env.PYTHON_VER }} - activate-environment: TESTconda - use-only-tar-bz2: false - - - name: Create MHKiT Conda environment - shell: bash -l {0} - run: | - conda env create -f environment.yml - conda activate mhkit-env + miniconda-version: ${{ env.CONDA_MINICONDA_VERSION }} + auto-update-conda: ${{ env.CONDA_AUTO_UPDATE_CONDA }} + environment-file: ${{ env.CONDA_ENVIRONMENT_FILE }} + activate-environment: ${{ env.CONDA_ENVIRONMENT_NAME }} + python-version: ${{ matrix.python-version }} + use-only-tar-bz2: ${{ env.CONDA_USE_ONLY_TAR_BZ2 }} + channels: ${{ env.CONDA_CHANNELS }} + conda-remove-defaults: ${{ env.CONDA_REMOVE_DEFAULTS }} - name: Install testing dependencies shell: bash -l {0} run: | - conda activate mhkit-env - conda install -y pytest coverage coveralls + conda install -y pytest coverage - name: Install mhkit shell: bash -l {0} run: | - conda activate mhkit-env - pip install -e ".[all,dev]" --no-deps + pip install -e ".[all,dev]" --no-deps - name: Prepare non-hindcast API data shell: bash -l {0} run: | - conda activate mhkit-env pytest mhkit/tests/river/test_io_usgs.py pytest mhkit/tests/tidal/test_io.py pytest mhkit/tests/wave/io/test_cdip.py - name: Upload data as artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: data path: ~/.cache/mhkit @@ -107,43 +121,37 @@ jobs: if: (needs.check-changes.outputs.should-run-hindcast == 'true') steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v3 + uses: conda-incubator/setup-miniconda@v4 with: - miniconda-version: 'latest' - auto-update-conda: true - activate-environment: TEST - python-version: ${{ env.PYTHON_VER }} - use-only-tar-bz2: false - - - name: Create MHKiT Conda environment - shell: bash -l {0} - run: | - conda env create -f environment.yml - conda activate mhkit-env + miniconda-version: ${{ env.CONDA_MINICONDA_VERSION }} + auto-update-conda: ${{ env.CONDA_AUTO_UPDATE_CONDA }} + environment-file: ${{ env.CONDA_ENVIRONMENT_FILE }} + activate-environment: ${{ env.CONDA_ENVIRONMENT_NAME }} + python-version: ${{ matrix.python-version }} + use-only-tar-bz2: ${{ env.CONDA_USE_ONLY_TAR_BZ2 }} + channels: ${{ env.CONDA_CHANNELS }} + conda-remove-defaults: ${{ env.CONDA_REMOVE_DEFAULTS }} - name: Install testing dependencies shell: bash -l {0} run: | - conda activate mhkit-env - conda install -y pytest coverage coveralls + conda install -y pytest coverage - name: Install mhkit shell: bash -l {0} run: | - conda activate mhkit-env - pip install -e ".[all,dev]" --no-deps + pip install -e ".[all,dev]" --no-deps - name: Prepare Wave Hindcast data shell: bash -l {0} run: | - conda activate mhkit-env pytest mhkit/tests/wave/io/hindcast/test_hindcast.py - name: Upload Wave Hindcast data as artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: wave-hindcast-data path: ~/.cache/mhkit @@ -156,104 +164,98 @@ jobs: if: (needs.check-changes.outputs.should-run-hindcast == 'true') steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v3 + uses: conda-incubator/setup-miniconda@v4 with: - miniconda-version: 'latest' - auto-update-conda: true - activate-environment: TEST - python-version: ${{ env.PYTHON_VER }} - use-only-tar-bz2: false - - - name: Create MHKiT Conda environment - shell: bash -l {0} - run: | - conda env create -f environment.yml - conda activate mhkit-env + miniconda-version: ${{ env.CONDA_MINICONDA_VERSION }} + auto-update-conda: ${{ env.CONDA_AUTO_UPDATE_CONDA }} + environment-file: ${{ env.CONDA_ENVIRONMENT_FILE }} + activate-environment: ${{ env.CONDA_ENVIRONMENT_NAME }} + python-version: ${{ matrix.python-version }} + use-only-tar-bz2: ${{ env.CONDA_USE_ONLY_TAR_BZ2 }} + channels: ${{ env.CONDA_CHANNELS }} + conda-remove-defaults: ${{ env.CONDA_REMOVE_DEFAULTS }} - name: Install testing dependencies shell: bash -l {0} run: | - conda activate mhkit-env - conda install -y pytest coverage coveralls + conda install -y pytest coverage - name: Install mhkit shell: bash -l {0} run: | - conda activate mhkit-env - pip install -e ".[all,dev]" --no-deps + pip install -e ".[all,dev]" --no-deps - name: Prepare Wind Hindcast data shell: bash -l {0} run: | - conda activate mhkit-env pytest mhkit/tests/wave/io/hindcast/test_wind_toolkit.py - name: Upload Wind Hindcast data as artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v6 with: name: wind-hindcast-data path: ~/.cache/mhkit - conda-build: - name: conda-${{ matrix.os }}/${{ matrix.python-version }} + conda-forge-build: + name: conda-forge-${{ matrix.os }}/${{ matrix.python-version }} needs: [set-os, prepare-nonhindcast-cache] runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: ${{fromJson(needs.set-os.outputs.matrix_os)}} - python-version: ['3.10', '3.11', '3.12'] + python-version: ['3.10', '3.11', '3.12', '3.13'] env: PYTHON_VER: ${{ matrix.python-version }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v3 + uses: conda-incubator/setup-miniconda@v4 with: - miniconda-version: 'latest' - auto-update-conda: true - environment-file: environment.yml - activate-environment: TEST + miniconda-version: ${{ env.CONDA_MINICONDA_VERSION }} + auto-update-conda: ${{ env.CONDA_AUTO_UPDATE_CONDA }} + environment-file: ${{ env.CONDA_ENVIRONMENT_FILE }} + activate-environment: ${{ env.CONDA_ENVIRONMENT_NAME }} python-version: ${{ matrix.python-version }} - use-only-tar-bz2: false - - - name: Create MHKiT Conda environment - shell: bash -l {0} - run: | - conda env create -f environment.yml - conda activate mhkit-env + use-only-tar-bz2: ${{ env.CONDA_USE_ONLY_TAR_BZ2 }} + channels: ${{ env.CONDA_CHANNELS }} + conda-remove-defaults: ${{ env.CONDA_REMOVE_DEFAULTS }} - name: Install testing dependencies shell: bash -l {0} run: | - conda activate mhkit-env - conda install -y pytest coverage coveralls + conda install -y pytest coverage - name: Install mhkit shell: bash -l {0} run: | - conda activate mhkit-env - pip install -e . --no-deps + pip install -e ".[all,dev]" --no-deps + + - name: Download data from artifact + uses: actions/download-artifact@v8 + with: + name: data + path: ~/.cache/mhkit - name: Run pytest & generate coverage report shell: bash -l {0} run: | - conda activate mhkit-env coverage run --rcfile=.github/workflows/.coveragerc --source=./mhkit/ -m pytest -c .github/workflows/pytest.ini coverage lcov - name: Upload coverage data to coveralls.io - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} - flag-name: conda-${{ runner.os }}-py${{ matrix.python-version }} + flag-name: conda-forge-${{ runner.os }}-py${{ matrix.python-version }} parallel: true path-to-lcov: ./coverage.lcov + fail-on-error: ${{ env.COVERALLS_FAIL_ON_ERROR }} pip-build: name: pip-${{ matrix.os }}/${{ matrix.python-version }} @@ -263,56 +265,58 @@ jobs: fail-fast: false matrix: os: ${{fromJson(needs.set-os.outputs.matrix_os)}} - python-version: ['3.10', '3.11', '3.12'] + python-version: ['3.10', '3.11', '3.12', '3.13'] steps: - - uses: conda-incubator/setup-miniconda@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + - name: Setup Python Virtual Environment + shell: bash + # The second command puts the venv bin directory on the PATH for + # subsequent steps in the job, which ensures that the correct Python + # version and installed packages are used. + run: | + python -m venv venv + echo "$PWD/venv/bin" >> $GITHUB_PATH + - name: Set up Git repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Download data from artifact - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: data path: ~/.cache/mhkit - - name: Install system dependencies - if: runner.os == 'Linux' - run: sudo apt-get install -y libhdf5-dev libnetcdf-dev - - name: Update and install packages - shell: bash -l {0} + shell: bash run: | python -m pip install --upgrade pip wheel - pip install -e ".[all,dev]" - - - name: Reinstall h5py and netCDF4 with system libraries - if: runner.os == 'Linux' - run: "pip install --force-reinstall --no-binary=:all: h5py netCDF4" + pip install -e ".[all,dev]" - name: Install setuptools for Python 3.12 if: matrix.python-version == '3.12' - run: pip install setuptools + shell: bash + run: | + pip install setuptools - name: Run pytest & generate coverage report - shell: bash -l {0} + shell: bash run: | coverage run --rcfile=.github/workflows/.coveragerc --source=./mhkit/ -m pytest -c .github/workflows/pytest.ini coverage lcov - name: Upload coverage data to coveralls.io - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: pip-${{ runner.os }}-py${{ matrix.python-version }} parallel: true path-to-lcov: ./coverage.lcov + fail-on-error: ${{ env.COVERALLS_FAIL_ON_ERROR }} hindcast-calls: name: hindcast-${{ matrix.os }}/${{ matrix.python-version }} @@ -331,47 +335,41 @@ jobs: fail-fast: false matrix: os: ${{fromJson(needs.set-os.outputs.matrix_os)}} - python-version: ['3.10', '3.11', '3.12'] + python-version: ['3.10', '3.11', '3.12', '3.13'] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Setup Miniconda - uses: conda-incubator/setup-miniconda@v3 + uses: conda-incubator/setup-miniconda@v4 with: - miniconda-version: 'latest' - auto-update-conda: true - environment-file: environment.yml - activate-environment: TEST + miniconda-version: ${{ env.CONDA_MINICONDA_VERSION }} + auto-update-conda: ${{ env.CONDA_AUTO_UPDATE_CONDA }} + environment-file: ${{ env.CONDA_ENVIRONMENT_FILE }} + activate-environment: ${{ env.CONDA_ENVIRONMENT_NAME }} python-version: ${{ matrix.python-version }} - use-only-tar-bz2: false - - - name: Create MHKiT Conda environment - shell: bash -l {0} - run: | - conda env create -f environment.yml - conda activate mhkit-env + use-only-tar-bz2: ${{ env.CONDA_USE_ONLY_TAR_BZ2 }} + channels: ${{ env.CONDA_CHANNELS }} + conda-remove-defaults: ${{ env.CONDA_REMOVE_DEFAULTS }} - name: Install testing dependencies shell: bash -l {0} run: | - conda activate mhkit-env - conda install -y pytest coverage coveralls + conda install -y pytest coverage - name: Install mhkit shell: bash -l {0} run: | - conda activate mhkit-env - pip install -e ".[all,dev]" --no-deps + pip install -e ".[all,dev]" --no-deps - name: Download Wave Hindcast data from artifact - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: wave-hindcast-data path: ~/.cache/mhkit/wave-hindcast - name: Download Wind Hindcast data from artifact - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: wind-hindcast-data path: ~/.cache/mhkit/wind-hindcast @@ -386,25 +384,25 @@ jobs: - name: Run hindcast pytest shell: bash -l {0} run: | - conda activate mhkit-env coverage run --rcfile=.github/workflows/.coveragehindcastrc -m pytest -c .github/workflows/pytest-hindcast.ini coverage lcov - name: Upload coverage data to coveralls.io - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@v2 with: github-token: ${{ secrets.GITHUB_TOKEN }} flag-name: hindcast-${{ runner.os }}-py${{ matrix.python-version }} parallel: true path-to-lcov: ./coverage.lcov + fail-on-error: ${{ env.COVERALLS_FAIL_ON_ERROR }} test-wheel-packaging: name: Test Built Wheel runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v6 with: python-version: '3.11' @@ -462,25 +460,28 @@ jobs: matrix: module: [wave, tidal, river, dolfyn, power, loads, mooring, acoustics, utils] - python-version: ['3.12'] + python-version: ['3.13'] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} - name: Download non-hindcast data - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: data path: ~/.cache/mhkit - name: Install system dependencies if: matrix.module != 'river' || matrix.module != 'power' || matrix.module != 'utils' || matrix.module != 'loads' - run: sudo apt-get install -y libhdf5-dev libnetcdf-dev + run: | + # Update apt-get cache + sudo apt-get update + sudo apt-get install -y libhdf5-dev libnetcdf-dev - name: Install MHKiT with optional dependency run: | @@ -514,7 +515,7 @@ jobs: needs.prepare-nonhindcast-cache.result == 'success' && needs.prepare-wave-hindcast-cache.result == 'skipped' && needs.prepare-wind-hindcast-cache.result == 'skipped' && - needs.check-changes.outputs.should-run-hindcast == 'false' + needs.check-changes.outputs.should-run-hindcast == 'false' ) || ( needs.prepare-nonhindcast-cache.result == 'success' && @@ -527,10 +528,10 @@ jobs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v6 with: python-version: '3.11' @@ -556,52 +557,46 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - - name: Set up Miniconda - uses: conda-incubator/setup-miniconda@v3 + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@v4 with: - miniconda-version: 'latest' - auto-update-conda: true - python-version: '3.12' - channels: conda-forge - activate-environment: TESTconda - use-only-tar-bz2: false - - - name: Create MHKiT Conda environment - shell: bash -l {0} - run: | - conda env create -f environment.yml - conda activate mhkit-env + miniconda-version: ${{ env.CONDA_MINICONDA_VERSION }} + auto-update-conda: ${{ env.CONDA_AUTO_UPDATE_CONDA }} + environment-file: ${{ env.CONDA_ENVIRONMENT_FILE }} + activate-environment: ${{ env.CONDA_ENVIRONMENT_NAME }} + python-version: ${{ matrix.python-version }} + use-only-tar-bz2: ${{ env.CONDA_USE_ONLY_TAR_BZ2 }} + channels: ${{ env.CONDA_CHANNELS }} + conda-remove-defaults: ${{ env.CONDA_REMOVE_DEFAULTS }} - name: Install notebook testing dependencies shell: bash -l {0} run: | - conda activate mhkit-env - conda install -y pytest coverage coveralls nbval jupyter utm folium + conda install -y pytest coverage nbval jupyter utm folium - name: Install mhkit shell: bash -l {0} run: | - conda activate mhkit-env - pip install -e ".[all,dev]" --no-deps + pip install -e ".[all,dev]" --no-deps - name: Download non-hindcast data - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: data path: ~/.cache/mhkit - name: Download Wave Hindcast data (if available) if: (needs.check-changes.outputs.should-run-hindcast == 'true') - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: wave-hindcast-data path: ~/.cache/mhkit/wave-hindcast - name: Download Wind Hindcast data (if available) if: (needs.check-changes.outputs.should-run-hindcast == 'true') - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8 with: name: wind-hindcast-data path: ~/.cache/mhkit/wind-hindcast @@ -622,7 +617,6 @@ jobs: - name: Run notebook shell: bash -l {0} run: | - conda activate mhkit-env if [[ "${{ matrix.notebook }}" == "examples/metocean_example.ipynb" || "${{ matrix.notebook }}" == "examples/WPTO_hindcast_example.ipynb" ]]; then if [[ "${{ needs.check-changes.outputs.should-run-hindcast }}" == 'true' ]]; then jupyter nbconvert --to notebook --execute --inplace --ExecutePreprocessor.timeout=${{ matrix.timeout }} "${{ matrix.notebook }}" @@ -639,7 +633,7 @@ jobs: [ prepare-wave-hindcast-cache, prepare-wind-hindcast-cache, - conda-build, + conda-forge-build, pip-build, hindcast-calls, ] @@ -647,14 +641,14 @@ jobs: always() && ( ( - needs.conda-build.result == 'success' && + needs.conda-forge-build.result == 'success' && needs.pip-build.result == 'success' && needs.prepare-wave-hindcast-cache.result == 'skipped' && needs.prepare-wind-hindcast-cache.result == 'skipped' && needs.hindcast-calls.result == 'skipped' ) || ( - needs.conda-build.result == 'success' && + needs.conda-forge-build.result == 'success' && needs.pip-build.result == 'success' && needs.prepare-wave-hindcast-cache.result == 'success' && needs.prepare-wind-hindcast-cache.result == 'success' && @@ -662,11 +656,10 @@ jobs: ) ) runs-on: ubuntu-latest - container: python:3-slim steps: - name: Coveralls Finished - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@v2 with: parallel-finished: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} + fail-on-error: ${{ env.COVERALLS_FAIL_ON_ERROR }} diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 27d52e520..6c85b7c67 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -8,10 +8,10 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v6 with: python-version: '3.11' diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 9cc2d2e05..766251d91 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -19,11 +19,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: fetch-depth: 0 - - uses: actions/setup-python@v5 + - uses: actions/setup-python@v6 with: python-version: '3.10' diff --git a/.github/workflows/test-wheel-build.yml b/.github/workflows/test-wheel-build.yml index 8186eff54..46ecbbe82 100644 --- a/.github/workflows/test-wheel-build.yml +++ b/.github/workflows/test-wheel-build.yml @@ -16,14 +16,14 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.11', '3.12'] + python-version: ['3.10', '3.11', '3.12', '3.13'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v6 with: fetch-depth: 0 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore index 9063f86c4..d24a4b879 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ $ cat .gitignore *.tws *~ *.png +*.index +*.dolfyn.log # Directories **/__pycache__/ @@ -33,6 +35,8 @@ $ cat .gitignore # Exemptions !**/examples/data/wave/*.mat !**/tests/data/wave/*.mat +!**/examples/data/dolfyn/test_data/*.dolfyn.log # Files created during tests mhkit/tests/wave/plots/ +**/examples/data/dolfyn/test_data/test_save.nc diff --git a/LICENSE.md b/LICENSE.md index 67b9ca56e..009012157 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2019, Alliance for Sustainable Energy, LLC under the terms of Contract DE-AC36-08GO28308, Battelle Memorial Institute under the terms of Contract DE-AC05-76RL01830, and National Technology & Engineering Solutions of Sandia, LLC under the terms of Contract DE-NA0003525. The U.S. Government retains certain rights in this software. +Copyright (c) 2026, Alliance for Energy Innovation, LLC under the terms of Contract DE-AC36-08GO28308, Battelle Memorial Institute under the terms of Contract DE-AC05-76RL01830, and National Technology & Engineering Solutions of Sandia, LLC under the terms of Contract DE-NA0003525. The U.S. Government retains certain rights in this software. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.md b/README.md index 85151bd56..ebe2960ab 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@
-MHKiT-Python is a Python package designed for marine renewable energy applications to assist in +MHKiT-Python is a Python package designed for marine energy applications to assist in data processing and visualization. The software package include functionality for: - Data processing @@ -32,59 +32,238 @@ See the [MHKiT documentation](https://mhkit-software.github.io/MHKiT) for more i ## Installation -[MHKiT-Python](https://github.com/MHKiT-Software/MHKiT-Python) requires [Python (3.10-3.12)](https://www.python.org/). -It is recommended to use the [Anaconda Python Distribution](https://www.anaconda.com/distribution/) (a fully featured Python installer with a GUI) -or [Miniconda](https://docs.anaconda.com/miniconda/#quick-command-line-install) (a lightweight installer with the ``conda`` command line utility). -Both will include most of MHKiT-Python's package dependencies. -MHKiT can be installed several ways: +[MHKiT-Python](https://github.com/MHKiT-Software/MHKiT-Python) requires [Python (3.10-3.13)](https://www.python.org/). -### Option 1: Install from Python +See [installation instructions](https://mhkit-software.github.io/MHKiT/installation.html) for more information. + +<xarray.Dataset> Size: 379kB\n",
- "Dimensions: (time: 183, range: 28, dirIMU: 3, dir: 4, beam: 4,\n",
+ "Dimensions: (time: 183, dirIMU: 3, dir: 4, range: 28, beam: 4,\n",
" earth: 3, inst: 3, q: 4, time_b5: 183, range_b5: 28)\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 1kB 2020-08-15T00:22:30.001030683 ....\n",
" * dirIMU (dirIMU) <U10 120B 'streamwise' 'x-stream' 'vert'\n",
- " * range (range) float64 224B 1.2 1.7 2.2 2.7 ... 13.2 13.7 14.2 14.7\n",
" * dir (dir) <U10 160B 'streamwise' 'x-stream' 'vert1' 'vert2'\n",
+ " * range (range) float64 224B 1.2 1.7 2.2 2.7 ... 13.2 13.7 14.2 14.7\n",
" * beam (beam) int32 16B 1 2 3 4\n",
" * earth (earth) <U1 12B 'E' 'N' 'U'\n",
" * inst (inst) <U1 12B 'X' 'Y' 'Z'\n",
@@ -2018,18 +2019,18 @@
" * range_b5 (range_b5) float64 224B 1.2 1.7 2.2 2.7 ... 13.7 14.2 14.7\n",
"Data variables: (12/38)\n",
" c_sound (time) float32 732B 1.502e+03 1.502e+03 ... 1.498e+03\n",
- " U_std (range, time) float32 20kB 0.04232 0.04293 ... nan nan\n",
" temp (time) float32 732B 14.49 14.59 14.54 ... 13.62 13.56 13.5\n",
" pressure (time) float32 732B 9.712 9.699 9.685 ... 9.58 9.584 9.591\n",
" mag (dirIMU, time) float32 2kB 3.534 3.565 ... -197.1 -197.1\n",
" accel (dirIMU, time) float32 2kB -1.261 -1.263 ... 9.714 9.712\n",
+ " batt (time) float32 732B 16.48 16.48 16.48 ... 16.25 16.26 16.26\n",
" ... ...\n",
- " boost_running (time) float32 732B 0.1267 0.1333 0.13 ... 0.2267 0.22 0.22\n",
" heading (time) float32 732B 3.287 3.261 3.337 ... 3.331 3.352 3.352\n",
" pitch (time) float32 732B -0.05523 -0.07217 ... -0.04288 -0.0429\n",
" roll (time) float32 732B -7.414 -7.424 -7.404 ... -6.433 -6.436\n",
" water_density (time) float32 732B 1.023e+03 1.023e+03 ... 1.023e+03\n",
" depth (time) float32 732B 10.28 10.26 10.25 ... 10.14 10.15 10.15\n",
+ " U_std (range, time) float32 20kB 0.04232 0.04293 ... nan nan\n",
"Attributes: (12/41)\n",
" fs: 1\n",
" n_bin: 300\n",
@@ -2043,7 +2044,7 @@
" range_offset: 0.6\n",
" declination: 15.8\n",
" declination_in_orientmat: 1\n",
- " principal_heading: 11.1898<xarray.Dataset> Size: 11MB\n",
+ "Dimensions: (time: 18073, time_altraw: 35, range: 13, beam: 4,\n",
+ " dir: 4, dirIMU: 3, n_altraw: 2583, x1: 4, x2: 4,\n",
+ " earth: 3, inst: 3)\n",
+ "Coordinates:\n",
+ " * time (time) datetime64[ns] 145kB 2024-10-22T19:29:36.3...\n",
+ " * time_altraw (time_altraw) datetime64[ns] 280B 2024-10-22T19:2...\n",
+ " * range (range) float64 104B 38.7 42.2 45.7 ... 77.2 80.7\n",
+ " * beam (beam) int32 16B 1 2 3 4\n",
+ " * dir (dir) int32 16B 1 2 3 4\n",
+ " * dirIMU (dirIMU) <U1 12B 'X' 'Y' 'Z'\n",
+ " * x1 (x1) int32 16B 1 2 3 4\n",
+ " * x2 (x2) int32 16B 1 2 3 4\n",
+ " * earth (earth) <U1 12B 'E' 'N' 'U'\n",
+ " * inst (inst) <U1 12B 'X' 'Y' 'Z'\n",
+ "Dimensions without coordinates: n_altraw\n",
+ "Data variables: (12/39)\n",
+ " c_sound (time) float32 72kB 1.503e+03 ... 1.485e+03\n",
+ " temp (time) float32 72kB 13.93 13.92 13.92 ... 8.23 8.23\n",
+ " pressure (time) float32 72kB 0.768 0.765 ... 74.71 74.71\n",
+ " heading (time) float32 72kB 216.1 215.8 ... 212.7 212.9\n",
+ " pitch (time) float32 72kB -27.59 -28.03 ... 2.21 2.22\n",
+ " roll (time) float32 72kB 73.04 71.68 67.74 ... -0.36 -0.4\n",
+ " ... ...\n",
+ " low_volt_skip (time) uint8 18kB 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0\n",
+ " active_config (time) uint8 18kB 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0\n",
+ " telemetry_data (time) uint8 18kB 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0\n",
+ " boost_running (time) uint8 18kB 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0\n",
+ " beam2inst_orientmat (x1, x2) float32 64B 1.462 0.0 -1.462 ... 0.0 0.532\n",
+ " orientmat (earth, inst, time) float32 651kB -0.5221 ... 0.9992\n",
+ "Attributes: (12/39)\n",
+ " filehead_config: {"CLOCKSTR": {"TIME": "\\"2024-10-22 19:29:32\\""}, ...\n",
+ " inst_model: Signature250\n",
+ " inst_make: Nortek\n",
+ " inst_type: ADCP\n",
+ " burst_config: {"press_valid": true, "temp_valid": true, "compass...\n",
+ " n_cells: 13\n",
+ " ... ...\n",
+ " rotate_vars: ['vel', 'accel', 'mag']\n",
+ " coord_sys: beam\n",
+ " fs: 1\n",
+ " bandwidth: "BROAD"\n",
+ " has_imu: 0\n",
+ " beam_angle: 20<xarray.Dataset> Size: 16MB\n",
"Dimensions: (date: 8572, frequency: 47)\n",
"Coordinates:\n",
- " * date (date) datetime64[ns] 69kB 2021-01-01T00:40:00 ... 2021-12-31T...\n",
+ " * date (date) datetime64[us] 69kB 2021-01-01T00:40:00 ... 2021-12-31T...\n",
" * frequency (frequency) float64 376B 0.02 0.0325 0.0375 ... 0.445 0.465 0.485\n",
"Data variables:\n",
" swden (date, frequency) float64 3MB 0.0 0.0 0.0 0.0 ... 0.01 0.02 0.0\n",
" swdir (date, frequency) float64 3MB 194.0 13.0 6.0 ... 167.0 159.0\n",
" swdir2 (date, frequency) float64 3MB 191.0 11.0 9.0 ... 169.0 106.0\n",
" swr1 (date, frequency) float64 3MB 0.16 0.26 0.21 ... 0.76 0.87 0.63\n",
- " swr2 (date, frequency) float64 3MB 0.99 0.93 0.9 ... 0.28 0.67 0.1"
],
"text/plain": [
"<xarray.DataArray (frequency: 47, direction: 180)> Size: 68kB\n",
- "array([[0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n",
- " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n",
- " [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n",
- " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n",
- " [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ...,\n",
- " 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n",
+ "array([[0. , 0. , 0. , ..., 0. , 0. ,\n",
+ " 0. ],\n",
+ " [0. , 0. , 0. , ..., 0. , 0. ,\n",
+ " 0. ],\n",
+ " [0. , 0. , 0. , ..., 0. , 0. ,\n",
+ " 0. ],\n",
" ...,\n",
- " [2.21512935e-04, 3.00007246e-04, 3.89537948e-04, ...,\n",
- " 4.78972678e-05, 9.59294370e-05, 1.53638415e-04],\n",
- " [5.05171904e-04, 5.68137407e-04, 6.34119449e-04, ...,\n",
- " 3.34637188e-04, 3.88407564e-04, 4.45255232e-04],\n",
- " [2.26590428e-04, 2.84552135e-04, 3.45964024e-04, ...,\n",
- " 7.35307830e-05, 1.21080223e-04, 1.72097824e-04]])\n",
+ " [0.01269176, 0.01718915, 0.02231888, ..., 0.00274431, 0.00549635,\n",
+ " 0.00880283],\n",
+ " [0.02894422, 0.03255188, 0.03633237, ..., 0.0191733 , 0.02225411,\n",
+ " 0.02551125],\n",
+ " [0.01298268, 0.01630364, 0.01982228, ..., 0.004213 , 0.00693739,\n",
+ " 0.00986048]], shape=(47, 180))\n",
"Coordinates:\n",
" * frequency (frequency) float64 376B 0.02 0.0325 0.0375 ... 0.445 0.465 0.485\n",
" * direction (direction) float64 1kB 0.0 2.0 4.0 6.0 ... 354.0 356.0 358.0\n",
"Attributes:\n",
- " units: m^2/Hz/deg\n",
+ " units: m^2/Hz/degree\n",
" long_name: Elevation variance spectrum\n",
" standard_name: spectrum\n",
- " description: *Elevation variance (m^2)* spectrum (/Hz/deg).