Standardize spectrum.meta.header #1125
Replies: 7 comments 1 reply
-
I think that the solution to '1' should be that we decide everything in meta['header'] should be a Header object. For '2' I think that structuring meta['header']into meta['header']['primary-header'] and meta['header']['data-header'] makes sense. Tabular fits doesn't allow writing to the 0th extension, so any format that uses this to write will not actually be able to preserve the structure of the output file (can either drop primary or concatenate), but structuring them like this in Spectrum1D will make it easier to write formats that do preserve this structure. |
Beta Was this translation helpful? Give feedback.
-
Is this about just using its |
Beta Was this translation helpful? Give feedback.
-
More specifically, its currently direct use of fits.HDUList([primary_hdu, fits.BinTableHDU(tab)]).writeto(file_name, **kwargs) (with whatever info we wish to have added to |
Beta Was this translation helpful? Give feedback.
-
FWIW I support both of @cshanahan1's proposals, it seems reasonable to store both primary and data headers in |
Beta Was this translation helpful? Give feedback.
-
I agree it makes sense to store all relevant headers. I am a bit uncertain about the naming – |
Beta Was this translation helpful? Give feedback.
-
While I agree that moving towards some level of consistency of what's in meta is good from making it easier to use spectra from different places, I feel that doing that so that the writers can dump out the header is a mistake. Most of the code in https://github.com/astropy/specutils/blob/main/specutils/io/default_loaders/dc_common.py exists to work around the fact that people copied across headers without checking that the contents were valid or still made sense (and most of my time spent on getting new survey data is pushing back on survey teams which have done this, and need to clean up their headers). Internally at Data Central we have a writer whose purpose is to provide a "quick-look" version of any spectra we have, and even though we know what's in the headers and have checked it (and if needed provide a fixed version), we use what's in the database (which is why it's currently not public, it's too coupled to our db structure). I think if we want to improve what FITS writers we have, then we should require users to pass the metadata in as additional arguments, and warn when they miss out metadata we think they should have (e.g. |
Beta Was this translation helpful? Give feedback.
-
Wouldn't that be caught to some extent by pulling exclusively from |
Beta Was this translation helpful? Give feedback.
-
Related issues / PRs mentioning this topic:
#617
#1102
#1107
It has come up several times that there is no consistency in what is populated in spectrum.meta['header'] when reading in a FITS file. Consequently, writing out a Spectrum1D to FITS is unpredictable (what extension will the keywords in meta.header be written to? what keywords will be dropped? what format should meta.header be?). For example, when using the tabular fits reader to read in a fits file, only some of the header keywords from the 1st extension (ignoring the 0th) will be populated in meta['header'] as an OrderedDict, but when using tabular-fits to write out this same Spectrum1D that was read in with tabular-fits, it requires a Header() object in spectrum.meta['header'].
There has been some recent discussion about a multi-extension fits read/write format to preserve a PrimaryHDU on the output file to describe the data within, and doing this would require more structure in .meta['header'] to determine what should be written to the 0th extension, and what should be written to the data extension.
So, we need to standardize:
jwst_reader
will combine 0th and 1st from a file read in, and put them all in the 1st when written out.Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions