punchbowl.level1.quartic_fit#

Functions#

create_coefficient_image(→ numpy.ndarray)

Given a set of coefficients that should apply for every pixel, convert them to the required format.

create_constant_quartic_coefficients(→ numpy.ndarray)

Create a constant coefficients image that preserves the original values, b = 1 and all other coefficients are 0.

photometric_calibration(→ numpy.ndarray)

Compute a non-linear photometric calibration of PUNCH images.

perform_quartic_fit_task(→ ndcube.NDCube)

Prefect task to perform the quartic fit calibration on the data.

Module Contents#

punchbowl.level1.quartic_fit.create_coefficient_image(flat_coefficients: numpy.ndarray, image_shape: tuple) numpy.ndarray#

Given a set of coefficients that should apply for every pixel, convert them to the required format.

Parameters:
  • flat_coefficients (np.ndarray) – A one-dimensional list of coefficients that should apply to every pixel in the image. Coefficients should be ordered from the highest power to lowest as expected in photometric_calibration, e.g. f(i,j) = a+b*IMG[i,j]+c*IMG[i,j]^2 would have flat_coefficients of [c, b, a]

  • image_shape (tuple) – A tuple of the shape of the image that will be calibrated using photometric_calibration

Returns:

An image of coefficients that apply to every pixel as expected by photometric_calibration

Return type:

np.ndarray

punchbowl.level1.quartic_fit.create_constant_quartic_coefficients(img_shape: tuple) numpy.ndarray#

Create a constant coefficients image that preserves the original values, b = 1 and all other coefficients are 0.

Parameters:

img_shape (tuple[Int]) – size of the image to create the coefficients for

Returns:

An image of coefficients that apply to every pixel as expected by photometric_calibration

Return type:

np.ndarray

punchbowl.level1.quartic_fit.photometric_calibration(image: numpy.ndarray, coefficient_image: numpy.ndarray) numpy.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)
punchbowl.level1.quartic_fit.perform_quartic_fit_task(data_object: ndcube.NDCube, quartic_coefficients_path: str | None = None) ndcube.NDCube#

Prefect task to perform the quartic fit calibration on the data.

Parameters:
  • data_object (PUNCHData) – a data object that needs calibration

  • quartic_coefficients_path (Optional[str]) – path to a cube of coefficients as produced by create_coefficients_image or create_ones_coefficients_image, skips correction if it is None

Returns:

modified version of the input with the quartic fit correction applied

Return type:

PUNCHData