torchbp.autofocus module

torchbp.autofocus.bp_cart_grad_minimum_entropy(data, data_time, pos, fc, r_res, grid, wa, tx_norm=None, max_steps=100, lr_max=10000, d0=0, pos_reg=1, lr_reduce=0.8, verbose=True, convergence_limit=0.01, max_step_limit=0.25, grad_limit_quantile=0.9, fixed_pos=0, data_fmod=0)[source]

Minimum entropy autofocus optimization autofocus.

Wrapper around minimum_entropy_autofocus.

Parameters:
  • data (Tensor) – Radar data.

  • data_time (Tensor) – Recording time of each data sample.

  • pos (Tensor) – Position at each data sample.

  • fc (float) – RF 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.

  • grid (PolarGrid or dict) – Grid definition. Correct definition depends on the radar image function.

  • wa (Tensor) – Azimuth windowing function. Should be applied to data already, used for scaling gradient.

  • tx_norm (Tensor) – Radar image is divided by this tensor before calculating entropy. If None no division is done.

  • max_steps (int) – Maximum number of optimization steps.

  • lr_max (float) – Maximum learning rate. Too large learning rate is scaled automatically.

  • d0 (float) – Zero range correction.

  • pos_reg (float) – Position regularization value.

  • lr_reduce (float) – Learning rate is multiplied with this value if new entropy is larger than previously.

  • verbose (bool) – Print progress during optimization.

  • convergence_limit (float) – If maximum position change is below this value stop optimization. Units in wavelengths.

  • max_step_limit (float) – Maximum step size in wavelengths.

  • grad_limit_quantile (float) – Quantile used for maximum step size calculation. 0 to 1 range.

  • fixed_pos (int) – First fixed_pos positions are kept fixed and are not optimized.

  • data_fmod (float) – Range modulation frequency applied to input data.

Returns:

  • sar_img (Tensor) – Optimized radar image.

  • origin (Tensor) – Mean of position tensor.

  • pos (Tensor) – Platform position.

  • step (int) – Number of steps.

Return type:

tuple[Tensor, Tensor, Tensor, int]

torchbp.autofocus.bp_polar_grad_minimum_entropy(data, data_time, pos, fc, r_res, grid, wa, tx_norm=None, max_steps=100, lr_max=10000, d0=0, pos_reg=1, lr_reduce=0.8, verbose=True, convergence_limit=0.01, max_step_limit=0.25, grad_limit_quantile=0.9, fixed_pos=0, data_fmod=0)[source]

Minimum entropy autofocus optimization autofocus.

Wrapper around minimum_entropy_autofocus.

Parameters:
  • data (Tensor) – Radar data.

  • data_time (Tensor) – Recording time of each data sample.

  • pos (Tensor) – Position at each data sample.

  • fc (float) – RF 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.

  • grid (PolarGrid or dict) – Grid definition. Correct definition depends on the radar image function.

  • wa (Tensor) – Azimuth windowing function. Should be applied to data already, used for scaling gradient.

  • tx_norm (Tensor) – Radar image is divided by this tensor before calculating entropy. If None no division is done.

  • max_steps (int) – Maximum number of optimization steps.

  • lr_max (float) – Maximum learning rate. Too large learning rate is scaled automatically.

  • d0 (float) – Zero range correction.

  • pos_reg (float) – Position regularization value.

  • lr_reduce (float) – Learning rate is multiplied with this value if new entropy is larger than previously.

  • verbose (bool) – Print progress during optimization.

  • convergence_limit (float) – If maximum position change is below this value stop optimization. Units in wavelengths.

  • max_step_limit (float) – Maximum step size in wavelengths.

  • grad_limit_quantile (float) – Quantile used for maximum step size calculation. 0 to 1 range.

  • fixed_pos (int) – First fixed_pos positions are kept fixed and are not optimized.

  • data_fmod (float) – Range modulation frequency applied to input data.

