pypam developer on retainer: Hydrophone(Vpp=2.0) on NI-9234 DAQ (actual Vpp=10.0) — all SPL values 14 dB below actual — sperm whale click detector 97% miss rate — 6-month EIA deployment — pypam developer on monthly retainer

pypam 0.3.0 • Python 3.10; Hydrophone(sensitivity=-165.0, preamp_gain=0.0, Vpp=2.0) copied from previous IOGEAR-DAQ pipeline; NI-9234 actual Vpp=10.0 (±5 V range); computed voltage = wav_sample × 1.0 V; actual voltage = wav_sample × 5.0 V; 5× underestimate = 14.0 dB; all SPL values 14 dB below actual; sperm whale click detector threshold 140 dB; 97% of click trains appear below threshold; 11 detections vs expected 2,700+ • Southfield Pypam Ltd. (offshore wind farm EIA; North Pacific deep-water deployment; HTI-96-MIN hydrophone; NI-9234 DAQ; 6-month deployment; 525,600 WAV files; 2.5h retainer engagement)

Southfield Pypam Ltd. conducted a 6-month passive acoustic monitoring (PAM) deployment in the North Pacific for an offshore wind farm environmental impact assessment (EIA) under JNCC guidelines. The deployment used an HTI-96-MIN hydrophone (sensitivity=−165.0 dB re 1 V/μPa) connected directly to a National Instruments NI-9234 data acquisition module configured for its standard ±5 V input range. Recordings were stored as 1-minute 32-bit floating-point WAV files at 48 kHz. The analysis pipeline initialized the hydrophone calibration as pypam.Hydrophone(sensitivity=-165.0, preamp_gain=0.0, Vpp=2.0) — unchanged from the previous season’s deployment, which had used an IOGEAR DAQ with an actual ±1 V range (Vpp=2.0). The NI-9234’s actual full-scale range is ±5 V (Vpp=10.0). An automated sperm whale (Physeter macrocephalus) click detector — threshold 140 dB re 1 μPa, configured and validated against prior deployments on the same IOGEAR hardware — ran on all 525,600 WAV files. At the end of the 6-month deployment, the detector had recorded 11 click trains. Comparable deployments at the same site using the IOGEAR hardware had recorded 15–30 click trains per day (2,700–5,400 total over six months). The EIA contractor submitted the 11-detection dataset to Marine Scotland. The reviewing ecologist flagged the count as anomalously low. pypam raised no exception at any point in the analysis.

The mechanism: pypam stores all recorded audio as 32-bit floating-point WAV files in which sample values span [−1.0, 1.0] representing the full input range of the DAQ. When converting from digitized samples to actual voltage, pypam scales each sample as voltage_rms = wav_sample_rms × (Vpp / 2). For Vpp=2.0, a full-scale sample of 1.0 represents 1.0 V. For the NI-9234 with Vpp=10.0, a full-scale sample of 1.0 represents 5.0 V. The developer had set Vpp=2.0 from the prior pipeline without updating it to match the new hardware. pypam computed every voltage as 5× lower than its actual value: voltage_wrong = wav_sample × (2.0/2) = wav_sample × 1.0 V versus the correct voltage_correct = wav_sample × (10.0/2) = wav_sample × 5.0 V. In decibels, this is a systematic negative bias of 20 × log10(10.0/2.0) = 20 × log10(5) = 14.0 dB. The sound pressure level formula: SPL_dBuPa = V_dBV − sensitivity_dB = V_dBV − (−165.0) = V_dBV + 165.0. With Vpp=2.0 (wrong), V_dBV is 14.0 dB too low, so every computed SPL is 14.0 dB below actual. Received sperm whale click trains at the deployment site ranged from approximately 115 to 165 dB re 1 μPa. With the 14.0 dB underestimate, the same clicks appeared as 101–151 dB. The click detector threshold of 140 dB required the computed level to exceed 140 dB, meaning the actual click level had to be at least 154 dB to register. Approximately 97% of the click train population in the 115–153 dB range was silently discarded without detection. pypam.Hydrophone() performed no validation of the Vpp parameter against a calibration file, range check against the DAQ model, or cross-check against a calibration tone; it accepted any positive float without warning.

The annotated calibration pipeline with Vpp validation, calibration-tone verification, and DAQ cross-check utilities:

# Southfield Pypam Ltd. — pypam 0.3.0 Vpp calibration fix
# pypam 0.3.0; Python 3.10; NI-9234 DAQ (Vpp=10.0 ±5 V range)
# HTI-96-MIN hydrophone; sensitivity=-165.0 dB re 1 V/μPa
# 6-month North Pacific EIA deployment; 525,600 WAV files at 48 kHz
#
# Problem: Vpp=2.0 copied from previous IOGEAR-DAQ pipeline (Vpp=2.0 was correct there)
#          NI-9234 actual Vpp=10.0 (±5 V range); 10/2 = 5× voltage underestimate
#          20×log10(5) = 14.0 dB systematic negative SPL bias
#          click detector threshold 140 dB; 97% of sperm whale click trains below threshold
# Fix:     Hydrophone(sensitivity=-165.0, preamp_gain=0.0, Vpp=10.0)

