Skip to content

Commit

Permalink
JP-2928: Update regression test data for miscellaneous NIRSpec modes (s…
Browse files Browse the repository at this point in the history
  • Loading branch information
melanieclarke authored Oct 16, 2024
2 parents 254b504 + 6772524 commit e3534b4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 78 deletions.
14 changes: 7 additions & 7 deletions jwst/regtest/test_nirspec_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def test_nirspec_missing_msa_fail(rtdata, fitsdiff_default_kwargs, monkeypatch):
that's missing an MSAMETFL. Exception should be raised.
"""

# Get the input file
rtdata.get_data('nirspec/mos/f170lp-g235m_mos_observation-6-c0e0_001_dn_nrs1_mod.fits')
# Get the input file, don't get the MSA file
rtdata.get_data('nirspec/mos/jw01180025001_05101_00001_nrs2_rate.fits')

# Run the calwebb_spec2 pipeline
args = ["calwebb_spec2", rtdata.input]
Expand All @@ -41,8 +41,8 @@ def test_nirspec_missing_msa_nofail(rtdata, fitsdiff_default_kwargs, monkeypatch
that's missing an MSAMETFL. Exception should NOT be raised.
"""

# Get the input file
rtdata.get_data('nirspec/mos/f170lp-g235m_mos_observation-6-c0e0_001_dn_nrs1_mod.fits')
# Get the input file, don't get the MSA file
rtdata.get_data('nirspec/mos/jw01180025001_05101_00001_nrs2_rate.fits')

# Run the calwebb_spec2 pipeline
args = ["calwebb_spec2",
Expand All @@ -69,7 +69,7 @@ def test_nirspec_assignwcs_skip(rtdata, fitsdiff_default_kwargs, caplog):
"""

# Get the input file
rtdata.get_data('nirspec/mos/f170lp-g235m_mos_observation-6-c0e0_001_dn_nrs1_mod.fits')
rtdata.get_data('nirspec/mos/jw01180025001_05101_00001_nrs2_rate.fits')

# Run the calwebb_spec2 pipeline
args = ["calwebb_spec2",
Expand All @@ -90,7 +90,7 @@ def test_nirspec_nrs2_nodata_api(rtdata, fitsdiff_default_kwargs):
"""

# Get the input file
rtdata.get_data('nirspec/ifu/jw84700006001_02101_00001_nrs2_rate.fits')
rtdata.get_data('nirspec/ifu/jw01128009001_0310c_00004_nrs2_rate.fits')

# Call the Spec2Pipeline
step = Spec2Pipeline()
Expand All @@ -109,7 +109,7 @@ def test_nirspec_nrs2_nodata_strun(rtdata, fitsdiff_default_kwargs, caplog):
"""

# Get the input file
rtdata.get_data('nirspec/ifu/jw84700006001_02101_00001_nrs2_rate.fits')
rtdata.get_data('nirspec/ifu/jw01128009001_0310c_00004_nrs2_rate.fits')

# Call the Spec2Pipeline
cmd = [
Expand Down
23 changes: 14 additions & 9 deletions jwst/regtest/test_nirspec_image2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@

@pytest.mark.bigdata
def test_nirspec_image2(rtdata, fitsdiff_default_kwargs):
rtdata.get_data("nirspec/imaging/jw84600010001_02102_00001_nrs2_rate.fits")
basename = 'jw03290001001_03101_00001_nrs2'
rtdata.get_data(f"nirspec/imaging/{basename}_rate.fits")

args = ["calwebb_image2", rtdata.input]
Step.from_cmdline(args)
rtdata.output = "jw84600010001_02102_00001_nrs2_cal.fits"
rtdata.output = f"{basename}_cal.fits"

rtdata.get_truth("truth/test_nirspec_image2/jw84600010001_02102_00001_nrs2_cal.fits")
rtdata.get_truth(f"truth/test_nirspec_image2/{basename}_cal.fits")

diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()
Expand All @@ -26,22 +27,25 @@ def test_nirspec_image2(rtdata, fitsdiff_default_kwargs):
@pytest.mark.bigdata
def test_flat_field_step_user_supplied_flat(rtdata, fitsdiff_default_kwargs):
"""Test providing a user-supplied flat field to the FlatFieldStep"""
data = rtdata.get_data('nirspec/imaging/usf_assign_wcs.fits')
user_supplied_flat = rtdata.get_data('nirspec/imaging/usf_flat.fits')
basename = 'jw03290001001_03101_00001_nrs2'
output_file = f'{basename}_flat_from_user_file.fits'
data = rtdata.get_data(f'nirspec/imaging/{basename}_assign_wcs.fits')
user_supplied_flat = rtdata.get_data(f'nirspec/imaging/{basename}_interpolatedflat.fits')

data_flat_fielded = FlatFieldStep.call(data, user_supplied_flat=user_supplied_flat)
rtdata.output = 'flat_fielded_step_user_supplied.fits'
rtdata.output = output_file
data_flat_fielded.write(rtdata.output)

rtdata.get_truth('truth/test_nirspec_image2/flat_fielded_step_user_supplied.fits')
rtdata.get_truth(f'truth/test_nirspec_image2/{output_file}')
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()


@pytest.mark.bigdata
def test_ff_inv(rtdata, fitsdiff_default_kwargs):
"""Test flat field inversion"""
with dm.open(rtdata.get_data('nirspec/imaging/usf_assign_wcs.fits')) as data:
input_file = 'nirspec/imaging/jw03290001001_03101_00001_nrs2_assign_wcs.fits'
with dm.open(rtdata.get_data(input_file)) as data:
flatted = FlatFieldStep.call(data)
unflatted = FlatFieldStep.call(flatted, inverse=True)

Expand All @@ -56,7 +60,8 @@ def test_ff_inv(rtdata, fitsdiff_default_kwargs):
@pytest.mark.bigdata
def test_correction_pars(rtdata, fitsdiff_default_kwargs):
"""Test use of correction parameters"""
with dm.open(rtdata.get_data('nirspec/imaging/usf_assign_wcs.fits')) as data:
input_file = 'nirspec/imaging/jw03290001001_03101_00001_nrs2_assign_wcs.fits'
with dm.open(rtdata.get_data(input_file)) as data:

# First use of FlatFieldStep will store the correction.
# The next use will use that correction
Expand Down
3 changes: 2 additions & 1 deletion jwst/regtest/test_nirspec_irs2_detector1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def run_detector1pipeline(rtdata_module):
Step.from_cmdline([
"calwebb_detector1",
rtdata.input,
"--steps.group_scale.save_results=True",
"--steps.dq_init.save_results=True",
"--steps.saturation.save_results=True",
"--steps.superbias.save_results=True",
Expand Down Expand Up @@ -52,7 +53,7 @@ def run_detector1_with_clean_flicker_noise(rtdata_module):


@pytest.mark.bigdata
@pytest.mark.parametrize("suffix", ['dq_init', 'saturation', 'superbias',
@pytest.mark.parametrize("suffix", ['group_scale', 'dq_init', 'saturation', 'superbias',
'refpix', 'linearity', 'dark_current', 'jump',
'0_ramp_fit', 'gain_scale',
'rate'])
Expand Down
42 changes: 0 additions & 42 deletions jwst/regtest/test_nirspec_subarray.py

This file was deleted.

29 changes: 10 additions & 19 deletions jwst/regtest/test_nirspec_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@

from jwst.stpipe import Step

ROOT = 'nrs_verify_nrs1'
# Input is jw01970001001_02102_00001_nrs1_uncal.fits, a verify-only image
# preceding an IFU observation, with EXP_TYPE=NRS_IMAGE.
# There is currently no data with EXP_TYPE=NRS_VERIFY available in
# the archive.
ROOT = 'jw01970002001_03101_00001_nrs1'


@pytest.fixture(scope='module')
def run_detector1(rtdata_module):
"""Run NRS_VERIFY through detector1"""
"""Run a verify-only NIRSpec image through detector1."""
rtdata = rtdata_module
rtdata.get_data(f'nirspec/imaging/{ROOT}_uncal.fits')

Expand All @@ -28,28 +32,15 @@ def run_detector1(rtdata_module):

@pytest.fixture(scope='module')
def run_image2(run_detector1, rtdata_module):
"""Run NRS_VERIFY through image2"""
"""Run a verify-only NIRSpec image through image2."""
rtdata = rtdata_module

# Get some predefined references due to insufficient coverage
# from CRDS.
refs = ['jwst_nirspec_fpa_0005.asdf', 'jwst_nirspec_flat_0061.fits', 'jwst_nirspec_area_0001.fits']
for ref in refs:
rtdata.get_data(f'nirspec/imaging/{ref}')

rtdata.input = f'{ROOT}_rate.fits'

args = [
'calwebb_image2', rtdata.input,
'--steps.assign_wcs.save_results=true',
'--steps.assign_wcs.override_fpa=jwst_nirspec_fpa_0005.asdf',
'--steps.flat_field.save_results=true',
'--steps.flat_field.override_flat=jwst_nirspec_flat_0061.fits',
'--steps.flat_field.override_sflat=N/A',
'--steps.flat_field.override_fflat=N/A',
'--steps.flat_field.override_dflat=N/A',
'--steps.photom.save_results=true',
'--steps.photom.override_area=jwst_nirspec_area_0001.fits',
'--steps.photom.save_results=true'
]
Step.from_cmdline(args)

Expand All @@ -61,7 +52,7 @@ def run_image2(run_detector1, rtdata_module):
'dark_current', 'jump', 'rate',
])
def test_verify_detector1(run_detector1, rtdata_module, fitsdiff_default_kwargs, suffix):
"""Test results of the detector1 and image2 processing"""
"""Test results of the detector1 processing."""
rtdata = rtdata_module
output = f'{ROOT}_{suffix}.fits'
rtdata.output = output
Expand All @@ -80,7 +71,7 @@ def test_verify_detector1(run_detector1, rtdata_module, fitsdiff_default_kwargs,
'assign_wcs', 'flat_field', 'cal',
])
def test_verify_image2(run_image2, rtdata_module, fitsdiff_default_kwargs, suffix):
"""Test results of the detector1 and image2 processing"""
"""Test results of the image2 processing."""
rtdata = rtdata_module
output = f'{ROOT}_{suffix}.fits'
rtdata.output = output
Expand Down

0 comments on commit e3534b4

Please sign in to comment.