kevin218 / Eureka

Eureka! is a data reduction and analysis pipeline intended for time-series observations with JWST.
https://eurekadocs.readthedocs.io/
MIT License
58 stars 45 forks source link

Adding the option to impose positive values on fitted eclipse maps #559

Open mark-hammond opened 1 year ago

mark-hammond commented 1 year ago

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 commented 1 year ago

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

taylorbell57 commented 1 year ago

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?

mark-hammond commented 1 year ago

Yes, go for it!

mark-hammond commented 11 months ago

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 _nutssamples.h5 file without the pixel values)

mark-hammond commented 11 months ago

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[bot] commented 6 months ago

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 ```diff @@ 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.