rpoleski / MulensModel

Microlensing Modelling package
https://rpoleski.github.io/MulensModel/
Other
57 stars 15 forks source link

Flux to Magnitude conversion for negative fluxes: #110

Closed jenniferyee closed 11 months ago

jenniferyee commented 1 year ago

for PlotUtils.get_flux_and_err_from_magnitude(), we have

err_mag = (err_flux / flux) * 2.5 / np.log(10.)

This means that if flux < 0, err_mag becomes < 0, which is clearly bad.

For example, this comes up in example 05 when the data are scaled for plotting.

What is the correct behavior here? Is it as simple as adding an absolute value?

err_mag = (err_flux / np.abs(flux)) * 2.5 / np.log(10.)
rpoleski commented 1 year ago

If scaled flux is negative, then there is no way to plot given point anyway. The uncertainty of such a point is not an important problem :) We may consider adding some marks indicating at which epochs there are points that are not plotted.

jenniferyee commented 11 months ago

I think it would be better to set err_mag = zero if fluxes are negative. The points aren't plotted anyway, and a zero value for the error would function as another kind of flag without causing everything to fail.

jenniferyee commented 11 months ago

Fixed (for plotting ONLY) in fcada18c48e315906a44b3989a97f39395251847

jenniferyee commented 11 months ago

@rpoleski didn't like the fix, so I fixed it in mulensdata instead. commit af5c4144d2e896871983d98b823c0b452ac46fc6

rpoleski commented 11 months ago

Can you review this commit?