Skip to content

Commit

Permalink
default mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed Jul 12, 2024
1 parent a8630d1 commit 6d24046
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions reduction/lr_reduction/event_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
25 changes: 23 additions & 2 deletions reduction/lr_reduction/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion reduction/lr_reduction/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 6d24046

Please sign in to comment.