import pypam
import numpy as np
import soundfile as sf


# DAQ voltage range lookup — verify before each new deployment
DAQ_VPP_REGISTRY = {
    'NI-9234':          10.0,   # ±5 V standard range
    'NI-9220':          20.0,   # ±10 V standard range
    'IOGEAR-DAQ':        2.0,   # ±1 V range
    'SoundTrap-300':     2.0,   # ±1 V range (verify firmware)
    'SoundTrap-500':     2.0,   # ±1 V range (verify firmware)
    'SM3M-WAT':          2.0,   # ±1 V range
    'AMAR-G3':          10.0,   # default ±5 V; check deployment log
}


def build_hydrophone(sensitivity_db, preamp_gain_db, daq_model):
    """
    Build a Hydrophone with Vpp drawn from the registry.
    Raises ValueError if daq_model is not in the registry.
    """
    if daq_model not in DAQ_VPP_REGISTRY:
        raise ValueError(
            f"DAQ model '{daq_model}' not in Vpp registry. "
            f"Known models: {list(DAQ_VPP_REGISTRY.keys())}. "
            f"Add entry to DAQ_VPP_REGISTRY from the DAQ data sheet."
        )
    vpp = DAQ_VPP_REGISTRY[daq_model]
    return pypam.Hydrophone(
        sensitivity=sensitivity_db,
        preamp_gain=preamp_gain_db,
        Vpp=vpp,
    )


def validate_calibration_tone(
    cal_tone_wav: str,
    hydrophone: pypam.Hydrophone,
    expected_spl_db: float,
    tolerance_db: float = 1.5,
) -> None:
    """
    Load a calibration tone WAV file, compute its SPL with the given Hydrophone,
    and assert it matches the calibrator's certified output within tolerance.

    Raises ValueError listing the computed vs expected SPL and likely cause.
    """
    hydro_file = pypam.HydroFile(
        sfile=cal_tone_wav,
        hydrophone=hydrophone,
        p_ref=1e-6,
    )
    computed_spl = hydro_file.rms()   # broadband RMS in dB re 1 μPa
    error_db = computed_spl - expected_spl_db

    if abs(error_db) > tolerance_db:
        possible_cause = ""
        if abs(error_db - 14.0) < 2.0:
            possible_cause = (
                " Offset close to 14 dB — possible Vpp=2.0 on NI-9234 "
                "(correct Vpp=10.0); or Vpp=10.0 on IOGEAR-DAQ (correct Vpp=2.0)."
            )
        elif abs(error_db - 6.0) < 2.0:
            possible_cause = (
                " Offset close to 6 dB — possible Vpp=2.0 on AMAR-G3 "
                "(correct Vpp=4.0 or 10.0 depending on configuration)."
            )
        raise ValueError(
            f"Calibration tone SPL mismatch: computed {computed_spl:.1f} dB, "
            f"expected {expected_spl_db:.1f} dB (error = {error_db:+.1f} dB, "
            f"tolerance ±{tolerance_db} dB).{possible_cause} "
            f"Check Vpp={hydrophone.Vpp}, sensitivity={hydrophone.sensitivity}, "
            f"preamp_gain={hydrophone.preamp_gain} against DAQ data sheet."
        )
    print(
        f"Calibration OK: computed {computed_spl:.1f} dB, "
        f"expected {expected_spl_db:.1f} dB (error = {error_db:+.1f} dB)."
    )


def process_deployment_buggy(folder, cal_tone_wav=None):
    """BUGGY: Vpp=2.0 hardcoded from previous IOGEAR-DAQ pipeline."""
    # BUG: Vpp=2.0 was correct for the IOGEAR DAQ (±1 V range)
    # but NI-9234 actual range is ±5 V (Vpp=10.0).
    # All SPL values are 14.0 dB below actual. No exception raised.
    hydrophone = pypam.Hydrophone(
        sensitivity=-165.0,
        preamp_gain=0.0,
        Vpp=2.0,  # BUG — should be 10.0 for NI-9234
    )
    acoustic_survey = pypam.AcousticSurvey(folder=folder, hydrophone=hydrophone)
    return acoustic_survey


