\(\renewcommand\AA{\unicode{x212B}}\)

TimeDifference v1

Summary

Calculates the time differences of a series of workspaces with respect to a reference. If a reference workspace isn’t provided, the first workspace from InputWorkspaces is used.

Properties

Name

Direction

Type

Default

Description

InputWorkspaces

Input

str list

Mandatory

Input workspaces. Comma separated workspace names of either Matrix or Group Workspaces. Must be on the ADS. Allowed values: [‘002192_Beam’, ‘002192_Beam_Flux’, ‘002193_Transmission’, ‘002194_Transmission’, ‘002195_Transmission’, ‘002196_Transmission’, ‘002197_Transmission’, ‘002219_Beam’, ‘002219_Beam_Flux’, ‘002227_Absorber’, ‘002228_Container’, ‘AgBE’, ‘AgBE_#1_d2.0m_c7.8m_w6.0A’, ‘D2O’, ‘D2O_#1_d2.0m_c7.8m_w6.0A’, ‘D33Mask2’, ‘D33_2m_SolidAngle’, ‘F127_D2O’, ‘F127_D2O_#1_d2.0m_c7.8m_w6.0A’, ‘F127_D2O_Anethol’, ‘F127_D2O_Anethol_#1_d2.0m_c7.8m_w6.0A’, ‘H2O’, ‘H2O_#1_d2.0m_c7.8m_w6.0A’, ‘SofTT’, ‘stitched’, ‘stitched_wav’, ‘trans1’, ‘trans1_wav’, ‘trans2’, ‘trans2_wav’, ‘ws’, ‘ws1’, ‘ws2’]

ReferenceWorkspace

Input

Workspace

Workspace to be used as time reference

OutputWorkspace

Output

TableWorkspace

Mandatory

Table containing difference time in relation to the reference workspace for each input workspace

Description

This algorithm takes a list of workspace names (workspaces can be Matrix or Group) and compares the middle time (defined below) at which each run occurs to a reference value. The differences are entered into the output table workspace with columns for the time in seconds and hours (plus errors). To establish the time at which each run occurs, the start times are taken from either run_start or start_time logs and the end times from run_end or end_time logs. For each workspace, the run duration is computed as : \(duration = end_{time} - start_{time}\) and the time as the middle time of the duration interval: \(midtime = start_{time} + duration/2\). Then, each difference time is computed by subtracting the calculated midtime stamp from the reference. \(difference = midtime - midtime_{ref}\) . Taking the duration as the absolute error of each midtime stamp, the error of the difference is computed as the sum of each midtime error.

  • If a reference workspace is not provided, the first workspace in the Workspaces property list will be set as the reference.

  • For group workspaces, start and end time stamps for all the workspaces contained in the group will be extracted, and the duration interval computed from the runs with the earliest and latest start and end times, respectively.

Usage

** Example **

time_origin = np.datetime64('2025-06-12T08:00:00.000000000')
experiment_duration = np.timedelta64(60,'s')

start_times = [0,100,200,300]

names = []
for start in start_times:
    names.append(str(start))
    start_time = time_origin + np.timedelta64(start,'s')
    end_time = start_time + experiment_duration
    CreateWorkspace(OutputWorkspace=names[-1], DataX = 0 , DataY = 1)
    AddSampleLog(Workspace=names[-1], LogName='start_time', LogText=str(start_time), LogType='String')
    AddSampleLog(Workspace=names[-1], LogName='end_time', LogText=str(end_time), LogType='String')

table = TimeDifference(InputWorkspaces=names)
print("Time Differences are, in seconds: " + str(table.column(2)))

Output:

Time Differences are, in seconds: [0.0, 100.0, 200.0, 300.0]

Categories: AlgorithmIndex | Utility

Source

Python: TimeDifference.py