Skip to content

Commit

Permalink
Adding multiprocessing regression testing for ramp fit and jump.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmacdonald-stsci committed Oct 28, 2024
1 parent 3109ad9 commit 7416b96
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 3 deletions.
56 changes: 56 additions & 0 deletions jwst/regtest/test_miri_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,52 @@ def run_detector1(rtdata_module):
Step.from_cmdline(args)


@pytest.fixture(scope="module")
def run_detector1_multi_rate(rtdata_module):
"""Run detector1 pipeline on MIRI imaging data."""
rtdata = rtdata_module
rtdata.get_data("miri/image/jw01024001001_04101_00001_mirimage_uncal.fits")

# Run detector1 pipeline only on one of the _uncal files
args = ["jwst.pipeline.Detector1Pipeline", rtdata.input,
"--save_calibrated_ramp=True",
"--steps.dq_init.save_results=True",
"--steps.saturation.save_results=True",
"--steps.firstframe.save_results=True",
"--steps.lastframe.save_results=True",
"--steps.reset.save_results=True",
"--steps.linearity.save_results=True",
"--steps.rscd.save_results=True",
"--steps.dark_current.save_results=True",
"--steps.refpix.save_results=True",
"--steps.ramp_fit.maximum_cores=2", # Multiprocessing
]
Step.from_cmdline(args)


@pytest.fixture(scope="module")
def run_detector1_multi_jump(rtdata_module):
"""Run detector1 pipeline on MIRI imaging data."""
rtdata = rtdata_module
rtdata.get_data("miri/image/jw01024001001_04101_00001_mirimage_uncal.fits")

# Run detector1 pipeline only on one of the _uncal files
args = ["jwst.pipeline.Detector1Pipeline", rtdata.input,
"--save_calibrated_ramp=True",
"--steps.dq_init.save_results=True",
"--steps.saturation.save_results=True",
"--steps.firstframe.save_results=True",
"--steps.lastframe.save_results=True",
"--steps.reset.save_results=True",
"--steps.linearity.save_results=True",
"--steps.rscd.save_results=True",
"--steps.dark_current.save_results=True",
"--steps.refpix.save_results=True",
"--steps.jump.maximum_cores=2", # Multiprocessing
]
Step.from_cmdline(args)


@pytest.fixture(scope="module")
def run_detector1_with_average_dark_current(rtdata_module):
"""Run detector1 pipeline on MIRI imaging data, providing an
Expand Down Expand Up @@ -115,6 +161,16 @@ def test_miri_image_detector1(run_detector1, rtdata_module, fitsdiff_default_kwa
_assert_is_same(rtdata_module, fitsdiff_default_kwargs, suffix)


def test_miri_image_detector1_multi_rate(run_detector1_multi_rate, rtdata_module, fitsdiff_default_kwargs):
"""Regression test of detector1 pipeline performed on MIRI imaging data."""
_assert_is_same(rtdata_module, fitsdiff_default_kwargs, "rate")


def test_miri_image_detector1_multi_jump(run_detector1_multi_jump, rtdata_module, fitsdiff_default_kwargs):
"""Regression test of detector1 pipeline performed on MIRI imaging data."""
_assert_is_same(rtdata_module, fitsdiff_default_kwargs, "rate")


@pytest.mark.bigdata
def test_detector1_mem_usage(rtdata_module):
"""Determine the memory usage for Detector 1"""
Expand Down
44 changes: 41 additions & 3 deletions jwst/regtest/test_niriss_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ def run_detector1(rtdata_module):

Step.from_cmdline(args)


@pytest.fixture(scope="module")
def run_detector1_multi(rtdata_module):
def run_detector1_multi_rate(rtdata_module):
"""Run calwebb_detector1 pipeline on NIRISS imaging data."""
rtdata = rtdata_module

Expand All @@ -61,6 +62,32 @@ def run_detector1_multi(rtdata_module):
Step.from_cmdline(args)


@pytest.fixture(scope="module")
def run_detector1_multi_jump(rtdata_module):
"""Run calwebb_detector1 pipeline on NIRISS imaging data."""
rtdata = rtdata_module

rtdata.get_data("niriss/imaging/jw01094001002_02107_00001_nis_uncal.fits")

# Run detector1 pipeline on an _uncal files
args = ["calwebb_detector1", rtdata.input,
"--steps.persistence.save_trapsfilled=False",
"--steps.dq_init.save_results=True",
"--steps.saturation.save_results=True",
"--steps.superbias.save_results=True",
"--steps.refpix.save_results=True",
"--steps.linearity.save_results=True",
"--steps.dark_current.save_results=True",
"--steps.charge_migration.skip=False",
"--steps.charge_migration.save_results=True",
"--steps.jump.save_results=True",
"--steps.jump.maximum_cores=2", # Multiprocessing
"--steps.ramp_fit.skip=True",
]

Step.from_cmdline(args)


@pytest.fixture(scope="module")
def run_detector1_with_clean_flicker_noise(rtdata_module):
"""Run detector1 pipeline on NIRISS imaging data with noise cleaning."""
Expand Down Expand Up @@ -136,8 +163,8 @@ def test_niriss_tweakreg_no_sources(rtdata, fitsdiff_default_kwargs):
result.shelve(model, modify=False)


def test_niriss_image_detector1_multi(
run_detector1_multi, rtdata_module, fitsdiff_default_kwargs):
def test_niriss_image_detector1_multi_rate(
run_detector1_multi_rate, rtdata_module, fitsdiff_default_kwargs):
"""
Runs test_niriss_image_detector1[rate], but with ramp fitting run with multiprocessing
on two processors.
Expand All @@ -147,6 +174,17 @@ def test_niriss_image_detector1_multi(
_assert_is_same(rtdata_module, fitsdiff_default_kwargs, "rate", truth_dir)


def test_niriss_image_detector1_multi_jump(
run_detector1_multi_jump, rtdata_module, fitsdiff_default_kwargs):
"""
Runs test_niriss_image_detector1[rate], but with ramp fitting run with multiprocessing
on two processors.
"""
truth_dir = 'test_niriss_image'
# fitsdiff_default_kwargs["numdiffs"] = 10
_assert_is_same(rtdata_module, fitsdiff_default_kwargs, "jump", truth_dir)


def _assert_is_same(rtdata_module, fitsdiff_default_kwargs, suffix, truth_dir):
"""Assertion helper for the above tests"""
rtdata = rtdata_module
Expand Down

0 comments on commit 7416b96

Please sign in to comment.