sidescanpy.export.windows.neighborhood#
Bounded, block-averaged ping neighborhoods for geometric/georef windows.
A geometric or georef window is resampled from the pings around its
center. load_geo_neighborhood() loads only those pings, only the
variables the resample reads, nadir-masks them at native resolution, and
block-averages them down to about SWATH_OVERSAMPLE source cells
per output pixel per axis – loading a full-swath neighborhood of every
per-sample array at native resolution costs gigabytes per window on a
real survey.
2026 rshomberg@uri.edu
Contents
Source cells kept per output pixel, per axis, after block averaging. |
|
Pings loaded and masked per piece in |
|
Variables the geometric/georef resample and the nadir mask read. |
|
Mean along-track meters per ping over pings |
|
Signed across-track coordinate (port negative) for a geometric window. |
|
Neighborhood half-span and block-average factors for one style. |
|
Nadir- and dropout-masked pings |
|
|
|
A loaded, block-averaged neighborhood for geometric/georef windows. |
|
Block-averaged neighborhood around |
- sidescanpy.export.windows.neighborhood.SWATH_OVERSAMPLE = 2.0#
Source cells kept per output pixel, per axis, after block averaging.
- sidescanpy.export.windows.neighborhood.SWATH_LOAD_BLOCK_PINGS = 2048#
Pings loaded and masked per piece in
load_swath_neighborhood().
- sidescanpy.export.windows.neighborhood.SWATH_LOAD_VARS#
Variables the geometric/georef resample and the nadir mask read.
- sidescanpy.export.windows.neighborhood.neighborhood_ping_spacing_m(ds_full, lo, hi)#
Mean along-track meters per ping over pings
[lo, hi).Navigation stalls (repeated fixes) are filled before measuring.
0.0for fewer than two pings.
- sidescanpy.export.windows.neighborhood.across_values(ds, across_axis)#
Signed across-track coordinate (port negative) for a geometric window.
"ground":across_track_m(ground-projected)."slant":slant_range_mwith the same sign convention – still meters, so a window covers the same real extent on both axes, but the water column is kept (slant_range_mis finite everywhere; the nadir mask still blanks the backscatter there).- Raises:
- ValueError
Unknown
across_axis.- KeyError
"slant"withoutslant_range_minds.
- sidescanpy.export.windows.neighborhood.geo_decimation(ds_full, ping_idx, style, *, size_px, jitter_px, resolution_m, across_axis='ground', swath_fill=False, margin_m=0.0)#
Neighborhood half-span and block-average factors for one style.
The half-span (pings) covers the output window in meters –
size_px * resolution_malong-track plus jitter andmargin_m– with slack for turns and edge-shifting. The(ping, sample)factors keep aboutSWATH_OVERSAMPLEsource cells per output pixel.- Parameters:
- ds_fullxr.Dataset
The whole (lazy) frequency channel.
- ping_idxint
Window center ping.
- stylestr
"chip","single-swath"or"dual-swath".- size_px, jitter_pxint
Output size and jitter of the window.
- resolution_mfloat or None
Output meters per pixel;
Noneestimates the valueextract_geo_style_window()will choose (chip:max(meters_per_sample, ping_spacing); swath styles: swath width /size_px, floored at the ping spacing unlessswath_fill).- across_axisstr, default “ground”
See
across_values().- swath_fillbool, default False
Estimate resolution the way
swath_fillwindows choose it.- margin_mfloat, default 0.0
Extra along-track meters the neighborhood must cover beyond the window (background windows load enough to check nearby targets).
- Returns:
- (half_span_pings, fp, fs)
- sidescanpy.export.windows.neighborhood.load_swath_neighborhood(ds_full, lo, hi, fp, fs, *, with_db, extra_vars=(), skip_vars=())#
Nadir- and dropout-masked pings
[lo, hi), block-averaged byfppings xfssamples.Loads only
SWATH_LOAD_VARS(plusextra_vars, minusskip_vars) inSWATH_LOAD_BLOCK_PINGS-sized pieces, masking each piece at native resolution (nadir gap, and dropouts withmask_dropouts()) before averaging.sample_rate_hzis divided byfssonominal_sample_interval_m()reports the averaged cell size.- Parameters:
- ds_fullxr.Dataset
The whole (lazy) frequency channel.
- lo, hiint
Ping range.
- fp, fsint
Ping and sample block-average factors (partial edge blocks are trimmed).
- with_dbbool
Also add
backscatter_db.- extra_vars, skip_varstuple of str
Variables to add to / remove from
SWATH_LOAD_VARS.
- Returns:
- xr.Dataset
- sidescanpy.export.windows.neighborhood.decimate_target(target, fs, fp)#
targetin a block-averaged neighborhood’s(fp, fs)pixel units.Moves
sample(integer division) and scalesbbox(x byfs, y byfp).
- class sidescanpy.export.windows.neighborhood.GeoNeighborhood(ds, target, local_ping, mps, items, lo, fp=1, fs=1)#
Bases:
objectA loaded, block-averaged neighborhood for geometric/georef windows.
- Attributes:
- dsxr.Dataset
The averaged neighborhood (see
load_swath_neighborhood()).- targetTarget or None
The window’s primary target in averaged units (
Nonefor a window with no primary target).- local_pingint
Center ping, indexed into
ds.- mpsfloat
Averaged meters per sample.
- itemsdict
{channel: [(target, ping), ...]}co-target candidates, in averaged units;pingmaps file pingptolo + (p - lo) // fpso thatping - loindexesds.- loint
File ping index of the neighborhood’s first ping.
- fp, fsint
Ping and sample averaging factors.
- to_averaged_sample(sample)#
A native sample index in this neighborhood’s averaged sample units.
- sidescanpy.export.windows.neighborhood.load_geo_neighborhood(ds_full, target, ping_idx, items_by_channel, styles, *, size_px, jitter_px, resolution_m, with_db, across_axis='ground', per_sample_latlon=True, swath_fill=False, margin_m=0.0)#
Block-averaged neighborhood around
ping_idxserving every style instyles.Uses the widest half-span and finest averaging factors any of
stylesneeds (seegeo_decimation()), and translatestargetanditems_by_channelinto the averaged units.- Parameters:
- ds_fullxr.Dataset
The whole (lazy) frequency channel.
- targetTarget or None
Primary target (
Nonefor a background window).- ping_idxint
Center ping (file index).
- items_by_channeldict
{channel: [(target, file_ping_idx), ...]}co-target candidates.- styleslist of str
- size_px, jitter_px, resolution_m, across_axis, swath_fill, margin_m
See
geo_decimation().- with_dbbool
Add
backscatter_db.- per_sample_latlonbool, default True
Load
latitude_per_sample/longitude_per_sample(only the georef level reads them).
- Returns:
- GeoNeighborhood
With
across_axis="slant",ds["across_track_m"]is replaced by signed slant range (seeacross_values()), so every downstream geometric lookup works in slant meters.