Skip to content

Commit

Permalink
Not sure what this newest black formatting is actually changing
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcvey3 committed Feb 12, 2025
1 parent 40d4be0 commit 31701d1
Show file tree
Hide file tree
Showing 26 changed files with 152 additions and 153 deletions.
12 changes: 6 additions & 6 deletions mhkit/acoustics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""
The passive acoustics module provides a set of functions
for analyzing and visualizing passive acoustic monitoring
for analyzing and visualizing passive acoustic monitoring
data deployed in water bodies. This package reads in raw
*.wav* files and conducts basic acoustics analysis and
*.wav* files and conducts basic acoustics analysis and
visualization.
To start using the module, import it directly from MHKiT:
``from mhkit import acoustics``. The analysis functions
are available directly from the main import, while the
I/O and graphics submodules are available from
are available directly from the main import, while the
I/O and graphics submodules are available from
``acoustics.io`` and ``acoustics.graphics``, respectively.
The base functions are intended to be used on top of the I/O submodule, and
include functionality to calibrate data, create spectral densities, sound
The base functions are intended to be used on top of the I/O submodule, and
include functionality to calibrate data, create spectral densities, sound
pressure levels, and time or band aggregate spectral data.
"""

Expand Down
2 changes: 1 addition & 1 deletion mhkit/acoustics/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def sound_pressure_spectral_density_level(spsd: xr.DataArray) -> xr.DataArray:


def _validate_method(
method: Union[str, Dict[str, Union[float, int]]]
method: Union[str, Dict[str, Union[float, int]]],
) -> Tuple[str, Optional[Union[float, int]]]:
"""
Validates the 'method' parameter and returns the method name and its argument (if any)
Expand Down
8 changes: 4 additions & 4 deletions mhkit/acoustics/graphics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
This submodule provides essential plotting functions for visualizing passive acoustics
data. The functions allow for customizable plotting of sound pressure spectral density
This submodule provides essential plotting functions for visualizing passive acoustics
data. The functions allow for customizable plotting of sound pressure spectral density
levels across time and frequency dimensions.
Each plotting function leverages the flexibility of Matplotlib, allowing for passthrough
Expand All @@ -11,12 +11,12 @@
-------------
1. **plot_spectrogram**:
- Generates a spectrogram plot from sound pressure spectral density level data,
- Generates a spectrogram plot from sound pressure spectral density level data,
with a logarithmic frequency scale by default for improved readability of acoustic data.
2. **plot_spectra**:
- Produces a spectral density plot with a log-transformed x-axis, allowing for clear
- Produces a spectral density plot with a log-transformed x-axis, allowing for clear
visualization of spectral density across frequency bands.
"""

Expand Down
18 changes: 9 additions & 9 deletions mhkit/acoustics/io.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
This submodule provides input/output functions for passive acoustics data,
focusing on hydrophone recordings stored in WAV files. The main functionality
includes reading and processing hydrophone data from various manufacturers
includes reading and processing hydrophone data from various manufacturers
and exporting audio files for easy playback and analysis.
Supported Hydrophone Models
Expand All @@ -14,28 +14,28 @@
1. **Data Reading**:
- `read_hydrophone`: Main function to read a WAV file from a hydrophone and
convert it to either a voltage or pressure time series, depending on the
- `read_hydrophone`: Main function to read a WAV file from a hydrophone and
convert it to either a voltage or pressure time series, depending on the
availability of sensitivity data.
- `read_soundtrap`: Wrapper for reading Ocean Instruments SoundTrap hydrophone
- `read_soundtrap`: Wrapper for reading Ocean Instruments SoundTrap hydrophone
files, automatically using appropriate metadata.
- `read_iclisten`: Wrapper for reading Ocean Sonics icListen hydrophone files,
including metadata processing to apply hydrophone sensitivity for direct
- `read_iclisten`: Wrapper for reading Ocean Sonics icListen hydrophone files,
including metadata processing to apply hydrophone sensitivity for direct
sound pressure calculation.
2. **Audio Export**:
- `export_audio`: Converts processed sound pressure data back into a WAV file
- `export_audio`: Converts processed sound pressure data back into a WAV file
format, with optional gain adjustment to improve playback quality.
3. **Data Extraction**:
- `_read_wav_metadata`: Extracts metadata from a WAV file, including bit depth
- `_read_wav_metadata`: Extracts metadata from a WAV file, including bit depth
and other header information.
- `_calculate_voltage_and_time`: Converts raw WAV data into voltage values and
- `_calculate_voltage_and_time`: Converts raw WAV data into voltage values and
generates a time index based on the sampling frequency.
"""

