Commit e3c5e8f9 authored by Neil Vaytet's avatar Neil Vaytet
Browse files

Inspired from Owens methods

parent 3b7f6ca7
......@@ -23,6 +23,50 @@ from itertools import chain
from mantid.simpleapi import *
def _wfm_psc_1():
"""
Definition V20 for wfm pulse shaping chopper 1 (closest to source)
:return: Returns the sorted angles of all edges in degrees. First entry is start angle of the first cut-out
second entry is end angle of first cut-out
"""
return [83.71, 94.7, 140.49, 155.79, 193.26, 212.56, 242.32, 265.33, 287.91, 314.37, 330.3, 360.0]
def _wfm_psc_2():
"""
Definition V20 for wfm pulse shaping chopper 2 (closest to sample)
:return: Returns the sorted angles of all edges in degrees. First entry is start angle of the first cut-out
second entry is end angle of first cut-out
"""
return [65.04, 76.03, 126.1, 141.4, 182.88, 202.18, 235.67, 254.97, 284.73, 307.74, 330.00, 360.0]
def tof_shifts(pscdata, psc_frequency=0):
print(pscdata)
cut_out_centre = np.reshape(pscdata,(len(pscdata)//2, 2)).mean(1)
cut_out_diffs = np.ediff1d(cut_out_centre)
return cut_out_diffs / (360.0*psc_frequency)
def get_frame_shifts(frequency_wfm_psc=None):
"""
This function generates a list of proper shifting parameters from psc data.
:param frequency_wfm_psc: Rotation frequency in Hz for WFM phase shaping choppers 1 & 2.
:return: List of relative frame shifts in microseconds.
"""
if type(frequency_wfm_psc) == list:
frequ1 = frequency_wfm_psc[0]
frequ2 = frequency_wfm_psc[1]
elif type(frequency_wfm_psc) == int:
frequ1 = frequency_wfm_psc
frequ2 = frequency_wfm_psc
else:
raise TypeError("Unknown frequency type")
relative_shifts = (tof_shifts(_wfm_psc_1(), psc_frequency=frequ1) + \
tof_shifts(_wfm_psc_2(), psc_frequency=frequ2)) * \
5.0e+05
return relative_shifts
def make_frame_shifts(initial_shift, other_shifts=(-2420, -2253, -2095, -1946, -1810)):
"""
This function constructs a list of proper shifting parameters for wavelength frames.
......@@ -44,29 +88,6 @@ def make_frame_shifts(initial_shift, other_shifts=(-2420, -2253, -2095, -1946, -
return [sum(frame_shift_increments[:i + 1]) for i in
range(len(frame_shift_increments))]
def tof_shifts(pscdata, psc_frequency=0):
cut_out_centre = np.reshape(pscdata,(len(pscdata)//2, 2)).mean(1)
cut_out_diffs = np.ediff1d(cut_out_centre)
return cut_out_diffs / (360.0*psc_frequency)
def get_frame_shifts(pscdata1, pscdata2, initial_shift=0, psc_frequency=0):
"""
This function generates a list of proper shifting parameters from psc data.
:param pscdata1: Input timing array 1 (cut out edges in degrees).
:param pscdata2: Input timing array 2 (cut out edges in degrees).
:param initial_shift: Shift to apply to first wavelength frame in microseconds.
:return: List of absolute frame shifts in microseconds.
"""
relative_shifts = (tof_shifts(pscdata1, psc_frequency=psc_frequency) + \
tof_shifts(pscdata2, psc_frequency=psc_frequency)) * \
5.0e+05
frame_shift_increments = np.concatenate(([initial_shift],relative_shifts))
return [sum(frame_shift_increments[:i + 1]) for i in
range(len(frame_shift_increments))]
class WFMProcessor(object):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment