IterativeNonlinearLSTSQwBackground

In addition to the methods and attributes from PointSpreadFunction and IterativeNonlinearLSTSQPSF, IterativeNonlinearLSTSQwBackground implements the following

class giant.point_spread_functions.psf_meta.IterativeNonlinearLSTSQwBackground(bg_b_coef=None, bg_c_coef=None, bg_d_coef=None, **kwargs)[source]

Bases: IterativeNonlinearLSTSQPSF

This class provides support for estimating the superposition of the PSF and a linear background gradient.

This class is typically not used by the user except when implementing a new PSF class that uses iterative nonlinear least squares to fit the PSF to data.

Beyond the typical implementation in IterativeNonLinearLSTSQ, this class provides a concrete implementation of methods compute_jacobian_bg(), evaluate_bg(), and apply_update_bg() which handle the linear background gradient of the form

\[f_{bg}(x, y) = f(x,y)+Bx+Cy+D\]

where \(f_{bg}(x,y)\) is the PSF with the background, \(f(x,y)\) is the PSF without the background, \(B\) is the slope of the gradient in the x direction, \(C\) is the slope of the gradient in the y direction and \(D\) is the constant background level.

The way this class should be used it to subclass it, then in the regular compute_jacobian() method call compute_jacobian_bg() and include with the rest of your Jacobian matrix (typically at the end), then in evaluate() call evaluate_bg() and add the results to the PSF, and finally in update_states() call update_states_bg() inputting the portion of the state vector that contains the background update according to where you added it to your existing Jacobian.

The background terms are stored in instance attributes bg_b_coef, bg_c_coef, and bg_d_coef.

Parameters:
  • bg_b_coef (float) – The x slope of the background gradient

  • bg_c_coef (float) – They y slope of the background gradient

  • bg_d_coef (float) – The constant offset of the background gradient

bg_b_coef: float

The x slope of the background gradient

bg_c_coef: float

The y slope of the background gradient

bg_d_coef: float

The constant offset of the background gradient

Summary of Added/Modified Methods

compute_jacobian_bg

This computes the Jacobian matrix for the background terms.

apply_update_bg

This applies the background update to the background state

evaluate_bg

This computes the background component at locations x and y.

fit_bg

This method tries to fit the background using linear least squares without worrying about any PSF included.