Skip to content

Commit

Permalink
Appropriately handle rounding freq vals (#337)
Browse files Browse the repository at this point in the history
* Implement rule change for freq and reflection selection OSIRIS

* Formatting and linting commit

---------

Co-authored-by: github-actions <[email protected]>
  • Loading branch information
Pasarus and github-actions authored Nov 4, 2024
1 parent 9700772 commit 4360070
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rundetection/rules/osiris_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _determine_reflection_from_tcb_values(
def _determine_reflection(self, job_request: JobRequest) -> str:
# Magic 50 number determined by knowing that no frequency below 50 uses 004,
# as per https://www.isis.stfc.ac.uk/Pages/osiris-user-guide.pdf
if job_request.additional_values["freq10"] < 50: # noqa: PLR2004
if round(job_request.additional_values["freq10"]) < 50: # noqa: PLR2004
return "002"
return self._determine_reflection_from_tcb_values(
tcb_detector_min=job_request.additional_values["tcb_detector_min"],
Expand Down
13 changes: 13 additions & 0 deletions test/rules/test_osiris_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,19 @@ def test_analyser_rule_verify_freq_less_than_50(job_request, reflection_rule):
assert job_request.additional_values["calibration_run_number"] == "00148587"


def test_analyser_rule_verify_freq_less_than_50_but_close(job_request, reflection_rule):
"""Test correct analyser returned"""
job_request.additional_values["mode"] = "spectroscopy"
job_request.additional_values["freq10"] = 49.981
job_request.additional_values["tcb_detector_min"] = 20500.0
job_request.additional_values["tcb_detector_max"] = 40500.0
job_request.additional_values["tcb_monitor_min"] = 16700.0
job_request.additional_values["tcb_monitor_max"] = 36700.0
reflection_rule.verify(job_request)
assert job_request.additional_values["reflection"] == "004"
assert job_request.additional_values["calibration_run_number"] == "00148587"


def test_verify_freq_greater_than_50_valid_tcb(job_request, reflection_rule):
"""Test correct analyser returned"""
job_request.additional_values = {
Expand Down

0 comments on commit 4360070

Please sign in to comment.