NMFwisp

Source Masks

This is a script for generating source masks for NMFwisp.

Overview

The source mask can be built from long-wavelength (LW) NIRCam images, which are usually obtained together with the short-wavelength (SW) images. LW images provide a clean source-detection image because they are not affected by wisps.

The script stacks all relevant LW images, detects sources in the stack, and projects the segmentation map onto the SW image that needs wisp subtraction. The LW images do not need to match the exact configuration of the SW image.

Example Data

The repository provides a helper script to download example data for source-mask generation. It downloads one SW target image to ../data and multiple LW images to ../data/LW_data. The SW image is the image to mask for wisp subtraction, and the LW images are stacked to build the segmentation map.

Install the download dependency and run:

python -m pip install astroquery
python download_data.py --data_dir ../data  --lw_dir ../data/LW_data

Workflow

First, build a segmentation map from the LW images:

python nmfwisp/sourcemask.py \
  --exp_dir ../data --lw_dir ../data/LW_data \
  --make_segmap 1 --segname "segmap.fits"

Then switch to the mode of building masks from the segmentation map by setting --make_segmap 0:

python nmfwisp/sourcemask.py \
  --exp_dir ../data --lw_dir ../data/LW_data \
  --make_segmap 0 --segname "segmap.fits"

Requirements

Source-mask generation requires the NMFwisp runtime dependencies plus packages for JWST data models, source detection, drizzling, and reprojection.

python -m pip install astropy scipy photutils reproject jwst "drizzle<2"

The drizzle dependency is pinned below version 2 for compatibility with the source-mask script.

Arguments

Argument Default Description
--exp_dir ./ Directory containing the target SW images to mask.
--lw_dir ./ Directory containing LW images used to build the segmentation map.
--exp_pattern *.fits Pattern used to select target SW images from exp_dir.
--lw_pattern *long*.fits Pattern used to select LW images from lw_dir.
--make_segmap 0 Set 1 to create the segmentation map and 0 to use the segmentation map to create source masks.
--segname None Name of the segmentation-map FITS file to write or read.
--regenerate 1 If nonzero, overwrite existing mask files.
--mask_dir None Optional output directory. Defaults to exp_dir.
--mask_suffix _smask.fits Suffix added for output mask files.