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

remove custom dms requirement logging in ramp fit regtests #1433

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions changes/1433.ramp_fitting.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove custom log messages for dms requirements (which are now mapped by the json file).
27 changes: 0 additions & 27 deletions romancal/lib/dms.py

This file was deleted.

45 changes: 12 additions & 33 deletions romancal/regtest/test_ramp_fitting.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
""" Module to test rampfit with optional output

Notes
-----
A requirement for the larger mission verification project is to have
tests tied to reqirements.
"""

from pathlib import Path

import pytest
import roman_datamodels as rdm

from romancal.lib.dms import log_result
from romancal.lib.suffix import replace_suffix
from romancal.ramp_fitting import RampFitStep

Expand All @@ -21,64 +15,53 @@
# ##########
# Conditions
# ##########
def cond_is_asdf(requirement, model, expected_path):
def cond_is_asdf(model, expected_path):
"""Check that the filename has the correct file type"""
msg = 'Testing that result file path has file type "asdf"'
result = expected_path.exists() and expected_path.suffix == ".asdf"
log_result(requirement, msg, result)
assert result, msg


def cond_is_imagemodel(requirement, model, expected_path):
def cond_is_imagemodel(model, expected_path):
"""Check that the result is an ImageModel"""
msg = "Testing that the result model is Level 2"
result = isinstance(model, rdm.datamodels.ImageModel)
log_result(requirement, msg, result)
assert result, msg


def cond_is_rampfit(requirement, model, expected_path):
def cond_is_rampfit(model, expected_path):
"""Check that the calibration suffix is 'rampfit'"""
msg = 'Testing that the result file has the suffix "rampfit"'
result = expected_path.exists() and expected_path.stem.endswith("rampfit")
log_result(requirement, msg, result)
assert result, msg


def cond_is_step_complete(requirement, model, expected_path):
def cond_is_step_complete(model, expected_path):
"""Check that the calibration step is marked complete"""
msg = "Testing that RampFitStep completed"
result = model.meta.cal_step.ramp_fit == "COMPLETE"
log_result(requirement, msg, result)
assert result, msg


def cond_is_truncated(requirement, model, expected_path):
def cond_is_truncated(model, expected_path):
"""Check if the data represents a truncated MA table/read pattern"""
msg = "Testing if data represents a truncated MA table"
result = model.meta.exposure.truncated
log_result(requirement, msg, result)
assert result, msg


def cond_is_uneven(requirement, model, expected_path):
def cond_is_uneven(model, expected_path):
"""Verify that the provided model represents uneven ramps"""
msg = "Testing that the ramps are uneven"
length_set = {len(resultant) for resultant in model.meta.exposure.read_pattern}
result = len(length_set) > 1
log_result(requirement, msg, result)
assert result, msg


def cond_science_verification(
requirement, model, expected_path, rtdata_module, ignore_asdf_paths
):
def cond_science_verification(model, expected_path, rtdata_module, ignore_asdf_paths):
"""Check against expected data results"""
msg = "Testing science veracity"
diff = compare_asdf(rtdata_module.output, rtdata_module.truth, **ignore_asdf_paths)

result = diff.identical
log_result(requirement, msg, result)
assert result, diff.report()


Expand All @@ -99,22 +82,18 @@ def cond_science_verification(
scope="module",
params=[
(
"DMS362",
Path("WFI/image/r0000101001001001001_01101_0001_WFI01_darkcurrent.asdf"),
CONDITIONS_FULL,
),
(
"DMS366",
Path("WFI/grism/r0000201001001001001_01101_0001_WFI01_darkcurrent.asdf"),
CONDITIONS_FULL,
),
(
"DMS363",
Path("WFI/image/r0000101001001001001_01101_0003_WFI01_darkcurrent.asdf"),
CONDITIONS_TRUNC,
),
(
"DMS367",
Path("WFI/grism/r0000201001001001001_01101_0003_WFI01_darkcurrent.asdf"),
CONDITIONS_TRUNC,
),
Expand All @@ -135,7 +114,7 @@ def rampfit_result(request, rtdata_module):
Model and path to model.
"""
# Setup inputs
requirement, artifactory_path, conditions = request.param
artifactory_path, conditions = request.param
input_data = rtdata_module.get_data(str(artifactory_path))
rtdata_module.input = input_data

Expand All @@ -153,7 +132,7 @@ def rampfit_result(request, rtdata_module):
rtdata_module.get_truth(str(output_artifactory_path))

try:
yield requirement, result_model, expected_path, conditions
yield result_model, expected_path, conditions
finally:
result_model.close()

Expand All @@ -171,18 +150,18 @@ def passfail(bool_expr):
@pytest.mark.bigdata
def test_rampfit_step(rampfit_result, rtdata_module, ignore_asdf_paths):
"""Test rampfit result against various conditions"""
requirement, model, expected_path, conditions = rampfit_result
model, expected_path, conditions = rampfit_result
error_msgs = []
for condition in conditions:
try:
condition(requirement, model, expected_path)
condition(model, expected_path)
except AssertionError as e:
error_msgs.append(str(e))

# Always do a full regression check.
try:
cond_science_verification(
requirement, model, expected_path, rtdata_module, ignore_asdf_paths
model, expected_path, rtdata_module, ignore_asdf_paths
)
except AssertionError as e:
error_msgs.append(str(e))
Expand Down