prometheus package

Submodules

prometheus.allfit module

ALLFIT.PY - Fit PSF to all stars in an image

prometheus.allfit.cutoutbbox(image, psf, cat)[source]

Get image cutout that covers that catalog of stars.

prometheus.allfit.fit(psf, image, cat, method='qr', fitradius=None, recenter=True, maxiter=10, minpercdiff=0.5, reskyiter=2, nofreeze=False, verbose=False)[source]

Fit PSF to all stars in an image.

To pre-group the stars, add a “group_id” in the input catalog.

Parameters
psfPSF object

PSF object with initial parameters to use.

imageCCDData object

Image to use to fit PSF model to stars.

cattable

Catalog with initial height/x/y values for the stars to use to fit the PSF. To pre-group the stars, add a “group_id” in the catalog.

methodstr, optional

Method to use for solving the non-linear least squares problem: “cholesky”, “qr”, “svd”, and “curve_fit”. Default is “cholesky”.

fitradiusfloat, optional

The fitting radius in pixels. By default the PSF FWHM is used.

recenterboolean, optional

Allow the centroids to be fit. Default is True.

maxiterint, optional

Maximum number of iterations to allow. Only for methods “qr” or “svd”. Default is 10.

minpercdifffloat, optional

Minimum percent change in the parameters to allow until the solution is considered converged and the iteration loop is stopped. Only for methods “qr” and “svd”. Default is 0.5.

reskyiterint, optional

After how many iterations to re-calculate the sky background. Default is 2.

verboseboolean, optional

Verbose output.

Returns
outtable

Table of best-fitting parameters for each star. id, height, height_error, x, x_err, y, y_err, sky

modelnumpy array

Best-fitting model of the stars and sky background.

prometheus.aperture module

APERTURE.PY - Aperture photometry

prometheus.aperture.apercorr(psf, image, objects, psfobj, verbose=False)[source]

Calculate aperture correction.

Parameters
psfPSF object

The best-fitting PSF model.

imagestring or CCDData object

The input image to fit. This can be the filename or CCDData object.

objectstable

The output table of best-fit PSF values for all of the sources.

psfobjtable

The table of PSF objects.

verboseboolean, optional

Verbose output to the screen. Default is False.

Returns
——-
objectstable
The output table with an “apcorr” column inserted and the aperture correction

applied to “psfmag”.

apcorfloat

The aperture correction in mag.

cgrownumpy array

The cumulative aperture correction array.

prometheus.aperture.aperphot(image, objects, aper=[3], gain=None, mag_zeropoint=25.0)[source]

Aperture photometry using sep.

Parameters
imCCDData object

The image to estimate the background for.

objectstable

Table of objects with x/y coordinate.

aperfloat, optional

Radius of the aperture. Default is 3.0 pixels.

gainfloat, optional

The gain. Default is 1.

mag_zeropointfloat

The magnitude zero-point to use. Default is 25.

Returns
photastropy table
Catalog of measured aperture photometry and other SE

parameters.

prometheus.aperture.circaperphot(im, positions, rap=[5.0], rbin=None, rbout=None)[source]

Calculate circular aperture photometry for a list of sources.

Parameters
im2D numpy array

The image to estimate the background for.

positionslist

List of two-element positions or catalog.

rapfloat, optional

Radius of the aperture. Default is 5.0 pixels.

rbinfloat, optional

Radius of the inner background aperture. Default is no background subtraction.

rboutfloat, optional

Radius of the outer background aperture. Default is no background subtraction.

Returns
photastropy table

Catalog of measured aperture photometry.

prometheus.aperture.diffprofile(xdata, A, B, C, Rseeing)[source]

Differential stellar flux profile.

Parameters
xdatafloat or numpy array

Two-element list or tuple of the outer and inner radii.

Afloat

A-parameter that affects the asymptotic power-law slope of the outer part of the profile.

Bfloat
B-parameter that affects the relative amplitude of the Moffat function versus the Gaussian

and exponential part of the profile.

Cfloat
C-parameter that defines the relative importance of the Gaussian and exponential

contributions to the seeing-dependent part of the profile.

Rseeingfloat

The seeing radius in pixels.

Returns
difffloat

The relative flux between two radii.

prometheus.aperture.empgrowth(apercat, apers)[source]

Calculate empirical growth curve.

Parameters
apercattable

Table of aperture magnitudes.

aperslist or numpy array

List of aperture radii.

Returns
egrownumpy array

The empirical differential growth curve.

egrowerrnumpy array

The uncertainty in egrow.

prometheus.aperture.fitgrowth(apercat, apers, rseeing)[source]

Fit the curve of growth to aperture photometry.

Parameters
apercattable

Table of aperture magnitudes.

aperslist or numpy array

List of aperture radii.

rseeingfloat

The seeing radius in pixels.

Returns
parsnumpy array

The bestfit parameters.

agrownumpy array

The analytical differential growth curve.

agrowerrnumpy array

Uncertainty in agrow.

prometheus.aperture.fudgefactor(err, resid, a=2, b=1)[source]

Lower the weights of outlier points.

Parameters
errnumpy array

The uncertainty array.

residnumpy array

The residual array of the data minus the best-fit model.

aint

A-parameter, normally kept at 2. Default is 2.

bint

B-parameter that is normally between 1 and 3. Default is 1.

Returns
fudgenumpy array
The fudge factor to apply to the uncertainties to downweight

outlier points.

prometheus.aperture.sumprofile(rk, A, B, C, Rseeing)[source]

Sum of radial stellar profile from 0 to a radius rk. See Stetson (1990) pg. 4.

Parameters
rkfloat or numpy array

The radius of the aperture.

Afloat

A-parameter that affects the asymptotic power-law slope of the outer part of the profile.

Bfloat
B-parameter that affects the relative amplitude of the Moffat function versus the Gaussian

and exponential part of the profile.

Cfloat
C-parameter that defines the relative importance of the Gaussian and exponential

contributions to the seeing-dependent part of the profile.

Rseeingfloat

The seeing radius in pixels.

Returns
sumfloat

The total flux from 0 to radius rk.

prometheus.aperture.totphot(apercat, apers, cgrow, cgrowerr)[source]

Calculate total aperture photometry for stars.

Parameters
apercattable

Table of aperture magnitudes.

aperslist or numpy array

List of aperture radii.

cgrownumpy array

Cumulative aperture correction array for “apers”.

cgrowerrnumpy array

Uncertainy in cgrow.

Returns
totmagnumpy array

Array of total magnitude for each star.

toterrnumpy array

Uncertainty in totmag.

prometheus.ccddata module

CCDDATA.PY - Thin wrapper around CCDData class

class prometheus.ccddata.BoundingBox(*args, **kwargs)[source]

Bases: photutils.aperture.bounding_box.BoundingBox

property data
property slices

Return the slices.

property xrange
property yrange
class prometheus.ccddata.CCDData(data, *args, error=None, bbox=None, gain=None, rdnoise=None, sky=None, copy=False, skyfunc=None, unit=None, **kwargs)[source]

Bases: astropy.nddata.CCDData

property bbox

Boundary box.

property ccont

Return C-Continuous data for data, error, mask, sky.

copy()[source]

Return a copy of the CCDData object.

property error

Return the uncertainty.

property gain

Return the gain.

isccont(data)[source]

Check if data is c-continuous.

isnative(data)[source]