Expand Down
3 changes: 1 addition & 2 deletions mhkit/dolfyn/adv/clean.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""Module containing functions to clean data
"""
"""Module containing functions to clean data"""

import warnings
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion mhkit/loads/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
The `loads` package of the MHKiT (Marine and Hydrokinetic Toolkit) library
provides tools and functionalities for analyzing and visualizing loads data
from marine and hydrokinetic (MHK) devices. This package is designed to
from marine and hydrokinetic (MHK) devices. This package is designed to
assist engineers, researchers, and analysts in understanding the forces and
stresses applied to MHK devices under various operational and environmental
conditions.
Expand Down
2 changes: 1 addition & 1 deletion mhkit/loads/extreme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
and wave data statistics.
It includes methods for calculating peaks over threshold, estimating
short-term extreme distributions,and performing wave amplitude
short-term extreme distributions,and performing wave amplitude
normalization for most likely extreme response analysis.
"""

Expand Down
28 changes: 14 additions & 14 deletions mhkit/loads/extreme/extremes.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
"""
This module provides functionality for estimating the short-term and
long-term extreme distributions of responses in a time series. It
includes methods for analyzing peaks, block maxima, and applying
statistical distributions to model extreme events. The module supports
various methods for short-term extreme estimation, including peaks
fitting with Weibull, tail fitting, peaks over threshold, and block
maxima methods with GEV (Generalized Extreme Value) and Gumbel
distributions. Additionally, it offers functionality to approximate
the long-term extreme distribution by weighting short-term extremes
long-term extreme distributions of responses in a time series. It
includes methods for analyzing peaks, block maxima, and applying
statistical distributions to model extreme events. The module supports
various methods for short-term extreme estimation, including peaks
fitting with Weibull, tail fitting, peaks over threshold, and block
maxima methods with GEV (Generalized Extreme Value) and Gumbel
distributions. Additionally, it offers functionality to approximate
the long-term extreme distribution by weighting short-term extremes
across different sea states.
Functions:
- ste_peaks: Estimates the short-term extreme distribution from peaks
- ste_peaks: Estimates the short-term extreme distribution from peaks
distribution using specified statistical methods.
- block_maxima: Finds the block maxima in a time-series data to be used
in block maxima methods.
- ste_block_maxima_gev: Approximates the short-term extreme distribution
- ste_block_maxima_gev: Approximates the short-term extreme distribution
using the block maxima method with the GEV distribution.
- ste_block_maxima_gumbel: Approximates the short-term extreme
- ste_block_maxima_gumbel: Approximates the short-term extreme
distribution using the block maxima method with the Gumbel distribution.
- ste: Alias for `short_term_extreme`, facilitating easier access to the
- ste: Alias for `short_term_extreme`, facilitating easier access to the
primary functionality of estimating short-term extremes.
- short_term_extreme: Core function to approximate the short-term extreme
- short_term_extreme: Core function to approximate the short-term extreme
distribution from a time series using chosen methods.
- full_seastate_long_term_extreme: Combines short-term extreme
- full_seastate_long_term_extreme: Combines short-term extreme
distributions using weights to estimate the long-term extreme distribution.
"""

