mirar.processors.photometry package

Submodules

mirar.processors.photometry.aperture_photometry module

Module with processors to perform aperture photometry

class mirar.processors.photometry.aperture_photometry.AperturePhotometry(*args, aper_diameters: float | list[float] = 10.0, bkg_in_diameters: float | list[float] = 25.0, bkg_out_diameters: float | list[float] = 40.0, col_suffix_list: str | list[str] = None, **kwargs)[source]

Bases: BasePhotometryProcessor

Processor to run aperture photometry on all candidates in candidate table

base_key = 'APERPHOT'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

perform_photometry(image_cutout: array, unc_image_cutout: array) tuple[list[float], list[float]][source]

Perform aperture photometry on a cutout

Parameters:
  • image_cutout – Image cutout

  • unc_image_cutout – Image uncertainty cutout

Returns:

List of fluxes and list of flux uncertainties

mirar.processors.photometry.base_photometry module

Module with classes to perform photometry on sources

class mirar.processors.photometry.base_photometry.BasePhotometryProcessor(phot_cutout_half_size: int = 20, temp_output_sub_dir: str = 'photometry', zp_key: str = 'ZP', zp_std_key: str = 'ZPSTD', img_key: str = 'SAVEPATH', unc_image_key: str = 'UNCPATH', psf_file_key: str = 'NPSFCAT', x_colname: str = 'xpos', y_colname: str = 'ypos', save_cutouts: bool = False)[source]

Bases: BaseSourceProcessor, ABC, ImageHandler

Parent processor to run photometry

generate_cutouts(imagename: Path, unc_imagename: Path, data_item: Image | Series) tuple[ndarray, ndarray][source]

Generate image and uncertainty image cutouts. This function first saves the image and uncertainty image to temporary files, then generates the cutouts, then deletes the temporary files. :param imagename: Path to the image :param unc_imagename: Path to the uncertainty image :param data_item: pandas DataFrame Series or astropy fits Header

Returns tuple:

2D numpy arrays of the image cutout and uncertainty image cutout

get_physical_coordinates(data_item: Series) tuple[int, int][source]

Get the physical coordinates of the source from the data item

Parameters:

data_item – Series from the data table

Returns:

X and Y coordinates of the source

save_temp_image(image) Path[source]

Save a temporary image and return its path

Parameters:

image – Image object

Returns:

Path to the temporary image

save_temp_image_uncimage(metadata: dict) tuple[Path, Path][source]

Function to save the image and uncertainty image to temporary files

Parameters:

metadata – Metadata dictionary

Returns:

Tuple of image and uncertainty image filenames

save_uncertainty_image(image: Image) Path[source]

Create an uncertainty image from the image and return the filenames of the image and uncertainty image

Parameters:

image – Image object

Returns:

Path to the uncertainty image

mirar.processors.photometry.psf_photometry module

Module with processors to perform point-spread-function photometry

class mirar.processors.photometry.psf_photometry.PSFPhotometry(phot_cutout_half_size: int = 20, temp_output_sub_dir: str = 'photometry', zp_key: str = 'ZP', zp_std_key: str = 'ZPSTD', img_key: str = 'SAVEPATH', unc_image_key: str = 'UNCPATH', psf_file_key: str = 'NPSFCAT', x_colname: str = 'xpos', y_colname: str = 'ypos', save_cutouts: bool = False)[source]

Bases: BasePhotometryProcessor

Processor to run PSF photometry on a source table

base_key = 'PSFPHOT'
description() str[source]

Return a description of the processor

Returns:

A description of the processor

get_psf_filename(row)[source]

Function to get the name of psf file Args:

row: row of a pandas Dataframe

Returns:

perform_photometry(image_cutout: ndarray, unc_image_cutout: ndarray, psf_filename: str | Path) tuple[float, float, float, float, float][source]

Function to perform PSF photometry on a cutout :param image_cutout: cutout of image :param unc_image_cutout: cutout of uncertainty image :param psf_filename: filename of psf file :return: flux, fluxunc, minchi2, xshift, yshift

mirar.processors.photometry.utils module

Module with utis for photometry

exception mirar.processors.photometry.utils.CutoutError[source]

Bases: ProcessorError

Error raised when cutout generation fails

mirar.processors.photometry.utils.aper_photometry(image_cutout: ndarray, image_unc_cutout: ndarray, aper_diameter: float, bkg_in_diameter: float, bkg_out_diameter: float, plot: bool = False, plotfilename: str = None)[source]

Perform aperture photometry Args:

param:

image_cutout: np.ndarray of the image cutout

param:

image_unc_cutout: np.ndarray of the image uncertainty cutout

param:

aper_diameter: aperture diameter in pixels

param:

bkg_in_diameter: inner background annulus diameter in pixels

param:

bkg_out_diameter: outer background annulus diameter in pixels

param:

plot: whether to plot the cutout

param:

plotfilename: filename to save plot to

Returns:
return:

aperture flux, aperture flux uncertainty

mirar.processors.photometry.utils.get_mags_from_fluxes(flux_list: ndarray[float], fluxunc_list: ndarray[float], zeropoint: float, zeropoint_unc: float) tuple[ndarray, ndarray][source]

Convert fluxes and flux uncertainties to magnitudes and magnitude uncertainties

Parameters:
  • flux_list – List of fluxes

  • fluxunc_list – List of flux uncertainties

  • zeropoint – Zeropoint

  • zeropoint_unc – Zeropoint uncertainties

Returns:

magnitudes, magnitude uncertainties

mirar.processors.photometry.utils.get_rms_image(image: Image) Image[source]

Get an RMS image from a regular image

Parameters:
  • image – An Image

  • rms – rms of the image

Returns:

An RMS Image

mirar.processors.photometry.utils.make_cutouts(image_paths: Path | list[Path], position: tuple, half_size: int) list[array][source]

Function to make cutouts Args:

param:

image_paths: Path or list of paths to the images

param:

position: (x,y) coordinates of the center of the cutouts

param:

half_size: half_size of the square cutouts

Returns:
return:

cutout_list: list of 2D numpy arrays

mirar.processors.photometry.utils.make_psf_shifted_array(psf_filename: str, cutout_size_psf_phot: int = 20, pad_psf_size: int = 60)[source]

Function to make a shifted array from a PSF model Args:

psf_filename: cutout_size_psf_phot: pad_psf_size:

Returns:

mirar.processors.photometry.utils.psf_photometry(image_cutout: ndarray, image_unc_cutout: ndarray, psfmodels: ndarray) tuple[float, float, float, float, float, ndarray][source]

Function to perform PSF photometry Args:

param:

image_cutout: 2D numpy array of the image cutout

param:

image_unc_cutout: 2D numpy array of the image uncertainty cutout

param:

psfmodels: 3D numpy array of the PSF models

Returns:
return:

psf_fluxes: PSF flux

return:

psf_flux_uncs: PSF flux uncertainty

return:

chi2s: chi2 value

return xshifts:

xshift required to match PSF to the source

return yshifts:

yshift required to match PSF to the source