Returns:

  • sar_img (Tensor) – Optimized radar image.

  • origin (Tensor) – Mean of position tensor.

  • pos (Tensor) – Platform position.

  • step (int) – Number of steps.

Return type:

tuple[Tensor, Tensor, Tensor, int]

torchbp.autofocus.gpga_bp_polar(img, data, pos, fc, r_res, grid_polar, window_width=None, max_iters=10, window_exp=0.7, min_window=5, d0=0.0, target_threshold_db=20, remove_trend=True, estimator='pd', lowpass_window='boxcar', eps=1e-06, interp_method='linear', data_fmod=0)[source]

Generalized phase gradient autofocus using 2D polar coordinate backprojection image formation. [1]

Parameters:
  • img (Tensor or None) – Complex input image. Shape should be: [Range, azimuth]. If None image is generated from the data.

  • 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.

  • 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 theta is sin of angle (-1, 1 for 180 degree view).

  • window_width (int or None) – Initial low-pass filter window width in samples. None for initial maximum size.

  • max_iters (int) – Maximum number of iterations.

  • window_exp (float) – Exponent on window_width decrease for each iteration.

  • min_window (int) – Minimum window size.

  • d0 (float) – Zero range correction.

  • target_threshold_db (float) – Filter out targets that are this many dB below the maximum amplitude target.

  • remove_trend (bool) – Remove linear trend in phase correction.

  • estimator (str) – Estimator to use. See pga_estimator function for possible choices.

  • lowpass_window (str) – FFT window to use for lowpass filtering. See scipy.get_window for syntax.

  • eps (float) – Minimum weight for weighted PGA.

  • interp_method (str) – Interpolation method “linear”: linear interpolation. (“lanczos”, N): Lanczos interpolation with order 2*N+1.

  • data_fmod (float) – Range modulation frequency applied to input data.

Return type:

tuple[Tensor, Tensor]

References

[1]

A. Evers and J. A. Jackson, “A Generalized Phase Gradient Autofocus Algorithm,” in IEEE Transactions on Computational Imaging, vol. 5, no. 4, pp. 606-619, Dec. 2019.

Returns:

  • img (Tensor) – Focused SAR image.

  • phi (Tensor) – Solved phase error.

Parameters:
  • img (Tensor | None)

  • data (Tensor)

  • pos (Tensor)

  • fc (float)

  • r_res (float)

  • grid_polar (PolarGrid | dict)

  • window_width (int | None)

  • max_iters (int)

  • window_exp (float)

  • min_window (int)

  • d0 (float)

  • target_threshold_db (float)

  • remove_trend (bool)

  • estimator (str)

  • lowpass_window (str)

  • eps (float)

  • interp_method (str)

  • data_fmod (float)

Return type:

tuple[Tensor, Tensor]

torchbp.autofocus.gpga_bp_polar_tde(img, data, pos, fc, r_res, grid_polar, azimuth_divisions, range_divisions, window_width=None, rms_error_limit=0.05, max_iters=20, window_exp=0.7, min_window=5, d0=0.0, target_threshold_db=20, remove_trend=True, lowpass_window='boxcar', eps=1e-06, interp_method='linear', estimate_z=True, att=None, g=None, g_extent=None, use_ffbp=False, ffbp_opts=None, verbose=False, data_fmod=0)[source]

Generalized phase gradient autofocus [1] using 2D polar coordinate backprojection image formation.

Estimates 3D position error by dividing the image into subimages, estimating slant range error to each subimage, and then solving for 3D position error from slant range errors. [2]

Z-axis estimation requires variable look angles in the image. Set estimate_z to False if this is not the case, for example ground based radar.

