Point Spread Function Photometry

class pyke.prf.PRFPhotometry(scene_model, prior, loss_function=<class 'oktopus.posterior.PoissonPosterior'>, **kwargs)[source]

This class performs PRF Photometry on TPF-like files.

Examples

>>> from pyke import KeplerTargetPixelFile, SimpleKeplerPRF, SceneModel, PRFPhotometry
>>> from oktopus import UniformPrior
>>> tpf = KeplerTargetPixelFile("https://archive.stsci.edu/missions/kepler/"
...                             "target_pixel_files/0084/008462852/"
...                             "kplr008462852-2013098041711_lpd-targ.fits.gz") 
Downloading https://archive.stsci.edu/missions/kepler/target_pixel_files/0084/008462852/kplr008462852-2013098041711_lpd-targ.fits.gz [Done]
>>> prf = SimpleKeplerPRF(tpf.channel, tpf.shape[1:], tpf.column, tpf.row) 
Downloading http://archive.stsci.edu/missions/kepler/fpc/prf/extracted/kplr16.4_2011265_prf.fits [Done]
>>> scene = SceneModel(prfs=prf) 
>>> prior = UniformPrior(lb=[1.2e5, 230., 128.,1e2], ub=[3.4e5, 235., 133., 1e3]) 
>>> phot = PRFPhotometry(scene, prior) 
>>> results = phot.fit(tpf.flux) 
>>> flux_fit = results[:, 0] 
>>> x_fit = results[:, 1] 
>>> y_fit = results[:, 2] 
>>> bkg_fit = results[:, 3] 

Attributes

scene_model (instance of SceneModel) Model which will be fit to the data
priors (instance of oktopus.JointPrior) Priors on the parameters that will be estimated
loss_function (subclass of oktopus.LossFunction) Noise distribution associated with each random measurement

Methods

fit(tpf_flux[, x0, cadences, method]) Fits the scene model to the given data in tpf_flux.
get_residuals()
fit(tpf_flux, x0=None, cadences='all', method='powell', **kwargs)[source]

Fits the scene model to the given data in tpf_flux.

Parameters:

tpf_flux : array-like

A pixel flux time-series, i.e., the pixel data, e.g, KeplerTargetPixelFile.flux, such that (time, row, column) represents the shape of tpf_flux.

x0 : array-like or None

Initial guesses on the parameters. The default is to use the mean of the prior distribution.

cadences : array-like of ints or str

A list or array that contains the cadences which will be fitted. Default is to fit all cadences.

kwargs : dict

Dictionary of additional parameters to be passed to scipy.optimize.minimize.

Returns:

opt_params : array-like

Matrix with the optimized parameter values. The i-th line contain the best parameter values at the i-th cadence. The order of the parameters in every line follows the order of the scene_model.

get_residuals()[source]
class pyke.prf.SceneModel(prfs, bkg_model=<function SceneModel.<lambda>>)[source]

This class builds a generic model for a scene.

Attributes

prfs (list of callables) A list of prfs
bkg_model (callable) A function that models the background variation. Default is a constant background

Methods

__call__(*params)
evaluate(*params)
Parameters:
gradient(*params)
plot(*params, **kwargs)
evaluate(*params)[source]
Parameters:

flux : scalar or array-like

Total integrated flux of the PRF model

center_col, center_row : scalar or array-like

Column and row coordinates of the center

scale_col, scale_row : scalar or array-like

Pixel scale in the column and row directions

rotation_angle : float

Rotation angle in radians

bkg_params : scalar or array-like

Parameters for the background model

gradient(*params)[source]
plot(*params, **kwargs)[source]
class pyke.prf.KeplerPRF(channel, shape, column, row)[source]

Kepler’s Pixel Response Function as designed by [R6].

This class provides the necessary interface to load Kepler PRF calibration files and to create a model that can be fit as a function of flux, center positions, width, and rotation angle.

References

[R6](1, 2) S. T. Bryson. The Kepler Pixel Response Function, 2010. <https://arxiv.org/abs/1001.0331>.

Examples

Objects from the KeplerPRF class are defined by a channel number, a pair of dimensions (the size of the image), and a reference coordinate (bottom left corner). In this example, we create a KeplerPRF object located at channel #44 with dimension equals 10 x 10, reference row and column coordinate equals (5, 5). After the object has been created, we may translate it to a given center coordinate. Additionally, we can specify total flux, pixel scales, and rotation around the object’s center.

>>> import math
>>> import matplotlib.pyplot as plt
>>> from pyke import KeplerPRF
>>> kepprf = KeplerPRF(channel=44, shape=(10, 10), column=5, row=5) 
Downloading http://archive.stsci.edu/missions/kepler/fpc/prf/extracted/kplr13.4_2011265_prf.fits [Done]
>>> prf = kepprf(flux=1000, center_col=10, center_row=10,
...              scale_row=0.7, scale_col=0.7, rotation_angle=math.pi/2) 
>>> plt.imshow(prf, origin='lower') 

Attributes

channel (int) KeplerTargetPixelFile.channel
shape ((int, int)) KeplerTargetPixelFile.shape[1:]
column (int) KeplerTargetPixelFile.column
row (int) KeplerTargetPixelFile.row

Methods

__call__(flux, center_col, center_row, …)
evaluate(flux, center_col, center_row, …) Interpolates the PRF model onto detector coordinates.
plot(*params, **kwargs)
evaluate(flux, center_col, center_row, scale_col, scale_row, rotation_angle)[source]

Interpolates the PRF model onto detector coordinates.

Parameters:

flux : float

Total integrated flux of the PRF

center_col, center_row : float

Column and row coordinates of the center

scale_col, scale_row : float

Pixel scale in the column and row directions

rotation_angle : float

Rotation angle in radians

Returns:

prf_model : 2D array

Two dimensional array representing the PRF values parametrized by flux, centroids, widths, and rotation.

plot(*params, **kwargs)[source]
class pyke.prf.SimpleKeplerPRF(channel, shape, column, row)[source]

Simple model of KeplerPRF.

This class provides identical functionality as in KeplerPRF, except that it is parametrized only by flux and center positions. The width scales and angle are fixed to 1.0 and 0, respectivelly.

Methods

__call__(flux, center_col, center_row)
evaluate(flux, center_col, center_row) Interpolates the PRF model onto detector coordinates.
gradient(flux, center_col, center_row) This function returns the gradient of the SimpleKeplerPRF model with respect to flux, center_col, and center_row.
plot(*params, **kwargs)
evaluate(flux, center_col, center_row)[source]

Interpolates the PRF model onto detector coordinates.

Parameters:

flux : float

Total integrated flux of the PRF

center_col, center_row : float

Column and row coordinates of the center

Returns:

prf_model : 2D array

Two dimensional array representing the PRF values parametrized by flux and centroids.

gradient(flux, center_col, center_row)[source]

This function returns the gradient of the SimpleKeplerPRF model with respect to flux, center_col, and center_row.

Parameters:

flux : float

Total integrated flux of the PRF

center_col, center_row : float

Column and row coordinates of the center

Returns:

grad_prf : list

Returns a list of arrays where the elements are the derivative of the KeplerPRF model with respect to flux, center_col, and center_row, respectively.

pyke.prf.get_initial_guesses(data, ref_col, ref_row)[source]

Compute the initial guesses for total flux, centers position, and PSF width using the sample moments of the data.

Parameters:

data : 2D array-like

Image data

ref_col, ref_row : scalars

Reference column and row (coordinates of the bottom left corner)

Inheritance Diagram