-
Notifications
You must be signed in to change notification settings - Fork 122
/
CompressEvents.py
47 lines (37 loc) · 2.2 KB
/
CompressEvents.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
#pylint: disable=no-init,invalid-name,attribute-defined-outside-init
import systemtesting
from mantid.simpleapi import *
class CompressEventsTesting(systemtesting.MantidSystemTest):
event_files = ["PG3_4844_event.nxs"] # /SNS/PG3/IPTS-2767/0/ for 2.5 hours
def requiredFiles(self):
return self.event_files
def runTest(self):
for filename in self.event_files:
wkspname = filename.split('.')[0]
outname = wkspname + '_out'
LoadEventNexus(Filename=filename, OutputWorkspace=wkspname, LoadMonitors=False)
totalEvents = mtd[wkspname].getNumberEvents()
SumSpectra(InputWorkspace=wkspname, OutputWorkspace=wkspname)
# max for Integration algorithm is not inclusive
for name in (outname, wkspname): # first out of place, then in place
CompressEvents(InputWorkspace=wkspname, OutputWorkspace=name,
WallClockTolerance=10.)
integral = Integration(InputWorkspace=name, RangeUpper=20000.)
compress10s = integral.readY(0)[0]
CompressEvents(InputWorkspace=wkspname, OutputWorkspace=name,
WallClockTolerance=3600.)
integral = Integration(InputWorkspace=name, RangeUpper=20000.)
compress1h = integral.readY(0)[0]
CompressEvents(InputWorkspace=wkspname, OutputWorkspace=name)
integral = Integration(InputWorkspace=name, RangeUpper=20000.)
compressfull = integral.readY(0)[0]
if not (totalEvents == compress10s == compress1h == compressfull):
msg = '{} total={:.0f} 10s={:.0f} 1h={:.0f} full={:.0f}'.format(name, totalEvents, compress10s,
compress1h, compressfull)
raise RuntimeError(msg)