Skip to content

Commit

Permalink
Close spec1d file in sensfunc script. Hopefully a fix for CI tests fa…
Browse files Browse the repository at this point in the history
…iling on windows.
  • Loading branch information
Dusty Reichwein committed Jul 11, 2023
1 parent 60ca665 commit bef8f67
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
30 changes: 15 additions & 15 deletions pypeit/scripts/sensfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,21 @@ def main(args):
" multi_spec_det = 3,7\n"
"\n")

# Determine the spectrograph
hdul = io.fits_open(args.spec1dfile)
spectrograph = load_spectrograph(hdul[0].header['PYP_SPEC'])
spectrograph_config_par = spectrograph.config_specific_par(hdul)

# Construct a primary FITS header that includes the spectrograph's
# config keys for inclusion in the output sensfunc file
primary_hdr = io.initialize_header()
add_keys = (
['PYP_SPEC', 'DATE-OBS', 'TELESCOP', 'INSTRUME', 'DETECTOR']
+ spectrograph.configuration_keys() + spectrograph.raw_header_cards()
)
for key in add_keys:
if key.upper() in hdul[0].header.keys():
primary_hdr[key.upper()] = hdul[0].header[key.upper()]
# Determine the spectrograph and generate the primary FITS header
with io.fits_open(args.spec1dfile) as hdul:
spectrograph = load_spectrograph(hdul[0].header['PYP_SPEC'])
spectrograph_config_par = spectrograph.config_specific_par(hdul)

# Construct a primary FITS header that includes the spectrograph's
# config keys for inclusion in the output sensfunc file
primary_hdr = io.initialize_header()
add_keys = (
['PYP_SPEC', 'DATE-OBS', 'TELESCOP', 'INSTRUME', 'DETECTOR']
+ spectrograph.configuration_keys() + spectrograph.raw_header_cards()
)
for key in add_keys:
if key.upper() in hdul[0].header.keys():
primary_hdr[key.upper()] = hdul[0].header[key.upper()]

# If the .sens file was passed in read it and overwrite default parameters

Expand Down
2 changes: 0 additions & 2 deletions pypeit/tests/test_runpypeit.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def test_run_pypeit():
sf = sensfunc.SensFunc.from_file(str(sens_file))
assert len(sf.wave) > 0
assert len(sf.zeropoint) > 0
sf = None

# Flux calibrate
with open(outdir / "fluxfile", "w") as f:
Expand Down Expand Up @@ -113,7 +112,6 @@ def test_run_pypeit():
assert len(specObjs[0].BOX_FLAM[mask]) != 0
assert len(specObjs[0].BOX_FLAM_IVAR[mask]) != 0
assert len(specObjs[0].BOX_FLAM_SIG[mask]) != 0
specObjs = None

# Clean-up
shutil.rmtree(outdir)
Expand Down

0 comments on commit bef8f67

Please sign in to comment.