\(\renewcommand\AA{\unicode{x212B}}\)
Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspace | Input | MatrixWorkspace | Mandatory | Workspace to copy logs from. |
OutputWorkspace | InOut | MatrixWorkspace | Mandatory | Workspace to copy logs to. |
MergeStrategy | Input | string | MergeReplaceExisting | The type of merge strategy to use on the logs. Allowed values: [‘WipeExisting’, ‘MergeKeepExisting’, ‘MergeReplaceExisting’] |
The algorithm will copy the sample logs in the input workspace to the the output workspace using one of three merge strategies.
Example - Copy Logs with default merge strategy
# Create two workspaces
demo_ws1 = CreateWorkspace(DataX=range(0,3), DataY=(0,2))
demo_ws2 = CreateWorkspace(DataX=range(0,3), DataY=(0,2))
# Add logs to first workspace
AddSampleLog(Workspace=demo_ws1, LogName='x', LogText='hello world', LogType='String')
AddSampleLog(Workspace=demo_ws1, LogName='y', LogText='1', LogType='Number')
AddSampleLog(Workspace=demo_ws1, LogName='z', LogText='2', LogType='Number Series')
# Add logs to second workspace
AddSampleLog(Workspace=demo_ws2, LogName='x', LogText='hello universe', LogType='String')
AddSampleLog(Workspace=demo_ws2, LogName='w', LogText='3', LogType='Number')
# Fetch the generated logs
run1 = demo_ws1.getRun()
log_x1 = run1.getLogData('x')
log_y = run1.getLogData('y')
log_z = run1.getLogData('z')
run2 = demo_ws2.getRun()
log_x2 = run2.getLogData('x')
log_w = run2.getLogData('w')
# Print the log values
print("Before CopyLog")
print("1st workspace log values x = {} , y = {} , z = {}".format(log_x1.value, log_y.value, log_z.value))
print("2nd workspace log values x = {} , w = {}".format(log_x2.value, log_w.value ))
# Copy logs of 1st workspace to 2nd workspace
CopyLogs( demo_ws1, demo_ws2)
# Fetch the new logs
run1 = demo_ws1.getRun()
log_x1 = run1.getLogData('x')
log_y = run1.getLogData('y')
log_z = run1.getLogData('z')
run2 = demo_ws2.getRun()
log_x2 = run2.getLogData('x')
log_w = run2.getLogData('w')
log_y2 = run2.getLogData('y')
log_z2 = run2.getLogData('z')
# Print the log values
print("After CopyLog")
print("1st workspace log values x = {} , y = {} , z = {}".format(log_x1.value, log_y.value, log_z.value))
print("2nd workspace log values x = {} , w = {} , y = {} , z = {}".format(log_x2.value, log_w.value, log_y2.value, log_z2.value))
Output:
Before CopyLog
1st workspace log values x = hello world , y = 1 , z = [2]
2nd workspace log values x = hello universe , w = 3
After CopyLog
1st workspace log values x = hello world , y = 1 , z = [2]
2nd workspace log values x = hello world , w = 3 , y = 1 , z = [2]
Example - Copy Logs with MergeKeepExisting merge strategy
# Create two workspaces
demo_ws1 = CreateWorkspace(DataX=range(0,3), DataY=(0,2))
demo_ws2 = CreateWorkspace(DataX=range(0,3), DataY=(0,2))
# Add logs to first workspace
AddSampleLog(Workspace=demo_ws1, LogName='x', LogText='hello world', LogType='String')
AddSampleLog(Workspace=demo_ws1, LogName='y', LogText='1', LogType='Number')
AddSampleLog(Workspace=demo_ws1, LogName='z', LogText='2', LogType='Number Series')
# Add logs to second workspace
AddSampleLog(Workspace=demo_ws2, LogName='x', LogText='hello universe', LogType='String')
AddSampleLog(Workspace=demo_ws2, LogName='w', LogText='3', LogType='Number')
# Fetch the generated logs
run1 = demo_ws1.getRun()
log_x1 = run1.getLogData('x')
log_y = run1.getLogData('y')
log_z = run1.getLogData('z')
run2 = demo_ws2.getRun()
log_x2 = run2.getLogData('x')
log_w = run2.getLogData('w')
# Print the log values
print("Before CopyLog")
print("1st workspace log values x = {} , y = {} , z = {}".format(log_x1.value, log_y.value, log_z.value))
print("2nd workspace log values x = {} , w = {}".format(log_x2.value, log_w.value))
# Copy logs of 1st workspace to 2nd workspace
CopyLogs( demo_ws1, demo_ws2, MergeStrategy='MergeKeepExisting')
# Fetch the new logs
run1 = demo_ws1.getRun()
log_x1 = run1.getLogData('x')
log_y = run1.getLogData('y')
log_z = run1.getLogData('z')
run2 = demo_ws2.getRun()
log_x2 = run2.getLogData('x')
log_w = run2.getLogData('w')
log_y2 = run2.getLogData('y')
log_z2 = run2.getLogData('z')
# Print the log values
print("After CopyLog")
print("1st workspace log values x = {} , y = {} , z = {}".format(log_x1.value, log_y.value, log_z.value))
print("2nd workspace log values x = {} , w = {} , y = {} , z = {}".format(log_x2.value, log_w.value, log_y2.value, log_z2.value))
Output:
Before CopyLog
1st workspace log values x = hello world , y = 1 , z = [2]
2nd workspace log values x = hello universe , w = 3
After CopyLog
1st workspace log values x = hello world , y = 1 , z = [2]
2nd workspace log values x = hello universe , w = 3 , y = 1 , z = [2]
Example - Copy Logs with WipeExisting merge strategy
# Create two workspaces
demo_ws1 = CreateWorkspace(DataX=range(0,3), DataY=(0,2))
demo_ws2 = CreateWorkspace(DataX=range(0,3), DataY=(0,2))
# Add sample logs first workspace
AddSampleLog(Workspace=demo_ws1, LogName='x', LogText='hello world', LogType='String')
AddSampleLog(Workspace=demo_ws1, LogName='y', LogText='1', LogType='Number')
AddSampleLog(Workspace=demo_ws1, LogName='z', LogText='2', LogType='Number Series')
# Add sample logs second workspace
AddSampleLog(Workspace=demo_ws2, LogName='x', LogText='hello universe', LogType='String')
AddSampleLog(Workspace=demo_ws2, LogName='w', LogText='3', LogType='Number')
# Fetch the generated logs
run1 = demo_ws1.getRun()
log_x1 = run1.getLogData('x')
log_y = run1.getLogData('y')
log_z = run1.getLogData('z')
run2 = demo_ws2.getRun()
log_x2 = run2.getLogData('x')
log_w = run2.getLogData('w')
# Print the log values
print("Before CopyLog")
print("1st workspace log values x = {} , y = {} , z = {}".format(log_x1.value, log_y.value, log_z.value))
print("2nd workspace log values x = {} , w = {}".format(log_x2.value, log_w.value))
# Copy logs of 1st workspace to 2nd workspace
CopyLogs( demo_ws1, demo_ws2, MergeStrategy='WipeExisting')
# Fetch the new logs
run1 = demo_ws1.getRun()
log_x1 = run1.getLogData('x')
log_y = run1.getLogData('y')
log_z = run1.getLogData('z')
run2 = demo_ws2.getRun()
log_x2 = run2.getLogData('x')
log_y2 = run2.getLogData('y')
log_z2 = run2.getLogData('z')
# Print the log values
print("After CopyLog")
print("1st workspace log values x = {} , y = {} , z = {}".format(log_x1.value, log_y.value, log_z.value))
print("2nd workspace log values x = {} , y = {} , z = {}".format(log_x2.value, log_y2.value, log_z2.value))
Output:
Before CopyLog
1st workspace log values x = hello world , y = 1 , z = [2]
2nd workspace log values x = hello universe , w = 3
After CopyLog
1st workspace log values x = hello world , y = 1 , z = [2]
2nd workspace log values x = hello world , y = 1 , z = [2]
Categories: AlgorithmIndex | Utility\Workspaces
C++ header: CopyLogs.h (last modified: 2020-03-20)
C++ source: CopyLogs.cpp (last modified: 2020-04-07)