Set a prior that maps are physical/non-negative?
See original GitHub issueIs your feature request related to a problem? Please describe.
When fitting lightcurves to spherical harmonics in some experiments, significant fractions of the posterior maps are unphysical with minimum fluxesintensities that are negative.
Describe the solution you’d like
It would be nice if there is a way to put in a prior that a map be positive. Is there a way to do this already? It looks like it could be done with pymc3 priors using Luger et al. 2018 equation 40 for ell=1 but maybe not so easily for higher orders. It looks like earlier starry
versions had .is_physical()
but I can’t find that in newer starry versions.
Describe alternatives you’ve considered
Perhaps one can look at the samples after the fact to see if they are physical with rendering on a course grid. Or go back to earlier versions of starry that use .is_physical()
in emcee
with the prior function.
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
@eas342 Sorry for my slow reply. In recent versions of
starry
there’s a minimize method that returns the value of the minimum intensity across the map. You could simply check if that’s less than zero and that would reproduce the behavior ofis_physical
in previous versions. But that’s quite inefficient. A better way, similar to what you suggested, can sometimes be to actually sample in the pixel intensities themselves. Then you can specify apm.Uniform
prior on those pixels directly. This is likely faster and easier for NUTS to sample than the example you provided. To compute the flux, simply apply the spherical harmonic transform matrixA
to vector of pixel intensities as follows:Examples of this can be found here: https://starry.readthedocs.io/en/latest/notebooks/PixelSampling/
Let me know if this helps!
I may have found a way to do this using
Potential
in pymc3 with the following lines inside the model.