pyke
pyke copied to clipboard
Add `SceneModel` classes to enable user-friendly PSF photometry
As a convenient "container" for the various priors and likelihoods that we may want to use when carrying out PSF photometry, we should think about adding a KeplerSceneModel class. In fact there could be several SceneModel classes with several degrees of model complexity (e.g. fixed vs variable focus) to suit different needs and experiments.
Here is very rough pseudo-code:
class KeplerSceneModel():
def __init__(self, star_priors, background_prior, focus_prior, noise_likelihood):
self.priors = priors
self.noise_likelihood = noise_likelihood
self.prfs = prfs... # KeplerPRF instances, one for each star
def simulate_data(self, args):
return sum([star(args) for star in self.prfs]) + bkg(args)
def evaluate(self, args, data=data):
logp = self.noiselikelihood(data - self.simulate_data(args))
+ background_prior(args)
+ focus_prior(args)
+ sum(star.logp(args) for star in star_priors]
return logp
def fit(data, cadences='all'):
return scipy.optimize(self.evaluate, guesses=priors.mean, fargs=data)
class StarPrior():
def __init__(self, prior_x, prior_y, prior_flux):
self.priors = priors
def logp(self, x, y, flux):
return prior_x(x) + prior_y(y) + prior_flux(flux)
Barentsen also suggested that the priors should be in the scene model and the KeplerPRF class should be hidden while creating a SceneModel object.
ping @amcody @barentsen and I all talked about this idea. We want to be able to hand-in priors on RA and Dec, and have the priors update with spacecraft induced motion.
Here's a very rough pseudocode of what Geert suggested:
scene = SceneModel(stars=[StarPrior(ra, dec, pos_uncertaity, flux), StarPrior(ra, dec, flux), ..],
background_prior=UniformPrior())
scene.fit(tpf)