torchbp.ops.backproj module
- torchbp.ops.backproj.backprojection_cart_2d(data, grid, fc, r_res, pos, d0=0.0, beamwidth=3.141592653589793, data_fmod=0)[source]
2D backprojection with cartesian coordinates.
Gradient can be calculated with respect to data and pos.
- Parameters:
data (Tensor) – Range compressed input data. Shape should be [nbatch, nsweeps, samples] or [nsweeps, samples]. If input is 3 dimensional the first dimensions is number of independent images to form at the same time. Whole batch is processed with same grid and other arguments.
grid (CartesianGrid or dict) –
Cartesian grid definition. Can be:
CartesianGrid object:
CartesianGrid(x_range=(-50, 50), y_range=(-50, 50), nx=200, ny=200)dict:
{"x": (x0, x1), "y": (y0, y1), "nx": nx, "ny": ny}
fc (float) – RF center frequency in Hz.
r_res (float) – Range bin resolution in data (meters). For FMCW radar: c/(2*bw*oversample), where c is speed of light, bw is sweep bandwidth, and oversample is FFT oversampling factor.
pos (Tensor) – Position of the platform at each data point. Shape should be [nsweeps, 3].
beamwidth (float) – Beamwidth of the antenna in radians. Points outside the beam are not calculated.
d0 (float) – Zero range correction.
data_fmod (float) – Range modulation frequency applied to input data.
- Returns:
img – Cartesian format radar image.
- Return type:
Tensor
- torchbp.ops.backproj.backprojection_polar_2d(data, grid, fc, r_res, pos, d0=0.0, dealias=False, att=None, g=None, g_extent=None, data_fmod=0, alias_fmod=0, normalize=True)[source]
2D backprojection with pseudo-polar coordinates.
Gradient can be calculated with respect to data and pos.
- Parameters:
data (Tensor) – Range compressed input data. Shape should be [nbatch, nsweeps, samples] or [nsweeps, samples]. If input is 3 dimensional the first dimensions is number of independent images to form at the same time. Whole batch is processed with same grid and other arguments.
grid (PolarGrid or dict) –
Polar grid definition. Can be:
PolarGrid object:
PolarGrid(r_range=(50, 100), theta_range=(-1, 1), nr=200, ntheta=400)dict:
{"r": (r0, r1), "theta": (theta0, theta1), "nr": nr, "ntheta": ntheta}
where
thetarepresents sin of angle (-1, 1 for 180 degree view).fc (float) – RF center frequency in Hz.
r_res (float) – Range bin resolution in data (meters). For FMCW radar: c/(2*bw*oversample), where c is speed of light, bw is sweep bandwidth, and oversample is FFT oversampling factor.
pos (Tensor) – Position of the platform at each data point. Shape should be [nsweeps, 3] or [nbatch, nsweeps, 3].
d0 (float) – Zero range correction.
dealias (bool) – If True removes the range spectrum aliasing. Equivalent to applying torchbp.util.bp_polar_range_dealias on the SAR image. Default is False.
att (Tensor) – Antenna rotation tensor. [Roll, pitch, yaw]. Only yaw is used and only if beamwidth < Pi to filter out data outside the antenna beam.
g (Tensor or None) – Square-root of two-way antenna gain in spherical coordinates, shape: [elevation, azimuth]. If TX antenna equals RX antenna, then this should be just antenna gain. (0, 0) angle is at the beam center.
g_extent (list or None) – List of [g_el0, g_az0, g_el1, g_az1]. g_el0, g_el1 are grx and gtx elevation axis start and end values. Units in radians. -pi/2 + +pi/2 if including data over the whole sphere. g_az0, g_az1 are grx and gtx azimuth axis start and end values. Units in radians. -pi to +pi if including data over the whole sphere.
data_fmod (float) – Range modulation frequency applied to input data.
alias_fmod (float) – Range modulation frequency applied to SAR image.
normalize (bool) – If True (default), apply W1/W2 normalization when antenna pattern is used. Set to False for FFBP to output unnormalized accumulation.
- Returns:
img – Pseudo-polar format radar image.
- Return type:
Tensor
- torchbp.ops.backproj.backprojection_polar_2d_knab(data, grid, fc, r_res, pos, d0=0.0, dealias=False, order=4, oversample=2, att=None, g=None, g_extent=None, data_fmod=0, alias_fmod=0)[source]
2D backprojection with pseudo-polar coordinates. Interpolates input data using knab interpolation.
Gradient not supported.
- Parameters:
data (Tensor) – Range compressed input data. Shape should be [nbatch, nsweeps, samples] or [nsweeps, samples]. If input is 3 dimensional the first dimensions is number of independent images to form at the same time. Whole batch is processed with same grid and other arguments.
grid (PolarGrid or dict) –
Polar grid definition. Can be:
PolarGrid object:
PolarGrid(r_range=(50, 100), theta_range=(-1, 1), nr=200, ntheta=400)dict:
{"r": (r0, r1), "theta": (theta0, theta1), "nr": nr, "ntheta": ntheta}
where
thetarepresents sin of angle (-1, 1 for 180 degree view).fc (float) – RF center frequency in Hz.
r_res (float) – Range bin resolution in data (meters). For FMCW radar: c/(2*bw*oversample), where c is speed of light, bw is sweep bandwidth, and oversample is FFT oversampling factor.
pos (Tensor) – Position of the platform at each data point. Shape should be [nsweeps, 3] or [nbatch, nsweeps, 3].
d0 (float) – Zero range correction.
dealias (bool) – If True removes the range spectrum aliasing. Equivalent to applying torchbp.util.bp_polar_range_dealias on the SAR image. Default is False.
order (int) – Number of nearby samples to use for interpolation of one new sample. Even number is preferred.
oversample (float) – Oversampling factor in the input data.
att (Tensor) – Antenna rotation tensor. [Roll, pitch, yaw]. Only yaw is used and only if beamwidth < Pi to filter out data outside the antenna beam.
g (Tensor or None) – Square-root of two-way antenna gain in spherical coordinates, shape: [elevation, azimuth]. If TX antenna equals RX antenna, then this should be just antenna gain. (0, 0) angle is at the beam center.
g_extent (list or None) – List of [g_el0, g_az0, g_el1, g_az1]. g_el0, g_el1 are grx and gtx elevation axis start and end values. Units in radians. -pi/2 + +pi/2 if including data over the whole sphere. g_az0, g_az1 are grx and gtx azimuth axis start and end values. Units in radians. -pi to +pi if including data over the whole sphere.
data_fmod (float) – Range modulation frequency applied to input data.
alias_fmod (float) – Range modulation frequency applied to SAR image.
- Returns:
img – Pseudo-polar format radar image.
- Return type:
Tensor
- torchbp.ops.backproj.backprojection_polar_2d_lanczos(data, grid, fc, r_res, pos, d0=0.0, dealias=False, order=6, att=None, g=None, g_extent=None, data_fmod=0, alias_fmod=0)[source]
2D backprojection with pseudo-polar coordinates. Interpolates input data using lanczos interpolation.
Gradient not supported.
- Parameters:
data (Tensor) – Range compressed input data. Shape should be [nbatch, nsweeps, samples] or [nsweeps, samples]. If input is 3 dimensional the first dimensions is number of independent images to form at the same time. Whole batch is processed with same grid and other arguments.
grid (PolarGrid or dict) –
Polar grid definition. Can be:
PolarGrid object:
PolarGrid(r_range=(50, 100), theta_range=(-1, 1), nr=200, ntheta=400)dict:
{"r": (r0, r1), "theta": (theta0, theta1), "nr": nr, "ntheta": ntheta}
where
thetarepresents sin of angle (-1, 1 for 180 degree view).fc (float) – RF center frequency in Hz.
r_res (float) – Range bin resolution in data (meters). For FMCW radar: c/(2*bw*oversample), where c is speed of light, bw is sweep bandwidth, and oversample is FFT oversampling factor.
pos (Tensor) – Position of the platform at each data point. Shape should be [nsweeps, 3] or [nbatch, nsweeps, 3].
d0 (float) – Zero range correction.
dealias (bool) – If True removes the range spectrum aliasing. Equivalent to applying torchbp.util.bp_polar_range_dealias on the SAR image. Default is False.
order (int) – Number of nearby samples to use for interpolation of one new sample.
att (Tensor) – Antenna rotation tensor. [Roll, pitch, yaw]. Only yaw is used and only if beamwidth < Pi to filter out data outside the antenna beam.
g (Tensor) – Square-root of two-way antenna gain in spherical coordinates, shape: [elevation, azimuth]. If TX antenna equals RX antenna, then this should be just antenna gain. (0, 0) angle is at the beam center.
g_extent (list or None) – List of [g_el0, g_az0, g_el1, g_az1]. g_el0, g_el1 are grx and gtx elevation axis start and end values. Units in radians. -pi/2 + +pi/2 if including data over the whole sphere. g_az0, g_az1 are grx and gtx azimuth axis start and end values. Units in radians. -pi to +pi if including data over the whole sphere.
data_fmod (float) – Range modulation frequency applied to input data.
alias_fmod (float) – Range modulation frequency applied to SAR image.
- Returns:
img – Pseudo-polar format radar image.
- Return type:
Tensor
- torchbp.ops.backproj.backprojection_polar_2d_resolution(wa, g, g_extent, grid, fc, pos, att, altitude=0.0, sweeps_chunk=64)[source]
Estimate the angular (azimuth) resolution of every polar pixel from the trajectory and antenna pattern.
- Parameters:
wa (Tensor) – Per-sweep amplitude weighting (window and/or transmit power), the same
wapassed tobackprojection_polar_2d_tx_power(), shape: [nsweeps] or [nbatch, nsweeps].g (Tensor) – Square-root of two-way antenna gain, shape: [elevation, azimuth]. See
backprojection_polar_2d_tx_power().g_extent (list) –
[el0, az0, el1, az1]angular extent ofgin radians.grid (PolarGrid or dict) – Polar grid definition,
thetais the sine of the azimuth angle.fc (float) – Radar center frequency (Hz). Used for the wavelength
c/fc.pos (Tensor) – Platform position per sweep, shape: [nsweeps, 3] or [nbatch, nsweeps, 3].
att (Tensor) – Antenna Euler angles [roll, pitch, yaw] per sweep, same shape as
pos. Roll and yaw are used (pitch is ignored), matchingbackprojection_polar_2d_tx_power().altitude (float) – If > 0 the grid is treated as slant-range (BP origin at sensor altitude,
posz ~ 0) and pixels are mapped to the ground using this altitude, matchingbackprojection_polar_2d_tx_power_slant(). If 0 (default) the grid is ground-range and the per-sweepposz is used.sweeps_chunk (int) – Number of sweeps processed at once. Trades memory for speed, does not affect the result.
- Returns:
resolution – Pseudo-polar map of the estimated angular azimuth resolution (radians), shape [nr, ntheta] or [nbatch, nr, ntheta]. Pixels never illuminated by any sweep are
inf.- Return type:
Tensor
- torchbp.ops.backproj.backprojection_polar_2d_tx_power(wa, g, g_extent, grid, r_res, pos, att, normalization=None, azimuth_resolution=True)[source]
Calculate square root of transmitted power to image plane. Can be used to correct for antenna pattern and distance effect on the radar image.
- Parameters:
wa (Tensor) – Weighting coefficient for amplitude of each pulse. Should include window function and transmit power variation if known, shape: [nsweeps] or [nbatch, nsweeps].
g (Tensor) – Square-root of two-way antenna gain in spherical coordinates, shape: [elevation, azimuth]. If TX antenna equals RX antenna, then this should be just antenna gain. (0, 0) angle is at the beam center.
g_az0 (float) – grx and gtx azimuth axis starting value. Units in radians. -pi if including data over the whole sphere.
g_el0 (float) – grx and gtx elevation axis starting value. Units in radians. -pi/2 if including data over the whole sphere.
g_az1 (float) – grx and gtx azimuth axis end value. Units in radians. +pi if including data over the whole sphere.
g_el1 (float) – grx and gtx elevation axis end value. Units in radians. +pi/2 if including data over the whole sphere.
grid (PolarGrid or dict) –
Polar grid definition. Can be:
PolarGrid object:
PolarGrid(r_range=(50, 100), theta_range=(-1, 1), nr=200, ntheta=400)dict:
{"r": (r0, r1), "theta": (theta0, theta1), "nr": nr, "ntheta": ntheta}
where
thetarepresents sin of angle (-1, 1 for 180 degree view).r_res (float) – Range bin resolution in data (meters). For FMCW radar: c/(2*bw*oversample), where c is speed of light, bw is sweep bandwidth, and oversample is FFT oversampling factor.
pos (Tensor) – Position of the platform at each data point. Shape should be [nsweeps, 3] or [nbatch, nsweeps, 3].
att (Tensor) – Euler angles of the radar antenna at each data point. Shape should be [nsweeps, 3] or [nbatch, nsweeps, 3]. [Roll, pitch, yaw]. Only roll and yaw are used at the moment.
normalization (str or None) –
- Valid choices are:
”sigma” to divide each value by sin of incidence angle. “gamma” to divide each value by of tan of incidence angle. “beta” or None for no incidence angle normalization. “point” to normalize to constant reflectivity (no ground patch).
azimuth_resolution (bool) – If True (default), also normalize for the varying azimuth resolution. The gain-weighted angular spread of the line of sight is measured per pixel and folded into the returned power so that dividing a SAR image by tx_power removes the residual azimuth brightness slope (caused by the resolution cell growing toward the swath edges) in addition to the antenna pattern and range falloff. See
backprojection_polar_2d_resolution()for the standalone map. Set to False to get the pure antenna/range illumination.g_extent (list)
- Returns:
tx_power – Pseudo-polar format image of square root of power returned from each pixel assuming constant reflectivity.
- Return type:
Tensor
- torchbp.ops.backproj.backprojection_polar_2d_tx_power_slant(wa, g, g_extent, grid, r_res, pos, att, altitude, normalization=None, azimuth_resolution=True)[source]
Slant-range variant of
backprojection_polar_2d_tx_power().For slant-range BP images (BP origin at sensor altitude, pos z ≈ 0), the standard tx_power kernel gets wrong elevation angles because pos_z ≈ 0. This variant maps each polar pixel (r, θ) to its ground position
(sqrt(r²cos²θ − H²), r·sinθ)and uses the supplied altitude H for all elevation / distance / normalization calculations.- Parameters:
wa (Tensor) – Same as
backprojection_polar_2d_tx_power().g (Tensor) – Same as
backprojection_polar_2d_tx_power().g_extent (list) – Same as
backprojection_polar_2d_tx_power().grid (PolarGrid | dict) – Same as
backprojection_polar_2d_tx_power().r_res (float) – Same as
backprojection_polar_2d_tx_power().pos (Tensor) – Same as
backprojection_polar_2d_tx_power().att (Tensor) – Same as
backprojection_polar_2d_tx_power().normalization (str | None) – Same as
backprojection_polar_2d_tx_power().azimuth_resolution (bool) – Same as
backprojection_polar_2d_tx_power().altitude (float) – Sensor altitude above ground (metres). Must be > 0.
- Returns:
tx_power – Same as
backprojection_polar_2d_tx_power().- Return type:
Tensor
- torchbp.ops.backproj.gpga_backprojection_2d_core(target_pos, data, pos, fc, r_res, d0=0.0, interp_method='linear', data_fmod=0)[source]
Generalized phase gradient autofocus.
- Parameters:
target_pos (Tensor) – Positions of point-like targets to use to focus the image. 3D Cartesian coordinates (x, y, z). Dimensions: [ntargets, 3].
data (Tensor) – Range compressed input data. Shape should be [nsweeps, samples].
pos (Tensor) – Position of the platform at each data point. Shape should be [nsweeps, 3].
fc (float) – RF center frequency in Hz.
r_res (float) – Range bin resolution in data (meters). For FMCW radar: c/(2*bw*oversample), where c is speed of light, bw is sweep bandwidth, and oversample is FFT oversampling factor.
d0 (float) – Zero range correction.
interp_method (str) – Interpolation method “linear”: linear interpolation. (“lanczos”, N): Lanczos interpolation with order N.
data_fmod (float) – Range modulation frequency applied to input data.
- Returns:
data_out – Values from input data used in backprojection of each target in target_pos tensor. Shape is [ntargets, nsweeps].
- Return type:
Tensor
- torchbp.ops.backproj.projection_cart_2d(img, pos, grid, fc, fs, gamma, sweep_samples, d0=0.0, dem=None, att=None, g=None, g_extent=None, use_rvp=True, normalization='beta', vel=None)[source]
Calculate FMCW radar data for each radar position in pos when measuring the scene in img.
- Parameters:
img (Tensor) – SAR image in Cartesian coordinates. Shape [nx, ny] or [nbatch, nx, ny].
grid (CartesianGrid or dict) –
Cartesian grid definition. Can be:
CartesianGrid object:
CartesianGrid(x_range=(-50, 50), y_range=(-50, 50), nx=200, ny=200)dict:
{"x": (x0, x1), "y": (y0, y1), "nx": nx, "ny": ny}
fc (float) – RF center frequency in Hz.
fs (float) – Sampling frequency in Hz.
gamma (float) – Distance to IF frequency conversion factor. For FMCW radar: BW / tsweep.
pos (Tensor) – Position of the platform at each data point. Shape should be [nsweeps, 3] or [nbatch, nsweeps, 3].
d0 (float) – Zero range correction.
dem (Tensor or None) – Digital elevation map. Should have shape: [nx, ny]. Set to zero if None.
att (Tensor or None) – Euler angles of the radar antenna at each data point. Shape should be [nsweeps, 3] or [nbatch, nsweeps, 3]. [Roll, pitch, yaw]. Only roll and yaw are used at the moment.
g (Tensor or None) – Square-root of two-way antenna gain in spherical coordinates, shape: [elevation, azimuth]. If TX antenna equals RX antenna, then this should be just antenna gain. (0, 0) angle is at the beam center.
g_extent (list or None) – List of [g_el0, g_az0, g_el1, g_az1]. g_el0, g_el1 are grx and gtx elevation axis start and end values. Units in radians. -pi/2 + +pi/2 if including data over the whole sphere. g_az0, g_az1 are grx and gtx azimuth axis start and end values. Units in radians. -pi to +pi if including data over the whole sphere.
use_rvp (bool) – True to add residual video phase term.
normalization (str) – Surface reflectivity definition to use. Valid choices are “sigma” or “gamma”. “sigma”: No look angle dependency (unphysical). “gamma”: Multiply the reflectivity be cross-sectional area of the patch (more realistic).
vel (Tensor or None) – Velocity tensor in m/s. Shape should match with pos.
sweep_samples (int)
- Returns:
data – FMCW radar data at each position. Shape [nbatch, nsweeps, nsamples].
- Return type:
Tensor
- torchbp.ops.backproj.projection_cart_2d_nufft(img, pos, grid, fc, fs, gamma, sweep_samples, d0=0.0, dem=None, att=None, g=None, g_extent=None, use_rvp=True, normalization='beta')[source]
NUFFT-based forward projection. Equivalent to
projection_cart_2d()without velocity (vel=None) but uses a Type-1 NUFFT for O(N log M) cost instead of O(N·M).Parameters match
projection_cart_2d()exceptvelis not accepted.- Parameters:
img (Tensor)
pos (Tensor)
grid (CartesianGrid | dict)
fc (float)
fs (float)
gamma (float)
sweep_samples (int)
d0 (float)
dem (Tensor | None)
att (Tensor | None)
g (Tensor | None)
g_extent (list | None)
use_rvp (bool)
normalization (str)
- Return type:
Tensor