Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JP-2928: Update FGS guider test data, add image3 test #8923

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
56 changes: 56 additions & 0 deletions jwst/regtest/test_fgs_image3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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}")

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)
Loading