Skip to content
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

Provide default data units in JWST data loader #449

Merged
merged 1 commit into from
Jun 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions specutils/io/default_loaders/jwst_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,17 @@ def jwst_loader(filename, spectral_axis_unit=None, **kwargs):
if hdu.name != 'EXTRACT1D':
continue

wavelength = hdu.data['WAVELENGTH'] * u.Unit(hdu.header['TUNIT1'])
flux = hdu.data['FLUX'] * u.Unit(hdu.header['TUNIT2'])
error = hdu.data['ERROR'] * u.Unit(hdu.header['TUNIT3'])
# Provide reasonable defaults based on the units assigned by the
# extract1d step of the JWST pipeline. TUNIT fields should be
# populated by the pipeline, but it's apparently possible for them
# to be missing in some files.
wavelength_units = u.Unit(hdu.header.get('TUNIT1', 'um'))
flux_units = u.Unit(hdu.header.get('TUNIT2', 'mJy'))
error_units = u.Unit(hdu.header.get('TUNIT3', 'mJy'))

wavelength = hdu.data['WAVELENGTH'] * wavelength_units
flux = hdu.data['FLUX'] * flux_units
error = hdu.data['ERROR'] * error_units

meta = dict(slitname=hdu.header.get('SLTNAME', ''))

Expand Down