Utils

Other support functions are documented bellow:

hostphot.utils.calc_sky_unc(image, exptime)

Calculates the uncertainty of the image from the sky standard deviation, sigma-clipped STD.

Parameters
  • image (ndarray) – Image in a 2D numpy array.

  • exptime (float) – Exposure time of the image.

Returns

error – Estimated error of the image.

Return type

float

hostphot.utils.pixel2pixel(x1, y1, img_wcs1, img_wcs2)

Convert the pixel coordinates from one image to another.

hostphot.utils.check_survey_validity(survey)

Check whether the given survey is whithin the valid options.

Parameters

survey (str) – Survey name: PS1, DES, SDSS, GALEX, WISE, 2MASS.

hostphot.utils.get_survey_filters(survey)

Gets all the valid filters for the given survey.

Parameters

survey (str) – Survey name: PS1, DES, SDSS, GALEX, WISE, 2MASS.

Returns

filters – Filters for the given survey.

Return type

str

hostphot.utils.survey_zp(survey)

Returns the zero-point for a given survey.

Note: for PS1, an extra \(+2.5*np.log10(exptime)\) needs to be added afterwards.

Parameters

survey (str) – Survey name: PS1, DES, SDSS, GALEX, WISE, 2MASS.

Returns

zp_dict – Zero-points for all the filters in the given survey. If the survey zero-point is different for each image, the string header is returned.

Return type

dict or str

hostphot.utils.get_image_gain(header, survey)

Returns the gain from an image’s header.

Note: for SDSS this is assumed to be one as it should already be included.

Parameters
  • header (fits header) – Header of an image.

  • survey (str) – Survey name: PS1, DES, SDSS, GALEX, WISE, 2MASS.

Returns

gain – Gain value.

Return type

float

hostphot.utils.get_image_readnoise(header, survey)

Returns the read noise from an image’s header. All values are per-pixel values.

Note: for SDSS this is assumed to be zero as it should already be included.

Parameters
  • header (fits header) – Header of an image.

  • survey (str) – Survey name: PS1, DES, SDSS, GALEX, WISE, 2MASS.

Returns

readnoise – Read noise value.

Return type

float

hostphot.utils.get_image_exptime(header, survey)

Returns the exposure time from an image’s header.

Parameters
  • header (fits header) – Header of an image.

  • survey (str) – Survey name: PS1, DES, SDSS, GALEX, WISE, 2MASS.

Returns

exptime – Exposure time in seconds.

Return type

float

hostphot.utils.uncertainty_calc(flux, flux_err, survey, filt=None, ap_area=0.0, header=None, bkg_rms=0.0)

Calculates the uncertainty propagation.

Parameters
  • flux (float) – Aperture flux.

  • survey (str) – Survey name. E.g. PS1, DES, SDSS, GALEX, WISE, etc.

  • filt (str, default None) – Survey-specific filter.

  • ap_area (float, default 0.0) – Aperture area.

  • header (fits header, default None) – Header of an image.

  • bkg_rms (float, default 0.0) – Background noise.

Returns

mag_err – Extra uncertainty in magnitudes.

Return type

float

hostphot.utils.survey_pixel_scale(survey, filt=None)

Returns the pixel scale for a given survey.

Parameters
  • survey (str) – Survey name: PS1, DES, SDSS, GALEX, WISE, 2MASS.

  • filt (str, default None) – Filter to use by surveys that have different pixel scales for different filters (e.g. Spitzer’s IRAC and MIPS instruments).

Returns

pixel_scale – Pixel scale in units of arcsec/pixel.

Return type

float

hostphot.utils.check_filters_validity(filters, survey)

Check whether the given filters are whithin the valid options for the given survey.

Parameters
  • filters (str) – Filters to use, e,g, griz.

  • survey (str) – Survey name: PS1, DES, SDSS, GALEX, WISE, 2MASS.

hostphot.utils.extract_filters(filters, survey, version=None)

Extracts transmission functions.

Parameters
  • filters (str) – Filters to extract.

  • survey (str) – Survey of the filters.

  • version (str) – Version of the filters to use. E.g. for the Legacy Survey as it uses DECam for the south and BASS+MzLS for the north.

Returns

filters_dict – Dictionary with transmission functions and their respective wavelengths.

Return type

dict

hostphot.utils.integrate_filter(spectrum_wave, spectrum_flux, filter_wave, filter_response, response_type='photon')

Calcultes the flux density of an SED given a filter response.

Parameters
  • spectrum_wave (array) – Spectrum’s wavelength range.

  • spectrum_flux (array) – Spectrum’s flux density distribution.

  • filter_wave (array) – Filter’s wavelength range.

  • filter_response (array) – Filter’s response function.

  • response_type (str, default photon) – Filter’s response type. Either photon or energy.

Returns

flux_filter – Flux density.

Return type

float

hostphot.utils.check_work_dir(wokrdir)

Checks if the working directory exists. If it does not, one is created.

Parameters

wokrdir (str) – Working directory path.

hostphot.utils.clean_dir(directory)

Removes the directory if it is empty.

Parameters

directory (str) – Directory path.

hostphot.utils.update_axislabels(ax)

Updates the labels and ticks of a plot.

Parameters

ax (.axes.SubplotBase.) – The axis of a subplot.