Skip to content

Commit

Permalink
Merge pull request #1079 from pllim/jwst-asdf-dev
Browse files Browse the repository at this point in the history
Compatibility with unreleased ASDF stack for JWST s2d data
  • Loading branch information
pllim committed Sep 12, 2023
2 parents 1674a27 + b6b0f44 commit 8f22791
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
9 changes: 0 additions & 9 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import pkg_resources

try:
from pytest_astropy_header.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS
ASTROPY_HEADER = True
except ImportError:
ASTROPY_HEADER = False

entry_points = []
for entry_point in pkg_resources.iter_entry_points('pytest11'):
entry_points.append(entry_point.name)

if "asdf_schema_tester" not in entry_points:
pytest_plugins = ['asdf.tests.schema_tester']


# Repeat this from specutils/conftest.py so tox picks it up.
def pytest_configure(config):
Expand Down
8 changes: 2 additions & 6 deletions specutils/io/default_loaders/jwst_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def _jwst_s2d_loader(filename, **kwargs):
slits = None

# Get a list of GWCS objects from the slits
with asdf_in_fits.open(filename) as af:
with fits.open(filename, memmap=False) as hdulist, asdf_in_fits.open(hdulist) as af:
# Slits can be listed under "slits", "products" or "exposures"
if "products" in af.tree:
slits = "products"
Expand All @@ -461,8 +461,6 @@ def _jwst_s2d_loader(filename, **kwargs):
if slits is not None:
wcslist = [slit["meta"]["wcs"] for slit in af.tree[slits]]

with fits.open(filename, memmap=False) as hdulist:

primary_header = hdulist["PRIMARY"].header

hdulist_sci = [hdu for hdu in hdulist if hdu.name == "SCI"]
Expand Down Expand Up @@ -567,11 +565,9 @@ def _jwst_s3d_loader(filename, **kwargs):
spectra = []

# Get a list of GWCS objects from the slits
with asdf_in_fits.open(filename) as af:
with fits.open(filename, memmap=False) as hdulist, asdf_in_fits.open(hdulist) as af:
wcslist = [af.tree["meta"]["wcs"]]

with fits.open(filename, memmap=False) as hdulist:

primary_header = hdulist["PRIMARY"].header

hdulist_sci = [hdu for hdu in hdulist if hdu.name == "SCI"]
Expand Down

0 comments on commit 8f22791

Please sign in to comment.