Skip to content

Conversation

@akeeste
Copy link
Contributor

@akeeste akeeste commented Sep 30, 2025

MHKiT v1.0.0

New Features

Functionality enhancements

Source code improvements

Bug fixes

Testing and Continuous Integration Updates

Documentation and Examples

Full Changelog: v0.9.0...v1.0.0

ssolson and others added 29 commits December 9, 2024 12:25
This PR updates our git workflow to use `main` as the MHKiT default
branch :
- Many modern projects use `main` as the default branch, aligning with
the GitHub recommendation and broader conventions.
- There is some non-linear history in the previous rebase causing issues
between `develop` & `master`
- `main` was created from the current `develop` branch creating a 1-to-1
liner history between `develop` and the new `main` branch
Simple fix to a problem created by a previous PR. Solves Issue #366
If a datafile is filled with bad bytes, the reader will get stuck in one
of two while loops.
fixes notebook tests failing trying to use python 3.13
Partial solution for Issue #368. Fixes an issue with a changing `bin1_dist_m` attribute, which was presumed constant before. Also solves an issue with changing surface layer cell sizes. The RDI reader will now also explicitly return the `range_offset` that the user programmed into the instrument.
Discovered a problem with the original function while conducting data analysis of ADV data from Puget Sound.

Updating this function per the textbook definition of the integral time scale - it is listed as Equation 5.3 in this paper
(http://dx.doi.org/10.1098/rsta.2012.0196). The code I'm replacing defined the integral time scale as when the autocorrelation function decays to 1/e of its original value, which is less robust than finding the first zero-crossing of the autocorrelation function, as is standard.

The integral length scale [m] is simply the average flow speed [m/s] multiplied by the integral time scale [s].
Fixes a bug where calculating SPLs in lower frequency bands was failing because the bandwidth resolution was on par with the frequency resolution, i.e. numpy.trapz was failing to calculate the integral because the input was only 1D over frequency. Also expanded testing to cover this particular case.
Makes the ADCP cleaning functions more robust - updated based on latest
reader updates for dual profiling instruments. Solution for Issue #373

---------

Co-authored-by: akeeste <[email protected]>
Resolves #381
- [x] 62600-100 Ed. 2 en 2024 (WEC Power Performance)
- [x] "capture length" to "capture width"
- [x] 62600-101 Ed. 2 en 2024 (Wave resource)
- [x] Generally, "IEC/TS" is updated to "IEC TS"
- [x] Update standard deviation degree of freedom
- [x] Confirm that we define bins edges/centers in the same was as the
62600
- Enforce PyLint and add type hints
This PR adds pylint enforcement to the MHKiT river module. 
Additionally this PR adds type hints to the river module functions.
Part of #275
I looked at the descriptive text on the MLER example and noticed some
problems. I've made some quick corrections in this PR.
- discharge function
- fluid power 
- Reynolds number. 

---------

Co-authored-by: ssolson <[email protected]>
add sound exposure level (SEL) and SEL weighting
Improves the nortek2 reader to handle block headers with a length of 12
bytes (which can happen for large data blocks according to the Nortek
integrator guide pdf - looking at the echo sounder here).

Improves/makes more robust the ability to search for a second global
configuration header if a file is corrupted/rewritten/appended to for
various edge cases.

Adds ability to read AD2CPs that are dual profiling with an echo
sounder, though the dual-profiling functionality is still effectively in
"beta".

Solution for Issue #391 and an update to PR #371 (which should have
solved Issue #392).
Co-authored-by: ululi1970

Issue #390 

Added a few Sentinel V specific code block readers. There are a few more
in the documentation that I did not add (that are not in this test
file), but I added "skip this many bytes" placeholders for if they're
needed in the future.

Also did a little cleanup and changed two ambiguous attribute names to
something more readable (hence a lot of test files changed), and I added
a hard stop to exit the forever loop problem. It may cause some partly
corrupted files that would otherwise be readable to fail, but we'll see.
Adds type hints and enforces linting on the
wave hindcast module.
This PR adds an example that uses MHKiT and WEC-Sim together to do a
power performance assessment:
- utilize resource characterization in PacWave notebook
- write MCR cases for WEC-Sim
- load WEC performance
- assess WEC performance

Right now I represent the resource using the 32-cluster results in the
PacWave notebook and irregular waves in WEC-Sim. I was considering
writing all 2000+ wave cases in that example to a WEC-Sim MCR file so
that we can demonstrate
`mhkit.wave.performance.power_performance_workflow()` but decided it
would be too expensive, even if regular waves were used in WEC-Sim.

I also have a half-finished example that shows how to write a
directional spectra (like in `directional_waves.ipynb`) for WEC-Sim. But
the WEC-Sim 'full directional spectra" feature needs documentation and
an example first.

The PR also includes a function to make the xarray representation of
WEC-Sim data a lot more useful

---------

Co-authored-by: Mohamed Shabara <[email protected]>
## Summary
1. Replaced live USGS API calls with mock calls in tests to prevent
failures in GitHub Actions due to repeated API connectivity issues. This
ensures the functions are still invoked without being dependent on
external API availability.
2. Adjusted acoustic module test tolerances to account for minor
floating-point discrepancies. These discrepancies likely stem from:
    - Over-precise stored constants created in older environments.
- Cumulative rounding errors from sequential operations (e.g.,
band_aggregate followed by time_aggregate).
    - Changes in behavior in newer versions of NumPy, Pandas, or xarray.

#### Justification for Tolerance Adjustment
- A tolerance of 1e-5 is acceptable since decibel outputs are typically
displayed with only two decimal places.
- Numerical differences at this scale (1e-6 to 1e-5) are common due to
aggregation method variations
This PR modernizes the package configuration by migrating from
`setup.py` to `pyproject.toml` and adds a new optional dependency group
for examples. It also includes various code improvements and CI workflow
updates.

- Migrated from `setup.py` to `pyproject.toml` for modern Python
packaging
- Removed `requirements.txt` in favor of `pyproject.toml` dependency
management
- Added new optional dependency groups for pip installs: E.g:
  - `examples`: Includes all dependencies needed for running examples
  - `all`: Includes all module dependencies
  - Individual module groups (wave, tidal, river, etc.)
- Updated GitHub Actions workflows to use `pip install -e ".[all, dev]"`
instead of `pip install -e .`

---------

Co-authored-by: Andrew Simms <[email protected]>
Co-authored-by: akeeste <[email protected]>
Discovered from a recent vessel survey that I misunderstood TDI's
documentation on a couple of VMDAS parameters. The speed and direction
parameters I thought it was pulling directly from the GPS it is
calculating from the change in latitude/longitude over time. I renamed
them and added the two variables that are actually directly from the
GPS.

Also discovered that VMDAS cannot take an RMC NMEA sentence, so the GPS
timestamps are lacking a datestamp. Which is not helpful if your ADCP's
clock is on local time and the GPS is always in UTC. So I added a code
block that checks if the GPS UTC time rolled over from 23:59:59 to
00:00:00 and manually updated the day.

---------

Co-authored-by: ssolson <[email protected]>
Co-authored-by: akeeste <[email protected]>
…on rate function (#406)

It was pointed out to me that a universal constant of 0.5 was hardcoded
into dolfyn when calculating dissipation rate using the Lumley and
Terray method. According to turbulence theory and historical
experimental validation, this is the value to use for the streamwise
velocity spectra. According to the same, the constant is different for
velocity spectra that are orthogonal to the streamwise direction -
usually taken to be somewhere between 0.65 and 0.69.

This PR allows the user to set this constant via function input.

Pope, Stephen B. "Turbulent flows." Measurement Science and Technology
12.11 (2001): 2020-2021. pp 231-232.
…ror (#408) (#409)

## Summary

Fix #408: ZeroDivisionError when reading RDI burst mode data files where
`sec_between_ping_groups=0` causes division by zero in sampling
frequency calculation.

## Changes

- Added check for `sec_between_ping_groups == 0` before calculation of
`fs`.

  - When true, set `fs` to `NaN` with descriptive warning.

- Added test using `unittest.mock.patch` to verify fix behavior with
burst mode configuration.

- Fixed pytest-asyncio deprecation warning in test configuration.

## Details

Per #408 RDI instruments in continuous burst mode set
`sec_between_ping_groups=0` for maximum ping rate, causing
ZeroDivisionError in:

```python
cfg["fs"] = 1 / (cfg["sec_between_ping_groups"] * cfg["pings_per_ensemble"])
```

The fix detects this condition and sets fs=NaN since burst mode
operation with variable timing prevents reliable sampling rate
determination using standard methods.

## Testing

Patch RDIReader.finalize to set `sec_between_ping_groups` to `0` and
verify the fix prevents the `ZeroDivisionError`, sets `fs` to `np.nan`
and warns the user.
This PR removes the ignore all future warnings added when some packages
were suggesting updating to numpy 2.0 but mhkit needed other packages to
update before that could happen.

---------

Co-authored-by: akeeste <[email protected]>
Reviewed function docstrings, particularly the ones related to
turbulence. Corrected some of the mathematical notation so they should
build better in Sphinx's api-build.
I updated the ADV example notebook with a clip of real data and plots
showing how to display data

---------

Co-authored-by: akeeste <[email protected]>
Discovered this problem working on PacWave data, where the second
dataset, which contains instrument-averaged velocity measurements,
errors out when trying to use dolfyn's 'rotate' functionality.

This PR ensures the second profile from Nortek instrument can be rotated
like that of the first. This is to fix a somewhat hacky fix from several
months back, and doesn't require the user to make additional changes to
the 2nd dataset beyond that what dolfyn already does.
This PR fixes a couple small issue with example notebooks:
- reruns the WEC-Sim power performance example so that it does not
include errors
- fixes typo in ADCP discharge example title
@akeeste
Copy link
Contributor Author

akeeste commented Sep 30, 2025

Commit 2529070 resolves conflicts in README.md

@akeeste
Copy link
Contributor Author

akeeste commented Sep 30, 2025

Unclear why tests aren't passing yet. They ran fine on #417 which was into dev. 56e86e8 was also into dev and failed even though only the readme was changed. Significantly more tests are running now that this PR is into main.

@akeeste
Copy link
Contributor Author

akeeste commented Sep 30, 2025

Notes on failing tests:

  • conda ubuntu 3.11 on PRs into main, not on pushes to develop - the test acoustics/test_metrics.py:test_nmfs_weighting() is failing due to a tolerance issue. We bump this to 1e-5 as in CI Test Clean Up: Mock USGS, Acoustic Tolerances #404 or it may resolve when merged since it's passing on the develop branch
  • pip windows 3.10 on PRs into main - the test tests\river\test_resource.py::TestResource::test_plot_discharge_timeseries failed. tk not installed properly?
  • pip windows 3.11 on pushes to develop - the test tests\river\test_resource.py::TestResource::test_plot_velocity_duration_curve failed. tcl not installed properly?
  • pip windows 3.12 on pushes to develop - the test \tests\river\test_resource.py::TestResource::test_plot_discharge_timeseries failed. tcl not installed properly?
  • pip windows 3.12 on PRs into main, - the test \tests\tidal\test_resource.py::TestResource::test_plot_current_timeseries failed. tcl not installed properly?

It's unclear why any of these are failing. Will retry shortly. GitHub Actions did change the image of windows this past month, so maybe that is causing issues

To resolve some intermittent tests failing when using conda and 3.11,
this PR bumps some acoustics tolerances to 1e-5 as reasoned in #404
@akeeste
Copy link
Contributor Author

akeeste commented Sep 30, 2025

The tcl/tk errors appear locally but are very intermittent. Disappearing/reappearing in different functions upon rerunning. @simmsa pointed out that forcing the matplotlib backend to use Agg may resolve the problem.

Also, I just noticed that e.g. tests/river/test_resource.py uses matplotlib.pylab instead of pyplot which is highly discouraged.

@akeeste
Copy link
Contributor Author

akeeste commented Sep 30, 2025

All tests except the wave hindcast are passing. The wave hindcast is in progress and has been hanging all day. I am merging this PR to get the release out and will revisit tests once merged into main.

@akeeste akeeste merged commit 2a25ba6 into main Sep 30, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants