Skip to content

Commit 5b9869c

Browse files
committed
Updates Direct Reduction scripts as of December 2024
* Fix MARI auto-ei disk phase edge case * Fix MERLIN auto-ei due to replacement chopper sensor * Set FixEi to False for MERLIN * Fix auto-ei error with continuous scans
1 parent 8a83fa2 commit 5b9869c

File tree

7 files changed

+25
-6
lines changed

7 files changed

+25
-6
lines changed

direct_inelastic/ISIS/DG_reduction.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
#==================Local Contact Inputs==================
6262
inst = 'INSTRUMENT_NAME'
6363
cycle = 'CYCLE_ID' # cycle number
64-
fixei = True # True for LET since no monitor 3
64+
fixei = FIXEIVAL # True for LET since no monitor 3
6565
powdermap = 'RINGS_MAP_XML' # rings mapping file - must be .xml format
6666
file_wait = 30 # wait for data file to appear (seconds)
6767
keepworkspaces = False # should be false for Horace scans
@@ -230,6 +230,7 @@ def load_sum(run_list, block_name=None):
230230
# https://github.com/mantidproject/mantid/issues/36194
231231
sumruns = False
232232
ws_full, bval = load_sum(sample, cs_block)
233+
ws = ws_full # So that auto-ei works (it assumes the workspace variable is "ws")
233234
ws_monitors = CloneWorkspace('ws_full_monitors')
234235
bval_range = max(bval) - min(bval)
235236
bval_nbins = int(bval_range / cs_bin_size)

direct_inelastic/ISIS/reduction_utils.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,21 @@ def inrange(tf, l):
363363
freq = mode(getLog('Fermi_Speed'))
364364
except ValueError:
365365
return []
366-
phase1, phase2 = (mode(getLog(nam)) for nam in ['Phase_Thick_1', 'Phase_Thick_2'])
367366
delay = getfracLog('Fermi_delay')
368367
lmc = 10.04 # Moderator-Fermi distance
369368
period = 1.e6 / freq
369+
try:
370+
phase1, phase2 = (mode(getLog(nam)) for nam in ['Phase_Thick_1', 'Phase_Thick_2'])
371+
except RuntimeError:
372+
# Pre-upgrade MARI - single slot disk
373+
phase_disk = mode(getLog('Phase_Thick')) + 500 # Offset used in mari_utils.gcl
374+
eis_disk = ((2286.26*7.05) / (phase_disk))**2
375+
if mode(getLog('Freq_Thick')) > 0 or (run.hasProperty('nchannels') and run.getProperty('nchannels').value > 1000):
376+
return [eis_disk]
377+
else:
378+
delay_calc = ((2286.26 * lmc) / np.sqrt(eis_disk))
379+
eis = list({((2286.26*lmc) / (delay_calc + s*period))**2 for s in range(-10, 10)})
380+
return [roundlog10(ei) for ei in np.sort(eis)[::-1] if ei > 10]
370381
try:
371382
ei_nominal = mode(getLog('Ei_nominal'))
372383
except RuntimeError: # Old file
@@ -381,10 +392,10 @@ def inrange(tf, l):
381392
disk_delta = delt_disk2 - delt_disk1
382393
slots_delta = np.round(disk_delta / 202.11) / 10
383394
assert slots_delta % 1.0 < 0.2, 'Bad slots calculation'
384-
slots = {0:[0,1,2,4], 1:[0,1], 2:[0,2], 4:[0]}[abs(int(slots_delta))]
395+
slots = {0:[0,1,2,4], 1:[0,1], 2:[0,2], 3:[0], 4:[0]}[abs(int(slots_delta))]
385396
disk_ref = 6 - (np.round(delt_disk1 / 202.11) / 10)
386397
assert disk_ref % 1.0 < 0.2, f'Bad disk calculation'
387-
disk = {0:disk_ref, 1:disk_ref-1, 2:1 if disk_ref==2 else 0, 4:0}[abs(int(slots_delta))]
398+
disk = {0:disk_ref, 1:disk_ref-1, 2:1 if disk_ref==2 else 0, 3:0, 4:0}[abs(int(slots_delta))]
388399
reps = [d-disk for d in slots]
389400
eis_disk = {((2286.26*lmc) / (delay_calc + s*2500.))**2 for s in reps}
390401
period = period / 2. if 'G' in chopper_type.upper() else period
@@ -432,9 +443,11 @@ def inrange(tf, l):
432443
ldc = 9.2176 # Mod-Disk distance
433444
if not rrm_mode:
434445
return [roundlog10(((2286.26*ldc) / disk_delay)**2)]
435-
else: # Assume using Gd chopper (t_offset = 2000/freq-5, for 'S' it is 300/freq-8)
446+
else: # Assume using Gd chopper (t_offset = 2000/freq-5, for 'S' it is 300/freq-8.1)
447+
# The opto on the Fermi was replaced on 28/11/24 - need to use different constants
448+
m, c = (2000, -5) if run.endTime().to_datetime64() < np.datetime64('2024-11-27') else (6483, -5.5)
436449
period = 20000 * (25. / freq)
437-
tof = (2286.26 * lmc) / np.sqrt(roundlog10(((2286.26 * lmc) / (delay - 2000/freq - 2))**2))
450+
tof = (2286.26 * lmc) / np.sqrt(roundlog10(((2286.26 * lmc) / (delay - m/freq - c))**2))
438451
tfmx = 7500 if np.abs(disk_delay - 12400) < 10 else 8500
439452
return [roundlog10(((2286.26*lmc) / tf)**2) for tf in [(tof + s*period) for s in range(-10, 10)] if tf > 1500 and tf < tfmx]
440453

