Skip to content

Commit e4c3fca

Browse files
authored
Merge pull request #37805 from mantidproject/37734_phase_bug_for_merlin_pychop
Fix for random phase value bug in PyChop
2 parents 3bdaa5f + 65d3d74 commit e4c3fca

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

docs/source/interfaces/direct/PyChop.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ If the *Instrument scientist mode* option is selected, a similar option is
6666
enabled for MERLIN if the G chopper is used. In this case, the phase (time
6767
delay) of the thick disk chopper can be adjusted. The time delay is the time-of-
6868
flight at which the chopper slit first opens (sweeps across the beam profile).
69+
In the event that this mode is then deselected, the time delay entered previously
70+
will be utilised for subsequent calculations instead of the default value.
6971

7072
The Matplotlib axes showing the calculated data have the standard toolbars.
7173

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Random phase values are no longer used on Merlin when using :ref:`PyChop` with instrument scientist mode disabled.

qt/python/mantidqtinterfaces/mantidqtinterfaces/PyChop/PyChopGui.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,20 @@ def setFreq(self, freqtext=None, **kwargs):
214214
# Checks for independent phases
215215
phases = []
216216
for key, widget in self.widgets.items():
217-
if key.endswith("Phase") and not widget["Label"].isHidden():
218-
idx = int(key[7])
219-
phase = widget["Edit"].text()
220-
if isinstance(self.engine.chopper_system.defaultPhase[idx], str):
221-
phase = str(phase)
222-
else:
223-
try:
224-
phase = float(phase) % (1e6 / self.engine.moderator.source_rep)
225-
except ValueError:
226-
raise ValueError(f'Incorrect phase value "{phase}" for {widget["Label"].text()}')
227-
phases.append(phase)
217+
if key.endswith("Phase"):
218+
# Special case for MERLIN
219+
# sets the default phase for Chopper0Phase if not in "Instrument Scientist Mode"
220+
if not widget["Label"].isHidden() or "MERLIN" in str(self.engine.instname) and key[7] == 0:
221+
idx = int(key[7])
222+
phase = widget["Edit"].text()
223+
if isinstance(self.engine.chopper_system.defaultPhase[idx], str):
224+
phase = str(phase)
225+
else:
226+
try:
227+
phase = float(phase) % (1e6 / self.engine.moderator.source_rep)
228+
except ValueError:
229+
raise ValueError(f'Incorrect phase value "{phase}" for {widget["Label"].text()}')
230+
phases.append(phase)
228231
if phases:
229232
self.engine.setFrequency(freq_in, phase=phases)
230233
else:
@@ -642,9 +645,9 @@ def _gen_text_ei(self, ei, obj_in):
642645
txt += "# Ei = %8.2f meV\n" % (ei)
643646
txt += "# Flux = %8.2f n/cm2/s\n" % (flux)
644647
txt += "# Elastic resolution = %6.2f meV\n" % (res[0])
645-
txt += "# Time width at sample = %6.2f us, of which:\n" % (1e6 * np.sqrt(tsqvan))
648+
txt += "# Time width at sample = %6.2f us, of which:\n" % (1e6 * np.sqrt(tsqvan[0]))
646649
for ky, val in list(tsqdic.items()):
647-
txt += "# %20s : %6.2f us\n" % (ky, 1e6 * np.sqrt(val))
650+
txt += "# %20s : %6.2f us\n" % (ky, 1e6 * np.sqrt(val[0]))
648651
txt += "# %s distances:\n" % (obj.instname)
649652
txt += "# x0 = %6.2f m (%s to Fermi)\n" % (x0, first_component)
650653
txt += "# x1 = %6.2f m (Fermi to sample)\n" % (x1)

scripts/pychop/merlin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ chopper_system:
2121
radius: 300 # Disk radius
2222
isDouble: False # Is this a double disk system?
2323
isPhaseIndependent: True # Is this disk to be phased independently?
24-
defaultPhase: 12800 # What is the default phase for this disk (either a time in microseconds
24+
defaultPhase: 12400 # What is the default phase for this disk (either a time in microseconds
2525
# or a slot index [as a string] for the desired rep to go through)
2626
phaseOffset: 11300 # Offset introduced after disk chopper controller update
2727
phaseName: 'Disk chopper phase delay time'

0 commit comments

Comments
 (0)