torchbp.ops.polar_interp module
- torchbp.ops.polar_interp.cart_to_polar(img, origin, grid_cart, grid_polar, fc, rotation=0, alias_fmod=0, method='linear')[source]
Interpolate Cartesian radar image to pseudo-polar grid.
Inverse of
polar_to_cart(). The input is an ordinary Cartesian image including the range carrier (as generated bycfbp(),backprojection_cart_2d()orpolar_to_cart()). The interpolation removes the carrier so that the output matches a polar image generated with dealias=True and range modulation alias_fmod. The main use is applying algorithms that assume a polar grid, such as phase gradient autofocus, to Cartesian format images:cart_to_polar-> process ->polar_to_cart()back.- Parameters:
img (Tensor) – 2D radar image in [x, y] format. Dimensions should match with grid_cart grid. [nbatch, x, y] if interpolating multiple images at the same time.
origin (Tensor) – 3D antenna phase center of the new polar image with respect to the input image. Units in meters [nbatch, 3] if img shape is 3D.
grid_cart (CartesianGrid or dict) –
Cartesian grid definition. Can be:
CartesianGrid object:
CartesianGrid(x_range=(x0, x1), y_range=(y0, y1), nx=nx, ny=ny)dict:
{"x": (x0, x1), "y": (y0, y1), "nx": nx, "ny": ny}
grid_polar (PolarGrid or dict) –
Polar grid definition. Can be:
PolarGrid object:
PolarGrid(r_range=(r0, r1), theta_range=(theta0, theta1), nr=nr, ntheta=ntheta)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.
rotation (float) – Polar origin rotation angle.
alias_fmod (float) – Range modulation frequency applied to output.
method (str or tuple) – Interpolation method. Valid choices are: - “linear”: Linear interpolation. - (“lanczos”, n): Lanczos resampling. n is the half of kernel length.
- Returns:
out – Interpolated radar image in [range, angle] format.
- Return type:
Tensor
- torchbp.ops.polar_interp.cart_to_polar_lanczos(img, origin, grid_cart, grid_polar, fc, rotation=0, alias_fmod=0, order=6)[source]
Interpolate Cartesian radar image to pseudo-polar grid with Lanczos interpolation.
Inverse of
polar_to_cart_lanczos(). The input image should include the range carrier, the output is dealiased. Seecart_to_polar().Gradient not supported.
- Parameters:
img (Tensor) – 2D radar image in [x, y] format. Dimensions should match with grid_cart grid. [nbatch, x, y] if interpolating multiple images at the same time.
origin (Tensor) – 3D antenna phase center of the new polar image with respect to the input image. Units in meters [nbatch, 3] if img shape is 3D.
grid_cart (CartesianGrid or dict) –
Cartesian grid definition. Can be:
CartesianGrid object:
CartesianGrid(x_range=(x0, x1), y_range=(y0, y1), nx=nx, ny=ny)dict:
{"x": (x0, x1), "y": (y0, y1), "nx": nx, "ny": ny}
grid_polar (PolarGrid or dict) –
Polar grid definition. Can be:
PolarGrid object:
PolarGrid(r_range=(r0, r1), theta_range=(theta0, theta1), nr=nr, ntheta=ntheta)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.
rotation (float) – Polar origin rotation angle.
alias_fmod (float) – Range modulation frequency applied to output.
order (int) – Number of nearby samples to use for interpolation of one new sample.
- Returns:
out – Interpolated radar image in [range, angle] format.
- Return type:
Tensor
- torchbp.ops.polar_interp.cart_to_polar_linear(img, origin, grid_cart, grid_polar, fc, rotation=0, alias_fmod=0)[source]
Interpolate Cartesian radar image to pseudo-polar grid with linear interpolation.
Inverse of
polar_to_cart_linear(). The input image should include the range carrier, the output is dealiased. Seecart_to_polar().- Parameters:
img (Tensor) – 2D radar image in [x, y] format. Dimensions should match with grid_cart grid. [nbatch, x, y] if interpolating multiple images at the same time.
origin (Tensor) – 3D antenna phase center of the new polar image with respect to the input image. Units in meters [nbatch, 3] if img shape is 3D.
grid_cart (CartesianGrid or dict) –
Cartesian grid definition. Can be:
CartesianGrid object:
CartesianGrid(x_range=(x0, x1), y_range=(y0, y1), nx=nx, ny=ny)dict:
{"x": (x0, x1), "y": (y0, y1), "nx": nx, "ny": ny}
grid_polar (PolarGrid or dict) –
Polar grid definition. Can be:
PolarGrid object:
PolarGrid(r_range=(r0, r1), theta_range=(theta0, theta1), nr=nr, ntheta=ntheta)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.
rotation (float) – Polar origin rotation angle.
alias_fmod (float) – Range modulation frequency applied to output.
- Returns:
out – Interpolated radar image in [range, angle] format.
- Return type:
Tensor
- torchbp.ops.polar_interp.div_2d_interp_linear(img1, img2)[source]
Calculate img1 / img2 and interpolate img2 dimensions to match img1.
Gradient is not supported.
- Parameters:
img1 (Tensor) – 2D or 3D image with complex64 or float type.
img2 (Tensor) – 2D or 3D image with complex64 or float type. If 3D, the first dimension must match with img1.
- Returns:
out – img1 / img2.
- Return type:
Tensor
- torchbp.ops.polar_interp.ffbp_merge2(img0, img1, dorigin0, dorigin1, grid_polars, fc, grid_polar_new=None, z0=0, method=('knab', 6, 1.5), alias=False, alias_fmod=0, output_alias=True, use_poly=True, poly_coefs=None, dem=None)[source]
Interpolate two pseudo-polar radar images to new grid and change origin position by dorigin.
Gradient not supported.
- Parameters:
img0 (Tensor) – 2D radar image in [range, angle] format. Dimensions should match with grid_polars grid. Image dimension can be different for each element in the list.
img1 (Tensor) – Same format as img0.
dorigin0 (Tensor) – Difference between the origin of the old image to the new image. Units in meters. Shape: [3].
dorigin1 (Tensor) – Same format as dorigin0.
grid_polar (list of PolarGrid or dict) –
List of polar grid definitions for each input image. Each element can be:
PolarGrid object:
PolarGrid(r_range=(r0, r1), theta_range=(theta0, theta1), nr=nr, ntheta=ntheta)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.
grid_polar_new (dict, optional) – Grid definition of the new image. If None uses the same grid as input, but with double the angle points.
z0 (float) – Height of the antenna phase center in the new image.
method (tuple) – Interpolation method: (“knab”, n, v) where n is the number of samples used and v is the oversampling factor in the data.
alias (bool) – Add back range dependent phase. Inverse of util.bp_polar_range_dealias.
alias_fmod (float) – Range modulation frequency applied to input.
output_alias (bool) – If True and alias is True apply alias_fmod to output.
use_poly (bool) – If True (default), use polynomial-approximation kernel for knab interpolation.
poly_coefs (Tensor, optional) – Precomputed polynomial coefficients. Use compute_knab_poly_coefs_full() to compute these for Knab kernels.
grid_polars (list[PolarGrid | dict])
dem (Tensor | None)
- Returns:
out – Interpolated radar image.
- Return type:
Tensor
- torchbp.ops.polar_interp.ffbp_merge2_knab(img0, img1, dorigin0, dorigin1, grid_polars, fc, grid_polar_new=None, z0=0, order=6, oversample=1.5, alias=False, alias_fmod=0, output_alias=True, dem=None)[source]
Interpolate two pseudo-polar radar images to new grid and change origin position by dorigin. Uses truncated sinc with Knab pulse for interpolation [1].
Gradient not supported.
- Parameters:
img0 (Tensor) – 2D radar image in [range, angle] format. Dimensions should match with grid_polars grid. Image dimension can be different for each element in the list.
img1 (Tensor) – Same format as img0.
dorigin0 (Tensor) – Difference between the origin of the old image to the new image. Units in meters. Shape: [3].
dorigin1 (Tensor) – Same format as dorigin0.
grid_polar (list of PolarGrid or dict) –
List of polar grid definitions for each input image. Each element can be:
PolarGrid object:
PolarGrid(r_range=(r0, r1), theta_range=(theta0, theta1), nr=nr, ntheta=ntheta)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.
grid_polar_new (dict, optional) – Grid definition of the new image. If None uses the same grid as input, but with double the angle points.
z0 (float) – Height of the antenna phase center in the new image.
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.
alias (bool) – Add back range dependent phase. Inverse of util.bp_polar_range_dealias.
alias_fmod (float) – Range modulation frequency applied to input.
output_alias (bool) – If True and alias is True apply alias_fmod to output.
dem (Tensor or None) – Digital elevation model sampled on the output polar grid (
grid_polar_new), shape [dem_nr, dem_ntheta] covering the same r and theta extent; may be coarser. The merge carriers then reference the 3D distance from the origins to the pixel at the DEM height. Input images must be dealiased with the matching DEM-referenced carrier (backprojection_polar_2dwithdealias=Trueand the same DEM).grid_polars (list[PolarGrid | dict])
- Return type:
Tensor
References
[1]J. Knab, “The sampling window,” in IEEE Transactions on Information Theory, vol. 29, no. 1, pp. 157-159, January 1983.
- Returns:
out – Interpolated radar image.
- Return type:
Tensor
- Parameters:
- torchbp.ops.polar_interp.ffbp_merge2_lanczos(img0, img1, dorigin0, dorigin1, grid_polars, fc, grid_polar_new=None, z0=0, order=6, alias=False, alias_fmod=0, output_alias=True, dem=None)[source]
Interpolate two pseudo-polar radar images to new grid and change origin position by dorigin.
Gradient not supported.
- Parameters:
img0 (Tensor) – 2D radar image in [range, angle] format. Dimensions should match with grid_polars grid. Image dimension can be different for each element in the list.
img1 (Tensor) – Same format as img0.
dorigin0 (Tensor) – Difference between the origin of the old image to the new image. Units in meters. Shape: [3].
dorigin1 (Tensor) – Same format as dorigin0.
grid_polar (list of PolarGrid or dict) –
List of polar grid definitions for each input image. Each element can be:
PolarGrid object:
PolarGrid(r_range=(r0, r1), theta_range=(theta0, theta1), nr=nr, ntheta=ntheta)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.
grid_polar_new (dict, optional) – Grid definition of the new image. If None uses the same grid as input, but with double the angle points.
z0 (float) – Height of the antenna phase center in the new image.
order (int) – Number of nearby samples to use for interpolation of one new sample.
alias (bool) – Add back range dependent phase. Inverse of util.bp_polar_range_dealias.
alias_fmod (float) – Range modulation frequency applied to input.
output_alias (bool) – If True and alias is True apply alias_fmod to output.
dem (Tensor or None) – Digital elevation model sampled on the output polar grid (
grid_polar_new), shape [dem_nr, dem_ntheta] covering the same r and theta extent; may be coarser. The merge carriers then reference the 3D distance from the origins to the pixel at the DEM height. Input images must be dealiased with the matching DEM-referenced carrier (backprojection_polar_2dwithdealias=Trueand the same DEM).grid_polars (list[PolarGrid | dict])
- Returns:
out – Interpolated radar image.
- Return type:
Tensor
- torchbp.ops.polar_interp.ffbp_merge2_poly(img0, img1, dorigin0, dorigin1, grid_polars, fc, grid_polar_new=None, z0=0, order=6, oversample=1.5, alias=False, alias_fmod=0, output_alias=True, poly_degree=None, poly_coefs=None, dem=None)[source]
Interpolate two pseudo-polar radar images to new grid and change origin position by dorigin. Uses polynomial approximation for interpolation.
This function uses polynomial approximation of the Knab kernel, avoiding expensive exp and sqrt operations.
Gradient not supported.
- Parameters:
img0 (Tensor) – 2D radar image in [range, angle] format. Dimensions should match with grid_polars grid. Image dimension can be different for each element in the list.
img1 (Tensor) – Same format as img0.
dorigin0 (Tensor) – Difference between the origin of the old image to the new image. Units in meters. Shape: [3].
dorigin1 (Tensor) – Same format as dorigin0.
grid_polar (list of PolarGrid or dict) –
List of polar grid definitions for each input image. Each element can be:
PolarGrid object:
PolarGrid(r_range=(r0, r1), theta_range=(theta0, theta1), nr=nr, ntheta=ntheta)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.
grid_polar_new (dict, optional) – Grid definition of the new image. If None uses the same grid as input, but with double the angle points.
z0 (float) – Height of the antenna phase center in the new image.
order (int) – Number of nearby samples to use for interpolation of one new sample. Even number is preferred. Must be in [2, 8].
oversample (float) – Oversampling factor in the input data.
alias (bool) – Add back range dependent phase. Inverse of util.bp_polar_range_dealias.
alias_fmod (float) – Range modulation frequency applied to input.
output_alias (bool) – If True and alias is True apply alias_fmod to output.
poly_degree (int, optional) – Degree of polynomial approximation for the full Knab kernel. The polynomial approximates sinc(x)*window(x) as a single polynomial in x², eliminating expensive sinpif and division operations. If None (default), automatically selected based on oversample: - oversample < 1.5: degree 10 - oversample >= 1.5: degree 12
poly_coefs (Tensor, optional) – Precomputed polynomial coefficients. If provided, poly_degree is ignored. Use compute_knab_poly_coefs_full() to compute these coefficients. Precomputing is useful when calling this function multiple times with the same order and oversample parameters.
dem (Tensor or None) – Digital elevation model sampled on the output polar grid (
grid_polar_new), shape [dem_nr, dem_ntheta] covering the same r and theta extent; may be coarser. The merge carriers then reference the 3D distance from the origins to the pixel at the DEM height. Input images must be dealiased with the matching DEM-referenced carrier (backprojection_polar_2dwithdealias=Trueand the same DEM).grid_polars (list[PolarGrid | dict])
- Returns:
out – Interpolated radar image.
- Return type:
Tensor
- torchbp.ops.polar_interp.ffbp_merge2_poly_weighted(img0, img1, dorigin0, dorigin1, grid_polars, fc, grid_polar_new=None, z0=0, order=6, oversample=1.5, alias=False, alias_fmod=0, output_alias=True, poly_coefs=None, w1_map0=None, w2_map0=None, weight_grid0=None, w1_map1=None, w2_map1=None, weight_grid1=None, output_weight_map=False, output_weight_decimation=1, dem=None)[source]
Interpolate two pseudo-polar radar images to new grid with antenna pattern weighting.
This is the weighted version of ffbp_merge2_poly used with antenna pattern weighting. The input images are unnormalized gain-weighted accumulations (leaves are formed with normalize=False). The merge interpolates and sums the accumulations:
merged = A0 + A1
and likewise sums the interpolated illumination moment maps W1 (sum of gains) and W2 (sum of squared gains). The regularized normalization
img = A * W1 / (W2 + lambda)is applied once at the top level inffbp.Gradient not supported.
- Parameters:
img0 (Tensor) – 2D radar image in [range, angle] format.
img1 (Tensor) – Same format as img0.
dorigin0 (Tensor) – Origin offset for img0. Shape: [3].
dorigin1 (Tensor) – Origin offset for img1. Shape: [3].
grid_polars (list of PolarGrid or dict) – List of polar grid definitions for each input image.
fc (float) – RF center frequency in Hz.
grid_polar_new (PolarGrid or dict, optional) – Grid definition of the output image.
z0 (float) – Height of the antenna phase center in the new image.
order (int) – Interpolation order. Must be in [2, 8].
oversample (float) – Oversampling factor in the input data.
alias (bool) – Add back range dependent phase.
alias_fmod (float) – Range modulation frequency applied to input.
output_alias (bool) – If True and alias is True, apply alias_fmod to output.
poly_coefs (Tensor, optional) – Precomputed polynomial coefficients.
w1_map0 (Tensor, optional) – W1 weight map (sum of gains) for img0. Shape: [w_nr0, w_ntheta0].
w2_map0 (Tensor, optional) – W2 weight map (sum of squared gains) for img0. Shape: [w_nr0, w_ntheta0].
weight_grid0 (PolarGrid or dict, optional) – Grid definition for weight maps of img0.
w1_map1 (Tensor, optional) – W1 weight map (sum of gains) for img1. Shape: [w_nr1, w_ntheta1].
w2_map1 (Tensor, optional) – W2 weight map (sum of squared gains) for img1. Shape: [w_nr1, w_ntheta1].
weight_grid1 (PolarGrid or dict, optional) – Grid definition for weight maps of img1.
output_weight_map (bool) – If True, return merged weight maps for propagation through hierarchy.
output_weight_decimation (int) – Decimation factor for output weight maps (1 = no decimation, 4 = 1/16 size). Higher values reduce VRAM usage but may reduce weight accuracy.
dem (Tensor | None)
- Returns:
out (Tensor) – Interpolated radar image.
w1_out (Tensor or None) – Merged W1 weight map if output_weight_map is True, else None. Shape is [nr // decimation, ntheta // decimation].
w2_out (Tensor or None) – Merged W2 weight map if output_weight_map is True, else None. Shape is [nr // decimation, ntheta // decimation].
merged_weight_grid (dict or None) – Grid definition for the output weight maps if output_weight_map is True, else None.
- Return type:
tuple[Tensor, Tensor | None, Tensor | None, dict | None]
- torchbp.ops.polar_interp.ffbp_tx_power_merge2(acc0, acc1, dorigin0, dorigin1, grid_polars, grid_polar_new, altitude=0.0, in_psi=False, out_psi=False)[source]
Merge two tx_power accumulator maps to a new grid with origin shifts.
Interpolates the 4-channel accumulator maps (S, W, P1, M2, see
torchbp.ops.backproj._backprojection_polar_2d_tx_power_accum()) bilinearly onto the output grid and combines them. The psi moments are combined with Chan’s parallel variance formula so the merge is exact up to interpolation. Used internally bybackprojection_polar_2d_tx_power_ffbp().- Parameters:
acc0 (Tensor) – First accumulator map, shape [4, nr, ntheta] matching grid_polars[0].
acc1 (Tensor or None) – Second accumulator map matching grid_polars[1]. None interpolates only acc0 to the new grid (single input regrid).
dorigin0 (Tensor) – Origin of the output grid relative to acc0 grid origin, shape [3]. Only x and y components are used.
dorigin1 (Tensor or None) – Same for acc1.
grid_polars (list of PolarGrid or dict) – Input grid definitions.
grid_polar_new (PolarGrid or dict) – Output grid definition.
altitude (float) – Slant grid altitude. 0 for ground grid.
in_psi (bool) – Input grid theta extents are psi = asin(theta) in radians and the maps are sampled uniformly in psi.
out_psi (bool) – Same for the output grid.
- Returns:
out – Merged accumulator map, shape [4, nr_new, ntheta_new].
- Return type:
Tensor
- torchbp.ops.polar_interp.mul_2d_interp_linear(img1, img2)[source]
Calculate img1 * img2 and interpolate img2 dimensions to match img1.
Gradient is not supported.
- Parameters:
img1 (Tensor) – 2D or 3D image with complex64 or float type.
img2 (Tensor) – 2D or 3D image with complex64 or float type. If 3D, the first dimension must match with img1.
- Returns:
out – img1 * img2.
- Return type:
Tensor
- torchbp.ops.polar_interp.polar_interp(img, origin_old, origin_new, grid_polar, fc, rotation=0, grid_polar_new=None, method='linear', alias_fmod=0)[source]
Interpolate pseudo-polar radar image to new grid and change origin position by dorigin. Allows choosing the interpolation method.
Gradient calculation is only supported with “linear” method.
- Parameters:
img (Tensor) – 2D radar image in [range, angle] format. Dimensions should match with grid_polar grid. [nbatch, range, angle] if interpolating multiple images at the same time.
origin_old (Tensor) – Origin of the img. Units in meters. [nbatch, 3] if img shape is 3D.
origin_new (Tensor) – Origin after interpolation.
grid_polar (PolarGrid or dict) –
Polar grid definition. Can be:
PolarGrid object:
PolarGrid(r_range=(r0, r1), theta_range=(theta0, theta1), nr=nr, ntheta=ntheta)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.
rotation (float) – Angle rotation to apply in radians.
grid_polar_new (dict, optional) – Grid definition of the new image. If None uses the same grid as input, but with double the angle points.
method (str or tuple) – Interpolation method. Valid choices are: - “linear”: Linear interpolation. - (“lanczos”, n): Lanczos resampling. n is the half of kernel length.
alias_fmod (float) – Range modulation frequency applied to input.
- Returns:
out – Interpolated radar image.
- Return type:
Tensor
- torchbp.ops.polar_interp.polar_interp_lanczos(img, dorigin, grid_polar, fc, rotation=0, grid_polar_new=None, z0=0, order=6, alias_fmod=0)[source]
Interpolate pseudo-polar radar image to new grid and change origin position by dorigin.
Gradient not supported.
- Parameters:
img (Tensor) – 2D radar image in [range, angle] format. Dimensions should match with grid_polar grid. [nbatch, range, angle] if interpolating multiple images at the same time.
dorigin (Tensor) – Difference between the origin of the old image to the new image. Units in meters [nbatch, 3] if img shape is 3D.
grid_polar (PolarGrid or dict) –
Polar grid definition. Can be:
PolarGrid object:
PolarGrid(r_range=(r0, r1), theta_range=(theta0, theta1), nr=nr, ntheta=ntheta)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.
rotation (float) – Angle rotation to apply in radians.
grid_polar_new (dict, optional) – Grid definition of the new image. If None uses the same grid as input, but with double the angle points.
z0 (float) – Height of the antenna phase center in the new image.
order (int) – Number of nearby samples to use for interpolation of one new sample.
alias_fmod (float) – Range modulation frequency applied to input.
- Returns:
out – Interpolated radar image.
- Return type:
Tensor
- torchbp.ops.polar_interp.polar_interp_linear(img, dorigin, grid_polar, fc, rotation=0, grid_polar_new=None, z0=0, alias_fmod=0)[source]
Interpolate pseudo-polar radar image to new grid and change origin position by dorigin.
Gradient can be calculated with respect to img and dorigin.
- Parameters:
img (Tensor) – 2D radar image in [range, angle] format. Dimensions should match with grid_polar grid. [nbatch, range, angle] if interpolating multiple images at the same time.
dorigin (Tensor) – Difference between the origin of the old image to the new image. Units in meters [nbatch, 3] if img shape is 3D.
grid_polar (PolarGrid or dict) –
Polar grid definition. Can be:
PolarGrid object:
PolarGrid(r_range=(r0, r1), theta_range=(theta0, theta1), nr=nr, ntheta=ntheta)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.
rotation (float) – Angle rotation to apply in radians.
grid_polar_new (dict, optional) – Grid definition of the new image. If None uses the same grid as input, but with double the angle points.
z0 (float) – Height of the antenna phase center in the new image.
alias_fmod (float) – Range modulation frequency applied to input.
- Returns:
out – Interpolated radar image.
- Return type:
Tensor
- torchbp.ops.polar_interp.polar_to_cart(img, origin, grid_polar, grid_cart, fc, rotation=0, alias_fmod=0, method='linear')[source]
Interpolate polar radar image to cartesian grid.
The input image should be either generated with dealias=True or call torchbp.util.bp_polar_range_dealias first.
- Parameters:
img (Tensor) – 2D radar image in [range, angle] format. Dimensions should match with grid_polar grid. [nbatch, range, angle] if interpolating multiple images at the same time.
origin (Tensor) – 3D antenna phase center of the old image in with respect to new image. Units in meters [nbatch, 3] if img shape is 3D.
grid_polar (PolarGrid or dict) –
Polar grid definition. Can be:
PolarGrid object:
PolarGrid(r_range=(r0, r1), theta_range=(theta0, theta1), nr=nr, ntheta=ntheta)dict:
{"r": (r0, r1), "theta": (theta0, theta1), "nr": nr, "ntheta": ntheta}
where
thetarepresents sin of angle (-1, 1 for 180 degree view)grid_cart (CartesianGrid or dict) –
Cartesian grid definition. Can be:
CartesianGrid object:
CartesianGrid(x_range=(x0, x1), y_range=(y0, y1), nx=nx, ny=ny)dict:
{"x": (x0, x1), "y": (y0, y1), "nx": nx, "ny": ny}
fc (float) – RF center frequency in Hz.
rotation (float) – Polar origin rotation angle.
method (str or tuple) – Interpolation method. Valid choices are: - “linear”: Linear interpolation. - (“lanczos”, n): Lanczos resampling. n is the half of kernel length.
alias_fmod (float) – Range modulation frequency applied to input.
- Returns:
out – Interpolated radar image.
- Return type:
Tensor
- torchbp.ops.polar_interp.polar_to_cart_lanczos(img, origin, grid_polar, grid_cart, fc, rotation=0, alias_fmod=0, order=6)[source]
Interpolate polar radar image to cartesian grid with linear interpolation.
The input image should be either generated with dealias=True or call torchbp.util.bp_polar_range_dealias first.
- Parameters:
img (Tensor) – 2D radar image in [range, angle] format. Dimensions should match with grid_polar grid. [nbatch, range, angle] if interpolating multiple images at the same time.
origin (Tensor) – 3D antenna phase center of the old image in with respect to new image. Units in meters [nbatch, 3] if img shape is 3D.
grid_polar (PolarGrid or dict) –
Polar grid definition. Can be:
PolarGrid object:
PolarGrid(r_range=(r0, r1), theta_range=(theta0, theta1), nr=nr, ntheta=ntheta)dict:
{"r": (r0, r1), "theta": (theta0, theta1), "nr": nr, "ntheta": ntheta}
where
thetarepresents sin of angle (-1, 1 for 180 degree view)grid_cart (CartesianGrid or dict) –
Cartesian grid definition. Can be:
CartesianGrid object:
CartesianGrid(x_range=(x0, x1), y_range=(y0, y1), nx=nx, ny=ny)dict:
{"x": (x0, x1), "y": (y0, y1), "nx": nx, "ny": ny}
fc (float) – RF center frequency in Hz.
rotation (float) – Polar origin rotation angle.
order (int) – Number of nearby samples to use for interpolation of one new sample.
alias_fmod (float) – Range modulation frequency applied to input.
- Returns:
out – Interpolated radar image.
- Return type:
Tensor
- torchbp.ops.polar_interp.polar_to_cart_linear(img, origin, grid_polar, grid_cart, fc, rotation=0, alias_fmod=0)[source]
Interpolate polar radar image to cartesian grid with linear interpolation.
The input image should be either generated with dealias=True or call torchbp.util.bp_polar_range_dealias first.
- Parameters:
img (Tensor) – 2D radar image in [range, angle] format. Dimensions should match with grid_polar grid. [nbatch, range, angle] if interpolating multiple images at the same time.
origin (Tensor) – 3D antenna phase center of the old image in with respect to new image. Units in meters [nbatch, 3] if img shape is 3D.
grid_polar (PolarGrid or dict) –
Polar grid definition. Can be:
PolarGrid object:
PolarGrid(r_range=(r0, r1), theta_range=(theta0, theta1), nr=nr, ntheta=ntheta)dict:
{"r": (r0, r1), "theta": (theta0, theta1), "nr": nr, "ntheta": ntheta}
where
thetarepresents sin of angle (-1, 1 for 180 degree view)grid_cart (CartesianGrid or dict) –
Cartesian grid definition. Can be:
CartesianGrid object:
CartesianGrid(x_range=(x0, x1), y_range=(y0, y1), nx=nx, ny=ny)dict:
{"x": (x0, x1), "y": (y0, y1), "nx": nx, "ny": ny}
fc (float) – RF center frequency in Hz.
rotation (float) – Polar origin rotation angle.
alias_fmod (float) – Range modulation frequency applied to input.
- Returns:
out – Interpolated radar image.
- Return type:
Tensor
- torchbp.ops.polar_interp.select_knab_poly_degree(oversample, order)[source]
Select minimum polynomial degree for full Knab kernel polynomial approximation.
Based on empirical testing with MSE threshold = 0.1 dB.
- Parameters:
oversample (float) – Oversampling ratio.
order (int) – Kernel order (number of samples used in interpolation).
- Returns:
Polynomial degree.
- Return type:
int