Ticket #6594: LoadingEventData.py

File LoadingEventData.py, 1.0 KB (added by Gesner Passos, 8 years ago)

Testing loading Event Data directly

Line 
1# set MANTID to SANS2D instrument, and add cycle_12_3 to the path to search
2
3#Load the event data
4run_num = 16183#16187
5ws_e, mon = Load(str(run_num),LoadMonitors=True)
6print ws_e.getNumberHistograms()/2 -1
7ws_e = CropWorkspace(ws_e,StartWorkspaceIndex=0,EndWorkspaceIndex=ws_e.getNumberHistograms()/2-1)
8
9# get the binning from the monitor
10monitors = mon.readX(0)
11step = 0
12values = []
13for i in range(len(monitors)-1):
14        if monitors[i+1] - monitors[i] == step: continue
15        values.append(monitors[i])
16        step = monitors[i+1] - monitors[i]
17        values.append(step)
18
19values.append(monitors[-1])
20
21# rebin the event data to produce histograms
22hist = Rebin(ws_e, Params=values, PreserveEvents=False)
23
24# concatenate the monitor and the histogram. You will end up with
25# the workspace: ws_e_monitors.
26# ShowInstrument in this workspace and you will see only a blank detectors
27ConjoinWorkspaces(mon, hist)
28
29
30# I was expecting something like this one.
31hist_ws = LoadNexus(str(run_num))
32
33CheckWorkspacesMatch('ws_e_monitors','hist_ws')