Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcvey3 committed Oct 1, 2024
1 parent 68dc32a commit 8fe42de
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion mhkit/acoustics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"""

from mhkit.acoustics import io, graphics
from .base import *
from .analysis import *
8 changes: 8 additions & 0 deletions mhkit/acoustics/base.py → mhkit/acoustics/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def minimum_frequency(
---------
Jennings 2011 - Computational Ocean Acoustics, 2nd ed.
"""

# Convert water_depth to a NumPy array for vectorized operations
water_depth = np.asarray(water_depth)

Expand Down Expand Up @@ -124,6 +125,8 @@ def sound_pressure_spectral_density(
spsd: xarray.DataArray (time, freq)
Spectral density [Pa^2/Hz] indexed by time and frequency
"""

# Type checks
if not isinstance(pressure, xr.DataArray):
raise TypeError("'pressure' must be an xarray.DataArray.")
if not isinstance(fs, (int, float)):
Expand Down Expand Up @@ -367,6 +370,8 @@ def band_average(
Frequency band-averaged sound pressure spectral density level [dB re 1 uPa^2/Hz]
indexed by time and frequency
"""

# Type checks
if not isinstance(spsdl, xr.DataArray):
raise TypeError("'spsdl' must be an xarray.DataArray.")
if not isinstance(octave, int):
Expand Down Expand Up @@ -618,6 +623,7 @@ def _band_sound_pressure_level(
out: xarray.DataArray (time, freq_bins)
Sound pressure level [dB re 1 uPa] indexed by time and frequency of specified bandwidth
"""

# Type checks
if not isinstance(spsd, xr.DataArray):
raise TypeError("'spsd' must be an xarray.DataArray.")
Expand Down Expand Up @@ -703,6 +709,7 @@ def third_octave_sound_pressure_level(
mspl: xarray.DataArray (time, freq_bins)
Sound pressure level [dB re 1 uPa] indexed by time and third octave bands
"""

# Type checks
if not isinstance(spsd, xr.DataArray):
raise TypeError("'spsd' must be an xarray.DataArray.")
Expand Down Expand Up @@ -761,6 +768,7 @@ def decidecade_sound_pressure_level(
mspl : xarray.DataArray (time, freq_bins)
Sound pressure level [dB re 1 uPa] indexed by time and third octave bands
"""

# Type checks
if not isinstance(spsd, xr.DataArray):
raise TypeError("'spsd' must be an xarray.DataArray.")
Expand Down
2 changes: 1 addition & 1 deletion mhkit/acoustics/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

import matplotlib.pyplot as plt
from .base import _fmax_warning
from .analysis import _fmax_warning


def plot_spectogram(spsdl, fmin=10, fmax=100000, fig=None, ax=None, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion mhkit/acoustics/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def _calculate_voltage_and_time(
raw_voltage = raw.astype(float) / max_count * peak_voltage

# Get time
end_time = np.datetime64(start_time) + np.timedelta64(length, "s")
end_time = np.datetime64(start_time) + np.timedelta64(length * 1000, "ms")
time = pd.date_range(start_time, end_time, raw.size + 1)

return raw_voltage, time, max_count
Expand Down
1 change: 0 additions & 1 deletion mhkit/dolfyn/adv/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from ..velocity import VelBinner
from ..tools.misc import group, slice1d_along_axis

warnings.simplefilter("ignore", np.exceptions.RankWarning)

sin = np.sin
cos = np.cos
Expand Down
4 changes: 2 additions & 2 deletions mhkit/tests/acoustics/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def test_fmax_warning(self):
"""
Test that fmax warning adjusts the maximum frequency if necessary.
"""
from mhkit.acoustics.base import _fmax_warning
from mhkit.acoustics.analysis import _fmax_warning

# Test case where fmax is greater than Nyquist frequency
fn = 1000
Expand All @@ -260,7 +260,7 @@ def test_validate_method(self):
"""
Test the validation of the 'method' parameter in band_average or time_average.
"""
from mhkit.acoustics.base import _validate_method
from mhkit.acoustics.analysis import _validate_method

# Valid method string
method_name, method_arg = _validate_method("median")
Expand Down

0 comments on commit 8fe42de

Please sign in to comment.