Eureka icon indicating copy to clipboard operation
Eureka copied to clipboard

Adding the option to impose positive values on fitted eclipse maps

Open mark-hammond opened this issue 1 year ago • 6 comments

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.

mark-hammond avatar Aug 14 '23 11:08 mark-hammond

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

mark-hammond avatar Aug 21 '23 09:08 mark-hammond

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?

taylorbell57 avatar Aug 24 '23 21:08 taylorbell57

Yes, go for it!

mark-hammond avatar Aug 25 '23 06:08 mark-hammond

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)

mark-hammond avatar Sep 18 '23 08:09 mark-hammond

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

mark-hammond avatar Sep 18 '23 09:09 mark-hammond

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.

Files Patch % Lines
src/eureka/S5_lightcurve_fitting/plots_s5.py 4.83% 59 Missing :warning:
...curve_fitting/differentiable_models/StarryModel.py 27.77% 26 Missing :warning:
...c/eureka/S5_lightcurve_fitting/gradient_fitters.py 25.00% 12 Missing :warning:
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.

codecov[bot] avatar Feb 10 '24 00:02 codecov[bot]