Check if data has native byte order.

issepready(data)[source]

Check if data is ready for sep (native byte order and c-continuous).

property mad

Calculate the MAD of the image data. Uses only unmasked data.

property max

Calculate the max of the image data. Uses only unmasked data.

property mean

Calculate the mean of the image data. Uses only unmasked data.

property median

Calculate the median of the image data. Uses only unmasked data.

property min

Calculate the min of the image data. Uses only unmasked data.

native()[source]

Make sure that the arrays use native endian for sep.

property rdnoise

Return the read noise.

classmethod read(filename)[source]

Read in an image from file.

property sepdata

Return C-Continuous and native byte order data for sep.

sepready(data=None)[source]

Return sep-ready data (native byte order and c-continuous).

property sky

Return the sky.

property std

Calculate the standard deviation of the image data. Uses only unmasked data.

tohdu()[source]

Convert the image to an HDU so it can be written to a file. Note that only the image data is converted to the HDU (no error, mask, flags or sky).

Returns
hdufits HDU object

The FITS HDU object.

write(outfile, overwrite=True)[source]

Write the image data to a file.

Parameters
outfilestr

The output filename.

overwriteboolean, optional

Overwrite the file if it already exists. Default is True.

property x

X-array.

property y

Y-array.

prometheus.ccddata.getgain(image)[source]

Get the gain from the header.

prometheus.ccddata.getrdnoise(image)[source]

Get the read noise from the header.

prometheus.ccddata.poissonnoise(data, gain=1.0, rdnoise=0.0)[source]

Generate Poisson noise model (ala DAOPHOT).

prometheus.detection module

DETECTION.PY - Detection algorithms

prometheus.detection.daodetect(image, nsigma=1.5, fwhm=3.0)[source]

Detection with DAOFinder.

prometheus.detection.detect(image, method='sep', nsigma=1.5, fwhm=3.0, minarea=3, deblend_nthresh=32, deblend_cont=1.5e-05, kernel=None, maskthresh=0.0)[source]

Detection algorithm

Parameters
imageCCDData object

The image to detect sources in.

methodstr, optional

Method to use. Options are sep, dao, and iraf. Default is sep.

nsigmafloat, optional

Detection threshold in number of sigma. Default is 1.5.

fwhmfloat, optional

Estimate for PSF full width at half maximum. Default is 3.0.

minareaint, optional

Minimum area requirement for an object (sep only). Default is 3.

deblend_nthreshint, optional

Number of deblending thresholds (sep only). Default is 32.

deblend_contfloat, optional
Minimum contrast ratio used for object deblending (sep only).

Default is 0.000015. To entirely disable deblending, set to 1.0.

kernelnumpy array, optional

Filter kernel used for on-the-fly filtering (used to enhance detection). Default is a 3x3 array.

maskthreshfloat, optional

Threshold for a pixel to be masked (sep only). Default is 0.0.

Returns
——-
objectsastropy Table

Table of objects with centroids.

segmapnumpy array

Segmentation (sep only).

prometheus.detection.irafdetect(image, nsigma=1.5, fwhm=3.0)[source]

Detection with IRAFFinder.

prometheus.detection.peaks(image, nsigma=1.5, thresh=None)[source]

Detect peaks.

prometheus.detection.plotobj(image, objects)[source]

Plot objects on top of image.

prometheus.detection.sepdetect(image, nsigma=1.5, fwhm=3.0, minarea=3, deblend_nthresh=32, deblend_cont=1.5e-05, kernel=None, maskthresh=0.0, segmentation_map=False)[source]

Detection with sep.

prometheus.getpsf module

GETPSF.PY - Determine the PSF by fitting to multiple stars in an image

class prometheus.getpsf.PSFFitter(psf, image, cat, fitradius=None, verbose=False)[source]

Bases: object

jac(x, *args, retmodel=False, refit=True)[source]

jacobian.

mklookup(order=0)[source]

Make an empirical look-up table for the residuals.

model(x, *args, refit=True, verbose=False)[source]

model function.

starmodel(star=None, pars=None)[source]

Generate 2D star model images that can be compared to the original cutouts. if star=None, then it will return all of them as a list.

prometheus.getpsf.findpsfnei(allcat, psfcat, npix)[source]

Find stars near PSF stars.

Parameters
allcattable

Catalog of all sources in the image.

psfcattable

Catalog of PSF stars.

npixint

Search radius in pixels.

Returns
indallnumpy array
List of indices into allcat that are neighbors to

the PSF stars (within radius of npix), and are not PSF stars themselves.

prometheus.getpsf.fitpsf(psf, image, cat, fitradius=None, method='qr', maxiter=10, minpercdiff=1.0, verbose=False)[source]

Fit PSF model to stars in an image.

Parameters
psfPSF object

PSF object with initial parameters to use.

imageCCDData object

Image to use to fit PSF model to stars.

cattable

Catalog with initial height/x/y values for the stars to use to fit the PSF.

fitradiusfloat, table

The fitting radius. If none is input then the initial PSF FWHM will be used.

methodstr, optional

Method to use for solving the non-linear least squares problem: “qr”, “svd”, “cholesky”, and “curve_fit”. Default is “qr”.

maxiterint, optional

Maximum number of iterations to allow. Only for methods “qr”, “svd”, and “cholesky”. Default is 10.

minpercdifffloat, optional

Minimum percent change in the parameters to allow until the solution is considered converged and the iteration loop is stopped. Only for methods “qr” and “svd”. Default is 1.0.

verboseboolean, optional

Verbose output.

Returns
newpsfPSF object

New PSF object with the best-fit model parameters.

parsnumpy array

Array of best-fit model parameters

perrornumpy array

Uncertainties in “pars”.

psfcattable

Table of best-fitting height/xcen/ycen values for the PSF stars.

prometheus.getpsf.getpsf(psf, image, cat, fitradius=None, lookup=False, lorder=0, method='qr', subnei=False, allcat=None, maxiter=10, minpercdiff=1.0, reject=False, maxrejiter=3, verbose=False)[source]

Fit PSF model to stars in an image with outlier rejection of badly-fit stars.

Parameters
psfPSF object

PSF object with initial parameters to use.

imageCCDData object

Image to use to fit PSF model to stars.

cattable

Catalog with initial height/x/y values for the stars to use to fit the PSF.

fitradiusfloat, table

The fitting radius. If none is input then the initial PSF FWHM will be used.

lookupboolean, optional

Use an empirical lookup table. Default is False.

lorderint, optional

The order of the spatial variations (0=constant, 1=linear). Default is 0.

methodstr, optional

Method to use for solving the non-linear least squares problem: “qr”, “svd”, “cholesky”, and “curve_fit”. Default is “qr”.

subneiboolean, optional

Subtract stars neighboring the PSF stars. Default is False.

allcattable, optional

Catalog of all objects in the image. This is needed for bad PSF star rejection.

maxiterint, optional

Maximum number of iterations to allow. Only for methods “qr”, “svd”, and “cholesky”. Default is 10.

minpercdifffloat, optional

Minimum percent change in the parameters to allow until the solution is considered converged and the iteration loop is stopped. Only for methods “qr” and “svd”. Default is 1.0.

rejectboolean, optional

Reject PSF stars with high RMS values. Default is False.

maxrejiterint, boolean

Maximum number of PSF star rejection iterations. Default is 3.

