GriddedPSFModel

class photutils.psf.GriddedPSFModel(nddata, *, flux=1.0, x_0=0.0, y_0=0.0, fill_value=0.0)[source]

Bases: ModelGridPlotMixin, Fittable2DModel

A fittable 2D model containing a grid ePSF models.

The ePSF models are defined at fiducial detector locations and are bilinearly interpolated to calculate an ePSF model at an arbitrary (x, y) detector position.

When evaluating this model, it cannot be called with x and y arrays that have greater than 2 dimensions.

Parameters:
nddataNDData

A NDData object containing the grid of reference ePSF arrays. The data attribute must contain a 3D ndarray containing a stack of the 2D ePSFs with a shape of (N_psf, ePSF_ny, ePSF_nx).

The meta attribute must be dict containing the following:

  • 'grid_xypos': A list of the (x, y) grid positions of each reference ePSF. The order of positions should match the first axis of the 3D ndarray of ePSFs. In other words, grid_xypos[i] should be the (x, y) position of the reference ePSF defined in data[i].

  • 'oversampling': The integer oversampling factor(s) of the ePSF. If oversampling is a scalar then it will be used for both axes. If oversampling has two elements, they must be in (y, x) order.

The meta attribute may contain other properties such as the telescope, instrument, detector, and filter of the ePSF.

Notes

Internally, the grid of ePSFs will be arranged and stored such that it is sorted first by y and then by x.

Methods

read(*args, **kwargs)

Class method to create a GriddedPSFModel instance from a STDPSF FITS file. This method uses stdpsf_reader() with the provided parameters.

Attributes Summary

flux

param_names

Names of the parameters that describe models of this type.

read

Read and parse a FITS file into a GriddedPSFModel instance.

x_0

y_0

Methods Summary

clear_cache()

Clear the internal cache.

copy()

Return a copy of this model where only the model parameters are copied.

deepcopy()

Return a deep copy of this model.

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

Evaluate the GriddedPSFModel for the input parameters.

Attributes Documentation

flux = Parameter('flux', value=1.0)
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.

read

Read and parse a FITS file into a GriddedPSFModel instance.

This class enables the astropy unified I/O layer for GriddedPSFModel. This allows easily reading a file in different supported data formats using syntax such as:

>>> from photutils.psf import GriddedPSFModel
>>> psf_model = GriddedPSFModel.read('filename.fits', format=format)

Get help on the available readers for GriddedPSFModel using the help() method:

>>> # Get help reading Table and list supported formats
>>> GriddedPSFModel.read.help()

>>> # Get detailed help on the STSPSF FITS reader
>>> GriddedPSFModel.read.help('stdpsf')

>>> # Get detailed help on the WebbPSF FITS reader
>>> GriddedPSFModel.read.help('webbpsf')

>>> # Print list of available formats
>>> GriddedPSFModel.read.list_formats()
Parameters:
*argstuple, optional

Positional arguments passed through to data reader. If supplied the first argument is typically the input filename.

formatstr

File format specifier.

**kwargsdict, optional

Keyword arguments passed through to data reader.

Returns:
outGriddedPSFModel

A gridded ePSF model corresponding to FITS file contents.

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

Methods Documentation

clear_cache()[source]

Clear the internal cache.

copy()[source]

Return a copy of this model where only the model parameters are copied.

All other copied model attributes are references to the original model. This prevents copying the ePSF grid data, which may contain a large array.

This method is useful if one is interested in only changing the model parameters in a model copy. It is used in the PSF photometry classes during model fitting.

Use the deepcopy method if you want to copy all of the model attributes, including the ePSF grid data.

deepcopy()[source]

Return a deep copy of this model.

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

Evaluate the GriddedPSFModel for the input parameters.