-
-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend spectrum information written by tabular_fits_writer
#539
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, @dhomeier. Some minor suggestions, but not necessary.
header.update([k for k in spectrum.meta.items() if | ||
isinstance(k[1], hdr_types)]) | ||
|
||
# Strip header of FITS reserved keywords (strangely, loop does not work!) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, you could do:
for keyword in ['NAXIS', 'NAXIS1', 'NAXIS2']:
header.remove(keyword, ignore_missing=True)
|
||
columns = [disp, flux] | ||
colnames = [dispname, "flux"] | ||
# Include uncertainty - ToDo: uncertainty units? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's alright to not deal with uncertainty units because they should be assumed the same as the flux units.
colnames = [dispname, "flux"] | ||
# Include uncertainty - ToDo: uncertainty units? | ||
if spectrum.uncertainty is not None: | ||
columns.append(spectrum.uncertainty.array * spectrum.uncertainty.unit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
columns.append(spectrum.uncertainty.array * spectrum.uncertainty.unit) | |
columns.append(spectrum.uncertainty.quantity) |
Thanks for the suggestions, I think they make for notably more concise code! |
This is an attempt to address some of the issues reported in #531, notably adding the missing unit information to the written spectrum. It also adds the
uncertainty
column, if present, and indicates the type ofspectral_axis
inTTYPE1
. The last commit adds writing of any other header metadata, taking the 2nd option discussed in#531 (comment) (with a new kwarg
update_header
). It also passes other kwargs though to the table writer, allowing e.g. to force overwriting of existing files.Added tests for all these functions in
test_loaders.py
Files thus written still fail to be read in as
tabular-fits
on theWCSWrapper
error, but since they are fully compliant (except for a missing checksum) FITS files with complete spectral information, this really seems to be more of a problem on the reader side.