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

refactor two-bck option #24

Merged
merged 2 commits into from
Mar 12, 2024
Merged
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Reduction scripts for the Liquids Reflectometer. This includes both automated re


## Release notes:
- reduction v2.0.19 [03/2024] Add dead time correction and clean up functional background option
- reduction v2.0.14 [02/2024] Add functional background
- reduction v2.0.13 [08/2023] Get correct angle with free liquids
- reduction v2.0.9 [04/2023] Subtract normalization background & add x-direction option
Expand Down
2 changes: 1 addition & 1 deletion reduction/lr_reduction/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.0.18'
__version__ = '2.0.19'
11 changes: 4 additions & 7 deletions reduction/lr_reduction/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ def _value_check(key, data, reference):


def process_from_template(run_number, template_path, q_summing=False, normalize=True,
tof_weighted=False, bck_in_q=False, clean=False, info=False,
functional_background=False):
tof_weighted=False, bck_in_q=False, clean=False, info=False):
"""
The clean option removes leading zeros and the drop when doing q-summing
"""
Expand All @@ -141,14 +140,12 @@ def process_from_template(run_number, template_path, q_summing=False, normalize=
ws_sc = api.Load("REF_L_%s" % run_number)
return process_from_template_ws(ws_sc, template_path, q_summing=q_summing,
tof_weighted=tof_weighted, bck_in_q=bck_in_q,
clean=clean, info=info, normalize=normalize,
functional_background=functional_background)
clean=clean, info=info, normalize=normalize)


def process_from_template_ws(ws_sc, template_data, q_summing=False,
tof_weighted=False, bck_in_q=False, clean=False,
info=False, normalize=True, theta_value=None, ws_db=None,
functional_background=False):
info=False, normalize=True, theta_value=None, ws_db=None):
# Get the sequence number
sequence_number = 1
if ws_sc.getRun().hasProperty("sequence_number"):
Expand Down Expand Up @@ -225,7 +222,7 @@ def process_from_template_ws(ws_sc, template_data, q_summing=False,
theta=np.abs(theta),
dead_time=template_data.dead_time,
paralyzable=template_data.paralyzable,
functional_background=functional_background,
mdoucet marked this conversation as resolved.
Show resolved Hide resolved
functional_background=template_data.two_backgrounds,
instrument=event_reduction.EventReflectivity.INSTRUMENT_4B)

# R(Q)
Expand Down
4 changes: 1 addition & 3 deletions reduction/lr_reduction/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@


def reduce(ws, template_file, output_dir, average_overlap=False,
q_summing=False, bck_in_q=False, is_live=False,
functional_background=False):
q_summing=False, bck_in_q=False, is_live=False):
"""
Function called by reduce_REFL.py, which lives in /SNS/REF_L/shared/autoreduce
and is called by the automated reduction workflow.
Expand All @@ -31,7 +30,6 @@ def reduce(ws, template_file, output_dir, average_overlap=False,
tof_weighted=q_summing,
clean=q_summing,
bck_in_q=bck_in_q,
functional_background=functional_background,
info=True)

# Save partial results
Expand Down
16 changes: 10 additions & 6 deletions reduction/test/test_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_info(nexus_dir):

def test_full_reduction(nexus_dir):
"""
Test the fill reduction chain
Test the full reduction chain
"""
template_path = 'data/template.xml'
qz_all = []
Expand Down Expand Up @@ -122,9 +122,13 @@ def test_reduce_functional_bck(nexus_dir, template_dir):
for i in range(198409, 198417):
with amend_config(data_dir=nexus_dir):
ws = mtd_api.Load("REF_L_%s" % i)
workflow.reduce(ws, template_path, output_dir=output_dir,
average_overlap=False,
functional_background=True)

sequence_number = ws.getRun().getProperty("sequence_number").value[0]
template_data = template.read_template(template_path, sequence_number)
template_data.two_backgrounds = True

workflow.reduce(ws, template_data, output_dir=output_dir,
average_overlap=False)

reference_path = 'data/reference_fbck.txt'
if os.path.isfile(reference_path):
Expand Down Expand Up @@ -164,9 +168,9 @@ def test_reduce_bck_option_mismatch(nexus_dir):
sequence_number = ws.getRun().getProperty("sequence_number").value[0]
template_data = template.read_template(template_path, sequence_number)
template_data.background_roi = template_data.background_roi[:2]
template_data.two_backgrounds = True
workflow.reduce(ws, template_data, output_dir=output_dir,
average_overlap=False,
functional_background=True)
average_overlap=False)

reference_path = 'data/reference_rq.txt'
if os.path.isfile(reference_path):
Expand Down
Loading