Quartic Fit Correction#
Concept#
The quartic fit correction takes care of the flat field, gain, and other pixel-by-pixel effects. There are five coefficients (a, b, c, d, e) for each pixel that define a function for correction:
For pixel at coordinate (i, j), the original image values in DN are corrected to be X using the five coefficients in a polynomial correction.
Applying correction#
The correction is carried out primarily in the punchbowl.level1.quartic_fit.photometric_calibration function:
- punchbowl.level1.quartic_fit.photometric_calibration(image: ndarray, coefficient_image: ndarray) ndarray
Compute a non-linear photometric calibration of PUNCH images.
- Parameters:
image (np.ndarray) – Image to be corrected.
coefficient_image (np.ndarray) – Frame containing uncertainty values. The first two dimensions are the spatial dimensions of the image. The last dimension iterates over the powers of the coefficients, starting with index 0 being the highest power and counting down.
- Returns:
a photometrically corrected frame
- Return type:
np.ndarray
Notes
Each instrument is subject to an independent non-linear photometric response, which needs to be corrected. The module converts from raw camera digitizer number (DN) to photometric units at each pixel. Each pixel is replaced with the corresponding value of the quartic polynomial in the current calibration file data product for that particular camera.
A quartic polynomial is applied as follows:
\[X_{i,j} = a_{i,j}+b_{i,j}*DN_{i,j}+c_{i,j}*DN_{i,j}^2+d_{i,j}*DN_{i,j}^3+e_{i,j}*DN_{i,j}^4\]for each pixel in the detector. Each quantity (a, b, c, d, e) is a function of pixel location (i,j), and is generated using dark current and Stim lamp maps. a = offset (dark and the bias). b, c, d, e = higher order terms. Specifically
coefficient_image[:,i,j] = [e, d, c, b, a](highest order terms first)As each pixel is independent, a quartic fit calibration file of dimensions 2k*2k*5 is constructed, with each layer containing one of the five polynomial coefficients for each pixel.
Examples
>>> punch_image = np.ones((100,100)) >>> coefficient_image = create_coefficient_image(np.array([0, 0, 0, 1, 0]), punch_image.shape) >>> data = photometric_calibration(punch_image, coefficient_image)
If you wish to incorporate this as a Prefect task in a custom pipeline,
using something like the punchbowl.level1.quartic_fit.perform_quartic_fit_task is recommended.