Expand Down
6 changes: 3 additions & 3 deletions mhkit/loads/extreme/mler.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""
This module provides functionalities to calculate and analyze Most
This module provides functionalities to calculate and analyze Most
Likely Extreme Response (MLER) coefficients for wave energy converter
design and risk assessment. It includes functions to:
- Calculate MLER coefficients (`mler_coefficients`) from a sea state
spectrum and a response Amplitude Response Operator (ARO).
- Define and manipulate simulation parameters (`mler_simulation`) used
across various MLER analyses.
- Renormalize the incoming amplitude of the MLER wave
- Renormalize the incoming amplitude of the MLER wave
(`mler_wave_amp_normalize`) to match the desired peak height for more
accurate modeling and analysis.
- Export the wave amplitude time series (`mler_export_time_series`)
- Export the wave amplitude time series (`mler_export_time_series`)
based on the calculated MLER coefficients for further analysis or
visualization.
"""
Expand Down
16 changes: 8 additions & 8 deletions mhkit/loads/extreme/peaks.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
"""
This module provides utilities for analyzing wave data, specifically
for identifying significant wave heights and estimating wave peak
distributions using statistical methods.
distributions using statistical methods.
Functions:
- _calculate_window_size: Calculates the window size for peak
- _calculate_window_size: Calculates the window size for peak
independence using the auto-correlation function of wave peaks.
- _peaks_over_threshold: Identifies peaks over a specified
- _peaks_over_threshold: Identifies peaks over a specified
threshold and returns independent storm peak values adjusted by
the threshold.
- global_peaks: Identifies global peaks in a zero-centered
- global_peaks: Identifies global peaks in a zero-centered
response time-series based on consecutive zero up-crossings.
- number_of_short_term_peaks: Estimates the number of peaks within a
specified short-term period.
Expand All @@ -20,13 +20,13 @@
- automatic_hs_threshold: Determines the best significant wave height
threshold for the peaks-over-threshold method.
- peaks_distribution_peaks_over_threshold: Estimates the peaks
distribution using the peaks over threshold method by fitting a
distribution using the peaks over threshold method by fitting a
generalized Pareto distribution.
References:
- Neary, V. S., S. Ahn, B. E. Seng, M. N. Allahdadi, T. Wang, Z. Yang,
and R. He (2020). "Characterization of Extreme Wave Conditions for
Wave Energy Converter Design and Project Risk Assessment.” J. Mar.
- Neary, V. S., S. Ahn, B. E. Seng, M. N. Allahdadi, T. Wang, Z. Yang,
and R. He (2020). "Characterization of Extreme Wave Conditions for
Wave Energy Converter Design and Project Risk Assessment.” J. Mar.
Sci. Eng. 2020, 8(4), 289; https://doi.org/10.3390/jmse8040289.
"""
Expand Down
4 changes: 2 additions & 2 deletions mhkit/loads/extreme/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
This module provides statistical analysis tools for extreme value
analysis in environmental and engineering applications. It focuses on
estimating values corresponding to specific return periods based on
the statistical distribution of observed or simulated data.
the statistical distribution of observed or simulated data.
Functionality:
- return_year_value: Calculates the value from a given distribution
- return_year_value: Calculates the value from a given distribution
corresponding to a specified return year. This function is particularly
useful for determining design values for engineering structures or for
risk assessment in environmental studies.
Expand Down
6 changes: 3 additions & 3 deletions mhkit/loads/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This module provides tools for analyzing and processing data signals
related to turbine blade performance and fatigue analysis. It implements
methodologies based on standards such as IEC TS 62600-3:2020 ED1,
incorporating statistical binning, moment calculations, and fatigue
incorporating statistical binning, moment calculations, and fatigue
damage estimation using the rainflow counting algorithm. Key
functionalities include:
Expand All @@ -11,8 +11,8 @@
for each bin, following IEC TS 62600-3:2020 ED1 guidelines. It supports
output in both pandas DataFrame and xarray Dataset formats.
- `blade_moments`: Calculates the flapwise and edgewise moments of turbine
blades using derived calibration coefficients and raw strain signals.
- `blade_moments`: Calculates the flapwise and edgewise moments of turbine
blades using derived calibration coefficients and raw strain signals.
This function is crucial for understanding the loading and performance
characteristics of turbine blades.
Expand Down
6 changes: 3 additions & 3 deletions mhkit/loads/graphics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
This module provides functionalities for plotting statistical data
related to a given variable or dataset.
related to a given variable or dataset.
- `plot_statistics` is designed to plot raw statistical measures
(mean, maximum, minimum, and optional standard deviation) of a
Expand All @@ -9,8 +9,8 @@
- `plot_bin_statistics` extends these capabilities to binned data,
offering a way to visualize binned statistics (mean, maximum, minimum)
along with their respective standard deviations. This function also
supports label and title customization, as well as saving the plot to
along with their respective standard deviations. This function also
supports label and title customization, as well as saving the plot to
a specified path.
"""

