Skip to content

Commit

Permalink
Fixed filename conflicts in badpix_selfcal test (#8792)
Browse files Browse the repository at this point in the history
Co-authored-by: Tyler Pauly <[email protected]>
  • Loading branch information
emolter and tapastro authored Sep 17, 2024
1 parent 5b49c08 commit be36c54
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions jwst/regtest/test_miri_mrs_badpix_selfcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@
import os


OUTSTEM_BKG = "result_bkgasn"
OUTSTEM_SELFCAL = "result_selfcalasn"

@pytest.fixture(scope="module")
def run_pipeline_background(rtdata_module):
'''Run the pipeline with asn in which the background exposures are marked as `background`.
'''

rtdata = rtdata_module
rtdata.get_asn("miri/mrs/jw01204-o021_20240127t024203_spec2_00010_asn.json")
Step.from_cmdline(['calwebb_spec2', rtdata.input,
f"--steps.badpix_selfcal.output_file={OUTSTEM_BKG}",
"--steps.badpix_selfcal.save_results=True",
"--steps.badpix_selfcal.save_flagged_bkg=True",
"--steps.badpix_selfcal.flagfrac_lower=0.0005",
"--steps.badpix_selfcal.skip=False"])
rtdata.output = "jw01204021001_02101_00004_mirifulong_badpix_selfcal.fits"
rtdata.output = f"{OUTSTEM_BKG}_badpix_selfcal.fits"
return rtdata


Expand All @@ -25,10 +31,11 @@ def run_pipeline_selfcal(rtdata_module):
rtdata = rtdata_module
rtdata.get_asn("miri/mrs/jw01204-o021_20240127t024203_spec2_00010_selfcal_asn.json")
Step.from_cmdline(['calwebb_spec2', rtdata.input,
f"--steps.badpix_selfcal.output_file={OUTSTEM_SELFCAL}",
"--steps.badpix_selfcal.save_results=True",
"--steps.badpix_selfcal.flagfrac_lower=0.0005",
"--steps.badpix_selfcal.skip=False"])
rtdata.output = "jw01204021001_02101_00004_mirifulong_badpix_selfcal.fits"
rtdata.output = f"{OUTSTEM_SELFCAL}_badpix_selfcal.fits"

return rtdata

Expand All @@ -40,15 +47,15 @@ def test_miri_mrs_badpix_selfcal(run_pipeline_selfcal, fitsdiff_default_kwargs):
rtdata = run_pipeline_selfcal

# Get the truth file
rtdata.get_truth("truth/test_miri_mrs_badpix_selfcal/jw01204021001_02101_00004_mirifulong_badpix_selfcal.fits")
rtdata.get_truth(f"truth/test_miri_mrs_badpix_selfcal/{OUTSTEM_SELFCAL}_badpix_selfcal.fits")

# Compare the results
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()

# check the bkg files in the background case, but not in the selfcal case
for idx in range(4):
fname = f"jw01204021001_02101_00004_mirifulong_badpix_selfcal_bkg_{idx}.fits"
fname = f"{OUTSTEM_SELFCAL}_badpix_selfcal_bkg_{idx}.fits"
assert not os.path.isfile(fname)


Expand All @@ -59,15 +66,15 @@ def test_miri_mrs_badpix_selfcal_bkg(run_pipeline_background, fitsdiff_default_k
rtdata = run_pipeline_background

# Get the truth file
rtdata.get_truth("truth/test_miri_mrs_badpix_selfcal/jw01204021001_02101_00004_mirifulong_badpix_selfcal.fits")
rtdata.get_truth(f"truth/test_miri_mrs_badpix_selfcal/{OUTSTEM_BKG}_badpix_selfcal.fits")

# Compare the results
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()

# check the bkg files in the background case, but not in the selfcal case
for idx in range(4):
fname = f"jw01204021001_02101_00004_mirifulong_badpix_selfcal_bkg_{idx}.fits"
fname = f"{OUTSTEM_BKG}_badpix_selfcal_bkg_{idx}.fits"
truth = rtdata.get_truth(f"truth/test_miri_mrs_badpix_selfcal/{fname}")
diff = FITSDiff(fname, truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()
assert diff.identical, diff.report()

0 comments on commit be36c54

Please sign in to comment.