cwitools.imaging.get_mask

cwitools.imaging.get_mask(image, header, reg, fit=True, fit_box=10, width=3, units='sigma', get_model=False)

Get fitted mask of sources based on a DS9 region file.

Args:

image (NumPy.ndarray): The input image data. header (Astropy Header): The header associated with the image reg (string): The path to the DS9 region file fit_box (int): The box size to extract/use for fitting each source. get_model (bool): Set to TRUE to return the both the mask and model width (float): The width of each mask, in standard deviations. units (str): Units of the width argument. Options are

‘px’ (pixels), ‘arcsec’ (arcseconds), or ‘sigmas’ (i.e. width=3 would mean each mask is set to 3*std_dev of the best-fit Gaussian)
Returns:
numpy.ndarray: A mask with source regions labelled sequentially. numpy.ndarray: (if get_model = TRUE) A model of the source flux.

Examples:

To get a mask representing the sources in a narrowband image (“NB.fits”) based on a DS9 region file (“mysources.reg”):

>>> from cwitools import imaging
>>> from astropy.io import fits
>>> nb_image, hdr = fits.open("NB.fits", header=True)
>>> reg = "mysources.reg"
>>> source_mask = imaging.get_mask(nb_image, hdr, reg)