resample_to_geometry

resample_to_geometry#

echopype.commongrid.resample_to_geometry(ds_Sv, target_variable: str = 'Sv', is_log: bool = True, target_channel: str | None = None, target_grid: DataArray | None = None)#

Regrids a variable across all channels in an Sv or Sp dataset to a common range geometry specified by either a target channel or a custom target grid. Ping time is assumed identical for all input channels.

Parameters:
ds_Svxr.Dataset

Input Dataset containing Sv data

target_variablestr, default “Sv”

Name of the variable to resample. The variable must exist in ds_Sv.

is_logbool, default True

Whether target_variable contains logarithmic values. If True, values are converted to the linear domain before weighted averaging and converted back afterward.

target_channelstr, optional

Channel used as reference grid. Must be provided if target_grid is None.

target_gridxr.DataArray, optional

Custom range grid. Must be provided if target_channel is None. The grid may have dimension ("range_sample",) for a common grid across all pings, or ("ping_time", "range_sample") for a ping-dependent grid. Its range_sample length may differ from that of the input dataset.

Returns:
xr.Dataset

A new Dataset where all channels share the same ping_time, range_sample, and echo_range as the target. ping_time is assumed identical across all input channels and preserved throughout the resampling process. The resulting target geometry, whether specified using target_channel` or target_grid, can be retrieved with target_grid = regridded_ds[“echo_range”].