What the Run object

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

You can look at the Run API reference for a full list of properties and operations, but here are some of the key ones.

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

# Get the start and end time of a run

# Get the total good proton charge

Accessing Properties

Listing all properties

ws = Load("MAR11060")

run = ws.getRun()

# Get a list of the property names

# 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.


print("Goniometer angles:  {}".format(wg.getRun().getGoniometer().getEulerAngles('YZY')))

Multiple goniometers can be accessed from the run object by

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)

print("Number of goniometers =", wg.getRun().getNumGoniometers())

for i in range(wg.getRun().getNumGoniometers()):
    print("Goniometer angles:  {}".format(wg.getRun().getGoniometer(i).getEulerAngles('YZY')))

Listing all properties

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)

Category: Concepts