opticam.photometers =================== .. py:module:: opticam.photometers Classes ------- .. autoapisummary:: opticam.photometers.BasePhotometer opticam.photometers.AperturePhotometer opticam.photometers.OptimalPhotometer Functions --------- .. autoapisummary:: opticam.photometers.perform_photometry opticam.photometers.get_growth_curve Module Contents --------------- .. py:class:: BasePhotometer(forced = False, source_matching_tolerance = 5.0, local_background_estimator = None) Bases: :py:obj:`abc.ABC` Base class for performing photometry on OPTICAM catalogues. .. py:attribute:: forced :value: False .. py:attribute:: source_matching_tolerance :value: 5.0 .. py:attribute:: local_background_estimator :value: None .. py:method:: compute(image, image_err, source_coords, image_coords, psf_params) :abstractmethod: Compute the fluxes of the catalogued sources from the given image. Parameters ---------- image : NDArray The image. If `local_background_estimator` is undefined, this image will be background subtracted. image_err : NDArray The error in the image. source_coords : NDArray The source coordinates in the catalogue. image_coords : None | NDArray The source coordinates in the image. If `match_sources` is True, this will be used to match sources in the image to sources in the catalogue. psf_params : Dict[str, float] The PSF parameters for the camera used to take the image. This parameter is defined in the catalogue and has the following keys: 'semimajor_sigma' (in pixels), 'semiminor_sigma' (in pixels), and 'orientation' (in *degrees*). Returns ------- Dict[str, List] The photometry results. .. py:method:: get_position(source_coords, image_coords, source_index, psf_params) Get the position of a source in an image. Parameters ---------- source_coords : NDArray The source coordinates in the catalogue. image_coords : NDArray | None The source coordinates in the image. source_index : int The source index. psf_params : Dict[str, float] The PSF parameters for the camera used to take the image. This parameter is defined in the catalogue and has the following keys: 'semimajor_sigma' (in pixels), 'semiminor_sigma' (in pixels), and 'orientation' (in *degrees*). Returns ------- NDArray The source coordinates. .. py:method:: get_closest_source(source_coords, image_coords, source_index, psf_params) Given a source, find the closest source in the catalogue. Parameters ---------- source_coords : NDArray The source coordinates in the catalogue. image_coords : NDArray | None The source coordinates in the image. source_index : int The source index. psf_params : Dict[str, float] The PSF parameters for the camera used to take the image. This parameter is defined in the catalogue and has the following keys: 'semimajor_sigma' (in pixels), 'semiminor_sigma' (in pixels), and 'orientation' (in *degrees*). Returns ------- NDArray | None The coordinates of the closest source. .. py:method:: define_results_dict() Define a results dictionary for the photometer depending on whether `local_background_estimator` is defined. Returns ------- Dict[str, List] The results dictionary with keys 'flux', 'flux_error'. If `local_background_estimator` is defined, the dictionary will also contain 'background' and 'background_error'. .. py:method:: pad_results_dict(results) Pad the results dictionary with None values for flux and flux error, and background and background error if `local_background_estimator' is defined. This is used when a source cannot be matched or its position is invalid. Parameters ---------- results : Dict[str, List] The results dictionary to pad. Returns ------- Dict[str, List] The padded results dictionary. .. py:method:: populate_results_dict(results, phot_function, image, image_err, position, psf_params) Populate the results dictionary with the computed flux, flux error, and background (if applicable) using the provided photometry function. Parameters ---------- results : Dict[str, List] The results dictionary to populate. phot_function : Callable The photometry function to use for computing the flux and flux error. This function should take the image, image error, position, and PSF parameters as arguments and return the flux and flux error, and optionally the background and background error if `local_background_estimator` is defined. image : NDArray The image. image_err : NDArray The error in the image. position : NDArray The position of the source in the image. psf_params : Dict[str, float] The PSF parameters for the camera used to take the image. This parameter is defined in the catalogue and has the following keys: 'semimajor_sigma' (in pixels), 'semiminor_sigma' (in pixels), and 'orientation' (in *degrees*). Returns ------- Dict[str, List] The updated results dictionary with the computed flux, flux error, and background (if applicable). .. py:class:: AperturePhotometer(semimajor_axis = None, semiminor_axis = None, orientation = None, forced = False, source_matching_tolerance = 5.0, local_background_estimator = None) Bases: :py:obj:`BasePhotometer` A photometer for performing aperture photometry. .. py:attribute:: semimajor_axis :value: None .. py:attribute:: semiminor_axis :value: None .. py:attribute:: orientation :value: None .. py:method:: compute(image, image_err, source_coords, image_coords, psf_params) Compute the fluxes of the catalogued sources from the given image. Parameters ---------- image : NDArray The image. If `local_background_estimator` is undefined, this image will be background subtracted. image_err : NDArray The error in the image. source_coords : NDArray The source coordinates in the catalogue. image_coords : None | NDArray The source coordinates in the image. If `match_sources` is True, this will be used to match sources in the image to sources in the catalogue. psf_params : Dict[str, float] The PSF parameters for the camera used to take the image. This parameter is defined in the catalogue and has the following keys: 'semimajor_sigma' (in pixels), 'semiminor_sigma' (in pixels), and 'orientation' (in *degrees*). Returns ------- Dict[str, List] The photometry results. .. py:method:: compute_aperture_flux(data, error, position, psf_params) Compute the aperture flux of a source in the image. Parameters ---------- data : NDArray The image. error : NDArray The error in the image. position : NDArray The position of the source. psf_params : Dict[str, float] The PSF parameters for the camera used to take the image. This parameter is defined in the catalogue and has the following keys: 'semimajor_sigma' (in pixels), 'semiminor_sigma' (in pixels), and 'orientation' (in *degrees*). Returns ------- Tuple[float, float] | Tuple[float, float, float, float] The flux and flux error. If `local_background_estimator` is defined, the background and its error are also returned. .. py:class:: OptimalPhotometer(forced = False, source_matching_tolerance = 5.0, local_background_estimator = None) Bases: :py:obj:`BasePhotometer` A photometer that implements the optimal photometry method described in Naylor 1998, MNRAS, 296, 339-346. .. py:method:: compute(image, image_err, source_coords, image_coords, psf_params) Compute the fluxes of the catalogued sources from the given image. Parameters ---------- image : NDArray The image. If `local_background_estimator` is undefined, this image will be background subtracted. image_err : NDArray The error in the image. source_coords : NDArray The source coordinates in the catalogue. image_coords : None | NDArray The source coordinates in the image. If `match_sources` is True, this will be used to match sources in the image to sources in the catalogue. psf_params : Dict[str, float] The PSF parameters for the camera used to take the image. This parameter is defined in the catalogue and has the following keys: 'semimajor_sigma' (in pixels), 'semiminor_sigma' (in pixels), and 'orientation' (in *degrees*). Returns ------- Dict[str, List] The photometry results. .. py:method:: compute_optimal_flux(image, error, position, psf_params) Compute the optimal flux of a source in the image as described in Naylor 1998, MNRAS, 296, 339-346. Parameters ---------- image : NDArray The image. error : NDArray The error in the image. position : NDArray The position of the source in the image, given as (y, x) coordinates. psf_params : Dict[str, float] The PSF parameters for the camera used to take the image. This parameter is defined in the catalogue and has the following keys: 'semimajor_sigma' (in pixels), 'semiminor_sigma' (in pixels), and 'orientation' (in *degrees*). Returns ------- Tuple[float, float] | Tuple[float, float, float, float] The flux and flux error. If `local_background_estimator` is defined, the background and its error are also returned. .. py:function:: perform_photometry(file, photometer, source_coords, gains, bmjds, barycenter, flat_corrector, rebin_factor, remove_cosmic_rays, background, threshold, finder, psf_params, fltr, logger) Perform photometry on a file. Parameters ---------- file : str The file path. photometer : BasePhotometer The photometer to use. source_coords : NDArray The coordinates of the sources. gains : Dict[str, float] The image gain. bmjds : Dict[str, float] The image time stamps. barycenter : bool Whether to apply a barycentric correction to the image time stamps. flat_corrector : FlatFieldCorrector | None The flat field corrector. rebin_factor : int The software pixel rebinning factor. remove_cosmic_rays : bool Whether to remove cosmic rays from the image. background : BaseBackground The two-dimensional background estimator. threshold : float The scalar source detection threshold in units of background RMS. finder : DefaultFinder The source finder. psf_params : Dict[str, Dict[str, float]] The PSF parameters. fltr : str The image filter. logger : Logger The logger. Returns ------- Dict[str, List] The photometry results. .. py:function:: get_growth_curve(image, x_centroid, y_centroid, r_max) Compute the growth curve for a point in an image. Parameters ---------- image : NDArray The image. x_centroid : float The x centroid of the point. y_centroid : float The y centroid of the point. r_max : int The maximum radius in pixels. Returns ------- Tuple[NDArray, NDArray] _description_