Expand Down
24 changes: 12 additions & 12 deletions mhkit/mooring/graphics.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
"""
This module provides a function for creating animated visualizations of a
MoorDyn node position dataset using the matplotlib animation API.
This module provides a function for creating animated visualizations of a
MoorDyn node position dataset using the matplotlib animation API.
It includes the main function `animate`, which creates either 2D or 3D
animations depending on the input parameters.
It includes the main function `animate`, which creates either 2D or 3D
animations depending on the input parameters.
In the animations, the position of nodes in the MoorDyn dataset are plotted
over time, allowing the user to visualize how these positions change.
In the animations, the position of nodes in the MoorDyn dataset are plotted
over time, allowing the user to visualize how these positions change.
This module also includes several helper functions that are used by
`animate` to validate inputs, generate lists of nodes along each axis,
calculate plot limits, and set labels and titles for plots.
This module also includes several helper functions that are used by
`animate` to validate inputs, generate lists of nodes along each axis,
calculate plot limits, and set labels and titles for plots.
The user can specify various parameters for the animation such as the
dimension (2D or 3D), the axes to plot along, the plot limits for each
axis, the interval between frames, whether the animation repeats, and the
The user can specify various parameters for the animation such as the
dimension (2D or 3D), the axes to plot along, the plot limits for each
axis, the interval between frames, whether the animation repeats, and the
labels and title for the plot.
Requires:
Expand Down
8 changes: 4 additions & 4 deletions mhkit/mooring/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
This module provides functions to read and parse MoorDyn output files.
The main function read_moordyn takes as input the path to a MoorDyn output file and optionally
the path to a MoorDyn input file. It reads the data from the output file, stores it in an
xarray dataset, and then if provided, parses the input file for additional metadata to store
the path to a MoorDyn input file. It reads the data from the output file, stores it in an
xarray dataset, and then if provided, parses the input file for additional metadata to store
as attributes in the dataset.
The helper function _moordyn_input is used to parse the MoorDyn output file. It loops through
each line in the output file, parses various sets of properties and parameters, and stores
The helper function _moordyn_input is used to parse the MoorDyn output file. It loops through
each line in the output file, parses various sets of properties and parameters, and stores
them as attributes in the provided dataset.
Typical usage example:
Expand Down
18 changes: 9 additions & 9 deletions mhkit/power/characteristics.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
"""
This module contains functions for calculating electrical power metrics from
measured voltage and current data. It supports both direct current (DC) and
alternating current (AC) calculations, including instantaneous frequency
analysis for AC signals and power calculations for three-phase AC systems.
The calculations can accommodate both line-to-neutral and line-to-line voltage
measurements and offer flexibility in output formats, allowing results to be
This module contains functions for calculating electrical power metrics from
measured voltage and current data. It supports both direct current (DC) and
alternating current (AC) calculations, including instantaneous frequency
analysis for AC signals and power calculations for three-phase AC systems.
The calculations can accommodate both line-to-neutral and line-to-line voltage
measurements and offer flexibility in output formats, allowing results to be
saved as either pandas DataFrames or xarray Datasets.
Functions:
instantaneous_frequency: Calculates the instantaneous frequency of a measured
voltage signal over time.
dc_power: Computes the DC power from voltage and current measurements, providing
both individual channel outputs and a gross power calculation.
ac_power_three_phase: Calculates the magnitude of active AC power for three-phase
systems, considering the power factor and voltage measurement configuration
systems, considering the power factor and voltage measurement configuration
(line-to-neutral or line-to-line).
"""

Expand Down
Loading

0 comments on commit 31701d1

Please sign in to comment.