marblestation / iSpec

Download input files from https://www.cfa.harvard.edu/~sblancoc/iSpec/dev/input.tar.gz
http://www.blancocuaresma.com/s/
GNU Affero General Public License v3.0
29 stars 6 forks source link

suggestion for normalizing continuum #1

Closed arashgmn closed 1 year ago

arashgmn commented 4 years ago

I think it's better to have an expression like zeros = np.abs(continuum_flux <= 1e-4) would be more robust to round-off errors. Just as a suggestion.

https://github.com/marblestation/iSpec/blob/1d6482857705db12131ed6b5dec486dcccd5cac1/ispec/spectrum.py#L406

marblestation commented 1 year ago

Thanks for the suggestion! Have you encountered a situation where this was a problem? Because continuum_flux comes from the modeled continuum, and this was thought for parts of the spectra where the continuum cannot be modeled and the model returns zero flux (so a == 0 works fine to detect that).

arashgmn commented 1 year ago

I opened this issue long ago when I was analysing some spectra that I don't have access to anymore. Unfortunately, I cannot recall if such a condition was problematic. Nonetheless, given that the flux is often of type float, I believe a condition such as np.isclose(continuum_flux,0) is more robust than the current condition.