Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspace | Input | MatrixWorkspace | Mandatory | An input workspace. |
RelativeTimeOffset | Input | number | 0 | A relative time offset in seconds. |
AbsoluteTimeOffset | Input | string | An absolute time offset as an ISO8601 string (YYYY-MM-DDTHH:MM::SS, eg 2013-10-25T13:58:03). | |
OutputWorkspace | Output | MatrixWorkspace | Mandatory | An output workspace. |
The algorithm modifies the time signatures of a MatrixWorkspace. The new time signature alters the logs and in case of an EventWorkspace the neutron times as well.
The time offset can be specified in one of the two following ways:
Only one of the two ways of shifting the time can be specified.
Note
To run these usage examples please first download the usage data, and add these to your path. In MantidPlot this is done using Manage User Directories.
Example - Relative Time Shift for an EventWorkspace:
# Load an event workspace
original_ws = Load('CNCS_7860_event.nxs')
# Specify the time shift
time_shift = 10000.5
# Change the zero time
shifted_ws = ChangeTimeZero(InputWorkspace = original_ws , RelativeTimeOffset = time_shift)
# Check some logs
original_proton_charge = original_ws.getRun()['proton_charge']
shifted_proton_charge = shifted_ws .getRun()['proton_charge']
# Check some events
original_pulse_times = original_ws.getSpectrum(7).getPulseTimes()
shifted_pulse_times = shifted_ws.getSpectrum(7).getPulseTimes()
print("Original proton_charge time: {} , {} , ...".format(original_proton_charge.nthTime(0), original_proton_charge.nthTime(1)))
print("Shifted proton_charge time: {} , {} , ...".format(shifted_proton_charge.nthTime(0), shifted_proton_charge.nthTime(1)))
print("Original pulse times: {} , {} , ...".format(original_pulse_times[0], original_pulse_times[1]))
print("Shifted pulse times: {} , {} , ...".format(shifted_pulse_times[0], shifted_pulse_times[1]))
Output:
Original proton_charge time: 2010-03-25T16:08:37 , 2010-03-25T16:08:37.016667999 , ...
Shifted proton_charge time: 2010-03-25T18:55:17.500000000 , 2010-03-25T18:55:17.516667999 , ...
Original pulse times: 2010-03-25T16:09:57.474029541 , 2010-03-25T16:10:33.529106140 , ...
Shifted pulse times: 2010-03-25T18:56:37.974029541 , 2010-03-25T18:57:14.029106140 , ...
Example - Absolute Time Shift for an EventWorkspace:
# Load an event workspace
original_ws = Load('CNCS_7860_event.nxs')
# Specify the time shift
time_shift = '2002-07-13T14:00:01'
# Change the zero time
shifted_ws = ChangeTimeZero(InputWorkspace = original_ws , AbsoluteTimeOffset = time_shift)
# Check some logs
original_proton_charge = original_ws.getRun()['proton_charge']
shifted_proton_charge = shifted_ws .getRun()['proton_charge']
# Check some events
original_pulse_times = original_ws.getSpectrum(7).getPulseTimes()
shifted_pulse_times = shifted_ws.getSpectrum(7).getPulseTimes()
print("Original proton_charge time: {} , {} , ...".format(original_proton_charge.nthTime(0), original_proton_charge.nthTime(1)))
print("Shifted proton_charge time: {} , {} , ...".format(shifted_proton_charge.nthTime(0), shifted_proton_charge.nthTime(1)))
print("Original pulse times: {} , {} , ...".format(original_pulse_times[0], original_pulse_times[1]))
print("Shifted pulse times: {} , {} , ...".format(shifted_pulse_times[0], shifted_pulse_times[1]))
Output:
Original proton_charge time: 2010-03-25T16:08:37 , 2010-03-25T16:08:37.016667999 , ...
Shifted proton_charge time: 2002-07-13T14:00:01 , 2002-07-13T14:00:01.016667999 , ...
Original pulse times: 2010-03-25T16:09:57.474029541 , 2010-03-25T16:10:33.529106140 , ...
Shifted pulse times: 2002-07-13T14:01:21.474029541 , 2002-07-13T14:01:57.529106140 , ...
Categories: Algorithms | Utility\Workspaces
C++ source: ChangeTimeZero.cpp (last modified: 2017-09-28)
C++ header: ChangeTimeZero.h (last modified: 2017-09-28)