EffectivePSF

class grizli.utils.EffectivePSF[source]

Bases: object

Tools for handling WFC3/IR Effective PSF

See documentation at http://www.stsci.edu/hst/wfc3/analysis/PSF.

PSF files stored in $GRIZLI/CONF/

Methods Summary

eval_ePSF(psf_xy, dx, dy[, extended_data])

Evaluate PSF at dx,dy coordinates

fit_ePSF(sci[, center, origin, ivar, N, ...])

Fit ePSF to input data

get_at_position([x, y, filter, rot90])

Evaluate ePSF at detector coordinates

get_ePSF(psf_params[, sci, ivar, origin, ...])

Evaluate an Effective PSF

load_PSF_data()

Load data from PSFSTD files

objective_epsf(params, self, psf_xy, sci, ...)

Objective function for fitting ePSFs

objective_epsf_center(params, self, psf_xy, ...)

Objective function for fitting ePSF centers

Methods Documentation

eval_ePSF(psf_xy, dx, dy, extended_data=None)[source]

Evaluate PSF at dx,dy coordinates

Parameters
psf_xynumpy.ndarray

The PSF data.

dxnumpy.ndarray

The x-coordinates of the evaluation points.

dynumpy.ndarray

The y-coordinates of the evaluation points.

rot90int, optional

The rotation angle in degrees, by default 0.

extended_datanumpy.ndarray, optional

Extended PSF data, by default None.

Returns
numpy.ndarray

The evaluated PSF values at the given coordinates.

fit_ePSF(sci, center=None, origin=[0, 0], ivar=1, N=7, filter='F140W', tol=0.0001, guess=None, get_extended=False, method='lm', ds9=None, psf_params=None, only_centering=True, rot90=0)[source]

Fit ePSF to input data

Parameters
scinumpy.ndarray

The input data to fit the ePSF to.

centertuple, optional

The center coordinates of the ePSF. If not provided, the center is calculated as the center of the input data.

originlist, optional

The origin coordinates of the ePSF.

ivarfloat or numpy.ndarray, optional

The inverse variance of the input data. Default is 1.

Nint, optional

The size of the ePSF region to fit. Default is 7.

filterstr, optional

The filter of the input data. Default is “F140W”.

tolfloat, optional

The tolerance for the fitting algorithm. Default is 1.0e-4.

guesstuple, optional

The initial guess for the ePSF parameters. If not provided, the guess is calculated based on the input data.

get_extendedbool, optional

Whether to include extended data in the fitting process. Default is False.

methodstr, optional

The fitting method to use. Default is “lm”.

ds9str, optional

Optional name of the DS9 instance to display the fitting process. Default is None.

psf_paramsnumpy.ndarray, optional

The parameters of the ePSF model. If provided, the fitting process is skipped and the provided parameters are returned.

only_centeringbool, optional

Whether to only fit for centering and compute normalizations. Default is True.

rot90int, optional

The rotation angle of the ePSF. Default is 0.

Returns
psf_modelnumpy.ndarray

The model of the ePSF.

bkgfloat

The background level of the ePSF.

Anumpy.ndarray

The normalization coefficients of the ePSF.

coeffsnumpy.ndarray

The coefficients of the ePSF.

get_at_position(x=507, y=507, filter='F140W', rot90=0)[source]

Evaluate ePSF at detector coordinates

Parameters
xint

X pixel coordinate.

yint

Y pixel coordinate.

filterstr, optional

Filter name, by default “F140W”.

rot90int, optional

The rotation angle in degrees, by default 0.

Returns
psf_xynumpy.ndarray

The evaluated ePSF values at the given coordinates.

get_ePSF(psf_params, sci=None, ivar=1, origin=[0, 0], shape=[20, 20], filter='F140W', get_extended=False, get_background=False, rot90=0)[source]

Evaluate an Effective PSF

Parameters
psf_paramslist or tuple

List or tuple of PSF parameters.

scinumpy.ndarray, optional

Science image. Default is None.

ivarfloat, optional

Inverse variance. Default is 1.

originlist, optional

Origin of the PSF. Default is [0, 0].

shapelist, optional

Shape of the PSF. Default is [20, 20].

filterstr, optional

Filter name. Default is “F140W”.

get_extendedbool, optional

Flag to get extended PSF. Default is False.

get_backgroundbool, optional

Flag to get background. Default is False.

rot90int, optional

Rotation angle. Default is 0.

Returns
output_psfnumpy.ndarray

Output PSF.

bkgnumpy.ndarray or None

Background image if get_background is True, else None.

load_PSF_data()[source]

Load data from PSFSTD files

Files should be located in ${GRIZLI}/CONF/ directory.

static objective_epsf(params, self, psf_xy, sci, ivar, xp, yp, extended_data, ret, ds9)[source]

Objective function for fitting ePSFs

Parameters
paramslist

List of fitting parameters [normalization, xc, yc, background].

selfobject

The object instance.

psf_xyarray-like

Array of PSF coordinates.

sciarray-like

Science image.

ivararray-like

Inverse variance image.

xparray-like

X positions.

yparray-like

Y positions.

extended_databool

Flag indicating whether extended data is used.

retstr

Return type. Possible values are ‘resid’, ‘lm’, ‘model’, or ‘chi2’.

ds9bool

Flag indicating whether to display the result in DS9.

Returns
——-
residarray-like

Residuals.

lm_residarray-like

Masked residuals for LM optimization.

modeltuple

Tuple containing the PSF model, background, Ax, and coeffs.

chi2float

Chi-squared value.

static objective_epsf_center(params, self, psf_xy, sci, ivar, xp, yp, extended_data, ret, ds9)[source]

Objective function for fitting ePSF centers

Parameters
paramslist

List of fitting parameters [xc, yc].

selfobject

The object instance.

psf_xyarray-like

Array of PSF coordinates.

sciarray-like

Science image.

ivararray-like

Inverse variance image.

xparray-like

X positions.

yparray-like

Y positions.

extended_databool

Flag indicating whether extended data is used.

retstr

Return type. Possible values are ‘resid’, ‘lm’, ‘model’, or ‘chi2’.

ds9bool

Flag indicating whether to display the result in DS9.

Returns
——-
residarray-like

Residuals.

lm_residarray-like

Masked residuals for LM optimization.

modeltuple

Tuple containing the PSF model, background, Ax, and coeffs.

chi2float

Chi-squared value.