Skip to content

Commit

Permalink
JP-3771: Add Multiprocessing Regression Tests for Ramp and Jump Steps (
Browse files Browse the repository at this point in the history
  • Loading branch information
kmacdonald-stsci authored Nov 21, 2024
2 parents ae9ce3f + 318af59 commit 86336dd
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 0 deletions.
58 changes: 58 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_multiprocess_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_multiprocess_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,18 @@ def test_miri_image_detector1(run_detector1, rtdata_module, fitsdiff_default_kwa
_assert_is_same(rtdata_module, fitsdiff_default_kwargs, suffix)


@pytest.mark.bigdata
def test_miri_image_detector1_multiprocess_rate(run_detector1_multiprocess_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")


@pytest.mark.bigdata
def test_miri_image_detector1_multiprocess_jump(run_detector1_multiprocess_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
116 changes: 116 additions & 0 deletions jwst/regtest/test_niriss_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,84 @@ def run_detector1(rtdata_module):
Step.from_cmdline(args)


@pytest.fixture(scope="module")
def run_detector1_multiprocess_rate(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.ramp_fit.maximum_cores=2", # Multiprocessing
]

Step.from_cmdline(args)


@pytest.fixture(scope="module")
def run_detector1_multiprocess_rate_save_opt(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.ramp_fit.maximum_cores=2", # Multiprocessing
"--steps.ramp_fit.save_opt=True",
"--steps.ramp_fit.opt_name=jw01094001002_02107_00001_nis.fits",
]

Step.from_cmdline(args)


@pytest.fixture(scope="module")
def run_detector1_multiprocess_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 @@ -67,6 +145,7 @@ def test_niriss_image_detector1(run_detector1, rtdata_module, fitsdiff_default_k
_assert_is_same(rtdata_module, fitsdiff_default_kwargs, suffix, truth_dir)



@pytest.mark.bigdata
@pytest.mark.parametrize("suffix", ["cfn_clean_flicker_noise", "mask",
"flicker_bkg", "flicker_noise",
Expand Down Expand Up @@ -110,6 +189,43 @@ def test_niriss_tweakreg_no_sources(rtdata, fitsdiff_default_kwargs):
result.shelve(model, modify=False)


@pytest.mark.bigdata
def test_niriss_image_detector1_multiprocess_rate(
run_detector1_multiprocess_rate, 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, "rate", truth_dir)


@pytest.mark.bigdata
@pytest.mark.parametrize("suffix", ["rate", "fitopt"])
def test_niriss_image_detector1_multiprocess_rate_save_opt(
run_detector1_multiprocess_rate_save_opt, rtdata_module, fitsdiff_default_kwargs, suffix):
"""
Runs test_niriss_image_detector1[rate], but with ramp fitting run with multiprocessing
on two processors and the optional results product.
"""
truth_dir = 'test_niriss_image'
# fitsdiff_default_kwargs["numdiffs"] = 10
_assert_is_same(rtdata_module, fitsdiff_default_kwargs, suffix, truth_dir)


@pytest.mark.bigdata
def test_niriss_image_detector1_multiprocess_jump(
run_detector1_multiprocess_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 86336dd

Please sign in to comment.