Ir al contenido

underwater.bioacoustics.weighting

La referencia de la API se publica en inglés en los dos idiomas: se genera a partir de los docstrings del código, que son su texto original.

Regulatory auditory weighting and exposure criteria for marine mammals.

Noise-exposure assessments weight a spectrum by a hearing-group filter before comparing it with a threshold. The filter is the same band-pass form in all current guidance (NMFS 2018 Equation 1, Southall et al. 2019 Equation 2):

with f in kilohertz. C is fixed by putting the peak of W at 0 dB, so the companion exposure function has its minimum at the weighted threshold . Only the parameter table changes between guidance versions, so the version is explicit in the API and is carried on every result object:

  • "nmfs-2024" — NOAA Fisheries, Updated Technical Guidance, version 3.0 (October 2024), Table 5 and Table ES3. The default: it supersedes the 2018 revision, uses for every group, renames the groups to the Southall scheme (LF/HF/VHF cetaceans, PW/OW in water, PA/OA in air) and replaces “PTS onset” with “auditory injury (AUD INJ) onset”.
  • "nmfs-2018" — the 2018 revision, version 2.0, Table 3 and Table ES3. Still cited by assessments already in flight.
  • "southall-2019" — Southall et al., Aquatic Mammals 45(2), Tables 5, 6 and 7, the peer-reviewed criteria; adds sirenians (SI) and both in-air carnivore groups. Numerically identical to NMFS 2018 on the five shared groups.

Group names are not portable between versions. NMFS 2018 calls the mid-frequency cetaceans MF and the porpoise-type group HF; NMFS 2024 and Southall call the same two HF and VHF. Each guidance version only accepts its own codes.

The module exposes the weighting itself (auditory_weighting), the published thresholds (exposure_criteria) and the assessment chain (weighted_exposure), which weights a band spectrum, accumulates it over a number of events and reports the exceedance of each applicable criterion.

Implemented clean-room from the three documents; validated against the worked example of NMFS (2018) Appendix D ( for the five groups), against C recomputed as the peak of W for all three parameter sets, and against the published and injury = TTS + 20 dB identities.

Auto-generated from the source docstrings by scripts/generate_api_docs.py (make api-docs). Do not edit by hand.

auditory_weighting(
frequency_hz: NDArray[np.float64] | list[float] | float,
group: str,
*,
guidance: str = 'nmfs-2024',
) -> AuditoryWeightingResult

Auditory weighting function W(f) of a marine-mammal hearing group.

Parameters

NameDescription
frequency_hzFrequency or frequencies, in Hz (strictly positive).
groupHearing-group code as used by guidance.
guidance"nmfs-2024" (default, current), "nmfs-2018" or "southall-2019".

Returns: An AuditoryWeightingResult.

Raises

ExceptionWhen
ValueErrorIf an input is invalid.
AuditoryWeightingResult(
frequencies: NDArray[np.float64],
weighting: NDArray[np.float64],
exposure_function: NDArray[np.float64],
parameters: WeightingParameters,
guidance: str,
group: str,
weighted_tts_onset: float,
)

Auditory weighting and exposure functions of one hearing group.

Attributes

NameDescription
frequenciesFrequencies, in Hz.
weightingWeighting-function amplitude W(f), in dB ().
exposure_functionExposure function , in dB (the frequency-dependent TTS-onset level).
parametersThe WeightingParameters used.
guidanceThe guidance version.
groupHearing-group code.
weighted_tts_onset, the minimum of the exposure function, in dB.
AuditoryWeightingResult.plot(
ax: Axes | None = None,
*,
language: str = 'en',
**kwargs: Any,
) -> Axes

Plot the weighting function versus frequency.

exposure_criteria(
group: str,
*,
guidance: str = 'nmfs-2024',
impulsive: bool = False,
) -> ExposureCriteria

Published TTS and injury onset criteria of a hearing group.

Parameters

NameDescription
groupHearing-group code as used by guidance.
guidance"nmfs-2024" (default), "nmfs-2018" or "southall-2019".
impulsiveReturn the impulsive-noise criteria (dual metric: a weighted SEL and an unweighted peak SPL) instead of the non-impulsive ones.

Returns: An ExposureCriteria.

Raises

ExceptionWhen
ValueErrorIf the version or the group is unknown.
ExposureCriteria(
group: str,
guidance: str,
impulsive: bool,
tts_sel: float | None,
injury_sel: float | None,
tts_peak_spl: float | None,
injury_peak_spl: float | None,
injury_label: str,
sel_reference: str,
peak_reference: str,
source: str,
)

Published TTS and injury (PTS / AUD INJ) onset criteria for one group.

Sound exposure levels are weighted; peak sound pressure levels are unweighted (“flat”), as every source states. None means the criterion is not published by that guidance version.

Attributes

NameDescription
groupHearing-group code.
guidanceThe guidance version.
impulsiveWhether these are the impulsive-noise criteria.
tts_selWeighted TTS-onset sound exposure level, in dB.
injury_selWeighted injury-onset (PTS / AUD INJ) SEL, in dB.
tts_peak_splUnweighted TTS-onset peak SPL, in dB.
injury_peak_splUnweighted injury-onset peak SPL, in dB.
injury_label"PTS" or "AUD INJ", as the source names it.
sel_referenceHuman-readable SEL reference of the group.
peak_referenceHuman-readable peak-SPL reference of the group.
sourceTable the numbers come from.
hearing_groups(guidance: str = 'nmfs-2024') -> tuple[str, ...]

Hearing-group codes defined by a guidance version.

Parameters

NameDescription
guidanceOne of WEIGHTING_GUIDANCE.

Returns: The group codes, in the order the source tabulates them.

Raises

