Skip to content

Commit

Permalink
BUG: JWST readers compatibility with asdf dev
Browse files Browse the repository at this point in the history
because it should not operate on closed ASDF file handler.
  • Loading branch information
pllim committed Sep 12, 2023
1 parent 1674a27 commit 809d062
Showing 1 changed file with 2 additions and 6 deletions.
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 809d062

Please sign in to comment.