Parameters:
  • img (Tensor or None) – Complex input image. Shape should be: [Range, azimuth]. If None image is generated from the data.

  • 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.

  • 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 theta is sin of angle (-1, 1 for 180 degree view).

  • azimuth_divisions (int) – Number of divisions for local images in azimuth direction.

  • range_divisions (int) – Number of divisions for local images in range direction.

  • window_width (int or None) – Initial low-pass filter window width in samples. None for initial maximum size.

  • rms_error_limit (float) – Phase RMS error limit in radians for stopping the optimization iteration.

  • max_iters (int) – Maximum number of iterations.

  • window_exp (float) – Exponent on window_width decrease for each iteration.

  • min_window (int) – Minimum window size.

  • d0 (float) – Zero range correction.

  • target_threshold_db (float) – Filter out targets that are this many dB below the maximum amplitude target.

  • remove_trend (bool) – Remove linear trend in phase correction.

  • lowpass_window (str) – FFT window to use for lowpass filtering. See scipy.get_window for syntax.

  • eps (float) – Minimum weight for weighted PGA.

  • interp_method (str) – Interpolation method “linear”: linear interpolation. (“lanczos”, N): Lanczos interpolation with order 2*N+1.

  • estimate_z (bool) – Estimate Z-axis position error. Default is True.

  • 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.

  • use_ffbp (bool) – Use fast factorized backprojection for image formation.

  • ffbp_opts (dict) – Dictionary of options for ffbp.

  • verbose (bool) – Print progress stats.

  • data_fmod (float) – Range modulation frequency applied to input data.

Return type:

tuple[Tensor, Tensor]

References

[1]

A. Evers and J. A. Jackson, “A Generalized Phase Gradient Autofocus Algorithm,” in IEEE Transactions on Computational Imaging, vol. 5, no. 4, pp. 606-619, Dec. 2019.

[2]

Z. Ding et al., “An Autofocus Approach for UAV-Based Ultrawideband Ultrawidebeam SAR Data With Frequency-Dependent and 2-D Space-Variant Motion Errors,” in IEEE Transactions on Geoscience and Remote Sensing, vol. 60, pp. 1-18, 2022, Art no. 5203518.

Returns:

  • img (Tensor) – Focused SAR image.

  • pos_new (Tensor) – Solved 3D position error.

Parameters:
  • img (Tensor | None)

  • data (Tensor)

  • pos (Tensor)

  • fc (float)

  • r_res (float)

  • grid_polar (PolarGrid | dict)

  • azimuth_divisions (int)

  • range_divisions (int)

  • window_width (int | None)

  • rms_error_limit (float)

  • max_iters (int)

  • window_exp (float)

  • min_window (int)

  • d0 (float)

  • target_threshold_db (float)

  • remove_trend (bool)

  • lowpass_window (str)

  • eps (float)

  • interp_method (str)

  • estimate_z (bool)

  • att (Tensor | None)

  • g (Tensor | None)

  • g_extent (list | None)

  • use_ffbp (bool)

  • ffbp_opts (dict | None)

  • verbose (bool)

  • data_fmod (float)

Return type:

tuple[Tensor, Tensor]

torchbp.autofocus.insar_rme(img_s, data_m, data_s, pos_m, pos_s, fc, r_res, grid_polar, window_width=None, max_iters=10, window_exp=0.7, min_window=5, d0=0.0, target_threshold_db=20, lowpass_window='boxcar', eps=1e-06, interp_method='linear', verbose=False, data_fmod=0, img_m=None, spatial_coherence=None)[source]

InSAR residual motion error estimation by cross-pass phase comparison.

Estimates pass 2 range-direction position errors by comparing demodulated target phase between passes. For each pass 2 sweep, the nearest pass 1 sweep (by along-track distance to target) provides a reference. The geometric range difference from the baseline is computed and removed, leaving only the RME phase.

Pass 1 should be autofocused first. Both passes must be on the same polar grid (same origin).

