Skip to content

Commit

Permalink
Restore setpointing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
melanieclarke committed Oct 9, 2024
1 parent 31adc33 commit e2e6a5d
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
25 changes: 25 additions & 0 deletions jwst/regtest/test_nircam_tsgrism.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from astropy.io.fits.diff import FITSDiff
from astropy.table import Table, setdiff

from jwst.lib.set_telescope_pointing import add_wcs
from jwst.stpipe import Step


Expand Down Expand Up @@ -96,3 +97,27 @@ def test_nircam_tsgrism_stage3_whtlt(run_pipelines):

# setdiff returns a table of length zero if there is no difference
assert len(setdiff(table, table_truth)) == 0


@pytest.mark.bigdata
def test_nircam_setpointing_tsgrism(rtdata, fitsdiff_default_kwargs):
"""
Regression test of the set_telescope_pointing script on a level-1b NIRCam file.
"""
# Get SIAF PRD database file
siaf_path = rtdata.get_data("common/prd.db")
rtdata.get_data("nircam/tsgrism/jw00721012001_03103_00001-seg001_nrcalong_uncal.fits")
# The add_wcs function overwrites its input
rtdata.output = rtdata.input

# Call the WCS routine, using the ENGDB_Service
try:
add_wcs(rtdata.input, siaf_path=siaf_path)
except ValueError:
pytest.skip('Engineering Database not available.')

rtdata.get_truth("truth/test_nircam_setpointing/jw00721012001_03103_00001-seg001_nrcalong_uncal.fits")

fitsdiff_default_kwargs['rtol'] = 1e-6
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()
41 changes: 41 additions & 0 deletions jwst/regtest/test_nircam_tsimg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from pathlib import Path
import pytest
from astropy.io.fits.diff import FITSDiff

from jwst.lib import engdb_tools
from jwst.lib.set_telescope_pointing import add_wcs
from jwst.lib.tests.engdb_mock import EngDB_Mocker
from jwst.stpipe import Step


Expand Down Expand Up @@ -51,3 +55,40 @@ def test_nircam_tsimage_stage3_phot(run_pipelines, diff_astropy_tables):
rtdata.get_truth("truth/test_nircam_tsimg_stage23/jw01068-o006_t004_nircam_f150w2-f164n-sub64p_phot.ecsv")

assert diff_astropy_tables(rtdata.output, rtdata.truth)


@pytest.mark.bigdata
def test_nircam_setpointing_tsimg(rtdata, engdb, fitsdiff_default_kwargs):
"""
Regression test of the set_telescope_pointing script on a level-1b
NIRCam TSO imaging file.
"""
# Get SIAF PRD database file
siaf_path = rtdata.get_data("common/prd.db")
rtdata.get_data("nircam/tsimg/jw00312006001_02102_00001-seg001_nrcb1_uncal.fits")
# The add_wcs function overwrites its input, so output = input
rtdata.output = rtdata.input

# Call the WCS routine, using the ENGDB_Service
try:
add_wcs(rtdata.input, engdb_url='http://localhost', siaf_path=siaf_path)
except ValueError:
pytest.skip('Engineering Database not available.')

rtdata.get_truth("truth/test_nircam_setpointing/jw00312006001_02102_00001-seg001_nrcb1_uncal.fits")

fitsdiff_default_kwargs['rtol'] = 1e-6
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()


# ########
# Fixtures
# ########
@pytest.fixture
def engdb():
"""Setup the mock engineering database"""
db_path = Path(__file__).parents[1] / 'lib' / 'tests' / 'data' / 'engdb'
with EngDB_Mocker(db_path=db_path):
engdb = engdb_tools.ENGDB_Service(base_url='http://localhost')
yield engdb

0 comments on commit e2e6a5d

Please sign in to comment.