spacetelescope / dat_pyinthesky

Notebooks for "notebook-driven development" for the Data Analysis Tools efforts
https://dat-pyinthesky.readthedocs.io/en/latest/
8 stars 44 forks source link

IFU_cube_continuum_fit data file has invalid header, please fix it #177

Open pllim opened 2 years ago

pllim commented 2 years ago

The primary header of https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/IFU_cube_continuum_fit/NGC4151_Hband.fits is invalid and needs to be fixed. You can see the following error when you access it.

>>> from astropy.io import fits
>>> from astropy.utils.data import download_file
>>> fn = download_file('https://data.science.stsci.edu/redirect/JWST/jwst-data_analysis_tools/IFU_cube_continuum_fit/NGC4151_Hband.fits', cache=True)
>>> pf = fits.open(fn)
>>> pf[0].header['MODE']
.../astropy/io/fits/header.py in __getitem__(self, key)
    161             return card.rawvalue
    162
--> 163         value = card.value
    164         if value == UNDEFINED:
    165             return None

.../astropy/io/fits/card.py in value(self)
    284             value = self._value
    285         elif self._valuestring is not None or self._image:
--> 286             value = self._value = self._parse_value()
    287         else:
    288             if self._keyword == '':

.../astropy/io/fits/card.py in _parse_value(self)
    732
    733         if m is None:
--> 734             raise VerifyError("Unparsable card ({}), fix it first with "
    735                               ".verify('fix').".format(self.keyword))
    736

VerifyError: Unparsable card (MODE), fix it first with .verify('fix').

To fix it, run pf.verify('fix') and write it back out.

>>> pf.verify('fix')
WARNING: VerifyWarning: Verification reported errors: [astropy.io.fits.verify]
WARNING: VerifyWarning: HDU 0: [astropy.io.fits.verify]
WARNING: VerifyWarning:     Card 142: [astropy.io.fits.verify]
WARNING: VerifyWarning:         Card 'MODE' is not FITS standard (invalid value string: 'IFU / Reduction mode').  Fixed 'MODE' card to meet the FITS standard. [astropy.io.fits.verify]
WARNING: VerifyWarning: Note: astropy.io.fits uses zero-based indexing.
 [astropy.io.fits.verify]

>>> pf[0].header['MODE']
'IFU'

If this file was generated by an observatory, please also alert them to fix their pipeline. cc @orifox @camipacifici