Parameters:
  • img_s (Tensor or None) – Pass 2 image [nr, ntheta]. If None, generated from data.

  • data_m (Tensor) – Range compressed pass 1 (master) data [nsweeps_m, samples].

  • data_s (Tensor) – Range compressed pass 2 (slave) data [nsweeps_s, samples].

  • pos_m (Tensor) – Pass 1 corrected positions [nsweeps_m, 3].

  • pos_s (Tensor) – Pass 2 positions to correct [nsweeps_s, 3].

  • fc (float) – RF center frequency in Hz.

  • r_res (float) – Range bin resolution in data (meters).

  • grid_polar (PolarGrid or dict) – Polar grid definition.

  • window_width (int or None) – Initial low-pass filter window width. None for automatic.

  • max_iters (int) – Maximum number of iterations.

  • window_exp (float) – Exponent for decreasing window width each iteration.

  • min_window (int) – Minimum window size.

  • d0 (float) – Zero range correction.

  • target_threshold_db (float) – Filter out targets below this threshold (dB below max).

  • lowpass_window (str) – FFT window for lowpass filtering.

  • eps (float) – Minimum weight.

  • interp_method (str) – Interpolation method: “linear” or (“lanczos”, N).

  • verbose (bool) – Print progress.

  • data_fmod (float) – Range modulation frequency applied to input data.

  • img_m (Tensor | None)

  • spatial_coherence (Tensor | None)

Returns:

  • img_s (Tensor) – Focused pass 2 image.

  • pos_s_new (Tensor) – Corrected pass 2 positions (range direction).

Return type:

tuple[Tensor, Tensor]

torchbp.autofocus.insar_rme_blocksvd(data_s, pos_s, img_m, fc, r_res, grid_polar, n_az_blocks=32, n_r_blocks=16, d0=0.0, data_fmod=0.0, row_weight='coherence', align_blocks=True, aperture_mask=True, aperture_pad=1.0, phi_lowpass=0, interp_method='linear', pixel_chunk=256, spatial_coherence=None, return_alpha=False, return_magnitude=False, verbose=False)[source]

Closed-form block-coherent InSAR residual motion error estimation.

Estimates per-slave-sweep range-direction position errors by combining per-block coherent statistics computed against an existing master image.

Notes

The image is tiled into n_r_blocks x n_az_blocks non-overlapping blocks. For each block b:

  1. The block’s pixel positions are passed as targets to gpga_backprojection_2d_core on the slave data, producing B[k, m] = data_s[m, r_idx(pix_k, m)] * exp(-j k R(pix_k, m)), i.e. the per-sweep slave backprojection footprint at the block’s pixels. Master is never demodulated to targets.

  2. The per-block per-sweep statistic is the inner product against the existing master image patch: alpha^{(b)}_m = Sum_k conj(img_m[pix_k]) * B[k, m]. This is the closed-form maximizer (over per-sweep phase) of the block’s coherent inner product, with the master image acting as the optimal pixel weighting.

The per-block alpha-vectors are then combined into a global per-sweep phase. Each block has an unknown complex constant c_b (per-block baseline + topo phase). With align_blocks=True, each block’s alpha is divided by its mean phase to absorb c_b, and the aligned alphas are coherently summed:

alpha_combined_m = Sum_b alpha^{(b)}_m / e^{j angle(Sum_m alpha^{(b)}_m)}
phi_m = +angle(alpha_combined_m) (data is corrected by exp(-j phi))

The corrected slave position is pos_s + [dr_m, 0, 0] (range-only, in the slave’s local frame where the +X axis is the radar look direction).

