sidescanpy.grids.resample#

Resampling channel data to georeferenced grids.

Provides resample_channel_to_grid() to aggregate sidescan backscatter from survey geometry to a regular grid using various aggregation methods, and grid_channel() to do so on a UTM grid fit to the channel’s own extent.

Contents

ResamplingMethod

Resampling aggregation method.

resample_channel_to_grid

Resample channel backscatter to a regular grid.

grid_channel

Grid a georeferenced channel onto a UTM grid fit to its own extent.

class sidescanpy.grids.resample.ResamplingMethod(*values)#

Bases: str, Enum

Resampling aggregation method.

sidescanpy.grids.resample.resample_channel_to_grid(channel, grid_def, method=ResamplingMethod.MEAN, separate_sides=False, max_search_radius_m=None, backscatter_var='backscatter_intensity')#

Resample channel backscatter to a regular grid.

Parameters:
channelxr.Dataset

Channel dataset with a backscatter variable (see backscatter_var) and per-sample coordinates (latitude_per_sample, longitude_per_sample).

grid_defGridDefinition

Target grid definition (bbox, resolution, CRS).

methodResamplingMethod or str, default “mean”

Aggregation method: mean, median, max, nearest, or idw, as the enum or its string value.

separate_sidesbool, default False

If True, output separate port and starboard bands (diagnostic mode). If False, merge port and starboard into single backscatter variable.

max_search_radius_mfloat, optional

Maximum search radius in meters. If None, use 1.5x grid resolution.

backscatter_varstr, default “backscatter_intensity”

Name of the backscatter variable in channel to resample. Corrections are applied in place to “backscatter_intensity” (dB once TVG has run, linear amplitude before); for the uncorrected signal of a corrected channel, assign sidescanpy.processing.uncorrected_backscatter(channel) to a variable and grid that.

Returns:
SideScanGriddedRaster

Gridded backscatter raster with n_contributing_samples tracking.

Raises:
ValueError

If channel is missing required variables, grid bounds don’t overlap, or method is not a known resampling method.

Notes

This function does not filter out or otherwise special-case the TVG floor-clipped sample population (see apply_tvg()’s “KNOWN ISSUE” docstring note). Those samples generally have finite georeferenced coordinates, so they pass the np.isfinite(lat)/ np.isfinite(lon) filter here like any other sample and get included in each cell’s aggregation. With method=MEAN (the default) and typical real-survey point densities (thousands of raw samples per cell at 1m resolution), that ~1% outlier population gets diluted, not removed — it’s swamped by the majority-real samples in the same cell, not excluded from the average. This dilution is exactly why a gridded raster’s effective dynamic range (and therefore its percentile-based color scale) can differ sharply from a per-sample waterfall’s.

sidescanpy.grids.resample.grid_channel(channel, resolution_m=1.0, method=ResamplingMethod.MEAN, *, backscatter_var='backscatter_intensity', max_search_radius_m=None)#

Grid a georeferenced channel onto a UTM grid fit to its own extent.

The grid covers bbox_from_channel_dataset() in the UTM zone of its center (utm_grid_from_wgs84_bbox()), and the channel is resampled onto it with resample_channel_to_grid().

Parameters:
channelxr.Dataset

Channel with latitude_per_sample/longitude_per_sample (georeferencing applied) and backscatter_var.

resolution_mfloat, default 1.0

Cell size in meters.

methodResamplingMethod or str, default “mean”

Aggregation method ("mean", "median", "max", "nearest", "idw").

backscatter_varstr, default “backscatter_intensity”

Variable to grid.

max_search_radius_mfloat, optional

Passed to resample_channel_to_grid().

Returns:
SideScanGriddedRaster