1 | # set MANTID to SANS2D instrument, and add cycle_12_3 to the path to search |
---|
2 | |
---|
3 | #Load the event data |
---|
4 | run_num = 16183#16187 |
---|
5 | ws_e, mon = Load(str(run_num),LoadMonitors=True) |
---|
6 | print ws_e.getNumberHistograms()/2 -1 |
---|
7 | ws_e = CropWorkspace(ws_e,StartWorkspaceIndex=0,EndWorkspaceIndex=ws_e.getNumberHistograms()/2-1) |
---|
8 | |
---|
9 | # get the binning from the monitor |
---|
10 | monitors = mon.readX(0) |
---|
11 | step = 0 |
---|
12 | values = [] |
---|
13 | for 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 | |
---|
19 | values.append(monitors[-1]) |
---|
20 | |
---|
21 | # rebin the event data to produce histograms |
---|
22 | hist = 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 |
---|
27 | ConjoinWorkspaces(mon, hist) |
---|
28 | |
---|
29 | |
---|
30 | # I was expecting something like this one. |
---|
31 | hist_ws = LoadNexus(str(run_num)) |
---|
32 | |
---|
33 | CheckWorkspacesMatch('ws_e_monitors','hist_ws') |
---|