Parameters:
  • data_s (Tensor [nsweeps_s, nsamples]) – Range-compressed slave data.

  • pos_s (Tensor [nsweeps_s, 3]) – Slave platform positions in the slave’s local frame.

  • img_m (Tensor [nr, ntheta] or [1, nr, ntheta]) – Master image already formed on grid_polar. Must be on the same grid as the slave will be reformed on; no master/slave image interpolation is performed.

  • fc (float) – RF center frequency in Hz.

  • r_res (float) – Range bin resolution in data (meters).

  • grid_polar (PolarGrid or dict) – Polar grid definition.

  • n_az_blocks (int) – Image tiling. The total number of blocks is the product. Use enough azimuth blocks to give multi-block coverage of every sweep (a few times nsweeps_s / aperture_length); a small number of range blocks (5–20) is enough for diversity. Block size should be small enough that topographic phase is approximately constant within a block (otherwise per-block coherent integration cancels).

  • n_r_blocks (int) – Image tiling. The total number of blocks is the product. Use enough azimuth blocks to give multi-block coverage of every sweep (a few times nsweeps_s / aperture_length); a small number of range blocks (5–20) is enough for diversity. Block size should be small enough that topographic phase is approximately constant within a block (otherwise per-block coherent integration cancels).

  • d0 (float) – Zero range correction.

  • data_fmod (float) – Range modulation frequency applied to input data.

  • row_weight ("coherence" | "power" | "uniform") – Per-block row weight. “coherence” Weight be coherence. Recommended for real data. “power” divides by image power. “uniform” uses no weighting.

  • align_blocks (bool) – If True, divide each block’s alpha by its mean phase before combining. This absorbs the per-block complex constant c_b (baseline / sub-pixel position) and is essential when topographic phase varies across the image.

  • aperture_mask (bool) – If True (recommended), zero out per-block alpha entries for slave sweeps outside the block’s synthetic-aperture window.

  • aperture_pad (float) – Multiplier on the polar grid’s angular extent used by aperture_mask. 1.0 uses the exact grid extent; >1 widens the per-block window.

  • spatial_coherence (Tensor [nr, ntheta] or None) – Per-pixel coherence map (e.g. from torchbp.ops.power_coherence_2d) used to downweight decorrelated regions. The map is squared (coh**2 weighting) and multiplied into the master image patch before forming each block’s alpha, so contributions from vegetation or shadow areas are suppressed pixel-by-pixel.

  • phi_lowpass (int) – If > 0, lowpass-filter the recovered phase along the sweep axis with a Hamming window of this width (in samples). Use a value much smaller than nsweeps_s and at least a few times smaller than the expected RME bandwidth. 0 disables filtering.

  • interp_method (str) – Interpolation method passed to gpga_backprojection_2d_core.

  • return_alpha (bool) – If True, also return the [nblocks, nsweeps_s] alpha matrix for diagnostics.

  • verbose (bool) – Print progress.

  • pixel_chunk (int)

  • return_magnitude (bool)

Returns:

  • pos_s_new (Tensor [nsweeps_s, 3]) – Corrected slave positions (only the range component is modified).

  • phi (Tensor [nsweeps_s]) – Estimated per-sweep RME phase, zero-mean.

  • alpha (Tensor [nblocks, nsweeps_s], optional) – Returned only when return_alpha=True.

Return type:

tuple[Tensor, Tensor]

torchbp.autofocus.insar_rme_blocksvd_strata(data_s, pos_s, img_m, fc, r_res, grid_polar, n_strata=8, n_az_blocks_per_strata=32, strata_spacing='elevation', estimate_z=False, d0=0.0, data_fmod=0.0, phi_lowpass=0, delta_lowpass=0, spatial_coherence=None, interp_method='linear', pixel_chunk=256, return_phi_strata=False, verbose=False, altitude=None)[source]

Stratified closed-form InSAR RME with optional XZ decomposition.

Splits the polar grid into n_strata range bands, runs an independent insar_rme_blocksvd per band to obtain a high-SNR per-sweep slant-range error estimate Delta r_s(m), then per sweep solves a small (K_strata x n_axes) weighted linear system using the look vector from the slave platform to each strata centroid. The result is a per-sweep position correction (XZ or X depending on estimate_z).

