Skip to content

Commit

Permalink
Update FGS guider data, add image3 test
Browse files Browse the repository at this point in the history
  • Loading branch information
melanieclarke committed Oct 25, 2024
1 parent 17b7133 commit 19cdcda
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 24 deletions.
34 changes: 10 additions & 24 deletions jwst/regtest/test_fgs_guider.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
62 changes: 62 additions & 0 deletions jwst/regtest/test_fgs_image3.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 19cdcda

Please sign in to comment.