verboseboolean, optional

Verbose output.

Returns
newpsfPSF object

New PSF object with the best-fit model parameters.

parsnumpy array

Array of best-fit model parameters

perrornumpy array

Uncertainties in “pars”.

psfcattable

Table of best-fitting height/xcen/ycen values for the PSF stars.

prometheus.getpsf.mkempirical(cube, order=0, coords=None, shape=None, rect=False, lookup=False)[source]

Take a star cube and collapse it to make an empirical PSF using median and outlier rejection.

Parameters
cubenumpy array
Three-dimensional cube of star images (or residual images) of shape

(Npix,Npix,Nstars).

orderint, optional
The order of the variations. 0-constant, 1-linear terms. If order=1,

Then coords and shape must be input.

coordstuple, optional
Two-element tuple of the X/Y coordinates of the stars. This is needed

to generate the linear empirical model (order=1).

shapetuple, optional
Two-element tuple giving the shape (Ny,Nx) of the image. This is

needed to generate the linear empirical model (order=1).

rectboolean, optional

Return a list of RectBivariateSpline functions rather than a numpy array.

lookupboolean, optional

Parameter to indicate if this is a lookup table. If lookup=False, then the constant term is constrained to be non-negative. Default is False.

Returns
epsfnumpy array
The empirical PSF model If order=0, then this is just a 2D image. If

order=1, then it will be a 3D cube (Npix,Npix,4) where the four terms are [constant, X-term, Y-term, X*Y-term]. If rect=True, then a list of RectBivariateSpline functions are returned.

prometheus.getpsf.starcube(cat, image, npix=51, fillvalue=nan)[source]

Produce a cube of cutouts of stars.

Parameters
cattable
The catalog of stars to use. This should have “x” and “y” columns and

preferably also “height”.

imageCCDData object

The image to use to generate the stellar images.

fillvaluefloat, optional
The fill value to use for pixels that are bad are off the image.

Default is np.nan.

Returns
cubenumpy array

Two-dimensional cube (Npix,Npix,Nstars) of the star images.

prometheus.getpsf.subtractnei(image, allcat, psfcat, psf)[source]

Subtract neighboring stars to PSF stars from the image.

Parameters
imageCCDDdata object

The input image from which to subtract PSF neighbor stars.

allcattable

Catalog of all sources in the image.

psfcattable

Catalog of PSF stars.

psfPSF object

The PSF model.

Returns
residCCDData object

The input images with the PSF neighbor stars subtracted.

prometheus.groupfit module

GROUPFIT.PY - Fit groups of stars in an image

class prometheus.groupfit.GroupFitter(psf, image, cat, fitradius=None, verbose=False)[source]

Bases: object

centroid()[source]

Centroid all of the stars.

checkbounds(pars, bounds)[source]

Check the parameters against the bounds.

cov()[source]

Determine the covariance matrix.

property freepars

Return the free parameters.

property freestars

Return the free stars.

freeze(pars, frzpars)[source]

Freeze stars and parameters

heightfit(trim=True)[source]

Fit the heights only for the stars.

jac(x, *args, retmodel=False, trim=False, allparams=False, verbose=None)[source]

Calculate the jacobian for the pixels and parameters we are fitting

limbounds(pars, bounds)[source]

Limit the parameters to the boundaries.

limsteps(steps, maxsteps)[source]

Limit the parameter steps to maximum step sizes.

mkbounds(pars, imshape, xoff=10)[source]

Make bounds for a set of input parameters.

model(x, *args, trim=False, allparams=False, verbose=None)[source]

Calculate the model for the pixels we are fitting.

property modelflatten

This returns the current best model (no sky) for only the “flatten” pixels using the PARS values.

property modelim

This returns the full image of the current best model (no sky) using the PARS values.

newpars(pars, steps, bounds, maxsteps)[source]

Get new parameters given initial parameters, steps and constraints.

property nfreepars

Return the number of free parameters.

property nfreestars

Return the number of free stars.

property nfreezepars

Return the number of frozen parameters.

property nfreezestars

Return the number of frozen stars.

sky(method='sep', rin=None, rout=None)[source]

(Re)calculate the sky.

property skyflatten

Return the sky values for the pixels that we are fitting.

property starheight

Return the best-fit heights for all stars.

property starpars

Return the [height,xcen,ycen] parameters in [Nstars,3] array. You can GET a star’s parameters like this: pars = self.starpars[4] You can also SET a star’s parameters a similar way: self.starpars[4] = pars

property starxcen

Return the best-fit X centers for all stars.

property starycen

Return the best-fit Y centers for all stars.

steps(pars, bounds=None, dx=0.2)[source]

Return step sizes to use when fitting the stellar parameters.

unfreeze()[source]

Unfreeze all parameters and stars.

prometheus.groupfit.fit(psf, image, cat, method='qr', fitradius=None, recenter=True, maxiter=10, minpercdiff=0.5, reskyiter=2, nofreeze=False, absolute=False, verbose=False)[source]

Fit PSF to group of stars in an image.

Parameters
psfPSF object

PSF object with initial parameters to use.

imageCCDData object

Image to use to fit PSF model to stars.

cattable

Catalog with initial height/x/y values for the stars to use to fit the PSF.

methodstr, optional

Method to use for solving the non-linear least squares problem: “cholesky”, “qr”, “svd”, and “curve_fit”. Default is “cholesky”.

fitradius: float, optional

The fitting radius in pixels. By default the PSF FWHM is used.

recenterboolean, optional

Allow the centroids to be fit. Default is True.

maxiterint, optional

Maximum number of iterations to allow. Only for methods “cholesky”, “qr” or “svd”. Default is 10.

minpercdifffloat, optional

Minimum percent change in the parameters to allow until the solution is considered converged and the iteration loop is stopped. Only for methods “cholesky”, “qr” and “svd”. Default is 0.5.

reskyiterint, optional

After how many iterations to re-calculate the sky background. Default is 2.

absoluteboolean, optional
Input and output coordinates are in “absolute” values using the image bounding box.

Default is False, everything is relative.

nofreezeboolean, optional

Do not freeze any parameters even if they have converged. Default is False.

verboseboolean, optional

Verbose output.

Returns
outtable

Table of best-fitting parameters for each star. id, height, height_error, x, x_err, y, y_err, sky

modelnumpy array

Best-fitting model of the stars and sky background.

skynumpy array

Best-fitting sky image.

prometheus.leastsquares module

LEASTSQUARES.PY - Least squares solvers

prometheus.leastsquares.checkbounds(pars, bounds)[source]

Check the parameters against the bounds.

prometheus.leastsquares.cholesky_jac_solve(jac, resid, weight=None)[source]

Solve part a non-linear least squares equation using Cholesky decomposition using the Jacobian.

prometheus.leastsquares.cholesky_jac_sparse_solve(jac, resid, weight=None)[source]

Solve part a non-linear least squares equation using Cholesky decomposition using the Jacobian, with sparse matrices.

prometheus.leastsquares.cholesky_solve(A, b)[source]

Solve linear least squares problem with Cholesky decomposition.

prometheus.leastsquares.inverse(a)[source]

Safely take the inverse of a square 2D matrix.

prometheus.leastsquares.ishermitian(A)[source]

check if a matrix is Hermitian (equal to it’s conjugate transpose).

prometheus.leastsquares.isposdef(A)[source]