Same closed-form / no-master-GPGA / no-master-interpolation properties as insar_rme_blocksvd. Compared to the plain blocksvd:

  • X-only typically yields a more accurate X correction (per-strata blocksvd is better-conditioned and the LS averages across strata).

  • XZ can recover a real Z error when the geometry has enough elevation diversity (significant variation of sin(el) across the range swath, i.e. low altitude / wide range, or tall platform / short range).

Parameters:
  • data_s (Tensor) – Same as insar_rme_blocksvd().

  • pos_s (Tensor) – Same as insar_rme_blocksvd().

  • img_m (Tensor) – Same as insar_rme_blocksvd().

  • fc (float) – Same as insar_rme_blocksvd().

  • r_res (float) – Same as insar_rme_blocksvd().

  • grid_polar (PolarGrid | dict) – Same as insar_rme_blocksvd().

  • n_strata (int) – Number of range strata. Should be >= 2 for XZ mode (more strata → more LS averaging, but each strata has fewer pixels).

  • n_az_blocks_per_strata (int) – Number of azimuth blocks per strata, passed to the per-strata insar_rme_blocksvd() call.

  • estimate_z (bool) – If True, also solve for Z position error. Requires n_strata >= 2 and meaningful elevation-angle diversity across strata.

  • d0 (float) – Forwarded to per-strata insar_rme_blocksvd().

  • data_fmod (float) – Forwarded to per-strata insar_rme_blocksvd().

  • phi_lowpass (int) – Forwarded to per-strata insar_rme_blocksvd().

  • spatial_coherence (Tensor | None) – Forwarded to per-strata insar_rme_blocksvd().

  • interp_method (str) – Forwarded to per-strata insar_rme_blocksvd().

  • pixel_chunk (int) – Forwarded to per-strata insar_rme_blocksvd().

  • delta_lowpass (int) – If > 0, Hamming-window lowpass after the LS. Useful to suppress LS noise on Z when its conditioning is marginal.

  • return_phi_strata (bool) – If True, also return the [n_strata, nsweeps] per-strata phase matrix for diagnostics.

  • verbose (bool) – Print per-strata progress.

  • altitude (float or None) – Sensor altitude for slant-range grids (BP origin at sensor altitude, pos_s z ≈ 0). When set, uses slant-range geometry for elevation strata (sin_el = H/r) and look vectors. When None (default), altitude is inferred from pos_s[:, 2] and ground-range geometry is used (sin_el = H/sqrt(r**2+H**2)).

  • strata_spacing (str)

Returns:

  • pos_s_new (Tensor [nsweeps, 3]) – Corrected slave positions; X is always corrected, Z corrected only when estimate_z=True.

  • delta (Tensor [nsweeps, 3]) – Per-sweep XYZ correction added to pos_s. Non-estimated axes are zero.

  • phi_strata (Tensor [n_strata, nsweeps], optional) – Returned when return_phi_strata=True.

Return type:

tuple[Tensor, Tensor]

torchbp.autofocus.minimum_entropy_grad_autofocus(f, data, data_time, pos, fc, r_res, grid, wa, tx_norm=None, max_steps=100, lr_max=10000, d0=0, pos_reg=1, lr_reduce=0.8, verbose=True, convergence_limit=0.01, max_step_limit=0.25, grad_limit_quantile=0.9, fixed_pos=0, minimize_only=False, data_fmod=0)[source]

Minimum entropy autofocus using backpropagation optimization through image formation.

