megbedell / wobble

precise data-driven RV fitting, now with tellurics!
https://wobble.readthedocs.io
MIT License
39 stars 16 forks source link

stop fully masking negative fluxes #51

Open megbedell opened 5 years ago

megbedell commented 5 years ago

Currently if any fluxes in the HARPS data are reported as negative, we set the ivars to zero.. but this has the effect of leaving no data in the deep cores of super strong lines, which makes the template go to continuum in the middle of the line (bc regularization). We should change this to preserve a little information in the line cores. This is relevant especially for doing science with the stellar template!

mzechmeister commented 5 years ago

Negative data points can occur simply at zero flux due to readout noise. I flag significant negative flux values. https://github.com/mzechmeister/serval/blob/73e1fd843b196ab75f5b95c3652519b7ed90c2d3/src/read_spec.py#L513 In contrast to that, negative template fluxes appear unphysically and should be avoided. Probably, it can not occur in your model, since you work in log-space. But I'm curios how you transform the negative data.

megbedell commented 5 years ago

Thanks, this is useful info! Currently I take every pixel that has unnormalized flux count < 1 and set it to 1, along with setting the inverse variance on that point to zero so that it's essentially masked out: https://github.com/megbedell/wobble/blob/041cd58fa8fb87bb5b41ee23bd1ea716bab7051b/wobble/data.py#L122 I also mask out pixels on either side of the "bad" one, although that may not be the correct thing to do if it's read noise causing the negative fluxes. In the cases I've seen it seems more like the background sky subtraction (which is done in the HARPS pipeline spectral extraction) is overly aggressive. I do this setting to 1 step because transforming the flux to log space won't work otherwise - so as you say we don't have any issues with unphysical negative fluxes in the template, but the problem is sort of transferred to come earlier in the process when logging the data!