punchbowl.level1.vignette#

Functions#

_load_vignetting_function(→ ndcube.NDCube)

correct_vignetting_task(→ ndcube.NDCube)

Prefect task to correct the vignetting of an image.

generate_vignetting_calibration_wfi(, rows_adjust, ...)

Create calibration data for vignetting.

generate_vignetting_calibration_nfi(→ numpy.ndarray | str)

Create calibration data for vignetting for the NFI spacecraft.

Module Contents#

punchbowl.level1.vignette._load_vignetting_function(vignetting_path: str | pathlib.Path | punchbowl.util.DataLoader | None) ndcube.NDCube[source]#
punchbowl.level1.vignette.correct_vignetting_task(data_object: ndcube.NDCube, vignetting_path: str | pathlib.Path | punchbowl.util.DataLoader | None, second_vignetting_path: str | pathlib.Path | punchbowl.util.DataLoader | None = None, allow_extrapolation: bool = False) ndcube.NDCube[source]#

Prefect task to correct the vignetting of an image.

Vignetting is a reduction of an image’s brightness or saturation toward the periphery compared to the image center, created by the optical path. The Vignetting Module will transform the data through a flat-field correction map, to cancel out the effects of optical vignetting created by distortions in the optical path. This module also corrects detector gain variation and offset.

Correction maps will be 2048*2048 arrays, to match the input data, and built using the starfield brightness pattern. Mathematical Operation:

I’_{i,j} = I_i,j / FF_{i,j}

Where I_{i,j} is the number of counts in pixel i, j. I’_{i,j} refers to the modified value. FF_{i,j} is the small-scale flat field factor for pixel i, j. The correction mapping will take into account the orientation of the spacecraft and its position in the orbit.

Uncertainty across the image plane is calculated using the modelled flat-field correction with stim lamp calibration data. Deviations from the known flat-field are used to calculate the uncertainty in a given pixel. The uncertainty is convolved with the input uncertainty layer to produce the output uncertainty layer.

Parameters:
  • data_object (PUNCHData) – data on which to operate

  • vignetting_path (str | Path | DataLoader) – path to vignetting function to apply to input data

  • second_vignetting_path (str | Path | DataLoader | None) – if provided, the two vignetting functions will be interpolated between

  • allow_extrapolation (bool) – if second_vignetting_path is provided, whether to allow extrapolation beyond the two vignetting files. If False and data_object’s date_obs is outside this range, the interpolation will be “clamped” to one of the two files, rather than extrapolating.

Returns:

modified version of the input with the vignetting corrected

Return type:

PUNCHData

punchbowl.level1.vignette.generate_vignetting_calibration_wfi(path_vignetting: str, path_mask: str, spacecraft: str, vignetting_threshold: float = 1.2, rows_ignore: tuple = (13, 15), rows_adjust: tuple = (15, 16), rows_adjust_source: tuple = (16, 20), mask_erosion: tuple = (6, 6)) numpy.ndarray[source]#

Create calibration data for vignetting.

Parameters:
  • path_vignetting (str) – path to raw input vignetting function

  • path_mask (str) – path to spacecraft mask function

  • spacecraft (str) – spacecraft number

  • vignetting_threshold (float, optional) – threshold for bad vignetting pixels, by default 1.2

  • rows_ignore (tuple, optional) – rows to exclude entirely from original vignetting data, by default (13,15) for 128x128 input

  • rows_adjust (tuple, optional) – rows to adjust to the minimum of a set of rows above (per column), by default (15,16) for 128x128 input

  • rows_adjust_source (tuple, optional) – rows to use for statistics to adjust vignetting rows as above, by default (16,20) for 128x128 input

  • mask_erosion (tuple, optional) – kernel to use in erosion operation to reduce the mask applied to the vignetting function, by default (6,6)

Returns:

vignetting function array

Return type:

np.ndarray

punchbowl.level1.vignette.generate_vignetting_calibration_nfi(input_files: list[str], path_speckle: str, path_mask: str, path_dark: str, polarizer: str, dateobs: str, version: str, output_path: str | None = None, max_files: int = -1) numpy.ndarray | str[source]#

Create calibration data for vignetting for the NFI spacecraft.

Parameters:
  • input_files (list[str]) – Paths to input NFI files for processing

  • path_speckle (str) – Path to the speckle mask FITS file

  • path_mask (str) – Path to the NFI mask bin file

  • path_dark (str) – Path to the dark frame FITS file

  • polarizer (str) – Polarizer name

  • dateobs (str) – Timestamp for calibration file

  • version (str) – File version

  • output_path (str | None) – Path to calibration file output

  • max_files (int) – If set, only the first this many non-outlier files will be loaded and used

Returns:

vignetting function array or written file path

Return type:

np.ndarray | str