Check if a matrix positive definite.

prometheus.leastsquares.jac_covariance(jac, resid, wt=None)[source]

Determine the covariance matrix.

Parameters
jacnumpy array
The 2-D jacobian (first derivative relative to the parameters) array

with dimensions [Npix,Npar].

residnumpy array

Residual array (data-best model) with dimensions [Npix].

wtnumpy array, optional

Weight array (typically 1/sigma**2) with dimensions [Npix].

Returns
covnumpy array

Covariance array with dimensions [Npar,Npar].

prometheus.leastsquares.jac_solve(jac, resid, method=None, weight=None)[source]

Thin wrapper for the various jacobian solver method.

prometheus.leastsquares.kkt_jac_solve(jac, resid, weight=None, maxiter=None)[source]

Solve part a non-linear least squares equation using KKT (Karush-Kuhn-Tucker) method with the Jacobian.

prometheus.leastsquares.limbounds(pars, bounds)[source]

Limit the parameters to the boundaries.

prometheus.leastsquares.limsteps(steps, maxsteps)[source]

Limit the parameter steps to maximum step sizes.

prometheus.leastsquares.lsq_solve(xdata, data, jac, initpar, error=None, method='qr', model=None, bounds=None, fixed=None, steps=None, maxiter=20, minpercdiff=0.5, verbose=False)[source]

Solve a non-linear problem with least squares.

xdatalist or numpy array

x and y values of the data.

datanumpy array

Data values.

jacfunction
Jacobian function. If model is not input then this is assumed to return

both the model and jacobian.

initparnumpy array

Initial guess parameters.

errornumpy array, optional

Uncertainties in data.

methodstr, optional
Method to use for solving the non-linear least squares problem: “cholesky”,

“qr”, “svd”, and “curve_fit”. Default is “qr”.

modelfunction, optional

Model function.

