Skip to content

Commit

Permalink
update AR and add coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Apr 2, 2024
1 parent 62f2596 commit 297d963
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 14 deletions.
26 changes: 26 additions & 0 deletions reduction/test/test_scaling_factors.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,29 @@ def test_compute_sf_with_deadtime_tof_200(nexus_dir):
assert output is True

check_results(output_cfg, 'data/sf_197912_Si_dt_par_46_200.cfg')


def test_compute_sf_with_deadtime_tof_200_sort(nexus_dir):
"""
Test the computation of scaling factors
"""
with amend_config(data_dir=nexus_dir):
ws = mtd_api.Load("REF_L_197912")

output_dir = '/tmp'

output_cfg = os.path.join(output_dir, "sf_197912_Si_test_dt.cfg")
if os.path.isfile(output_cfg):
os.remove(output_cfg)

output = sf_workflow.process_scaling_factors(ws, output_dir,
order_by_runs=False,
use_deadtime=True,
deadtime=4.6,
deadtime_tof_step=200,
paralyzable=False,
wait=False, postfix='_test_dt')
assert output is True

check_results(output_cfg, 'data/sf_197912_Si_dt_par_46_200.cfg')

32 changes: 18 additions & 14 deletions scripts/autoreduce/reduce_REF_L.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@
# Check the measurement geometry. This will be useful later
#if ws.getRun().getProperty('BL4B:CS:ExpPl:OperatingMode').value[0] == 'Free Liquid':

# Determine whether we have to go through the legacy reduction to
# process direct beams
if not old_version and ws.getRun().hasProperty("data_type"):
data_type = ws.getRun().getProperty("data_type").value[0]
old_version = not data_type == 0

if old_version:
SetInstrumentParameter(ws, ParameterName="dq-constant", Value="0.0", ParameterType="Number")
output = LRAutoReduction(#Filename=event_file_path,
Expand All @@ -90,17 +84,27 @@
TemplateFile=template_file)
first_run_of_set=int(output[1])
else:
print("Average overlap: %s" % avg_overlap)
print("Constant-Q binning: %s" % const_q)
from lr_reduction import workflow
if True:
data_type = ws.getRun().getProperty("data_type").value[0]
# Direct beam data
if data_type == 1:
from lr_reduction.scaling_factors import workflow as sf_workflow
sf_workflow.process_scaling_factors(ws, output_dir,
tof_step=200,
order_by_runs=True,
use_deadtime=True,
deadtime=4.2,
deadtime_tof_step=200,
paralyzable=True,
wait=True,
slit_tolerance=0.07)
else:
# Scattering data
print("Average overlap: %s" % avg_overlap)
print("Constant-Q binning: %s" % const_q)
from lr_reduction import workflow
first_run_of_set = workflow.reduce(ws, template_file, output_dir,
average_overlap=avg_overlap,
q_summing=const_q, bck_in_q=False)
else:
first_run_of_set = workflow.reduce_fixed_two_theta(ws, template_file, output_dir,
average_overlap=avg_overlap,
q_summing=const_q, bck_in_q=False)

#-------------------------------------------------------------------------
# Produce plot for the web monitor
Expand Down

0 comments on commit 297d963

Please sign in to comment.