Run#
This is a Python binding to the C++ class Mantid::API::Run.
A Run holds data related to the properties of the experimental run, e.g. good proton charge, total frames etc. It also holds all of the sample log files as sets of time-series data. Currently used properties within Mantid includes run_start, which specified the date the data were collected. Where an instrument has been modified over time, and multiple instrument definition files have been defined for it, this property is used to loads the IDF valid when the data were collected.
Working with Run object in Python#
Getting the Run Object from a Workspace#
run = ws.getRun()
Run Properties#
from mantid.kernel import DateAndTime
run = ws.getRun()
# Set the start and end time of a run
run.setStartAndEndTime(DateAndTime("2015-01-27T11:00:00"),
DateAndTime("2015-01-27T11:57:51"))
# Get the start and end time of a run
print(run.startTime())
print(run.endTime())
# Get the total good proton charge
print(run.getProtonCharge())
Accessing Properties#
Listing all properties#
ws = Load("MAR11060")
run = ws.getRun()
# Get a list of the property names
print(run.keys())
# Loop over all of the Properties
for prop in run.getProperties():
print("{0} {1}".format(prop.name, prop.value))
Getting a specific property#
ws = CreateSampleWorkspace()
run = ws.getRun()
# Check if property exists
print("Is runstart present: {0}".format(("run_start" in run.keys())))
# or
print("Is runstart present: {0}".format(run.hasProperty("run_start")))
#get the Property
runStart = run.getProperty("run_start")
print("Property name: " + runStart.name)
print("Property value: " + runStart.value)
The Goniometer#
If the instrument contains a Goniometer it can be accessed from the run object.
wg=CreateSingleValuedWorkspace()
AddSampleLog(wg,"Motor1","45.","Number")
SetGoniometer(wg,Axis0="Motor1,0,1,0,1",Axis1="5,0,1,0,1")
print("Goniometer angles: {}".format(wg.getRun().getGoniometer().getEulerAngles('YZY')))
Multiple goniometers can be accessed from the run object by
wg=CreateSingleValuedWorkspace()
AddTimeSeriesLog(wg, Name="Motor1", Time="2010-01-01T00:00:00", Value=0)
AddTimeSeriesLog(wg, Name="Motor1", Time="2010-01-01T00:01:00", Value=45)
AddTimeSeriesLog(wg, Name="Motor1", Time="2010-01-01T00:02:00", Value=90)
SetGoniometer(wg,Axis0="Motor1,0,1,0,1",Average=False)
print("Number of goniometers =", wg.getRun().getNumGoniometers())
for i in range(wg.getRun().getNumGoniometers()):
print("Goniometer angles: {}".format(wg.getRun().getGoniometer(i).getEulerAngles('YZY')))
What information is stored here?#
On loading experimental data there is a default set of properties that are populated within the run. These are as follows:
ISIS (not including ISIS Muon data)#
run_header - The complete header for this run
run_title - The run title
run_start - Start date and time. Format: YYYY-MM-DD HH:MM:SS (+)
run_end - End date and time. Format: YYYY-MM-DD HH:MM:SS (+)
nspectra - The number of spectra in the raw data file
nchannels - The number of time channels in the raw data
nperiods - The number of periods within the raw data
dur - The run duration
durunits - The units of the run duration, 1 = seconds
dur_freq - Test interval for above
dmp - Dump interval
dmp_units - The units (scaler) for above
dmp_freq - Test interval for above
freq - 2**k where source frequency = 50 / 2**k
gd_prtn_chrg - Good proton charge (uA.hour)
tot_prtn_chrg - Total proton charge (uA.hour)
goodfrm - Good frames
rawfrm - Raw frames
dur_wanted - Requested run duration (units as for “duration” above)
dur_secs - Actual run duration in seconds
mon_sum1 - Monitor sum 1
mon_sum2 - Monitor sum 2
mon_sum3 - Monitor sum 3
rb_proposal - The proposal number
ISIS Muon data#
run_title - The run title
run_start - Start date and time. Format: YYYY-MM-DD HH:MM:SS (+)
run_end - End date and time. Format: YYYY-MM-DD HH:MM:SS (+)
nspectra - The number of spectra in the raw data file
goodfrm - Good frames
dur_secs - Run duration in seconds
run_number - Run number
sample_temp - Temperature of the sample
sample_magn_field - Magnetic field of the sample
(+) or YYYY-MM-DDTHH:MM:SS (ISO 8601 format, see 1)
Reference#
- class mantid.api.Run#
- addProperty((Run)self, (str)name, (object)value, (bool)replace) None :#
Adds a property with the given name and value. If replace=True then an existing property is overwritten
- addProperty( (Run)self, (str)name, (object)value, (str)units, (bool)replace) -> None :
Adds a property with the given name, value and unit. If replace=True then an existing property is overwritten
- endTime((Run)self) mantid.kernel._kernel.DateAndTime :#
Return the total ending time of the run.
- get((object)self, (object)key, (object)default) object :#
Returns the value pointed to by the key or the default value given.
- get( (object)self, (object)key) -> object :
Returns the value pointed to by the key or None if it does not exist.
- getGoniometer((Run)self[, (int)index=0]) mantid.geometry._geometry.Goniometer :#
Return Goniometer object associated with this run by index, default first goniometer.
- getLogData((Run)self, (str)name) mantid.kernel._kernel.Property :#
Returns the named log. Use ‘.value’ to return the value. The same as getProperty.
- getLogData( (Run)self) -> mantid.kernel._kernel.std_vector_property :
Return the list of logs for this run. The same as getProperties.
- getNumGoniometers((Run)self) int :#
Return the number of goniometer objects associated with this run.
- getProperties((Run)self) mantid.kernel._kernel.std_vector_property :#
Return the list of run properties managed by this object.
- getProperty((Run)self, (str)name) mantid.kernel._kernel.Property :#
Returns the named property (log value). Use ‘.value’ to return the value.
- getPropertyAsSingleValue((Run)self, (str)name) float :#
Return a log as a single float value. Time series values are averaged.
- getPropertyAsSingleValueWithTimeAveragedMean((Run)self, (str)name) float :#
Returns a log as a single float value. Calculated using time-averaged mean.
- getProtonCharge((Run)self) float :#
Return the total good proton charge for the run
- getStatistics((Run)self, (str)name) mantid.kernel._kernel.TimeSeriesPropertyStatistics :#
Returns the all of the statistics about the obect
- getTimeAveragedStd((Run)self, (str)name) float :#
Returns the time averaged standard deviation
- getTimeAveragedValue((Run)self, (str)name) float :#
Returns the time averaged value of a log
- getTimeROI((Run)self) mantid.kernel._kernel.TimeROI :#
Return the time regoin of interest
- hasProperty((Run)self, (str)name) bool :#
Returns True if the given log value is contained within the run
- integrateProtonCharge((Run)self[, (str)logname='proton_charge']) None :#
Set the total good proton charge for the run, from the proton charge log
- keys((Run)self) list :#
Returns the names of the properties as list
- setStartAndEndTime((Run)self, (mantid.kernel._kernel.DateAndTime)start, (mantid.kernel._kernel.DateAndTime)end) None :#
Set the start and end time of the run
- startTime((Run)self) mantid.kernel._kernel.DateAndTime :#
Return the total starting time of the run.