boundslist, optional
Input lower and upper bounds/constraints on the fitting parameters (tuple of two

lists.

fixedboolean list, optinal

List of boolean values if what to hold fixed and what should be free to vary.

stepsfunction, optional
Function to limit the steps to some maximum values. Should take parameters

and bounds.

maxiterint, optional

Maximum number of iterations. Default is 20.

minpercdifffloat, optional
Minimum percent change in the parameters to allow until the solution is

considered converged and the iteration loop is stopped. Default is 0.5.

verboseboolean, optional

Verbose output to the screen. Default is False.

Returns
parsnumpy array

Best-fit parameters.

perrornumpy array

Uncertainties in best-fit parameters.

covnumpy array

Covariance matrix.

prometheus.leastsquares.lu_jac_solve(jac, resid, weight=None)[source]

Solve part a non-linear least squares equation using LU decomposition using the Jacobian.

prometheus.leastsquares.lu_solve(A, b)[source]

Solve linear least squares problem with LU decomposition.

prometheus.leastsquares.newpars(pars, steps, bounds=None, maxsteps=None)[source]

Return new parameters that fit the constraints.

prometheus.leastsquares.qr_jac_solve(jac, resid, weight=None)[source]

Solve part of a non-linear least squares equation using QR decomposition using the Jacobian.

prometheus.leastsquares.svd_jac_solve(jac, resid, weight=None)[source]

Solve part of a non-linear least squares equation using Single Value Decomposition (SVD) using the Jacobian.

prometheus.models module

MODELS.PY - PSF photometry models

class prometheus.models.PSFBase(mpars, npix=51, binned=False, verbose=False)[source]

Bases: object

Initialize the PSF model object.

Parameters
mparsnumpy array

PSF model parameters array.

npixint, optional

Number of pixels to model [Npix,Npix]. Must be odd. Default is 51 pixels.

binnedboolean, optional
verboseboolean, optional

Verbose output when performing operations. Default is False.

add(im, cat, sky=False, radius=None, nocopy=False)[source]

Method to add stars using the PSF model from an image.

Parameters
imCCDData object

Image to use for fitting.

catcatalog

Catalog of stellar parameters. Columns must include height, x, y and sky.

skyboolean, optional

Include sky in the model that is subtracted. Default is False.

radiusfloat, optional

PSF radius to use. The default is to use the full size of the PSF.

nocopy: boolean, optional
Return the original image with the stars added. Default is False

and a copy of the image will be returned.

Returns
addimCCDData object

Image with stellar models added.

bbox2xy(bbox)[source]

Convenience method to convert boundary box of X/Y limits to 2-D X and Y arrays. The upper limits are EXCLUSIVE following the python convention.

property bounds

Return the lower and upper bounds for the parameters.

checkbounds(pars, bounds=None)[source]

Check the parameters against the bounds.

Parameters
parsnumpy array or list

List or array of parameters for which to check the constraints.

boundstuple, optional

Two-element tuple of lower and upper constrainst on pars.

Returns
checknumpy array
Integer array indicating if the parameter crossed the boundaries.

0-fine, 1-beyond the lower bound; 2-beyond the upper bound.

copy()[source]

Create a new copy of this LSF object.

deriv()[source]

Return the derivate of the function. Must be defined by subclass.

evaluate()[source]

Evaluate the function. Must be defined by subclass.

fit(im, pars, niter=2, radius=None, allpars=False, method='qr', nosky=False, minpercdiff=0.5, absolute=False, retpararray=False, retfullmodel=False, recenter=True, bounds=None, verbose=False)[source]

Method to fit a single star using the PSF model.

Parameters
imCCDData object

Image to use for fitting.

parsnumpy array, list or catalog

Initial parameters. If numpy array or list the values should be [height, xcen, ycen]. If a catalog is input then it must at least the “x” and “y” columns.

niterint, optional

Number of iterations to perform. Default is 2.

radiusfloat, optional

Fitting radius in pixels. Default is to use the PSF FWHM.

allparsboolean, optional

Fit PSF model parameters as well. Default is to only fit the stellar parameters of [height, xcen, ycen, sky].

methodstr, optional

Method to use for solving the non-linear least squares problem: “cholesky”, “qr”, “svd”, and “curve_fit”. Default is “qr”.

minpercdifffloat, optional

Minimum percent change in the parameters to allow until the solution is considered converged and the iteration loop is stopped. Default is 0.5.

noskyboolean, optional

Do not fit the sky, only [height, xcen, and ycen]. Default is False.

weightboolean, optional

Weight the data by 1/error**2. Default is weight=True.

absoluteboolean, optional
Input and output coordinates are in “absolute” values using the image bounding box.

Default is False, everything is relative.

retpararrayboolean, optional
Return best-fit parameter values as an array. Default is to return parameters

as a catalog.

retfullmodelboolean, optional

Return model over the full PSF region. Default is False.

recenterboolean, optional

Allow the centroids to be fit. Default is True.

boundslist, optional
Input lower and upper bounds/constraints on the fitting parameters (tuple of two

lists (e.g., ([height_lo,x_low,y_low],[height_hi,x_hi,y_hi])).

verboseboolean, optional

Verbose output to the screen. Default is False.

Returns
outcatcatalog or numpy array
Output catalog of best-fit values (id, height, height_error, x, x_error, y, y_error,

sky, sky_error, niter). If retpararray=True, then the parameters and parameter uncertainties will be output as numpy arrays.

perrornumpy array

Array of uncertainties of the best-fit values. Only if retpararray=True is set.

modelCCDData object
The best-fitting model. This only includes the model for the region that was used

in the fit. To return the model for the full image set retfullmodel=True.

mparsnumpy array

Best-fit model parameter values. Only if allpars=True and retpararray=False are set.

flux(pars=None, footprint=False)[source]

Return the flux/volume of the model given the height. Must be defined by subclass.

fwhm()[source]

Return the FWHM of the model function. Must be defined by subclass

property haslookup

Check if there is a lookup table.

jac(xdata, *args, retmodel=False, allpars=False, **kwargs)[source]

Method to return Jacobian matrix. This includes the contribution of the lookup table.

Parameters
xdatanumpy array

X and Y values in a [2,N] array.

argsfloat

Model parameter values as separate positional input parameters, [height, xcen, ycen, sky]. If allpars=True, then the model parameters are added at the end, i.e. [height, xcen, ycen, sky, model parameters].

retmodelboolean, optional

Return the model as well. Default is retmodel=False.

allparsboolean, optional

PSF model parameters have been input as well (behind the stellar parameters). Default is False.

Returns
if retmodel==False
jacnumpy array

Jacobian matrix of partial derivatives [N,Npars].

modelnumpy array

Array of (1-D) model values for the input xdata and parameters. If retmodel==True, then (model,jac) are returned.

jacall(xdata, *args, retmodel=False, **kwargs)[source]

Convenience function to use with curve_fit() to fit all parameters of a single stellar profile.

limbounds(pars, bounds=None)[source]

Limit the parameters to the boundaries.

Parameters
parsnumpy array or list

List or array of parameters.

boundstuple, optional

Two-element tuple of lower and upper constrainst on pars.

Returns
outparsnumpy array

Array of output parameters that are limited to the bounds.

limsteps(steps, maxsteps)[source]

Limit the parameter steps to maximum step sizes.

Parameters
stepsnumpy array

Array of step sizes to limit.

maxstepnumpy array

Array of maximum step sizes to limit the input steps to.

Returns
outstepsnumpy array

array of step sizes that have been limited to the maximum values.

mkbounds(pars, imshape)[source]

Make bounds for a set of input parameters.

Parameters
parsnumpy array or list

List or array of parameters for which to produce constraints.

imshapetuple

Two-element tuple of the image size.

Returns
boundstuple

Two-element tuple of lower and upper constraints in pars.

model(xdata, *args, allpars=False, **kwargs)[source]

Function to use with curve_fit() to fit a single stellar profile. This includes the contribution of the lookup table.

Parameters
xdatanumpy array

X and Y values in a [2,N] array.

argsfloat

Model parameter values as separate positional input parameters, [height, xcen, ycen, sky]. If allpars=True, then the model parameters are added at the end, i.e. [height, xcen, ycen, sky, model parameters].

allparsboolean, optional

PSF model parameters have been input as well (behind the stellar parameters). Default is False.

Returns
modelnumpy array

Array of (1-D) model values for the input xdata and parameters.

modelall(xdata, *args, **kwargs)[source]

Convenience function to use with curve_fit() to fit all parameters of a single stellar profile.

newpars(pars, steps, bounds, maxsteps)[source]

Get new parameters given initial parameters, steps and constraints.

Parameters
parsnumpy array or list

List or array of initial parameters.

stepsnumpy array

Array of steps to add to pars.

boundstuple, optional

Two-element tuple of lower and upper constrainst on pars.

maxstepnumpy array

Array of maximum step sizes to limit the input steps to.

Returns
newparsnumpy array or list
Array of new parameters that have been incremented by

steps but limited by bounds and maxsteps.

property params

Return the PSF model parameters.

classmethod read(filename)[source]

Load a PSF file.

resid(cat, image, fillvalue=nan)[source]

Produce a residual map of the cutout of the star (within the PSF footprint) and the best-fitting PSF.

Parameters
cattable
The catalog of stars to use. This should have “x” and “y” columns and

preferably also “height”.

imageCCDData object

The image to use to generate the residuals images.

fillvaluefloat, optional
The fill value to use for pixels that are bad are off the image.

Default is np.nan.

Returns
residnumpy array
Three-dimension cube (Npix,Npix,Nstars) of the star images with the

best-fitting PSF model subtracted.

starbbox(coords, imshape, radius=None)[source]

Return the boundary box for a star given radius and image size.

Parameters
coords: list or tuple

Central coordinates (xcen,ycen) of star (absolute values).

imshape: list or tuple

Image shape (ny,nx) values. Python images are (Y,X).

radius: float, optional

Radius in pixels. Default is psf.npix//2.

Returns
bboxBoundingBox object

Bounding box of the x/y ranges. Upper values are EXCLUSIVE following the python convention.

steps(pars=None, bounds=None, star=False)[source]

Return step sizes to use when fitting the PSF model parameters (at least initial sizes).

Parameters
parsnumpy array or list

List or array of parameters for which to produce step sizes.

boundstuple, optional

Two-element tuple of lower and upper constrainst on pars.

starboolean, optional

Stellar parameters are included. Default is False.

Returns
stepsnumpy array

Array of step sizes.

sub(im, cat, sky=False, radius=None, nocopy=False)[source]

Method to subtract stars using the PSF model from an image.

Parameters
imCCDData object

Image to use for fitting.

catcatalog

Catalog of stellar parameters. Columns must include height, x, y and sky.

skyboolean, optional

Include sky in the model that is subtracted. Default is False.

radiusfloat, optional

PSF radius to use. The default is to use the full size of the PSF.

nocopy: boolean, optional
Return the original image with the star subtracted. Default is False

and a copy of the image will be returned.

Returns
subimnumpy array

Image with stellar models subtracted.

thumbnail(filename=None, figsize=6)[source]

Generate a thumbnail image of the PSF.

Parameters
filenamestr, optional

Filename of the output thumbnail file. Default is “psf.png”.

figsizefloat, optional

The figure size in inches. Default is 6.

Returns
The PSF thumbnail is saved to a file.
tohdu()[source]

Convert the PSF object to an HDU. Defined by subclass.

trim(trimflux)[source]

Trim the PSF size to a radius where “trimflux” is removed.

property unitfootflux

Return the unit flux inside the footprint.

write(filename, overwrite=True)[source]

Write a PSF to a file. Defined by subclass.

class prometheus.models.PSFEmpirical(mpars, imshape=None, korder=3, npix=51, binned=True, order=0, lookup=False)[source]

Bases: prometheus.models.PSFBase

Empirical look-up table PSF, can vary spatially.

Initialize the PSF model object.

Parameters
mparsnumpy array

PSF model parameters array.

npixint, optional

Number of pixels to model [Npix,Npix]. Must be odd. Default is 51 pixels.

binnedboolean, optional
verboseboolean, optional

Verbose output when performing operations. Default is False.

deriv(x, y, pars=None, data=None, nderiv=None)[source]

Empirical look-up table derivative with respect to parameters

evaluate(x, y, pars=None, data=None, deriv=False, nderiv=None)[source]

Empirical look-up table

flux(pars=None, footprint=True)[source]

Return the flux/volume of the model given the height or parameters.

fwhm()[source]

Return the FWHM of the model.

tohdu()[source]

Convert the PSF object to an HDU so it can be written to a file.

Returns
hdufits HDU object

The FITS HDU object.

write(filename, overwrite=True)[source]

Write a PSF to a file.

class prometheus.models.PSFGaussian(mpars=None, npix=51, binned=False)[source]

Bases: prometheus.models.PSFBase

Initialize the PSF model object.

Parameters
mparsnumpy array

PSF model parameters array.

npixint, optional

Number of pixels to model [Npix,Npix]. Must be odd. Default is 51 pixels.

binnedboolean, optional
verboseboolean, optional

Verbose output when performing operations. Default is False.

deriv(x, y, pars, binned=None, nderiv=None)[source]

Two dimensional Gaussian model derivative with respect to parameters

evaluate(x, y, pars, binned=None, deriv=False, nderiv=None)[source]

Two dimensional Gaussian model function

flux(pars=None, footprint=False)[source]

Return the flux/volume of the model given the height or parameters.

fwhm(pars=None)[source]

Return the FWHM of the model.

tohdu()[source]

Convert the PSF object to an HDU so it can be written to a file. This does not include the lookup table.

Returns
hdufits HDU object

The FITS HDU object.

write(filename, overwrite=True)[source]

Write a PSF to a file.

class prometheus.models.PSFGausspow(mpars=None, npix=51, binned=False)[source]

Bases: prometheus.models.PSFBase

DoPHOT PSF, sum of Gaussian ellipses.

Initialize the PSF model object.

Parameters
mparsnumpy array

PSF model parameters array.

npixint, optional

Number of pixels to model [Npix,Npix]. Must be odd. Default is 51 pixels.

binnedboolean, optional
verboseboolean, optional

Verbose output when performing operations. Default is False.

deriv(x, y, pars=None, binned=None, nderiv=None)[source]

Two dimensional DoPHOT Gausspow model derivative with respect to parameters

evaluate(x, y, pars=None, binned=None, deriv=False, nderiv=None)[source]

Two dimensional DoPHOT Gausspow model function

flux(pars=None, footprint=False)[source]

Return the flux/volume of the model given the height or parameters.

fwhm(pars=None)[source]

Return the FWHM of the model.

tohdu()[source]

Convert the PSF object to an HDU so it can be written to a file.

Returns
hdufits HDU object

The FITS HDU object.

write(filename, overwrite=True)[source]

Write a PSF to a file.

class prometheus.models.PSFMoffat(mpars=None, npix=51, binned=False)[source]

Bases: prometheus.models.PSFBase

Initialize the PSF model object.

Parameters
mparsnumpy array

PSF model parameters array.

npixint, optional

Number of pixels to model [Npix,Npix]. Must be odd. Default is 51 pixels.

binnedboolean, optional
verboseboolean, optional

Verbose output when performing operations. Default is False.

deriv(x, y, pars, binned=None, nderiv=None)[source]

Two dimensional Moffat model derivative with respect to parameters

evaluate(x, y, pars, binned=None, deriv=False, nderiv=None)[source]

Two dimensional Moffat model function

flux(pars=None, footprint=False)[source]

Return the flux/volume of the model given the height or parameters.

fwhm(pars=None)[source]

Return the FWHM of the model.

tohdu()[source]

Convert the PSF object to an HDU so it can be written to a file. This does not include the lookup table.

Returns
hdufits HDU object

The FITS HDU object.

write(filename, overwrite=True)[source]

Write a PSF to a file.

class prometheus.models.PSFPenny(mpars=None, npix=51, binned=False)[source]

Bases: prometheus.models.PSFBase

Gaussian core and Lorentzian wings, only Gaussian is tilted.

Initialize the PSF model object.

Parameters
mparsnumpy array

PSF model parameters array.

npixint, optional

Number of pixels to model [Npix,Npix]. Must be odd. Default is 51 pixels.

binnedboolean, optional
verboseboolean, optional

Verbose output when performing operations. Default is False.

deriv(x, y, pars=None, binned=None, nderiv=None)[source]

Two dimensional Penny model derivative with respect to parameters

evaluate(x, y, pars=None, binned=None, deriv=False, nderiv=None)[source]

Two dimensional Penny model function

flux(pars=None, footprint=False)[source]

Return the flux/volume of the model given the height or parameters.

fwhm(pars=None)[source]

Return the FWHM of the model.

tohdu()[source]

Convert the PSF object to an HDU so it can be written to a file. This does not include the lookup table.

Returns
hdufits HDU object

The FITS HDU object.

write(filename, overwrite=True)[source]

Write a PSF to a file.

prometheus.models.bbox2xy(bbox)[source]

Convenience method to convert boundary box of X/Y limits to 2-D X and Y arrays. The upper limits are EXCLUSIVE following the python convention.

Parameters
bboxBoundingBox object

A BoundingBox object defining a rectangular region of an image.

Returns
xnumpy array

The 2D array of X-values of the bounding box region.

ynumpy array

The 2D array of Y-values of the bounding box region.

prometheus.models.contourfwhm(im)[source]

Measure the FWHM of a PSF or star image using contours.

Parameters
imnumpy array

The 2D image of a star.

Returns
fwhmfloat

The full-width at half maximum.

prometheus.models.empirical(x, y, pars, data, shape=None, deriv=False, korder=3)[source]

Evaluate an empirical PSF.

Parameters
xnumpy array

Array of X-values of points for which to compute the empirical model.

ynumpy array

Array of Y-values of points for which to compute the empirical model.

parsnumpy array or list

Parameter list. pars = [amplitude, x0, y0].

derivboolean, optional

Return the derivatives as well.

nderivint, optional
The number of derivatives to return. The default is None

which means that all are returned if deriv=True.

Returns
gnumpy array
The empirical model for the input x/y values and parameters (same

shape as x/y).

derivativelist
List of derivatives of g relative to the input parameters.

This is only returned if deriv=True.

prometheus.models.gaussian2d(x, y, pars, deriv=False, nderiv=None)[source]

Two dimensional Gaussian model function.

Parameters
xnumpy array

Array of X-values of points for which to compute the Gaussian model.

ynumpy array

Array of Y-values of points for which to compute the Gaussian model.

parsnumpy array or list

Parameter list. pars = [amplitude, x0, y0, xsigma, ysigma, theta]

derivboolean, optional

Return the derivatives as well.

nderivint, optional
The number of derivatives to return. The default is None

which means that all are returned if deriv=True.

Returns
gnumpy array
The Gaussian model for the input x/y values and parameters (same

shape as x/y).

derivativelist
List of derivatives of g relative to the input parameters.

This is only returned if deriv=True.

prometheus.models.gaussian2d_abc2sigtheta(a, b, c)[source]

Convert 2D Gaussian a, b, c coefficients to sigma_x, sigma_y and theta. The inverse of guassian2d_sigtheta2abc(). f(x,y) = A*exp(-0.5 * (a*xdiff**2 + b*xdiff*ydiff + c*ydiff**2))

Parameters
afloat

The x**2 coefficient in the 2D elliptical Gaussian equation.

bfloat

The y**2 coefficient in the 2D elliptical Gaussian equation.

cfloat

The x*y coefficient in the 2D elliptical Gaussian equation.

Returns
xstdfloat

The Gaussian sigma in the x-dimension.

ystdfloat

The Gaussian sigma in the y-dimension.

thetafloat

The orientation angle of the elliptical 2D Gaussian (radians).

prometheus.models.gaussian2d_flux(pars)[source]

Return the total flux (or volume) of a 2D Gaussian.

Parameters
parsnumpy array or list

Parameter list. pars = [amplitude, x0, y0, xsigma, ysigma, theta]

Returns
fluxfloat

Total flux or volumne of the 2D Gaussian.

prometheus.models.gaussian2d_fwhm(pars)[source]

Return the FWHM of a 2D Gaussian.

Parameters
parsnumpy array or list

Parameter list. pars = [amplitude, x0, y0, xsigma, ysigma, theta]

Returns
fwhmfloat

The full-width at half maximum of the Gaussian.

prometheus.models.gaussian2d_integrate(x, y, pars, deriv=False, nderiv=None, osamp=4)[source]

Two dimensional Gaussian model function integrated over the pixels.

Parameters
xnumpy array

Array of X-values of points for which to compute the Gaussian model.

ynumpy array

Array of Y-values of points for which to compute the Gaussian model.

parsnumpy array or list

Parameter list. pars = [amplitude, x0, y0, xsigma, ysigma, theta]

derivboolean, optional

Return the derivatives as well.

nderivint, optional
The number of derivatives to return. The default is None

which means that all are returned if deriv=True.

osampint, optional
The oversampling of the pixel when doing the integrating.

Default is 4.

Returns
gnumpy array
The Gaussian model for the input x/y values and parameters (same

shape as x/y).

derivativelist
List of derivatives of g relative to the input parameters.

This is only returned if deriv=True.

prometheus.models.gaussian2d_sigtheta2abc(xstd, ystd, theta)[source]

Convert 2D Gaussian sigma_x, sigma_y and theta to a, b, c coefficients. f(x,y) = A*exp(-0.5 * (a*xdiff**2 + b*xdiff*ydiff + c*ydiff**2))

Parameters
xstdfloat

The Gaussian sigma in the x-dimension.

ystdfloat

The Gaussian sigma in the y-dimension.

thetafloat

The orientation angle of the elliptical 2D Gaussian (radians).

Returns
afloat

The x**2 coefficient in the 2D elliptical Gaussian equation.

bfloat

The y**2 coefficient in the 2D elliptical Gaussian equation.

cfloat

The x*y coefficient in the 2D elliptical Gaussian equation.

prometheus.models.gausspow2d(x, y, pars, deriv=False, nderiv=None)[source]

DoPHOT PSF, sum of elliptical Gaussians.

Parameters
xnumpy array

Array of X-values of points for which to compute the Gausspow model.

ynumpy array

Array of Y-values of points for which to compute the Gausspow model.

parsnumpy array or list
Parameter list.

pars = [amplitude, x0, y0, sigx, sigy, theta, beta4, beta6]

derivboolean, optional

Return the derivatives as well.

nderivint, optional
The number of derivatives to return. The default is None

which means that all are returned if deriv=True.

Returns
gnumpy array
The Gausspow model for the input x/y values and parameters (same

shape as x/y).

derivativelist
List of derivatives of g relative to the input parameters.

This is only returned if deriv=True.

prometheus.models.gausspow2d_flux(pars)[source]

Return the flux of a 2D DoPHOT Gausspow function.

Parameters
parsnumpy array or list
Parameter list.

pars = [amplitude, x0, y0, sigx, sigy, theta, beta4, beta6]

Returns
fluxfloat

Total flux or volumne of the 2D Gausspow function.

prometheus.models.gausspow2d_fwhm(pars)[source]

Return the FWHM of a 2D DoPHOT Gausspow function.

Parameters
parsnumpy array or list
Parameter list.

pars = [amplitude, x0, y0, sigx, sigy, theta, beta4, beta6]

Returns
fwhmfloat

The full-width at half maximum of the Penny function.

prometheus.models.gausspow2d_integrate(x, y, pars, deriv=False, nderiv=None, osamp=4)[source]

DoPHOT PSF, integrated over the pixels.

Parameters
xnumpy array

Array of X-values of points for which to compute the Gausspow model.

ynumpy array

Array of Y-values of points for which to compute the Gausspow model.

parsnumpy array or list
Parameter list.

pars = [amplitude, x0, y0, sigx, sigy, theta, beta4, beta6]

derivboolean, optional

Return the derivatives as well.

nderivint, optional
The number of derivatives to return. The default is None

which means that all are returned if deriv=True.

osampint, optional
The oversampling of the pixel when doing the integrating.

Default is 4.

Returns
gnumpy array
The Gausspow model for the input x/y values and parameters (same

shape as x/y).

derivativelist
List of derivatives of g relative to the input parameters.

This is only returned if deriv=True.

prometheus.models.hfluxrad(im)[source]

Calculate the half-flux radius of a star in an image.

Parameters
imnumpy array

The image of a star.

Returns
hfluxrad: float

The half-flux radius.

prometheus.models.imfwhm(im)[source]

Measure the FWHM of a PSF or star image.

Parameters
imnumpy array

The image of a star.

Returns
fwhmfloat

The full-width at half maximum of the star.

prometheus.models.moffat2d(x, y, pars, deriv=False, nderiv=None)[source]

Two dimensional Moffat model function.

Parameters
xnumpy array

Array of X-values of points for which to compute the Moffat model.

ynumpy array

Array of Y-values of points for which to compute the Moffat model.

parsnumpy array or list

Parameter list. pars = [amplitude, x0, y0, xsigma, ysigma, theta, beta]

derivboolean, optional

Return the derivatives as well.

nderivint, optional
The number of derivatives to return. The default is None

which means that all are returned if deriv=True.

Returns
gnumpy array
The Moffat model for the input x/y values and parameters (same

shape as x/y).

derivativelist
List of derivatives of g relative to the input parameters.

This is only returned if deriv=True.

prometheus.models.moffat2d_flux(pars)[source]

Return the total Flux of a 2D Moffat.

Parameters
parsnumpy array or list

Parameter list. pars = [amplitude, x0, y0, xsigma, ysigma, theta, beta]

Returns
fluxfloat

Total flux or volumne of the 2D Moffat.

prometheus.models.moffat2d_fwhm(pars)[source]

Return the FWHM of a 2D Moffat function.

Parameters
parsnumpy array or list

Parameter list. pars = [amplitude, x0, y0, xsigma, ysigma, theta, beta]

Returns
fwhmfloat

The full-width at half maximum of the Moffat.

prometheus.models.moffat2d_integrate(x, y, pars, deriv=False, nderiv=None, osamp=4)[source]

Two dimensional Moffat model function integrated over the pixels.

Parameters
xnumpy array

Array of X-values of points for which to compute the Moffat model.

ynumpy array

Array of Y-values of points for which to compute the Moffat model.

parsnumpy array or list

Parameter list. pars = [amplitude, x0, y0, xsigma, ysigma, theta, beta]

derivboolean, optional

Return the derivatives as well.

nderivint, optional
The number of derivatives to return. The default is None

which means that all are returned if deriv=True.

osampint, optional
The oversampling of the pixel when doing the integrating.

Default is 4.

Returns
gnumpy array
The Moffat model for the input x/y values and parameters (same

shape as x/y).

derivativelist
List of derivatives of g relative to the input parameters.

This is only returned if deriv=True.

prometheus.models.penny2d(x, y, pars, deriv=False, nderiv=None)[source]

Gaussian core and Lorentzian-like wings, only Gaussian is tilted.

Parameters
xnumpy array

Array of X-values of points for which to compute the Penny model.

ynumpy array

Array of Y-values of points for which to compute the Penny model.

parsnumpy array or list
Parameter list.

pars = [amplitude, x0, y0, xsigma, ysigma, theta, relamp, sigma]

derivboolean, optional

Return the derivatives as well.

nderivint, optional
The number of derivatives to return. The default is None

which means that all are returned if deriv=True.

Returns
gnumpy array
The Penny model for the input x/y values and parameters (same

shape as x/y).

derivativelist
List of derivatives of g relative to the input parameters.

This is only returned if deriv=True.

prometheus.models.penny2d_flux(pars)[source]

Return the total Flux of a 2D Penny function.

Parameters
parsnumpy array or list
Parameter list.

pars = [amplitude, x0, y0, xsigma, ysigma, theta, relamp, sigma]

Returns
fluxfloat

Total flux or volumne of the 2D Penny function.

prometheus.models.penny2d_fwhm(pars)[source]

Return the FWHM of a 2D Penny function.

Parameters
parsnumpy array or list
Parameter list.

pars = [amplitude, x0, y0, xsigma, ysigma, theta, relamp, sigma]

Returns
fwhmfloat

The full-width at half maximum of the Penny function.

prometheus.models.penny2d_integrate(x, y, pars, deriv=False, nderiv=None, osamp=4)[source]

Gaussian core and Lorentzian-like wings, only Gaussian is tilted integrated over the pixels.

Parameters
xnumpy array

Array of X-values of points for which to compute the Penny model.

ynumpy array

Array of Y-values of points for which to compute the Penny model.

parsnumpy array or list
Parameter list.

pars = [amplitude, x0, y0, xsigma, ysigma, theta, relamp, sigma]

derivboolean, optional

Return the derivatives as well.

nderivint, optional
The number of derivatives to return. The default is None

which means that all are returned if deriv=True.

osampint, optional
The oversampling of the pixel when doing the integrating.

Default is 4.

Returns
gnumpy array
The Penny model for the input x/y values and parameters (same

shape as x/y).

derivativelist
List of derivatives of g relative to the input parameters.

This is only returned if deriv=True.

prometheus.models.psfmodel(name, pars=None, **kwargs)[source]

Select PSF model based on the name.

Parameters
namestr

The type of PSF model to use: ‘gaussian’, ‘moffat’, ‘penny’, ‘gausspow’, ‘empirical’.

parsnumpy array

The model parameters.

kwargsdictionary

Any other keyword arguments that should be to initialize the PSF model.

Returns
psfPSF model

The requested PSF model.

prometheus.models.read(filename)

Load a PSF file.

prometheus.models.relcoord(x, y, shape)[source]

Convert absolute X/Y coordinates to relative ones to use with the lookup table.

Parameters
xnumpy array

Input x-values of positions in an image.

ynumpy array

Input Y-values of positions in an image.

shapetuple or list

Two-element tuple or list of the (Ny,Nx) size of the image.

Returns
relxnumpy array

The relative x-values ranging from -1 to +1.

relynumpy array

The relative y-values ranging from -1 to +1.

prometheus.models.starbbox(coords, imshape, radius)[source]

Return the boundary box for a star given radius and image size.

Parameters
coords: list or tuple

Central coordinates (xcen,ycen) of star (absolute values).

imshape: list or tuple

Image shape (ny,nx) values. Python images are (Y,X).

radius: float

Radius in pixels.

Returns
bboxBoundingBox object

Bounding box of the x/y ranges. Upper values are EXCLUSIVE following the python convention.

prometheus.prometheus module

PROMETHEUS.PY - PSF photometry

prometheus.prometheus.run(image, psfname='gaussian', iterdet=0, psfsubnei=False, psffitradius=None, fitradius=None, npsfpix=51, binned=False, lookup=False, lorder=0, psftrim=None, recenter=True, reject=False, apcorr=False, timestamp=False, verbose=False)[source]

Run PSF photometry on an image.

Parameters
imagestring or CCDData object

The input image to fit. This can be the filename or CCDData object.

psfnamestring, optional

The name of the PSF type to use. The options are “gaussian”, “moffat”, “penny” and “gausspow”. Default is “gaussian”.

iterdetboolean, optional
Number of iterations to use for detection. Default is iterdet=0, meaning

detection is only performed once.

psfsubneiboolean, optional

Subtract neighboring stars to PSF stars when generating the PSF. Default is False.

psffitradiusfloat, optional
The fitting readius when constructing the PSF (in pixels). By default

the FWHM is used.

fitradius: float, optional
The fitting radius when fitting the PSF to the stars in the image (in pixels).

By default the PSF FWHM is used.

npsfpixint, optional

The size of the PSF footprint. Default is 51.

binnedboolean, optional
Use a binned model that integrates the analytical function across a pixel.

Default is false.

lookupboolean, optional

Use an empirical lookup table. Default is False.

lorderint, optional

The order of the spatial variations (0=constant, 1=linear). Default is 0.

psftrim: float, optional

Trim the PSF size to a radius where “psftrim” fraction of flux is removed. Default is None.

recenterboolean, optional

Allow the centroids to be fit. Default is True.

rejectboolean, optional

When constructin the PSF, reject PSF stars with high RMS values. Default is False.

apcorrboolean, optional

Apply aperture correction. Default is False.

timestampboolean, optional

Add timestamp in verbose output (if verbose=True). Default is False.

verboseboolean, optional

Verbose output to the screen. Default is False.

Returns
cattable

The output table of best-fit PSF values for all of the

modelCCDData object

The best-fitting model for the stars (without sky).

skyCCDData object

The background sky image used for the image.

psfPSF object

The best-fitting PSF model.

prometheus.sky module

SKY.PY - Sky estimation algorithms

prometheus.sky.photutilsky(image, box_size=(50, 50), filter_size=(3, 3))[source]

Estimate sky background using photutils.

prometheus.sky.sepsky(image, box_size=(64, 64), filter_size=(3, 3))[source]

Estimate sky background using sep.

prometheus.synth module

SYNTH.PY - Make synthetic star catalogs and images

prometheus.synth.makecat(nstars=1000, heightr=[100.0, 100000.0], xr=[50.0, 950.0], yr=[50.0, 950.0])[source]

Make synthetic catalog of stars.

prometheus.synth.makeimage(nstars=1000, nx=1024, ny=1024, psf=None, cat=None, noise=True, backgrnd=1000.0)[source]

Make synthetic image

prometheus.utils module

UTILS.PY - Some PSF utility routines

prometheus.utils.estimatefwhm(objects, verbose=False)[source]

Estimate FWHM using objects.

prometheus.utils.getprintfunc(inplogger=None)[source]

Allows you to modify print() locally with a logger.

prometheus.utils.jacpoly2d(xdata, *pars)[source]

jacobian of 2D linear polynomial.

prometheus.utils.neighbors(objects, nnei=1)[source]

Find the closest neighbors to a star.

prometheus.utils.pickpsfstars(objects, fwhm, nstars=100, logger=None, verbose=False)[source]

Pick PSF stars.

prometheus.utils.poly2d(xdata, *pars)[source]

model of 2D linear polynomial.

prometheus.utils.poly2dfit(x, y, data, maxiter=2)[source]

Fit a 2D linear function to data robustly.

prometheus.utils.splitfilename(filename)[source]

Split filename into directory, base and extensions.

Module contents