opticam.photometers
Classes
Base class for performing photometry on OPTICAM catalogues. |
|
A photometer for performing aperture photometry. |
|
A photometer that implements the optimal photometry method described in Naylor 1998, MNRAS, 296, 339-346. |
Functions
|
Compute the optimal weight for each pixel in an image. |
|
Compute the optimal flux and its error. |
|
Compute the growth curve for a point in an image. |
Module Contents
- class opticam.photometers.BasePhotometer(forced=False, source_matching_tolerance=5.0, local_background_estimator=None)
Bases:
abc.ABCBase class for performing photometry on OPTICAM catalogues.
- Parameters:
forced (bool)
source_matching_tolerance (float)
local_background_estimator (opticam.background.local_background.BaseLocalBackground | Callable | None)
- forced = False
- source_matching_tolerance = 5.0
- local_background_estimator = None
- abstractmethod compute(image, bias_var, dark_var, flat_var, background_rms, cat_coords, image_coords, psf_params, read_noise)
Compute the fluxes of the catalogued sources from the given image.
Parameters
- imageNDArray
The image. If self.local_background_estimator is undefined, this image will be background subtracted.
- bias_varfloat | NDArray
The bias correction variance term.
- dark_varfloat | NDArray
The dark noise correction variance term.
- flat_varfloat | NDArray
The flat-field correction variance term.
- background_rmsNDArray | None
The background RMS. May be None if self.local_background_estimator is defined.
- cat_coordsNDArray
The source coordinates in the catalogue.
- image_coordsNDArray | None
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_paramsDict[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).
- read_noisefloat
The detector’s read noise.
Returns
- Dict[str, List]
The photometry results.
- Parameters:
image (numpy.typing.NDArray)
bias_var (float | numpy.typing.NDArray)
dark_var (float | numpy.typing.NDArray)
flat_var (float | numpy.typing.NDArray)
background_rms (numpy.typing.NDArray | None)
cat_coords (numpy.typing.NDArray)
image_coords (numpy.typing.NDArray | None)
psf_params (Dict[str, float])
read_noise (float)
- Return type:
Dict[str, List]
- get_position(cat_coords, image_coords, source_index, psf_params)
Get the position of a source in an image.
Parameters
- cat_coordsNDArray
The source coordinates in the catalogue.
- image_coordsNDArray | None
The source coordinates in the image.
- source_indexint
The source index.
- psf_paramsDict[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.
- Parameters:
cat_coords (numpy.typing.NDArray)
image_coords (numpy.typing.NDArray | None)
source_index (int)
psf_params (Dict[str, float])
- Return type:
numpy.typing.NDArray | None
- get_closest_source(cat_coords, image_coords, source_index, psf_params)
Given a source, find the closest source in the catalogue.
Parameters
- cat_coordsNDArray
The source coordinates in the catalogue.
- image_coordsNDArray | None
The source coordinates in the image.
- source_indexint
The source index.
- psf_paramsDict[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.
- Parameters:
cat_coords (numpy.typing.NDArray)
image_coords (numpy.typing.NDArray | None)
source_index (int)
psf_params (Dict[str, float])
- Return type:
numpy.typing.NDArray | None
- 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_err’. If local_background_estimator is defined, the dictionary will also contain ‘bkg’ and ‘bkg_err’.
- Return type:
Dict[str, List]
- 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
- resultsDict[str, List]
The results dictionary to pad.
Returns
- Dict[str, List]
The padded results dictionary.
- Parameters:
results (Dict[str, List])
- Return type:
Dict[str, List]
- populate_results_dict(results, phot_function, image, bias_var, dark_var, flat_var, background_rms, position, psf_params, read_noise)
Populate the results dictionary with the computed flux, flux error, and background (if applicable) using the provided photometry function.
Parameters
- resultsDict[str, List]
The results dictionary to populate.
- phot_functionCallable
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.
- imageNDArray
The image.
- bias_varfloat | NDArray
The bias correction variance term.
- dark_varfloat | NDArray
The dark noise correction variance term.
- flat_varfloat | NDArray
The flat-field correction variance term.
- background_rmsNDArray | None
The background RMS. May be None if self.local_background_estimator is defined.
- positionNDArray
The position of the source in the image.
- psf_paramsDict[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).
- read_noisefloat
The detector’s read noise.
Returns
- Dict[str, List]
The updated results dictionary with the computed flux, flux error, and background (if applicable).
- Parameters:
results (Dict[str, List])
phot_function (Callable)
image (numpy.typing.NDArray)
bias_var (float | numpy.typing.NDArray[numpy.float64])
dark_var (float | numpy.typing.NDArray[numpy.float64])
flat_var (float | numpy.typing.NDArray[numpy.float64])
background_rms (numpy.typing.NDArray | None)
position (numpy.typing.NDArray)
psf_params (Dict[str, float])
read_noise (float)
- Return type:
Dict[str, List]
- class opticam.photometers.AperturePhotometer(semimajor_axis=None, semiminor_axis=None, orientation=None, forced=False, source_matching_tolerance=5.0, local_background_estimator=None)
Bases:
BasePhotometerA photometer for performing aperture photometry.
- Parameters:
semimajor_axis (int | None)
semiminor_axis (int | None)
orientation (float | None)
forced (bool)
source_matching_tolerance (float)
local_background_estimator (None | opticam.background.local_background.BaseLocalBackground)
- semimajor_axis = None
- semiminor_axis = None
- orientation = None
- compute(image, bias_var, dark_var, flat_var, background_rms, cat_coords, image_coords, psf_params, read_noise)
Compute the fluxes of the catalogued sources from the given image.
Parameters
- imageNDArray
The image. If self.local_background_estimator is undefined, this image will be background subtracted.
- bias_varfloat | NDArray
The bias correction variance term.
- dark_varfloat | NDArray
The dark noise correction variance term.
- flat_varfloat | NDArray
The flat-field correction variance term scaled by the square of the calibrated image.
- background_rmsNDArray | None
The background RMS. May be None if self.local_background_estimator is defined.
- cat_coordsNDArray
The source coordinates in the catalogue.
- image_coordsNDArray | None
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_paramsDict[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).
- read_noisefloat
The detector’s read noise.
Returns
- Dict[str, List]
The photometry results.
- Parameters:
image (numpy.typing.NDArray)
bias_var (float | numpy.typing.NDArray)
dark_var (float | numpy.typing.NDArray)
flat_var (float | numpy.typing.NDArray)
background_rms (numpy.typing.NDArray | None)
cat_coords (numpy.typing.NDArray)
image_coords (numpy.typing.NDArray | None)
psf_params (Dict[str, float])
read_noise (float)
- Return type:
Dict[str, List]
- compute_aperture_flux(image, bias_var, dark_var, flat_var, background_rms, position, psf_params, read_noise)
Compute the aperture flux of a source in the image.
Parameters
- imageNDArray
The image.
- bias_varfloat | NDArray
The bias correction variance term.
- dark_varfloat | NDArray
The dark noise correction variance term.
- flat_varfloat | NDArray
The flat-field correction variance term scaled by the square of the calibrated image.
- background_rmsNDArray | None
The background RMS. May be None if self.local_background_estimator is defined.
- positionNDArray
The position of the source.
- psf_paramsDict[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).
- read_noisefloat
The instrument’s read noise.
Returns
- Tuple[float, float] | Tuple[float, float, float, float, float]
The flux and its error. If local_background_estimator is defined, the local background and its error are also returned.
- Parameters:
image (numpy.typing.NDArray)
bias_var (float | numpy.typing.NDArray)
dark_var (float | numpy.typing.NDArray)
flat_var (float | numpy.typing.NDArray)
background_rms (numpy.typing.NDArray | None)
position (numpy.typing.NDArray)
psf_params (Dict[str, float])
read_noise (float)
- Return type:
Tuple[float, float] | Tuple[float, float, float, float]
- get_aperture(position, psf_params)
- Parameters:
position (numpy.typing.NDArray)
psf_params (Dict[str, float])
- Return type:
photutils.aperture.EllipticalAperture
- class opticam.photometers.OptimalPhotometer(forced=False, source_matching_tolerance=5.0, local_background_estimator=None)
Bases:
BasePhotometerA photometer that implements the optimal photometry method described in Naylor 1998, MNRAS, 296, 339-346.
- Parameters:
forced (bool)
source_matching_tolerance (float)
local_background_estimator (opticam.background.local_background.BaseLocalBackground | Callable | None)
- compute(image, bias_var, dark_var, flat_var, background_rms, cat_coords, image_coords, psf_params, read_noise)
Compute the fluxes of the catalogued sources from the given image.
Parameters
- imageNDArray
The image. If self.local_background_estimator is undefined, this image will be background subtracted.
- bias_varfloat | NDArray
The bias correction variance term.
- dark_varfloat | NDArray
The dark noise correction variance term.
- flat_varfloat | NDArray
The flat-field correction variance term scaled by the square of the calibrated image.
- background_rmsNDArray | None
The background RMS. May be None if self.local_background_estimator is defined.
- cat_coordsNDArray
The source coordinates in the catalogue.
- image_coordsNDArray | None
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_paramsDict[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).
- read_noisefloat
The detector’s read noise.
Returns
- Dict[str, List]
The photometry results.
- Parameters:
image (numpy.typing.NDArray)
bias_var (float | numpy.typing.NDArray[numpy.float64])
dark_var (float | numpy.typing.NDArray[numpy.float64])
flat_var (float | numpy.typing.NDArray[numpy.float64])
background_rms (numpy.typing.NDArray | None)
cat_coords (numpy.typing.NDArray)
image_coords (numpy.typing.NDArray | None)
psf_params (Dict[str, float])
read_noise (float)
- Return type:
Dict[str, List]
- compute_optimal_flux(image, bias_var, dark_var, flat_var, background_rms, position, psf_params, read_noise)
Compute the optimal flux of a source in the image as described in Naylor 1998, MNRAS, 296, 339-346.
Parameters
- imageNDArray
The image.
- bias_varfloat | NDArray
The bias correction variance term.
- dark_varfloat | NDArray
The dark noise correction variance term.
- flat_varfloat | NDArray
The flat-field correction variance term scaled by the square of the calibrated image.
- background_rmsNDArray | None
The background RMS. May be None if self.local_background_estimator is defined.
- positionNDArray
The position of the source in the image, given as (y, x) coordinates.
- psf_paramsDict[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).
- read_noisefloat
The instrument’s read noise.
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.
- Parameters:
image (numpy.typing.NDArray)
bias_var (float | numpy.typing.NDArray[numpy.float64])
dark_var (float | numpy.typing.NDArray[numpy.float64])
flat_var (float | numpy.typing.NDArray[numpy.float64])
background_rms (numpy.typing.NDArray | None)
position (numpy.typing.NDArray)
psf_params (Dict[str, float])
read_noise (float)
- Return type:
Tuple[float, float] | Tuple[float, float, float, float]
- opticam.photometers.get_optimal_weights(var, position, psf_major, psf_minor, psf_orientation)
Compute the optimal weight for each pixel in an image.
Parameters
- varNDArray[np.float64]
The variance image.
- positionNDArray[np.float64]
The position of the source.
- psf_majorfloat
The semi-major axis of the PSF.
- psf_minorfloat
The semi-minor axis of the PSF.
- psf_orientationfloat
The orientation of the PSF in degrees.
Returns
- Tuple[NDArray[np.float64], float]
The weights and the normalisation constant.
- Parameters:
var (numpy.typing.NDArray[numpy.float64])
position (numpy.typing.NDArray[numpy.float64])
psf_major (float)
psf_minor (float)
psf_orientation (float)
- Return type:
Tuple[numpy.typing.NDArray[numpy.float64], float]
- opticam.photometers.get_optimal_flux_and_error(image, bias_var, dark_var, flat_var, background_rms, read_noise, position, psf_params)
Compute the optimal flux and its error.
Parameters
- imageNDArray[np.float64]
The background-subtracted image.
- bias_varfloat | NDArray
The bias correction variance term.
- dark_varfloat | NDArray
The dark noise correction variance term.
- flat_varfloat | NDArray
The flat-field correction variance term scaled by the square of the calibrated image.
- background_rmsfloat | NDArray[np.float64]
The background RMS. May be a scalar value or an NDArray with the same shape as image.
- read_noisefloat
The instrument’s read noise.
- positionNDArray[np.float64]
The source position [x, y].
- psf_paramsDict[str, float]
The PSF parameters.
Returns
- Tuple[float, float]
The flux and its corresponding error.
- Parameters:
image (numpy.typing.NDArray[numpy.float64])
bias_var (float | numpy.typing.NDArray[numpy.float64])
dark_var (float | numpy.typing.NDArray[numpy.float64])
flat_var (float | numpy.typing.NDArray[numpy.float64])
background_rms (float | numpy.typing.NDArray[numpy.float64])
read_noise (float)
position (numpy.typing.NDArray[numpy.float64])
psf_params (Dict[str, float])
- Return type:
Tuple[float, float]
- opticam.photometers.get_growth_curve(image, x_centroid, y_centroid, r_max)
Compute the growth curve for a point in an image.
Parameters
- imageNDArray
The image.
- x_centroidfloat
The x centroid of the point.
- y_centroidfloat
The y centroid of the point.
- r_maxint
The maximum radius in pixels.
Returns
- Tuple[NDArray, NDArray]
_description_
- Parameters:
image (numpy.typing.NDArray)
x_centroid (float)
y_centroid (float)
r_max (int)
- Return type:
Tuple[numpy.typing.NDArray, numpy.typing.NDArray]