ExceptionWhen
ValueErrorIf the version is unknown.
weighted_exposure(
frequency_hz: NDArray[np.float64] | list[float],
band_sel: NDArray[np.float64] | list[float],
group: str,
*,
guidance: str = 'nmfs-2024',
impulsive: bool = True,
n_events: int = 1,
peak_spl: float | None = None,
) -> WeightedExposureResult

Weight a band spectrum, accumulate it and compare it with the criteria.

The per-band single-event sound exposure levels are weighted with auditory_weighting, summed on an energy basis and accumulated over n_events identical events (, the ISO 18406 Formula 9 identity used by cumulative_sel_identical). The result is compared with the group’s TTS and injury onset criteria; the peak sound pressure level, if supplied, is compared unweighted, as the dual-metric rule requires.

Parameters

NameDescription
frequency_hzBand centre frequencies, in Hz (1-D, positive).
band_selPer-band single-event SEL, in dB re 1 µPa²·s (or dB re (20 µPa)²·s for an in-air group); same length. -inf is accepted for a band that carries no energy, which is what strike_sel_spectrum returns for bands narrower than its FFT bin spacing; such a band adds nothing to the energy sum. Both input arrays are copied, so the result never aliases the caller’s data.
groupHearing-group code as used by guidance.
guidance"nmfs-2024" (default), "nmfs-2018" or "southall-2019".
impulsiveCompare against the impulsive criteria (the default, the case for pile driving and air guns).
n_eventsNumber of identical accumulated events, .
peak_splUnweighted zero-to-peak sound pressure level of the loudest single event, in dB; enables the peak-SPL half of the dual metric.

Returns: A WeightedExposureResult.

Raises

ExceptionWhen
ValueErrorIf an input is invalid.
WeightedExposureResult(
frequencies: NDArray[np.float64],
band_sel: NDArray[np.float64],
weighting: NDArray[np.float64],
weighted_band_sel: NDArray[np.float64],
unweighted_sel: float,
weighted_sel: float,
cumulative_sel: float,
peak_spl: float | None,
n_events: int,
criteria: ExposureCriteria,
sel_margin: float | None,
tts_margin: float | None,
peak_margin: float | None,
tts_peak_margin: float | None,
exceeds_injury: bool,
exceeds_tts: bool,
guidance: str,
group: str,
)

Weighted exposure of a spectrum against a hearing group’s criteria.

Attributes

NameDescription
frequenciesBand centre frequencies, in Hz.
band_selPer-band single-event sound exposure level, in dB.
weightingWeighting-function amplitude at each band, in dB.
weighted_band_selband_sel + W(f) per band, in dB.
unweighted_selEnergy sum of band_sel, in dB.
weighted_selEnergy sum of weighted_band_sel, in dB.
cumulative_selweighted_sel plus for the n_events accumulated events, in dB.
peak_splThe unweighted peak sound pressure level supplied, in dB (None when not given).
n_eventsNumber of accumulated events (e.g. hammer strikes).
criteriaThe ExposureCriteria compared against.
sel_margincumulative_sel - injury_sel, in dB (None when the criterion is not published); positive means the criterion is exceeded.
tts_margincumulative_sel - tts_sel, in dB (or None).
peak_marginpeak_spl - injury_peak_spl, in dB (or None).
tts_peak_marginpeak_spl - tts_peak_spl, in dB (or None) — the peak-SPL half of the dual metric on the TTS side, which can trip exceeds_tts on its own.
exceeds_injuryWhether any injury-onset criterion is reached. The test is margin >= 0, so an exposure landing exactly on the criterion counts as exceeding it; the criteria are onset thresholds and the precautionary reading is the one an assessment wants.
exceeds_ttsWhether any TTS-onset criterion is reached, on the same margin >= 0 convention as exceeds_injury.
guidanceThe guidance version.
groupHearing-group code.
WeightedExposureResult.plot(
ax: Axes | None = None,
*,
language: str = 'en',
**kwargs: Any,
) -> Axes

Plot the unweighted and weighted band spectra with the criteria.

Constant (tuple).

WEIGHTING_GUIDANCE = ('nmfs-2024', 'nmfs-2018', 'southall-2019')
weighting_parameters(
group: str,
*,
guidance: str = 'nmfs-2024',
) -> WeightingParameters

Weighting/exposure parameters of one hearing group.

Parameters

NameDescription
groupHearing-group code as used by guidance (case-insensitive).
guidanceOne of WEIGHTING_GUIDANCE.

Returns: The WeightingParameters row.

Raises

ExceptionWhen
ValueErrorIf the version or the group is unknown.
WeightingParameters(
group: str,
guidance: str,
description: str,
a: float,
b: float,
f1_khz: float,
f2_khz: float,
c_db: float,
c_db_as_printed: float,
k_db: float,
in_air: bool,
hearing_range_hz: tuple[float, float] | None,
)

Auditory weighting and exposure function parameters for one group.

Attributes

NameDescription
groupHearing-group code as used by its own guidance version.
guidanceThe guidance version the row comes from.
descriptionPlain-language name of the hearing group.
aLow-frequency exponent a.
bHigh-frequency exponent b.
f1_khzLow-frequency transition f1, in kHz.
f2_khzHigh-frequency transition f2, in kHz.
c_dbGain C that puts the peak of W at 0 dB, in dB.
c_db_as_printedC exactly as printed in the source table, in dB (differs from c_db only for the NMFS 2024 otariid row).
k_dbExposure-function constant K, in dB.
in_airWhether the group’s reference is 20 µPa (in air).
hearing_range_hzGeneralised hearing range of the group, in Hz, or None. Only the NMFS documents tabulate one (their Table ES1); Southall et al. do not, and the field is None for those rows rather than borrowed from elsewhere.