maskfill.maskfill
Module Contents
Functions
Find all NaN indices in an array which have at least 1 non-NaN neighbor in the given window |
|
Helper function to process masked pixels in the output image. Returns the updated output array. |
|
Maskfill function used to smoothly iteratively fill masks in images. See van Dokkum et al. 2023 (PASP) for details. |
|
Data
API
- maskfill.maskfill.find_nan_indices(arr: numpy.ndarray, window_size: int = 3)
Find all NaN indices in an array which have at least 1 non-NaN neighbor in the given window
- arrnp.ndarray
array to find NaNs with >0 non-NaN neighbors in
- window_sizeint, optional
window size (3x3 means the eight pixels around a given pixel), by default 3
- np.ndarray
all indices where the condition of a NaN with >0 non-NaN neighbor is True
- maskfill.maskfill.process_masked_pixels(input_image: numpy.ndarray, pad_width: int, mask: numpy.ndarray = None, operator_func: Callable = np.nanmean)
Helper function to process masked pixels in the output image. Returns the updated output array.
- input_imagenp.ndarray
image to process
- pad_widthint
width to pad image (depends on window size)
- masknp.ndarray, optional
if provided, the pixels to be windowed will be chosen from the mask, else it will fill any NaN values in input_image, by default None
- operator_funcCallable, optional
operation to apply to the masked or NaN pixels in the window of +/- padwidth, by default np.nanmean For maskfill to work, the operator function must compute statistics while ignoring NaN values in the input.
- np.ndarray
Image with all masked or NaN pixels that have neighboring non-NaN values replaced by the operator func applied to those neighbors.
- maskfill.maskfill.maskfill(input_image: Union[str, numpy.ndarray], mask: Union[str, numpy.ndarray], ext: int = 0, size: int = 3, operator: str = 'median', smooth: bool = True, writesteps: bool = False, output_file: str = None, verbose: bool = False)
Maskfill function used to smoothly iteratively fill masks in images. See van Dokkum et al. 2023 (PASP) for details.
- input_imageUnion[str,np.ndarray]
input image; either a path to a .fits file or a numpy ndarray
- maskUnion[str,np.ndarray]
mask image; either a path to a .fits file or a numpy ndarray [0 = good, 1 = bad/fill location] Note that any NaN values in the mask file will be ignored (i.e., treated as 0).
- extint, optional
fits extension in input and mask where data are stored, by default 0
- sizeint, optional
size for the filter to use (must be odd) — a size of three implies the 8 pixels surrounding 1 pixel are considered, by default 3
- operatorstr, optional
fill operator either ‘median’ or ‘mean’, by default ‘median’
- smoothbool, optional
whether to boxcar smooth the filled pixels using a mean with kernel = size after filling, by default True
- writestepsbool, optional
if True, save the output image of each iteration of the filling process, by default False
- output_filestr, optional
Write the final image to a fits file (if smoothing is enabled, a second extension with the non-smoothed version will be added), by default None
- verbosebool, optional
Flag for verbose messages during the filling, by default False
- output1, output2: np.ndarray, np.ndarray
output (filled) image. If no smoothing is requested, the output will be output,None If smoothing is requested, the output will be smoothed_output, output (i.e., both the smoothed and unsmoothed output). One can ignore the second output by calling smoothed_output, _ = maskfill(…) Similarly, if an output filename is provided, the 0th extension will have the output image smoothed if smoothing was requested, or unsmoothed if not. If smoothing was requested, the unsmoothed version will be stored in the 1st extension.
- maskfill.maskfill.cli()
- maskfill.maskfill.__version__ = '1.1.1'