Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Dec 12, 2024
1 parent 43819ac commit 44d2f17
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions reduction/test/test_reduction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# standard imports
from pathlib import Path
import os
from pathlib import Path

# third-party imports
import mantid
Expand All @@ -11,7 +11,6 @@
from lr_reduction import event_reduction, template, workflow
from lr_reduction.utils import amend_config


mtd_api.config["default.facility"] = "SNS"
mtd_api.config["default.instrument"] = "REF_L"
mantid.kernel.config.setLogLevel(3)
Expand Down Expand Up @@ -47,6 +46,33 @@ def test_attenuation(nexus_dir):
event_reduction.process_attenuation(ws_sc, 0.005)


def test_q_summing(nexus_dir):
"""
Test Q summing process
"""
template_path = 'data/template.xml'
template.read_template(template_path, 7)
with amend_config(data_dir=nexus_dir):
ws_sc = mtd_api.Load("REF_L_%s" % 198415)
qz_mid0, refl0, d_refl0, meta_data = template.process_from_template_ws(ws_sc, template_path, info=True)

assert(np.fabs(meta_data['dq_over_q'] - 0.02759) < 1e-3)

# Now try with Q summing, which should have similar results
qz_mid, refl, d_refl, meta_data = template.process_from_template_ws(ws_sc, template_path,
info=True, q_summing=True)

assert(np.fabs(meta_data['dq_over_q'] - 0.009354) < 1e-5)

np.loadtxt('data/reference_rq.txt').T
assert(len(qz_mid0) == len(qz_mid))
assert(np.fabs(np.mean(refl-refl0)) < 1e-6)

# Cleanup
output_dir = 'data/'
cleanup_partial_files(output_dir, range(198409, 198417))


def test_full_reduction(nexus_dir):
"""
Test the full reduction chain
Expand Down

0 comments on commit 44d2f17

Please sign in to comment.