Skip to content

Conversation

@mbruggs
Copy link
Contributor

@mbruggs mbruggs commented Jul 20, 2023

As disussed in #230, there were no general methods for performing an upcrossing analysis. This series of commits introduces such a module and uses it to implement the existing functionality within the loads.extreme.global_peaks function.

mbruggs added 2 commits July 19, 2023 11:38
The loads_extreme.global_peaks function was previously missing a test.

The test uses a simple function which can be independently analysed. The results of global_peaks and the independent analysis are then compared.
Previously there was no general means of performing an upcrossing analysis. The load.extreme.global_peaks function could only calculate peaks.

The module provides some common methods but also the ability for the user to define their own function over the zero crossing points.
@mbruggs
Copy link
Contributor Author

mbruggs commented Jul 20, 2023

Hello! Thanks as always for all the work on MHKit!

I wasn't sure exactly where to put this new functionality as it doesn't nicely sit within any of the existing modules. I opted for the qc module as it seems the most generic. Happy to move if you think there's somewhere better :)

With the recent addition of the upcrossing module, we can implement the loads.extreme.global_peaks function using it.
@mbruggs mbruggs force-pushed the up-crossing-analysis branch from db21d0e to 50de58d Compare July 20, 2023 12:10
@mbruggs
Copy link
Contributor Author

mbruggs commented Jul 20, 2023

It looks like the check below hasn't passed it dosen't seem to be related to my change:

Py 3.7 3.8, 3.9 | Windows Mac Linux / pip-windows-latest/3.9 (pull_request)

@ssolson
Copy link
Contributor

ssolson commented Jul 20, 2023

It looks like the check below hasn't passed it dosen't seem to be related to my change:

Py 3.7 3.8, 3.9 | Windows Mac Linux / pip-windows-latest/3.9 (pull_request)

Mark No worries and thank you. There are API issues that are being addressed in #241 .

@akeeste akeeste self-requested a review August 7, 2023 15:15
@akeeste akeeste self-assigned this Aug 7, 2023
@akeeste akeeste added the enhancement New feature or request label Aug 7, 2023
Copy link
Contributor

@akeeste akeeste left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mbruggs

Sorry for the delay. Thanks for your contribution here. I reviewed your PR and made some minor linting/docstring suggestions in mbruggs#2

The last piece before merging is to find an appropriate spot for this. Right now the QC module is made up entirely of pecos functions and more focused on the clean-up of timeseries data than its analysis.

Right now I'm leaning towards within mhkit.loads as a submodule mhkit.loads.upcrossing or within the general submodule mhkit.loads.general. I'm open to discussion on location though

@mbruggs
Copy link
Contributor Author

mbruggs commented Oct 13, 2023

Thanks for the review @akeeste! I made a comment that's hopefully quick to resolve in mbruggs#2.

I agree the location of this functionality is a bit tricky. I'm more than happy for it go into loads - my hesitation was that the methods are equally applicable to wave analysis.

@akeeste
Copy link
Contributor

akeeste commented Oct 16, 2023

@mbruggs That's a good point. Sterling and I discussed location today and decided this is probably best under mhkit.utils, since it is applicable to both loads, wave data and really could be applied to any other timeseries data of interest. I'll update that in mbruggs#2 this week

@akeeste akeeste self-requested a review October 30, 2023 16:34
@akeeste
Copy link
Contributor

akeeste commented Oct 30, 2023

Apologies about all the sporadic final commits. I missed a few things when moving the upcrossing module. Tests are now passing. Merging this PR. Thanks @mbruggs!

@akeeste akeeste merged commit 007b845 into MHKiT-Software:develop Oct 30, 2023
@akeeste akeeste linked an issue Nov 2, 2023 that may be closed by this pull request
@mbruggs
Copy link
Contributor Author

mbruggs commented Nov 8, 2023

@akeeste Thanks very much for all your work on this!

@ssolson ssolson mentioned this pull request Apr 24, 2024
@ssolson ssolson mentioned this pull request May 6, 2024
ssolson added a commit that referenced this pull request May 8, 2024
# MHKiT v0.8.0
We're excited to announce the release of MHKiT v0.8.0, which brings a host of new features, enhancements, and bug fixes across various modules, ensuring compatibility with Python 3.10 and 3.11, and introducing full xarray support for more flexible data handling. Significant updates in the Wave and DOLfYN modules improve functionality and extend capabilities.