direct_inelastic/LET/USER_Files_description.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<replace var = "MASK_FILE_XML" by_var="LET_mask_222.xml"/>
3535
<replace var = "CYCLE_ID" by_var="$cycleID$"/>
3636
<replace var = "RINGS_MAP_XML" by_var="LET_rings_222.xml"/>
37+
<replace var = "FIXEIVAL" by_var="True"/>
3738
</file_to_copy>
3839
<file_to_copy file_name="../ISIS/DG_monovan.py" copy_as="DG_monovan.py">
3940
<replace var = "INSTRUMENT_NAME" by_var="LET"/>

direct_inelastic/MAPS/USER_Files_description.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
<replace var = "MASK_FILE_XML" by_var="4to1_211_msk.xml"/>
4040
<replace var = "CYCLE_ID" by_var="$cycleID$"/>
4141
<replace var = "RINGS_MAP_XML" by_var="MAPS_rings.map"/>
42+
<replace var = "FIXEIVAL" by_var="True"/>
4243
</file_to_copy>
4344
<file_to_copy file_name="../ISIS/DG_monovan.py" copy_as="DG_monovan.py">
4445
<replace var = "INSTRUMENT_NAME" by_var="MAPS"/>

direct_inelastic/MARI/DG_reduction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ def load_sum(run_list, block_name=None):
232232
# https://github.com/mantidproject/mantid/issues/36194
233233
sumruns = False
234234
ws_full, bval = load_sum(sample, cs_block)
235+
ws = ws_full # So that auto-ei works (it assumes the workspace variable is "ws")
235236
ws_monitors = CloneWorkspace('ws_full_monitors')
236237
bval_range = max(bval) - min(bval)
237238
bval_nbins = int(bval_range / cs_bin_size)

direct_inelastic/MARI/USER_Files_description.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<replace var = "MASK_FILE_XML" by_var="mari_mask$cycleID$.xml"/>
4848
<replace var = "CYCLE_ID" by_var="$cycleID$"/>
4949
<replace var = "RINGS_MAP_XML" by_var="mari_res2013.map"/>
50+
<replace var = "FIXEIVAL" by_var="True"/>
5051
</file_to_copy>
5152
<file_to_copy file_name="../ISIS/DG_monovan.py" copy_as="DG_monovan.py">
5253
<replace var = "INSTRUMENT_NAME" by_var="MARI"/>

direct_inelastic/MERLIN/USER_Files_description.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<replace var = "MASK_FILE_XML" by_var="mask_242.xml"/>
3535
<replace var = "CYCLE_ID" by_var="$cycleID$"/>
3636
<replace var = "RINGS_MAP_XML" by_var="MERLIN_rings_242.xml"/>
37+
<replace var = "FIXEIVAL" by_var="False"/>
3738
</file_to_copy>
3839
<file_to_copy file_name="../ISIS/DG_monovan.py" copy_as="DG_monovan.py">
3940
<replace var = "INSTRUMENT_NAME" by_var="MERLIN"/>

0 commit comments

Comments
 (0)