Skip to content

Commit

Permalink
Minor changes to DC loaders for future surveys
Browse files Browse the repository at this point in the history
This makes it easier to use a fallback header and access the last
spectra from a wrapper loader. These changes are to support loading some
of the IFS surveys (such as SAMI) that Data Central hosts.
  • Loading branch information
aragilar committed Feb 6, 2024
1 parent 17a6f6b commit dbe14cf
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions specutils/io/default_loaders/dc_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,12 @@ def add_single_spectra_to_map(
return None

if valid_wcs or not spec_wcs_info:
wcs = WCS(header)
try:
wcs = WCS(header)
except (ValueError, KeyError):
if fallback_header is None:
raise
wcs = WCS(fallback_header)

Check warning on line 314 in specutils/io/default_loaders/dc_common.py

View check run for this annotation

Codecov / codecov/patch

specutils/io/default_loaders/dc_common.py#L309-L314

Added lines #L309 - L314 were not covered by tests
if drop_wcs_axes is not None:
if isinstance(drop_wcs_axes, Callable):
wcs = drop_wcs_axes(wcs)
Expand Down Expand Up @@ -352,9 +357,7 @@ def add_single_spectra_to_map(
spectrum.uncertainty = UNCERTAINTY_MAP[purpose](aligned_flux)
spectrum.meta["uncertainty_header"] = header

# We never actually want to return something, this just flags it to pylint
# that we know we're breaking out of the function when skip is selected
return None
return spectrum

Check warning on line 360 in specutils/io/default_loaders/dc_common.py

View check run for this annotation

Codecov / codecov/patch

specutils/io/default_loaders/dc_common.py#L360

Added line #L360 was not covered by tests


def get_purpose(
Expand Down

0 comments on commit dbe14cf

Please sign in to comment.