## Python 3.10 & 3.11 Support
MHKiT now supports python 3.10 and 3.11. Support for 3.12 will follow in the next minor update.
- #240


## Wave Module
### Enhancements:
**Automatic Threshold Calculation for Peaks-Over-Threshold**: We've introduced a new feature that automatically calculates the "best" threshold for identifying significant wave events. This method, originally developed by Neary, V. S., et al. in their 2020 study, has now been translated from Matlab to Python, enhancing our existing peaks-over-threshold functionality.

**Wave Heights Analysis**: A new function, `wave_heights`, has been added to extract the heights of individual waves from a time series. This function uses zero up-crossing analysis to accurately measure wave heights, improving upon our previous methods which only provided the maximum value between up-crossings.

**Enhanced Zero Crossing Analysis**: Building on the above, the zero crossing code previously embedded in `global_peaks` has been isolated into a helper function. This modular approach not only refines the codebase but also supports new functionalities such as calculating wave heights, zero crossing periods, and identifying crests.

### Bug Fixes:
**Contour Sampling Error in Wave Contours**: A bug identified in `mhkit.wave.contours.samples_contour` has been resolved. The issue occurred when period samples defined using the maximum period resulted in values outside the interpolation range of the contour data. This was corrected by ensuring that all sampling points are within the interpolation range and adjusting the contour data selection process accordingly.

- #268 
- #252 
- #278


## Xarray Support
MHKiT functions now fully support the use of xarray for passing and returning data.

- #279 
- #282
- #285
- #302
- #310


## DOLfYN

Thanks to the many user contributions and users of MHKiT the DOLFYN module include a significant number of enhancements and bug fixes. 

### Enhancements:
**Altimeter Support**: Enhanced the Nortek Signature Reader to add capability for reading ADCP dual profile configurations.

**Data Handling Improvements**: Introduced logic to skip messy header data that can accumulate during measurements collected via Nortek software on PCs and Macs.

**Instrument Noise Subtraction**: Added a function to subtract instrument noise from turbulence intensity estimation using RMS calculations, providing results that differ by approximately 1% from the existing standard deviation-based "I" property.

**Improved File Handling**: Updates for RDI files to handle changing "number of cells" and variable "cell sizes," which are now bin-averaged into the largest cell size.

### Bug Fixes:
**Power Spectra Calculation**: Fixed a bug where a given noise value was not being subtracted from the power spectra, and noise was inadvertently added as an input to dissipation rate calculations.

**Improved Header Handling**: Allowed RDI reader to skip junk headers effectively.

**Nortek Reader C Types Update**: Adjusted C types in the Nortek reader to handle below-zero water temperatures and to allow pitch and roll values to go negative.


- #280 
- #289
- #290
- #292
- #293
- #294
- #299


## River & Tidal: D3D
Added limits to `variable_interpolation` and added 3 array input capability to `create_points`
- #271

## Developer Experience
### Black formatting
Black formatting is now enforced on all MHKiT files. This ensures consistent formatting across the MHKiT package.
- #281

### Linting & Type Hints
MHKiT is in the process of enforcing pylint and adding type hints to all functions. Currently this has been achieved and is enforced in the Loads and Power modules.
- #288 
- #296 

### CI/CD
This release introduces significant reduction in testing time for development. This is achieved by reducing the number of tests for pulls against the develop branch and only running hindcast test when changes are made to it. A bug in the hindcast CI was fixed which only ran on changes to the hindcast tests instead of the hindcast module. Additionally the wave and wind hindcast needed to be separated in 2 jobs due to the excessive time taken to run a wind cache. This created a number of follow on PRs around solidifying the logic of these job. A special case for Python 3.8, pip, and Mac OS was added to use homebrew to install NetCDF and HDF5 to get tests to pass.
- #241
- #270
- #306
- #311
- #317
- #318
- #319
- #320
- #324

### Clean Up
MHKiT fixed an implementation error where functions used assert instead of built in errors for type and value checking. Additionally these PRs removed unused files, fixed typos, and created an argument which allows users to run CDIP API calls silently.
- #276
- #272
- #273
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide more general zero up crossing analysis

3 participants