mzechmeister / serval

calculate radial velocities from stellar spectra
MIT License
36 stars 9 forks source link

ValueError: Floating point nan values are not allowed in FITS headers. II #27

Closed mzechmeister closed 5 years ago

mzechmeister commented 5 years ago

This error can arise in coadding: spt.header['HIERARCH SERVAL COADD SN%03i' % o] = (float("%.3f" % sn), 'signal-to-noise estimate')

Here a nan has entered the coadding. But using -skippre, the error doesn't occur.

The main problem is that the section attribute seems not to provide a copy. So when the data are loaded:

https://github.com/mzechmeister/serval/blob/f48e7cb6fc8af3a1fd789cd54ad7d5cc77cbe86c/src/inst_CARM_NIR.py#L132 or https://github.com/mzechmeister/serval/blob/f48e7cb6fc8af3a1fd789cd54ad7d5cc77cbe86c/src/inst_CARM_NIR.py#L155

and modified inplace by https://github.com/mzechmeister/serval/blob/f48e7cb6fc8af3a1fd789cd54ad7d5cc77cbe86c/src/inst_CARM_NIR.py#L173-L174 or https://github.com/mzechmeister/serval/blob/f48e7cb6fc8af3a1fd789cd54ad7d5cc77cbe86c/src/inst_CARM_NIR.py#L173-L174

the data are cumulatively multiplied with 10000 (related to #22). Moreover, the bad pixels are flagged and interpolated inplace (to avoid interpolation problems for the highest SNR spectrum): https://github.com/mzechmeister/serval/blob/f48e7cb6fc8af3a1fd789cd54ad7d5cc77cbe86c/src/inst_CARM_NIR.py#L150

Everything is fine when loaded the first time, but the second time the interpolated values are remembered, while its error is still nan and enters calculation, since only nan flux is flagged.