weighted_operations
- jwst.ami.leastsqnrm.weighted_operations(img, model, dqm=None)[source]
Perform least squares matrix operations to solve A x = b weighting by Poisson variance.
A is the model, b is the data (image), and x is the coefficient vector we are solving for.
Here we are weighting data by Poisson variance:
x = inv(At.W.A).(At.W.b)
where W is a diagonal matrix of weights w_i, weighting each data point i by the inverse of its variance:
w_i = 1 / sigma_i ^ 2
For photon noise, the data, i.e., the image values b_i have variance proportional to b_i with an, e.g., ADU to electrons conversion factor. If this factor is the same for all pixels, we do not need to include it here.
- Parameters:
- img2D float array
Input data
- model2D float array
Analytic model
- dqm2D bool array
Bad pixel mask, same shape as image.
- Returns:
- x1D float array
Coefficient vector
- res2D float array
Residual; difference between model and fit
Notes
Use matrix_operations() for equal weighting of data.