Image Masking

hostphot.image_masking.create_mask(name, host_ra, host_dec, filt, survey, ra=None, dec=None, bkg_sub=None, threshold=15, sigma=8, r=6, crossmatch=False, gal_dist_thresh=-1, deblend_cont=0.005, extract_params=False, common_params=None, save_plots=True, save_mask_params=True)

Calculates the aperture parameters to mask detected sources.

Parameters:
  • name (str) – Name of the object to find the path of the fits file.

  • host_ra (float) – Host-galaxy right ascension in degrees.

  • host_dec (float) – Host-galaxy declination in degrees.

  • filt (str or list) – Filter to use to load the fits file. List is commonly used for coadds.

  • survey (str) – Survey to use for the zero-points and correct filter path.

  • ra (float, default None) – Right ascension of an object, in degrees. Used for plotting.

  • dec (float, default None) – Declination of an object, in degrees. Used for plotting.

  • bkg_sub (bool, default None) – If True, the image gets background subtracted. By default, only the images that need it get background subtracted (WISE, 2MASS and VISTA).

  • threshold (float, default 15) – Threshold used by sep.extract() to extract objects.

  • sigma (float, default 8) – Standard deviation in pixel units of the 2D Gaussian kernel used to convolve the image.

  • r (float, default 6) – Scale of the aperture size for the sources to be masked.

  • crossmatch (bool, default False) – If True, the detected objects are cross-matched with a Gaia catalog.

  • crossmatch – If True, the detected objects are cross-matched with a Gaia catalog.

  • gal_dist_thresh (float, default -1.) – Distance in arcsec to crossmatch the galaxy coordinates with a detected object, where the object nearest to the galaxy position is considered as the galaxy (within the given threshold). If no objects are found within the given distance threshold, the galaxy is considered as not found and a warning is printed. If a non-positive value is given, the threshold is considered as infinite, i.e. the closest detected object is considered as the galaxy (default option).

  • deblend_cont (float, default 0.005) – Minimum contrast ratio used for object deblending. Default is 0.005. To entirely disable deblending, set to 1.0.

  • extract_params (bool, default False) – If True, returns the parameters listed below.

  • common_params (tuple, default None) – Parameters to use for common masking of different filters. These are the same as the outputs of this function.

  • save_plots (bool, default True) – If True, the mask and galaxy aperture figures are saved.

  • save_mask_params (bool, default True) – If True, the extracted mask parameters are saved into a pickle file.

Returns:

  • **This are only returned if extract_params==True.**

  • gal_obj (array) – Galaxy object.

  • nogal_obj (array) – Non-galaxy objects.

  • img_wcs (WCS) – Image’s WCS.

  • sigma (float, default 8) – Standard deviation in pixel units of the 2D Gaussian kernel used to convolve the image.

  • r (float) – Scale of the aperture size for the sources to be masked.

  • flip (bool) – Whether to flip the orientation of the aperture.

hostphot.image_masking.load_mask_params(name, filt, survey)

Loads previously saved mask parameters.

Parameters:
  • name (str) – Name of the object to find the path of the mask-parameters file.

  • filt (str) – Name of the filter used to create the mask parameters. Coadds are also valid.

  • survey (str) – Survey name to be used.

Returns:

mask_params – Mask paremeters with the same format as the output of the create_mask function.

Return type:

tuple

hostphot.image_masking.mask_image(data, objects, r=6, sigma=20)

Masks objects in an image (2D array) by convolving it with a 2D Gaussian kernel.

Parameters:
  • data (ndarray) – Image data.

  • objects (array) – Objects extracted with sep.extract().

  • r (float, default 6) – Scale of the semi-mayor and semi-minor axes of the ellipse of the objects.

  • sigma (float, default 20) – Standard deviation in pixel units of the 2D Gaussian kernel used to convolve the image.

Returns:

masked_data – Masked image data.

Return type:

2D array

hostphot.image_masking.plot_masked_image(hdu, masked_hdu, objects, gal_obj=None, r=6, host_ra=None, host_dec=None, ra=None, dec=None, title=None, outfile=None)

Plots the masked image together with the original image and the detected objects.

Parameters:
  • data (ndarray) – Image data.

  • masked_data (2D array) – Masked image data.

  • objects (array) – Objects extracted with sep.extract().

  • img_wcs (WCS) – Image’s WCS.

  • gal_obj (array, default None) – Galaxy object.

  • r (float, default 6) – Scale of the aperture size for the masked sources.

  • host_ra (float, default None) – Right ascension of the galaxy, in degrees. Used for plotting the position of the galaxy.

  • host_dec (float, default None) – Declination of the galaxy, in degrees. Used for plotting the position of the galaxy.

  • ra (float, default None) – Right ascension of an object, in degrees. Used for plotting the position of the object.

  • dec (float, default None) – Declination of an object, in degrees. Used for plotting the position of the object.

  • title (str, default None) – Title of the image

  • outfile (str, default None) – If given, path where to save the output figure.