corgidrp.combine#
Module to support frame combination
Functions#
|
Combines several images together |
|
Combines a sequence of exposures assuming a constant nubmer of frames per group. |
|
Derotates an array based on the provided NORTHANG angle, about the provided |
|
Applies logic to propagate the dq arrays and error arrays |
Module Contents#
- corgidrp.combine.combine_images(data_subset, err_subset, dq_subset, collapse, num_frames_scaling, other_hdus=None)[source]#
Combines several images together
- Parameters:
data_subset (np.array) – 3-D array of N 2-D images
err_subset (np.array) – 4-D array of N 3-D error maps
dq_subset (np.array) – 3-D array of N 2-D DQ maps
collapse (str) – “mean” or “median”.
num_frames_scaling (bool) – Multiply by number of frames in sequence in order to ~conserve photons
other_hdus (list of HDULists, optional) – list of other HDULists to be combined in the same way
- Returns:
- combined images
np.array: 2-D array of combined images np.array: 3-D array of combined error map np.array: 2-D array of combined DQ maps list of np.array: list of the combined data of other HUDs
- Return type:
tuple
- corgidrp.combine.combine_subexposures(input_dataset, num_frames_per_group=None, collapse='mean', num_frames_scaling=True, combine_other_hdus=False)[source]#
Combines a sequence of exposures assuming a constant nubmer of frames per group. The length of the dataset must be divisible by the number of frames per group.
The combination is done with either the mean or median, but the collapsed image can be scaled in order to ~conserve the total number of photons in the input dataset (this essentially turns a median into a sum)
- Parameters:
input_dataset (corgidrp.data.Dataset) – input data.
num_frames_per_group (int) – number of subexposures per group. If None, combines all images together
collapse (str) – “mean” or “median”. (default: mean)
num_frames_scaling (bool) – Multiply by number of frames in sequence in order to ~conserve photons (default: True)
combine_other_hdus (bool) – Whether to combine other HDUs in the same way as the main data, err, DQ. Otherwise, uses the HDUs from the first frame in a subset (default: False)
- Returns:
dataset after combination of every “num_frames_per_group” frames together
- Return type:
- corgidrp.combine.derotate_arr(data_arr, northang_deg, xcen, ycen, new_center=None, astr_hdr=None, is_dq=False, dq_round_threshold=0.05)[source]#
Derotates an array based on the provided NORTHANG angle, about the provided center. Treats DQ arrays specially, converting to float to do the rotation, and converting back to np.int64 afterwards. DQ output becomes only zeros and ones, so detailed DQ flag information is not preserved.
- Parameters:
data_arr (np.array) – an array with 2-4 dimensions
northang_deg (float) – angle (measured counter-clockwise) of the detector y axis from celestial north (degrees). Calculated from the northangle of the astrometric cal frame and the PA_APER offset between the astrom cal frame and the science frame.
xcen (float) – x-coordinate of center about which to rotate
ycen (float) – y-coordinate of center about which to rotate
new_center (tuple, optional) – tuple of x- and y- coordinate of the new center to shift to.
astr_hdr (astropy.fits.Header, optional) – WCS header which will be updated. Defaults to None.
is_dq (bool, optional) – Flag to determine if this is a DQ array. Defaults to False.
dq_round_threshold (float, optional) – value between 0-1 which determines the threshold for spreading dq values to neighboring pixels after derotation.
- Returns:
The derotated array.
- Return type:
np.array
- corgidrp.combine.prop_err_dq(sci_dataset, ref_dataset, mode, dq_thresh=1, new_center=None)[source]#
Applies logic to propagate the dq arrays and error arrays in a dataset through PSF subtraction.
- Parameters:
sci_dataset (corgidrp.data.Dataset) – The input science dataset.
ref_dataset (corgidrp.data.Dataset) – The input reference dataset (or None if ADI only).
mode (str) – The PSF subtraction mode, e.g. “ADI”, “RDI”, “ADI+RDI”.
dq_thresh (int) – Minimum dq flag value to be considered a bad pixel. Defaults to 1.
new_center (tuple) – New center (xy) to align all frames. Defaults to pixel closest to array center.
- Returns:
the dq array and err array which should apply to the PSF subtraction output dataset.
- Return type:
tuple of np.array