Commit 3b7f6ca7 authored by Neil Vaytet's avatar Neil Vaytet
Browse files

Added get_wfm_windows for automatic frame edge finding. Also added...

Added get_wfm_windows for automatic frame edge finding. Also added get_frame_shifts to compute frame shifts from chopper data.
parent 7a705ecc
......@@ -17,5 +17,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# *********************************************************************
from wfm_processing import WFMProcessor, make_frame_shifts
from data_handling import load, save_fits_stack, normalize
\ No newline at end of file
from wfm_processing import WFMProcessor, make_frame_shifts, get_frame_shifts
from data_handling import load, save_fits_stack, normalize
from get_wfm_windows import detectPeaks, checkPeaks, getWFMWindows
This diff is collapsed.
......@@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# *********************************************************************
import numpy as np
from .readout_gaps import ReadoutGaps
from itertools import chain
from mantid.simpleapi import *
......@@ -43,6 +44,29 @@ 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