DiscretePRF

class photutils.psf.sandbox.DiscretePRF(prf_array, normalize=True, subsampling=1)[source]

Bases: astropy.modeling.Fittable2DModel

A discrete Pixel Response Function (PRF) model.

The discrete PRF model stores images of the PRF at different subpixel positions or offsets as a lookup table. The resolution is given by the subsampling parameter, which states in how many subpixels a pixel is divided.

In the typical case of wanting to create a PRF from an image with many point sources, use the create_from_image method, rather than directly initializing this class.

The discrete PRF model class in initialized with a 4 dimensional array, that contains the PRF images at different subpixel positions. The definition of the axes is as following:

  1. Axis: y subpixel position

  2. Axis: x subpixel position

  3. Axis: y direction of the PRF image

  4. Axis: x direction of the PRF image

The total array therefore has the following shape (subsampling, subsampling, prf_size, prf_size)

Parameters
prf_arrayndarray

Array containing PRF images.

normalizebool

Normalize PRF images to unity. Equivalent to saying there is no flux outside the bounds of the PRF images.

subsamplingint, optional

Factor of subsampling. Default = 1.

Notes

See Terminology for more details on the distinction between PSF and PRF as used in this module.

Attributes Summary

flux

param_names

Names of the parameters that describe models of this type.

prf_shape

Shape of the PRF image.

x_0

y_0

Methods Summary

create_from_image(imdata, positions, size[, …])

Create a discrete point response function (PRF) from image data.

evaluate(x, y, flux, x_0, y_0)

Discrete PRF model evaluation.

Attributes Documentation

flux = Parameter('flux', value=nan)
param_names = ('flux', 'x_0', 'y_0')

Names of the parameters that describe models of this type.

The parameters in this tuple are in the same order they should be passed in when initializing a model of a specific type. Some types of models, such as polynomial models, have a different number of parameters depending on some other property of the model, such as the degree.

When defining a custom model class the value of this attribute is automatically set by the Parameter attributes defined in the class body.

prf_shape

Shape of the PRF image.

x_0 = Parameter('x_0', value=nan)
y_0 = Parameter('y_0', value=nan)

Methods Documentation

classmethod create_from_image(imdata, positions, size, fluxes=None, mask=None, mode='mean', subsampling=1, fix_nan=False)[source]

Create a discrete point response function (PRF) from image data.

Given a list of positions and size this function estimates an image of the PRF by extracting and combining the individual PRFs from the given positions.

NaN values are either ignored by passing a mask or can be replaced by the mirrored value with respect to the center of the PRF.

Note that if fluxes are not specified explicitly, it will be flux estimated from an aperture of the same size as the PRF image. This does not account for aperture corrections so often will not be what you want for anything other than quick-look needs.

Parameters
imdataarray

Data array with the image to extract the PRF from

positionsList or array or Table

List of pixel coordinate source positions to use in creating the PRF. If this is a Table it must have columns called x_0 and y_0.

sizeodd int

Size of the quadratic PRF image in pixels.

maskbool array, optional

Boolean array to mask out bad values.

fluxesarray, optional

Object fluxes to normalize extracted PRFs. If not given (or None), the flux is estimated from an aperture of the same size as the PRF image.

mode{‘mean’, ‘median’}
One of the following modes to combine the extracted PRFs:
  • ‘mean’: Take the pixelwise mean of the extracted PRFs.

  • ‘median’: Take the pixelwise median of the extracted PRFs.

subsamplingint

Factor of subsampling of the PRF (default = 1).

fix_nanbool

Fix NaN values in the data by replacing it with the mirrored value. Assuming that the PRF is symmetrical.

Returns
prfphotutils.psf.sandbox.DiscretePRF

Discrete PRF model estimated from data.

evaluate(x, y, flux, x_0, y_0)[source]

Discrete PRF model evaluation.

Given a certain position and flux the corresponding image of the PSF is chosen and scaled to the flux. If x and y are outside the boundaries of the image, zero will be returned.

Parameters
xfloat

x coordinate array in pixel coordinates.

yfloat

y coordinate array in pixel coordinates.

fluxfloat

Model flux.

x_0float

x position of the center of the PRF.

y_0float

y position of the center of the PRF.