Skip to content

Add a @skymodel macro #356

@ptiede

Description

@ptiede

Right now the sky modeling interface while simple has a lot of boilerplate. I think a lot of this can be simplified by a macro.
As an example consider the Gaussian model

function sky(x, meta)
    (; sig, tau, fg, pa)
   return modify(Gaussian(), Stretch(sig, sig*(1+tau)), Rotate(pa), Renormalize(fg))
end

prior = (
         sig = Uniform(1.0, 5.0),
         tau = Uniform(0.0, 1.0),
         fg = Uniform(0.0, 10.0),
         pa = WrappedUniform(pi)
)

g = imagepixels(10.0, 10.0, 128, 128)
skym = SkyModel(sky, prior, g)

the idea is to compress this to

@skymodel function gaussian(g)
    sig ~ Uniform(1.0, 5.0)
    tau ~ Uniform(1.0, 5.0)
    fg ~ Uniform(0.0, 10.0)
    pa ~ WrappedUniform(pi)
    return modify(Gaussian(), Stretch(sig, sig*(1+tau)), Rotate(pa), Renormalize(fg))
end

g = imagepixels(10.0, 10.0, 128, 128)
skym = gaussian(g)

which will parse to identical code. The big thing I need to think about is how to deal with hierarchical models, but likely that can be done by just passing the hyperparameter prior as a argument?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions