diff --git a/jwst/regtest/test_fgs_guider.py b/jwst/regtest/test_fgs_guider.py index af1e2b2a90..36841d14b3 100644 --- a/jwst/regtest/test_fgs_guider.py +++ b/jwst/regtest/test_fgs_guider.py @@ -1,16 +1,19 @@ """Regression tests for FGS Guidestar in ID and FINEGUIDE modes""" import pytest -from jwst.resample.resample import OutputTooLargeError -from jwst.stpipe import Step - from jwst.regtest import regtestdata as rt +from jwst.stpipe import Step -file_roots = ['exptype_fgs_acq1', 'exptype_fgs_fineguide', 'exptype_fgs_id_image', 'exptype_fgs_id_stack'] +EXP_TYPES = ['fgs_acq1', 'fgs_fineguide', 'fgs_id-image', 'fgs_id-stack'] +FILE_ROOTS = ['jw01029001001_gs-acq1_2022142180746', + 'jw01029001001_gs-fg_2022142181502', + 'jw01029001001_gs-id_1_image', + 'jw01029001001_gs-id_1_stacked'] +GUIDER_SUFFIXES = ['cal', 'dq_init', 'guider_cds'] -@pytest.fixture(scope='module', params=file_roots, ids=file_roots) +@pytest.fixture(scope='module', params=FILE_ROOTS, ids=FILE_ROOTS) def run_guider_pipelines(rtdata_module, request): """Run pipeline for guider data""" rtdata = rtdata_module @@ -27,26 +30,9 @@ def run_guider_pipelines(rtdata_module, request): return rtdata -guider_suffixes = ['cal', 'dq_init', 'guider_cds'] - - @pytest.mark.bigdata -@pytest.mark.parametrize('suffix', guider_suffixes, ids=guider_suffixes) +@pytest.mark.parametrize('suffix', GUIDER_SUFFIXES, ids=GUIDER_SUFFIXES) def test_fgs_guider(run_guider_pipelines, fitsdiff_default_kwargs, suffix): """Regression for FGS Guider data""" rt.is_like_truth(run_guider_pipelines, fitsdiff_default_kwargs, suffix, - 'truth/fgs/test_fgs_guider', is_suffix=True) - - -@pytest.mark.bigdata -def test_fgs_toobig(rtdata, fitsdiff_default_kwargs, caplog, monkeypatch): - """Test for the situation where the combined mosaic is too large""" - - # Set the environment to not allow the resultant too-large image. - monkeypatch.setenv('DMODEL_ALLOWED_MEMORY', "0.9") - - rtdata.get_asn('fgs/image3/image3_asn.json') - - args = ['calwebb_image3', rtdata.input] - with pytest.raises(OutputTooLargeError): - Step.from_cmdline(args) + 'truth/test_fgs_guider', is_suffix=True) diff --git a/jwst/regtest/test_fgs_image3.py b/jwst/regtest/test_fgs_image3.py new file mode 100644 index 0000000000..77488afdb7 --- /dev/null +++ b/jwst/regtest/test_fgs_image3.py @@ -0,0 +1,62 @@ +import pytest +from astropy.io.fits.diff import FITSDiff + +from jwst.resample.resample import OutputTooLargeError +from jwst.stpipe import Step + + +@pytest.fixture(scope="module") +def run_fgs_image3(rtdata_module): + rtdata = rtdata_module + rtdata.get_asn('fgs/image3/jw01029-o001_20240716t172128_image3_00001_asn.json') + + args = ["calwebb_image3", rtdata.input] + Step.from_cmdline(args) + + +@pytest.mark.bigdata +@pytest.mark.parametrize("suffix", ['i2d', 'segm']) +def test_fgs_image3(run_fgs_image3, rtdata_module, fitsdiff_default_kwargs, suffix): + """Regression test for FGS data in the image3 pipeline""" + rtdata = rtdata_module + output = f"jw01029-o001_t009_fgs_clear_{suffix}.fits" + rtdata.output = output + + rtdata.get_truth(f"truth/test_fgs_image3/{output}") + + # Adjust tolerance for machine precision with float32 drizzle code + if suffix == "i2d": + fitsdiff_default_kwargs["rtol"] = 3e-3 + fitsdiff_default_kwargs["atol"] = 2e-2 + + diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs) + assert diff.identical, diff.report() + + +@pytest.mark.bigdata +def test_fgs_image3_catalog(run_fgs_image3, rtdata_module, diff_astropy_tables): + rtdata = rtdata_module + rtdata.output = "jw01029-o001_t009_fgs_clear_cat.ecsv" + rtdata.get_truth("truth/test_fgs_image3/jw01029-o001_t009_fgs_clear_cat.ecsv") + + assert diff_astropy_tables(rtdata.output, rtdata.truth, rtol=1e-3, atol=1e-4) + + +@pytest.mark.bigdata +def test_fgs_toobig(rtdata, fitsdiff_default_kwargs, caplog, monkeypatch): + """Test for the situation where the combined mosaic is too large""" + + # Set the environment to not allow the resultant too-large image. + # Note: this test was originally run on two pre-flight images + # with WCSs from very different parts of the sky. + # This condition should hopefully never be encountered in reductions + # of in-flight data. To test the software failsafe, we now use real data + # that makes a reasonable sized mosaic, but set the allowed memory to a + # small value. + monkeypatch.setenv('DMODEL_ALLOWED_MEMORY', "0.0001") + + rtdata.get_asn('fgs/image3/jw01029-o001_20240716t172128_image3_00001_asn.json') + + args = ['jwst.resample.ResampleStep', rtdata.input] + with pytest.raises(OutputTooLargeError): + Step.from_cmdline(args)