\(\renewcommand\AA{\unicode{x212B}}\)
Run Info and Sample Logs¶
Each workspace has a method called getRun(), which can be used to access information regarding the experimental run. A full list of the methods available on the returned object is at Run.
The logs recorded during a run are also stored on the Run object and can be accessed using the getLogData() method. It has two variants:
ws = Load('CNCS_7860_event')
run = ws.getRun()
# You can access all the available log properties using the keys method
print('Sample Logs:', run.keys())
# With no argument it returns all logs
all_logs = run.getLogData()
# Returns the named log, raising an exception if the name is not found
temperature = run.getLogData('SampleTemp')
# Use name & value to access the name values
vals = temperature.value; print('Temp Values:',vals)
Most logs are a time-series property with the attributes described here. The values at each time can be accessed individually or as a collection.
Filtering¶
Note that you can use the algorithms FilterByLogValue v1 or FilterByTime v1. The LogFilter class can be used to filter logs using other logs. For instance, a log value describes a sine wave (Right-click > Show Sample logs on the Loaded workspace below).
Two additional logs mask out the positive and negative portions of this log. We can filter according to either.
from mantid.simpleapi import *
from mantid.kernel import LogFilter
ws = Load("LogWS.nxs")
run = ws.getRun()
wave_log = run.getLogData('sinewave')
negative_log = run.getLogData('negative')
positive_log = run.getLogData('positive')
# Show the size of the original log.
print("Unfiltered log contains %i values" % (wave_log.size()))
# Filter the original log removing negative data
filter = LogFilter(wave_log)
filter.addFilter(negative_log)
filtered_log = filter.data()
print("Filtered log contains %i positive values" % (filtered_log.size()))
# Now filter the original data removing positive values
filter = LogFilter(wave_log)
filter.addFilter(positive_log)
filtered_log = filter.data()
print("Filtered log contains %i negative values" % (filtered_log.size()))
Output:
Unfiltered log contains 100 values
Filtered log contains 50 positive values
Filtered log contains 50 negative values
Sample Log Algorithms¶
As well as the filtering algorithms, there are plenty of other Sample Log operations that are encompassed in algorithms: