romanimpreprocess.utils.maskhandling
Tools for building a mask by growing the input bitmask by different amounts.
Classes
- CombinedMask
Class to generate a boolean mask from multiple flags.
Attributes
Classes
Class to generate a boolean mask from multiple flags. |
Module Contents
- class CombinedMask(maskdict)[source]
Class to generate a boolean mask from multiple flags.
- Parameters:
maskdict (dict) – A dictionary of how much to grow each flag (see notes for description).
Notes
To take a dq array, and flag any pixel with
'gw_affected_data'and the cardinal-nearest neigbors if'jump_det'is set:myMaskFunc = CombinedMask({'jump_det': 5, 'gw_affected_data': 1}) mymask = myMaskFunc.build(dq)
The mask names are as described in
roman_datamodels.dqflags.pixel. Note that capitalization is automatic so this function is not case-sensitive.Options for growing are specified by the number of pixels affected: * 1 = that pixel * 5 = cardinal nearest neighbors * 9 = 3x3 block * 25 = 5x5 block
- build(dq)[source]
Make boolean mask from a data quality array.
- Parameters:
dq (np.array of uint32) – 2D data quality array.
- Returns:
Grown mask; True indicates a masked pixel, False a normal pixel.
- Return type:
np.array of bool
- convert_file(file_in, file_mask)[source]
Stand-alone function to make a mask from a file.
The type of output depends on the file_mask extension: * If .asdf is requested, simply writes the boolean array. * If .fits is requested, makes a masked image (HDU0, for display purposes)
and an int8 version (HDU1).
- Parameters:
file_in (str) – The input ASDF file, in L2 format.
file_mask (str) – The output file.
- Return type:
None