Newer
Older
.. algorithm::
.. summary::
.. alias::
.. properties::
Description
-----------
Workspaces contain information in logs. Often these detail what happened
to the sample during the experiment. This algorithm allows one named log
to be entered.
The log can be either a String, a Number, or a Number Series. If you
select Number Series, the workspace start time will be used as the time
of the log entry, and the number in the text used as the (only) value.
If the LogText contains a numeric value, the created log will be of
integer type if an integer is passed and floating point (double)
otherwise. This applies to both the Number & Number Series options.
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
Usage
-----
**Example - Add Sample Logs in different ways**
.. testcode:: AddSampleLogExample
# Create a host workspace
demo_ws = CreateWorkspace(DataX=range(0,3), DataY=(0,2))
# Add sample logs
AddSampleLog(Workspace=demo_ws, LogName='x', LogText='hello world', LogType='String')
AddSampleLog(Workspace=demo_ws, LogName='y', LogText='1', LogType='Number')
AddSampleLog(Workspace=demo_ws, LogName='z', LogText='2', LogType='Number Series')
# Fetch the generated logs
run = demo_ws.getRun()
log_x = run.getLogData('x')
log_y = run.getLogData('y')
log_z = run.getLogData('z')
# Print the log values
print log_x.value
print log_y.value
print log_z.value
Output:
.. testoutput:: AddSampleLogExample
hello world
1
[2]
**Example - How to add a Time Series Log**
Strictly, this does not use :ref:`algm-AddSampleLog` at all.
.. testcode:: AddTimeSeriesLog
from mantid.kernel import FloatTimeSeriesProperty, DateAndTime
# Create a host workspace
ws = CreateWorkspace(DataX=[0,1,2], DataY=[1,1])
# Create a time series property. This holds all the data we want
tsp = FloatTimeSeriesProperty('x')
# Create an absolute start time
run_start = DateAndTime("2000-01-01T00:00:00")
# Add some values to our new log
for i in range(10):
tsp.addValue(run_start + int(i *1e9), float(i))
# Add the property to the workspace
ws.mutableRun().addProperty('x', tsp, True)
# Fetch it off the workspace again just to show that it was correctly attached in the first place
log = ws.run().getLogData('x')
# Print the entries
print log.value
print log.times
.. testcleanup:: AddTimeSeriesLog
DeleteWorkspace('ws')
Output:
.. testoutput:: AddTimeSeriesLog
[ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9.]
[2000-Jan-01 00:00:00,2000-Jan-01 00:00:01,2000-Jan-01 00:00:02,2000-Jan-01 00:00:03,2000-Jan-01 00:00:04,2000-Jan-01 00:00:05,2000-Jan-01 00:00:06,2000-Jan-01 00:00:07,2000-Jan-01 00:00:08,2000-Jan-01 00:00:09]