Parameters:
  • f (function) – Radar image generation function.

  • data (Tensor) – Radar data.

  • data_time (Tensor) – Recording time of each data sample.

  • pos (Tensor) – Position at each data sample.

  • fc (float) – RF 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.

  • grid (PolarGrid or dict) – Grid definition. Correct definition depends on the radar image function.

  • wa (Tensor) – Azimuth windowing function. Should be applied to data already, used for scaling gradient.

  • tx_norm (Tensor) – Radar image is divided by this tensor before calculating entropy. If None no division is done.

  • max_steps (int) – Maximum number of optimization steps.

  • lr_max (float) – Maximum learning rate. Too large learning rate is scaled automatically.

  • d0 (float) – Zero range correction.

  • pos_reg (float) – Position regularization value.

  • lr_reduce (float) – Learning rate is multiplied with this value if new entropy is larger than previously.

  • verbose (bool) – Print progress during optimization.

  • convergence_limit (float) – If maximum position change is below this value stop optimization. Units in wavelengths.

  • max_step_limit (float) – Maximum step size in wavelengths.

  • grad_limit_quantile (float) – Quantile used for maximum step size calculation. 0 to 1 range.

  • fixed_pos (int) – First fixed_pos positions are kept fixed and are not optimized.

  • minimize_only (bool) – Reject steps that would increase image entropy.

  • data_fmod (float) – Range modulation frequency applied to input data.

Returns:

  • sar_img (Tensor) – Optimized radar image.

  • origin (Tensor) – Mean of position tensor.

  • pos (Tensor) – Platform position.

  • step (int) – Number of steps.

Return type:

tuple[Tensor, Tensor, Tensor, int]

torchbp.autofocus.pga(img, window_width=None, max_iters=10, window_exp=0.5, min_window=5, remove_trend=True, offload=False, estimator='wls', eps=1e-06)[source]

Phase gradient autofocus

Parameters:
  • img (Tensor) – Complex input image. Shape should be: [Range, azimuth].

  • window_width (int) – Initial window width. Default is None which uses full image size.

  • max_iter (int) – Maximum number of iterations.

  • window_exp (float) – Exponent for decreasing the window size for each iteration.

  • min_window (int) – Minimum window size.

  • remove_trend (bool) – Remove linear trend that shifts the image.

  • offload (bool) – Offload some variable to CPU to save VRAM on GPU at the expense of longer running time.

  • estimator (str) – Estimator to use. See pga_estimator function for possible choices.

  • eps (float) – Minimum weight for weighted PGA.

  • max_iters (int)

Returns:

  • img (Tensor) – Focused image.

  • phi (Tensor) – Solved phase error.

Return type:

tuple[Tensor, Tensor]

torchbp.autofocus.pga_estimator(g, estimator='wls', eps=1e-06, return_weight=False)[source]

Estimate phase error from set of measurements.

Parameters:
  • g (Tensor) – Demodulated phase from each target. Shape [Ntargets, Nazimuth].

  • estimator (str) –

    Estimator to use.
    • ”pd”: Phase difference. [1]

    • ”ml”: Maximum likelihood. [2]

    • ”wls”: Weighted least squares using estimated signal-to-clutter weighting. [3]

  • eps (float) – Minimum weight for weighted PGA.

  • return_weight (bool)

Return type:

Tuple[Tensor, Tensor] | Tensor

References

[1]

D. E. Wahl, P. H. Eichel, D. C. Ghiglia and C. V. Jakowatz, “Phase gradient autofocus - A robust tool for high resolution SAR phase correction,” in IEEE Transactions on Aerospace and Electronic Systems, vol. 30, no. 3, pp. 827-835, July 1994.

[2]

Charles V. Jakowatz and Daniel E. Wahl, “Eigenvector method for maximum-likelihood estimation of phase errors in synthetic-aperture-radar imagery,” J. Opt. Soc. Am. A 10, 2539-2546 (1993).

[3]

Wei Ye, Tat Soon Yeo and Zheng Bao, “Weighted least-squares estimation of phase errors for SAR/ISAR autofocus,” in IEEE Transactions on Geoscience and Remote Sensing, vol. 37, no. 5, pp. 2487-2494, Sept. 1999.

Returns:

phi – Solved phase error.

Return type:

Tensor

Parameters:
  • g (Tensor)

  • estimator (str)

  • eps (float)

  • return_weight (bool)