jgliss / pyplis

Python toolbox for the analysis of UV SO2 camera data
GNU General Public License v3.0
7 stars 5 forks source link

Img.save_as_fits() does not save meta data #5

Closed solvejgdinger closed 6 years ago

solvejgdinger commented 6 years ago

I use Img.save_as_fits() and Img.load_fits() for saving averaged dark images. However I run into the problem, that the Img.meta dictionary is not saved (and consequently reloaded). Thus exposure times etc cannot be used for dark correction.

This could be fixed by adding hdu.header.update(self.meta) to the Img.save_as_fits() method. This however results in the following error when calling the method

  File "C:\Users\asd\AppData\Local\Continuum\Anaconda3\envs\pyplis\lib\site-packages\astropy\io\fits\card.py", line 311, in value
    raise ValueError('Illegal value: {!r}.'.format(value))

ValueError: Illegal value: datetime.datetime(2017, 7, 20, 13, 29, 59, 257474).

as (probably) only standard types can be saved in a Fits header.

For now, single meta data can be saved by adding e.g.

hdu.header.update({'texp':self.meta['texp'],'temperature':self.meta['temperature']})

instead of the whole meta dictionary.

Nevertheless, on the long run, it should be possible to save the full meta dictionary reliably.

jgliss commented 6 years ago

Resolved in latest commit.