opticam_new.reduction.photometers

Classes

BasePhotometer

Base class for performing photometry on OPTICAM catalogues.

SimplePhotometer

A simple photometer that provides simple aperture photometry routines with support for local background estimations

OptimalPhotometer

A photometer that implements the optimal photometry method described in Naylor 1998, MNRAS, 296, 339-346.

Module Contents

class opticam_new.reduction.photometers.BasePhotometer(match_sources=True, source_matching_tolerance=2.0, local_background_estimator=None)

Bases: abc.ABC

Base class for performing photometry on OPTICAM catalogues.

Parameters:
match_sources = True
source_matching_tolerance = 2.0
scale_factor = 1
local_background_estimator = None
abstractmethod compute(image, image_err, source_coords, image_coords, psf_params)

Perform photometry on the given image using the provided source coordinates and PSF parameters. If defining a custom photometer, this method must be implemented. The resulting dictionary must contain ‘flux’ and ‘flux_err’ keys, as well as any additional metrics that the photometer computes. The time stamps for each image are handled by the catalogue, and so they do not need to be included in the results dictionary.

Parameters

imageNDArray

The image. If local_background_estimator is undefined, this image will be background subtracted.

image_errNDArray

The error in the image.

source_coordsNDArray

The source coordinates in the catalogue.

image_coordsNone | 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_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

Dict[str, List]

A dictionary containing the results of the photometry. The dictionary must contain ‘flux’ and ‘flux_error’ keys, as well as any additional metrics that the photometer computes. The time stamps for each image are handled by the catalogue, and so they do not need to be included in the results dictionary.

Parameters:
  • image (numpy.typing.NDArray)

  • image_err (numpy.typing.NDArray)

  • source_coords (numpy.typing.NDArray)

  • image_coords (None | numpy.typing.NDArray)

  • psf_params (Dict[str, float])

Return type:

Dict[str, List]

class opticam_new.reduction.photometers.SimplePhotometer(match_sources=True, source_matching_tolerance=2.0, local_background_estimator=None)

Bases: BasePhotometer

A simple photometer that provides simple aperture photometry routines with support for local background estimations using annuli.

Parameters:
compute(image, image_err, source_coords, image_coords, psf_params)

Compute the simple photometry for the given image using the provided source coordinates and PSF parameters.

Parameters

imageNDArray

The image. If local_background_estimator is undefined, this image will be background subtracted.

image_errNDArray

The error in the image.

source_coordsNDArray

The source coordinates in the catalogue.

image_coordsNone | 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_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

Dict[str, List]

The results of the photometry

Parameters:
  • image (numpy.typing.NDArray)

  • image_err (numpy.typing.NDArray)

  • source_coords (numpy.typing.NDArray)

  • image_coords (None | numpy.typing.NDArray)

  • psf_params (Dict[str, float])

Return type:

Dict[str, List]

compute_aperture_flux(data, error, position, psf_params)

Compute the aperture flux of a source in the image.

Parameters

dataNDArray

The image.

errorNDArray

The error in the image.

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

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:
  • data (numpy.typing.NDArray)

  • error (numpy.typing.NDArray)

  • position (numpy.typing.NDArray)

  • psf_params (Dict[str, float])

Return type:

Tuple[float, float] | Tuple[float, float, float, float]

get_position(source_coords, image_coords, source_index, psf_params)

Get the position of a source in an image.

Parameters

source_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:
  • source_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(source_coords, image_coords, source_index, psf_params)

Given a source, find the closest source in the catalogue.

Parameters

source_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:
  • source_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_error’. If local_background_estimator is defined, the dictionary will also contain ‘background’ and ‘background_error’.

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, 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

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.

image_errNDArray

The error in the image.

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

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)

  • image_err (numpy.typing.NDArray)

  • position (numpy.typing.NDArray)

  • psf_params (Dict[str, float])

Return type:

Dict[str, List]

class opticam_new.reduction.photometers.OptimalPhotometer(match_sources=True, source_matching_tolerance=2.0, local_background_estimator=None)

Bases: SimplePhotometer

A photometer that implements the optimal photometry method described in Naylor 1998, MNRAS, 296, 339-346.

Parameters:
compute(image, image_err, source_coords, image_coords, psf_params)

Compute the optimal photometry for each source in the image using the method described in Naylor 1998, MNRAS, 296, 339-346.

Parameters

imageNDArray

The image. If local_background_estimator is undefined, this image will be background subtracted.

image_errNDArray

The error in the image.

source_coordsNDArray

The source coordinates in the catalogue.

image_coordsNone | 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_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

Dict[str, List]

The results of the photometry, including ‘flux’, ‘flux_error’, and optionally ‘background’ and ‘background_error’ if local_background_estimator is defined.

Parameters:
  • image (numpy.typing.NDArray)

  • image_err (numpy.typing.NDArray)

  • source_coords (numpy.typing.NDArray)

  • image_coords (None | numpy.typing.NDArray)

  • psf_params (Dict[str, float])

Return type:

Dict[str, List]

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

imageNDArray

The image.

errorNDArray

The error in the image.

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

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)

  • error (numpy.typing.NDArray)

  • position (numpy.typing.NDArray)

  • psf_params (Dict[str, float])

Return type:

Tuple[float, float] | Tuple[float, float, float, float]