Global Photometry

Everything related to global photometry is documented bellow:

hostphot.global_photometry.extract_kronparams(name, host_ra, host_dec, filt, survey, ra=None, dec=None, bkg_sub=False, threshold=10, use_mask=True, optimize_kronrad=True, eps=0.0001, gal_dist_thresh=-1, deblend_cont=0.005, save_plots=True, save_aperture_params=True)

Calculates the aperture parameters for common aperture.

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

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

  • host_dec (float) – Host-galaxy declination of the galaxy 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 pixel scale.

  • 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.

  • 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 10) – Threshold used by sep.extract() to extract objects.

  • use_mask (bool, default True) – If True, the masked fits files are used. These must have been created beforehand.

  • optimize_kronrad (bool, default True) – If True, the Kron-radius scale is optimized, increasing the aperture size until the change in flux is less than eps.

  • eps (float, default 0.0001) – The Kron radius is increased until the change in flux is lower than eps. A value of 0.0001 means 0.01% change in flux.

  • 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.

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

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

Returns:

  • gal_obj (array) – Galaxy object.

  • img_wcs (WCS) – Image’s WCS.

  • kronrad (float) – Kron radius.

  • scale (float) – Scale for the Kron radius.

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

hostphot.global_photometry.kron_flux(data, err, gain, objects, kronrad, scale)

Calculates the Kron flux.

Parameters:
  • data (ndarray) – Data of an image.

  • err (float or 2D array) – Background error of the images.

  • gain (float) – Gain value.

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

  • kronrad (float) – Kron radius.

  • scale (float) – Scale of the Kron radius.

Returns:

  • flux (array) – Kron flux.

  • flux_err (array) – Kron flux error.

hostphot.global_photometry.load_aperture_params(name, filt, survey)

Loads previously saved aperture parameters.

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

  • filt (str) – Name of the filter used for the aperture parameters. Coadds are also valid.

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

Returns:

aperture_params – Aperture paremeters with the same format as the output of the extract_kronparams function.

Return type:

tuple

hostphot.global_photometry.multi_band_phot(name, host_ra, host_dec, filters=None, survey='PS1', ra=None, dec=None, bkg_sub=None, threshold=10, use_mask=True, correct_extinction=True, aperture_params=None, common_aperture=True, coadd_filters='riz', optimize_kronrad=True, eps=0.0001, gal_dist_thresh=-1, save_plots=True, save_results=True, raise_exception=True)

Calculates multi-band aperture photometry of the host galaxy for an object.

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

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

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

  • filters (str, default, None) – Filters to use to load the fits files. If None use all the filters of the given survey.

  • survey (str, default PS1) – Survey to use for the zero-points and pixel scale.

  • 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.

  • 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 10) – Threshold used by sep.extract() to extract objects.

  • use_mask (bool, default True) – If True, the masked fits files are used. These must have been created beforehand.

  • correct_extinction (bool, default True) – If True, the magnitudes are corrected for extinction.

  • aperture_params (tuple, default None) – Tuple with objects info and Kron parameters. Used for common aperture. If given, the Kron parameters are not re-calculated. If given, this supersedes the use of coadds for common aperture (common_aperture parameter).

  • common_aperture (bool, default True) – If True, use a coadd image for common aperture photometry. This is not used if aperture_params is given.

  • coadd_filters (str, default riz) – Filters of the coadd image. Used for common aperture photometry.

  • optimize_kronrad (bool, default True) – If True, the Kron-radius scale is optimized, increasing the aperture size until the change in flux is less than eps.

  • eps (float, default 0.0001) – The Kron radius is increased until the change in flux is lower than eps. A value of 0.0001 means 0.01% change in flux. when optimizing the Kron radius.

  • 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).

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

  • save_results (bool, default True) – If True, the magnitudes are saved into a csv file.

  • raise_exception (bool, default True) – If True, an exception is raised if the photometry fails for any filter.

Returns:

results_dict – Dictionary with the object’s photometry and other info.

Return type:

dict

Examples

>>> import hostphot.global_photometry as gp
>>> name = 'SN2004eo'
>>> host_ra, host_dec = 308.2092, 9.92755  # coords of host galaxy of SN2004eo
>>> ra, dec =  308.22579, 9.92853 # coords of SN2004eo
>>> results = gp.multi_band_phot(name, host_ra, host_dec,
                        survey=survey, ra=ra, dec=dec,
                        use_mask=True, common_aperture=True,
                        coadd_filters='riz', save_plots=True)
hostphot.global_photometry.optimize_kron_flux(data, err, gain, objects, eps=0.0001)

Optimizes the Kron flux by iteration over different scales.

The stop condition is met when the change in flux between iterations is less that eps.

Parameters:
  • data (ndarray) – Data of an image.

  • err (float or ndarray) – Background error of the images.

  • gain (float) – Gain value.

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

  • eps (float, default 0.0001 (0.1%)) – Minimum percent change in flux allowed between iterations.

Returns:

  • opt_flux (float) – Optimized Kron flux.

  • opt_flux_err (float) – Optimized Kron flux error.

  • kronrad (float) – Kron radius.

  • opt_scale (float) – Optimized scale for the Kron radius.

hostphot.global_photometry.photometry(name, host_ra, host_dec, filt, survey, ra=None, dec=None, bkg_sub=None, threshold=10, use_mask=True, correct_extinction=True, aperture_params=None, optimize_kronrad=True, eps=0.0001, gal_dist_thresh=-1, deblend_cont=0.005, save_plots=True)

Calculates the global aperture photometry of a galaxy using the Kron flux.

Note: the galaxy must be ideally centred in the image.

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

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

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

  • filt (str) – Filter to use to load the fits file.

  • survey (str) – Survey to use for the zero-points and pixel scale.

  • 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.

  • 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 10) – Threshold used by sep.extract() to extract objects.

  • use_mask (bool, default True) – If True, the masked fits files are used. These must have been created beforehand.

  • correct_extinction (bool, default True) – If True, corrects for Milky-Way extinction using the recalibrated dust maps by Schlafly & Finkbeiner (2011) and the extinction law from Fitzpatrick (1999).

  • aperture_params (tuple, default None) – Tuple with objects info and Kron parameters. Used for common aperture. If given, the Kron parameters are not re-calculated

  • optimize_kronrad (bool, default True) – If True, the Kron-radius scale is optimized, increasing the aperture size until the change in flux is less than eps.

  • eps (float, default 0.0001) – The Kron radius is increased until the change in flux is lower than eps. A value of 0.0001 means 0.01% change in flux.

  • 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.

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

Returns:

  • mag (float) – Aperture magnitude.

  • mag_err (float) – Error on the aperture magnitude.

  • flux (float) – Aperture flux.

  • total_flux_err (float) – Total flux error on the aperture flux.

  • zp (float) – Zeropoint.