@@ -24,20 +24,40 @@ def run_pipeline(rtdata_module, resource_tracker):
2424 args = ["calwebb_spec2" , rtdata .input ,
2525 "--steps.assign_wcs.save_results=true" ,
2626 "--steps.msa_flagging.save_results=true" ,
27- "--steps.nsclean.skip=False" ,
28- "--steps.nsclean.save_results=true" ,
2927 "--steps.bkg_subtract.save_results=true" ,
3028 "--steps.extract_2d.save_results=true" ,
3129 "--steps.srctype.save_results=true" ,
3230 "--steps.wavecorr.save_results=true" ,
3331 "--steps.flat_field.save_results=true" ,
3432 "--steps.pathloss.save_results=true" ,
3533 "--steps.barshadow.save_results=true" ]
36- # FIXME: Handle warnings properly.
37- # Example: RuntimeWarning: Invalid interval: upper bound XXX is strictly less than lower bound XXX
38- with pytest .warns (AstropyUserWarning , match = "Input data contains invalid values" ):
39- with resource_tracker .track ():
40- Step .from_cmdline (args )
34+
35+ with resource_tracker .track ():
36+ Step .from_cmdline (args )
37+
38+ return rtdata
39+
40+
41+ @pytest .fixture (scope = "module" )
42+ def run_pipeline_nsclean (rtdata_module , resource_tracker ):
43+ """Run the calwebb_spec2 pipeline on NIRSpec MOS with nsclean."""
44+
45+ rtdata = rtdata_module
46+
47+ # Get the MSA metadata file referenced in the input exposure
48+ rtdata .get_data ("nirspec/mos/jw01345066001_01_msa.fits" )
49+
50+ # Get the input ASN file and exposures
51+ rtdata .get_asn ("nirspec/mos/jw01345-o066_20230831t181155_spec2_00010_asn.json" )
52+
53+ # Run the calwebb_spec2 pipeline; save results from intermediate steps
54+ args = ["calwebb_spec2" , rtdata .input ,
55+ "--output_file=jw01345066001_05101_00003_nrs1_nsc" ,
56+ "--steps.nsclean.skip=False" ,
57+ "--steps.nsclean.save_results=True" ]
58+
59+ with resource_tracker .track ():
60+ Step .from_cmdline (args )
4161
4262 return rtdata
4363
@@ -47,7 +67,7 @@ def test_log_tracked_resources(log_tracked_resources, run_pipeline):
4767
4868
4969@pytest .mark .parametrize ("suffix" , [
50- "assign_wcs" , "msa_flagging" , "nsclean" , " bsub" , "extract_2d" , "wavecorr" , "flat_field" ,
70+ "assign_wcs" , "msa_flagging" , "bsub" , "extract_2d" , "wavecorr" , "flat_field" ,
5171 "srctype" , "pathloss" , "barshadow" , "cal" , "s2d" , "x1d" ])
5272def test_nirspec_mos_spec2 (run_pipeline , fitsdiff_default_kwargs , suffix ):
5373 """Regression test of the calwebb_spec2 pipeline on a
@@ -66,3 +86,24 @@ def test_nirspec_mos_spec2(run_pipeline, fitsdiff_default_kwargs, suffix):
6686 # Compare the results
6787 diff = FITSDiff (rtdata .output , rtdata .truth , ** fitsdiff_default_kwargs )
6888 assert diff .identical , diff .report ()
89+
90+
91+ @pytest .mark .parametrize ("suffix" , [
92+ "nsclean" , "cal" , "s2d" , "x1d" ])
93+ def test_nirspec_mos_spec2_nsclean (run_pipeline , fitsdiff_default_kwargs , suffix ):
94+ """Regression test of the calwebb_spec2 pipeline on a
95+ NIRSpec MOS exposure. Using an exposure that's part of a
96+ 3-shutter nod sequence, so there are nodded exposures available
97+ with which to do background subtraction."""
98+
99+ # Run the pipeline and retrieve outputs
100+ rtdata = run_pipeline
101+ output = f"jw01345066001_05101_00003_nrs1_nsc_{ suffix } .fits"
102+ rtdata .output = output
103+
104+ # Get the truth files
105+ rtdata .get_truth ("truth/test_nirspec_mos_spec2/" + output )
106+
107+ # Compare the results
108+ diff = FITSDiff (rtdata .output , rtdata .truth , ** fitsdiff_default_kwargs )
109+ assert diff .identical , diff .report ()
0 commit comments