Eureka
Eureka copied to clipboard
Adding the option to impose positive values on fitted eclipse maps
The default Starry-based eclipse mapping method fits the spherical harmonic coefficients directly, which allows maps containing regions of negative emission. In some circumstances it is desirable to require positive maps only.
This PR therefore adds the "pixel sampling" method described in https://starry.readthedocs.io/en/latest/notebooks/PixelSampling/, which is activated by adding a "pixel_ydeg" independent EPF parameter. The fitted map can then be required to be positive with a True "force_positive_map" ECF flag, which assigns a LogNormal prior to each pixel. The new "record_map" ECF flag allows the posterior distribution of the fitted maps to be recorded and plotted.
If "pixel_ydeg" is present and "force_positive_map" is False, each pixel is assigned a Normal prior allowing negative values, which gives similar results to the original method.
If this looks OK, I'm happy to add the new parameters to the documentation. I have tested fits with a variety of pixel distributions and flag combinations on my own machine.
I've fixed the conflict in S5_lightcurve_fitting/differentiable_models/StarryModel.py where the main branch was updated to allow negative rp; the positive maps branch now allows that to happen when pixel sampling isn't used
Thanks for submitting this Mark - I'm excited to get this incorporated! Is it alright with you if I make a few edits directly to your PR?
Yes, go for it!
I found that the pixel trace saving in gradient_fitters.py wasn't working as it needed converting to arviz format before saving (did it work for you previously? It could be different dependency versions) so I changed it to convert to arviz and save. I also made it only save if it's calculating a pixel map (as the rest of the trace is already saved elsewhere in the nuts_samples.h5 file without the pixel values)
I've also added the option to output the various parts of the calculated lightcurve from plot_s5.py with a "record_plot_data" switch, which I've needed for plotting things like residual eclipse mapping signals, as I don't think they're easily accessible from any of the default output options
Codecov Report
Attention: Patch coverage is 26.51515%
with 97 lines
in your changes are missing coverage. Please review.
Project coverage is 57.17%. Comparing base (
82c650a
) to head (e3af769
). Report is 107 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #559 +/- ##
==========================================
- Coverage 58.06% 57.17% -0.89%
==========================================
Files 97 98 +1
Lines 11855 12097 +242
==========================================
+ Hits 6884 6917 +33
- Misses 4971 5180 +209
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.