From 6d24046c3fa4b232a1ca3b2ec1dc0acceea024c7 Mon Sep 17 00:00:00 2001 From: Mathieu Doucet Date: Fri, 12 Jul 2024 19:27:18 -0400 Subject: [PATCH] default mode --- reduction/lr_reduction/event_reduction.py | 2 ++ reduction/lr_reduction/template.py | 25 +++++++++++++++++++++-- reduction/lr_reduction/workflow.py | 2 +- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/reduction/lr_reduction/event_reduction.py b/reduction/lr_reduction/event_reduction.py index beee160..86d4647 100644 --- a/reduction/lr_reduction/event_reduction.py +++ b/reduction/lr_reduction/event_reduction.py @@ -358,6 +358,8 @@ def specular_unweighted(self, q_summing=False, normalize=True): self.refl = refl self.d_refl = d_refl + self.norm = norm[db_bins] + self.d_norm = d_norm[db_bins] return self.q_bins, refl, d_refl def specular_weighted(self, q_summing=True, bck_in_q=False): diff --git a/reduction/lr_reduction/template.py b/reduction/lr_reduction/template.py index 037909d..2f77208 100644 --- a/reduction/lr_reduction/template.py +++ b/reduction/lr_reduction/template.py @@ -12,7 +12,7 @@ from . import event_reduction, reduction_template_reader TOLERANCE = 0.07 - +OUTPUT_NORM_DATA = False def read_template(template_file, sequence_number): """ @@ -180,7 +180,7 @@ def process_from_template_ws(ws_sc, template_data, q_summing=False, if theta_value is not None: theta = theta_value * np.pi / 180. else: - if ws_sc.getRun().getProperty('BL4B:CS:ExpPl:OperatingMode').value[0] == 'Free Liquid': + if 'BL4B:CS:ExpPl:OperatingMode' in ws_sc.getRun() and ws_sc.getRun().getProperty('BL4B:CS:ExpPl:OperatingMode').value[0] == 'Free Liquid': theta = thi_value * np.pi / 180. else: theta = ths_value * np.pi / 180. @@ -271,4 +271,25 @@ def process_from_template_ws(ws_sc, template_data, q_summing=False, meta_data['bck_in_q'] = bck_in_q return qz_mid, refl, d_refl, meta_data + if normalize and OUTPUT_NORM_DATA: + lr = ws_sc.getRun().getProperty('LambdaRequest').value[0] + s1h = abs(ws_sc.getRun().getProperty("S1VHeight").value[0]) + s1w = abs(ws_sc.getRun().getProperty("S1HWidth").value[0]) + s2h = abs(ws_sc.getRun().getProperty("SiVHeight").value[0]) + s2w = abs(ws_sc.getRun().getProperty("SiHWidth").value[0]) + + # Apply scaling factor + _norm = (a_q * event_refl.norm)[template_data.pre_cut:npts-template_data.post_cut] + _d_norm = (a_q * event_refl.d_norm)[template_data.pre_cut:npts-template_data.post_cut] + + wl=4.0*np.pi/qz_mid * np.sin(np.abs(theta)) + + with open('%s_%s_%2.3g_counts.txt' % (template_data.norm_file, lr, np.abs(ths_value)), 'w') as fd: + fd.write('# Theta: %g\n' % np.abs(ths_value)) + fd.write('# Slit 1 (h x w): %g x %g\n' % (s1h, s1w)) + fd.write('# Slit 2 (h x w): %g x %g\n' % (s2h, s2w)) + fd.write('# Q, wavelength, counts/mC, error\n') + for i in range(len(_norm)): + fd.write('%g %g %g %g\n' % (qz_mid[i], wl[i], _norm[i], _d_norm[i])) + return qz_mid, refl, d_refl diff --git a/reduction/lr_reduction/workflow.py b/reduction/lr_reduction/workflow.py index 082b7ae..9685f17 100644 --- a/reduction/lr_reduction/workflow.py +++ b/reduction/lr_reduction/workflow.py @@ -227,7 +227,7 @@ def reduce_explorer(ws, ws_db, theta_pv=None, center_pixel=145, db_center_pixel= from . import peak_finding if theta_pv is None: - if ws.getRun().getProperty('BL4B:CS:ExpPl:OperatingMode').value[0] == 'Free Liquid': + if 'BL4B:CS:ExpPl:OperatingMode' in ws.getRun() and ws.getRun().getProperty('BL4B:CS:ExpPl:OperatingMode').value[0] == 'Free Liquid': theta_pv = 'thi' else: theta_pv = 'ths'