pyke icon indicating copy to clipboard operation
pyke copied to clipboard

Add `SceneModel` classes to enable user-friendly PSF photometry

Open barentsen opened this issue 8 years ago • 3 comments

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 avatar Oct 09 '17 16:10 barentsen

Barentsen also suggested that the priors should be in the scene model and the KeplerPRF class should be hidden while creating a SceneModel object.

mirca avatar Nov 27 '17 16:11 mirca

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.

gully avatar Apr 11 '18 23:04 gully

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)

gully avatar Apr 11 '18 23:04 gully