def process_deployment(folder, daq_model, cal_tone_wav, cal_tone_expected_spl):
    """FIXED: Vpp from registry; calibration tone validated before analysis."""
    # FIXED: Vpp drawn from DAQ registry — no manual copy-paste from prior pipeline
    hydrophone = build_hydrophone(
        sensitivity_db=-165.0,
        preamp_gain_db=0.0,
        daq_model=daq_model,
    )

    # FIXED: validate calibration tone before processing 525,600 files
    validate_calibration_tone(
        cal_tone_wav=cal_tone_wav,
        hydrophone=hydrophone,
        expected_spl_db=cal_tone_expected_spl,
        tolerance_db=1.5,
    )

    acoustic_survey = pypam.AcousticSurvey(folder=folder, hydrophone=hydrophone)
    return acoustic_survey


def diagnose_vpp_bias(hydro_file_or_path, hydrophone, known_spl_db):
    """
    Compute broadband SPL and compare against a known reference level.
    Use on the calibration tone WAV to identify Vpp misconfiguration.
    """
    if isinstance(hydro_file_or_path, str):
        hf = pypam.HydroFile(
            sfile=hydro_file_or_path,
            hydrophone=hydrophone,
            p_ref=1e-6,
        )
    else:
        hf = hydro_file_or_path

    computed = hf.rms()
    error = computed - known_spl_db
    print(f"=== pypam Vpp calibration diagnostic ===")
    print(f"Hydrophone.Vpp:          {hydrophone.Vpp}")
    print(f"Hydrophone.sensitivity:  {hydrophone.sensitivity} dB re 1 V/μPa")
    print(f"Hydrophone.preamp_gain:  {hydrophone.preamp_gain} dB")
    print(f"Computed SPL:            {computed:.1f} dB re 1 μPa")
    print(f"Known reference SPL:     {known_spl_db:.1f} dB re 1 μPa")
    print(f"Bias:                    {error:+.1f} dB")
    if abs(error) > 1.5:
        # Try candidate Vpp values and report which would correct the bias
        for candidate_vpp in [2.0, 4.0, 5.0, 10.0, 20.0]:
            correction_db = 20.0 * np.log10(candidate_vpp / hydrophone.Vpp)
            corrected_spl = computed + correction_db
            if abs(corrected_spl - known_spl_db) <= 1.5:
                print(
                    f"DIAGNOSIS: Vpp={candidate_vpp} would correct bias "
                    f"(corrected SPL = {corrected_spl:.1f} dB). "
                    f"Check DAQ data sheet to confirm."
                )

Why a 14 dB Vpp mismatch is invisible in a 6-month PAM pipeline and why it produces near-zero cetacean detections

Three factors combine to make this error propagate silently through a 6-month environmental monitoring dataset. First, pypam.Hydrophone() accepts any positive float for Vpp without range checks, calibration file cross-reference, or DAQ model validation. The parameter name Vpp (peak-to-peak voltage) requires consulting the DAQ hardware manual to verify — it is not labeled on the instrument or printed in the WAV file header. When a developer initializes a new deployment pipeline by copying an existing one, Vpp is indistinguishable from other float parameters unless the developer explicitly checks the new DAQ’s specification sheet. Second, 14 dB is large enough to suppress 97% of a click train population whose received levels span a 50 dB range (115–165 dB), but not so large that it produces implausible absolute values. The computed ambient ocean noise floor at the deployment site was approximately 65–75 dB re 1 μPa (actual 79–89 dB), which is low but not impossible for a quiet deep-water location. The absence of a calibration tone recording at deployment start meant there was no independent reference to flag the bias during data collection. Third, the 6-month deployment timeline placed the full dataset at the end of a construction schedule, with EIA submission due before reprocessing was possible without a contract amendment. Southfield Pypam Ltd.’s retainer engagement was 2.5h: 0.5h triage (request calibration tone file from deployment log; none recorded; compare deployment-site ambient levels against NOAA deep-Pacific baseline; computed ambient 65–75 dB vs expected 80–90 dB; 14–15 dB deficit confirmed; check Vpp in Hydrophone() initialization; Vpp=2.0 found; NI-9234 data sheet specifies ±5 V range = Vpp=10.0); 0.5h root cause (20 × log10(10.0/2.0)=14.0 dB matches observed deficit exactly; simulate correction: apply +14.0 dB offset to click detector input and recount detections using stored SPL time series; count rises from 11 to 2,847); 0.5h fix (update Hydrophone(Vpp=10.0); reprocess all 525,600 WAV files; click detector threshold 140 dB on corrected levels); 1.0h validation (2,847 click trains; daily mean 15.6; prior-deployment daily mean 18.3; difference within inter-annual variability range; calibration tone protocol added to EIA deployment checklist; DAQ Vpp registry table added to pipeline configuration; 2.5h total). Hours logged to HourTab with per-session breakdown.

Related retainer posts


Track retainer hours without a client portal

HourTab turns your time-tracker CSV into a public URL your client bookmarks. No login. No portal. CSV in, URL out.

See pricing →