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

Prevent error when read_spectra sees unrecognized FITS extensions #2439

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

rongpu
Copy link
Contributor

@rongpu rongpu commented Feb 6, 2025

This PR allows desispec.io.read_spectra to read FITS files that contains unrecognized FITS extensions. Instead of throwing a fatal error, it now prints a warning and ignores the unrecognized extensions.

Example:

from desispec.io import read_spectra
spec = read_spectra('/pscratch/sd/r/rongpu/desi_dust_y1_release/spectra/main/bright/0/0/rvspecfit-main-bright-0.fits')

output:

WARNING:spectra.py:385:read_spectra: FITS extension REDSHIFTS is not recognized and is ignored
WARNING:spectra.py:385:read_spectra: FITS extension RVTAB is not recognized and is ignored
WARNING:spectra.py:385:read_spectra: FITS extension WAVELENGTH is not recognized and is ignored
WARNING:spectra.py:385:read_spectra: FITS extension SPECMOD is not recognized and is ignored
INFO:spectra.py:392:read_spectra: iotime 0.050 sec to read rvspecfit-main-bright-0.fits at 2025-02-06T13:07:39.662369

@rongpu rongpu requested a review from sbailey February 6, 2025 21:09
@coveralls
Copy link

coveralls commented Feb 6, 2025

Coverage Status

coverage: 39.357%. remained the same
when pulling 415cf9c on readspectra
into d7eb389 on main.

@sbailey
Copy link
Contributor

sbailey commented Feb 10, 2025

Looks good, thanks. I also verified that it still works on regular spectra and coadd files as expected.

@sbailey sbailey merged commit 9961f23 into main Feb 10, 2025
26 checks passed
@sbailey sbailey deleted the readspectra branch February 10, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants