Skip to content

Add prototype API for FM EK80#1664

Open
LOCEANlloydizard wants to merge 2 commits into
echostack-org:mainfrom
LOCEANlloydizard:broadband_processing
Open

Add prototype API for FM EK80#1664
LOCEANlloydizard wants to merge 2 commits into
echostack-org:mainfrom
LOCEANlloydizard:broadband_processing

Conversation

@LOCEANlloydizard
Copy link
Copy Markdown
Collaborator

@LOCEANlloydizard LOCEANlloydizard commented May 17, 2026

  • Add public compute_Sv_f() and compute_TS_f() for the API
  • Add _cal_complex_samples_f() prototype
  • Expose frequency_resolution and range_step parameters for spectral calibration
  • Return prototype Sv_f xarray output structure: (channel, ping_time, svf_range, frequency)

Refs: #1034

- Add public `compute_Sv_f()` and `compute_TS_f()` for the API
- Add `_cal_complex_samples_f()` prototype
- Expose `frequency_resolution` and `range_step` parameters for future spectral calibration
- Return prototype `Sv_f` xarray output structure:
  `(channel, ping_time, svf_range, frequency)`
Use lazy method getattr in calibration dispatcher to avoid access to unsupported compute_Sv_f / compute_TS_f methods on non-FM calibrators
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 17, 2026

Codecov Report

❌ Patch coverage is 55.00000% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.56%. Comparing base (6cf6cee) to head (c6886e3).
⚠️ Report is 45 commits behind head on main.

Files with missing lines Patch % Lines
echopype/calibrate/calibrate_ek.py 35.29% 11 Missing ⚠️
echopype/calibrate/api.py 66.66% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1664      +/-   ##
==========================================
- Coverage   85.58%   85.56%   -0.02%     
==========================================
  Files          79       78       -1     
  Lines        6998     7074      +76     
==========================================
+ Hits         5989     6053      +64     
- Misses       1009     1021      +12     
Flag Coverage Δ
integration 80.81% <55.00%> (+0.17%) ⬆️
unit 60.22% <55.00%> (-0.20%) ⬇️
unittests 85.46% <55.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leewujung
Copy link
Copy Markdown
Member

Hey @LOCEANlloydizard, I thought of a few other params after our discussion the other day so thought I'd lay them out and see what you think. Feel free to ping for more discussions!

def compute_Sv_spectrum(
    self,
    NFFT: int,
    range_step: float = 0.5,
    window: str = "hann",  # TODO: should this be default to None?
    frequency_resolution: Optional[float] = None,
) -> xr.Dataset:
    """Compute broadband EK80 Sv spectrum, or Sv(f).

    Parameters
    ----------
    NFFT : int
        Number of points in the FFT window for computing spectrum.
    range_step : float, default 0.5
        Range spacing in meters for the output Sv(f) window centres.
    window : str, default "hann"
        Type of window function to apply to each FFT segment.
        Options include "hann", "hamming", etc.
    frequency_resolution : optional[float], default None
        Frequency spacing in Hz for the output spectral grid.
        When this is provided, the output Sv(f) will be interpolated to this frequency grid.
        If None, the output Sv(f) will be on the original FFT frequency grid.

    Returns
    -------
    xr.Dataset
        A Dataset containing frequency-dependent volume backscattering strength.
    """


def compute_TS_spectrum(
    self,
    point_locations: xr.DataSet,
    NFFT: int,
    split_front: float = 0.25,
    window: str = "hann",
    frequency_resolution: Optional[float] = None,
) -> xr.Dataset:
    """Compute broadband EK80 Sv spectrum, or Sv(f).

    Parameters
    ----------
    point_locations : xr.DataSet
        Locations of the points for which to compute the spectrum.
        This is required to be an xarray.DataSet with dimensions ("target_id") and
        data variables "ping_time" and "depth" for each ``target_id``.
    NFFT : int
        Number of points in the FFT window for computing spectrum.
    split_front : float, default 0.25
        Each echo spectrum is computed from a segment of the complex echo signal.
        This parameter specifies how to identify the segment around the specified point location.
        For example, if split_front=0.25, then 25% the NFFT length will be before the point location,
        and the remaining 75% will be after the point location.
    window : str, default "hann"
        Type of window function to apply to each FFT segment.
        Options include "hann", "hamming", etc.
    frequency_resolution : optional[float], default None
        Frequency spacing in Hz for the output spectral grid.
        When this is provided, the output Sv(f) will be interpolated to this frequency grid.
        If None, the output Sv(f) will be on the original FFT frequency grid.

    Returns
    -------
    xr.Dataset
        A Dataset containing frequency-dependent point backscattering strength.
    """

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants