Ticket #8300: Filtering.py

File Filtering.py, 689 bytes (added by Owen Arnold, 7 years ago)
Line 
1from mantid.kernel import DateAndTime
2mtd.importAll()
3ws = WISH00026110
4
5def meanWithinRange(filterstart, filterend, logname):
6        run = ws.getRun()
7        temperature = run.getLogData(logname)
8        times = numpy.array(temperature.times)
9        values = numpy.array(temperature.value)
10        mask = (filterstart < times) & (times < filterend) # Get times between filter start and end.
11        return values[mask].mean() # Use mask to get the mean value in this time interval.
12
13filterstart = DateAndTime("2013-10-30T10:03+00:00") # Example filter start
14filterend = DateAndTime("2013-10-30T11:14+00:00") # Example filter end
15logname = 'Sample_Temp'
16print meanWithinRange(filterstart, filterend, logname)
17
18