Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SceneModel classes to enable user-friendly PSF photometry #125

Open
barentsen opened this issue Oct 9, 2017 · 3 comments
Open

Add SceneModel classes to enable user-friendly PSF photometry #125

barentsen opened this issue Oct 9, 2017 · 3 comments

Comments

@barentsen
Copy link
Member

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)
@mirca
Copy link
Member

mirca commented Nov 27, 2017

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

@gully
Copy link
Contributor

gully commented Apr 11, 2018

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
Copy link
Contributor

gully commented Apr 11, 2018

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants