本文整理匯總了Python中mantid.simpleapi.CreateWorkspace.mutableRun()["SensorA"]方法的典型用法代碼示例。如果您正苦於以下問題:Python CreateWorkspace.mutableRun()["SensorA"]方法的具體用法?Python CreateWorkspace.mutableRun()["SensorA"]怎麽用?Python CreateWorkspace.mutableRun()["SensorA"]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mantid.simpleapi.CreateWorkspace
的用法示例。
在下文中一共展示了CreateWorkspace.mutableRun()["SensorA"]方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: createTestWorkspace
# 需要導入模塊: from mantid.simpleapi import CreateWorkspace [as 別名]
# 或者: from mantid.simpleapi.CreateWorkspace import mutableRun()["SensorA"] [as 別名]
def createTestWorkspace(self):
""" Create a workspace for testing against with ideal log values
"""
from mantid.simpleapi import CreateWorkspace
from mantid.simpleapi import AddSampleLog
from time import gmtime, strftime, mktime
import numpy as np
# Create a matrix workspace
x = np.array([1.0, 2.0, 3.0, 4.0])
y = np.array([1.0, 2.0, 3.0])
e = np.sqrt(np.array([1.0, 2.0, 3.0]))
wksp = CreateWorkspace(DataX=x, DataY=y, DataE=e, NSpec=1, UnitX="TOF")
# Add run_start
tmptime = strftime("%Y-%m-%d %H:%M:%S", gmtime(mktime(gmtime())))
AddSampleLog(Workspace=wksp, LogName="run_start", LogText=str(tmptime))
tsp_a = kernel.FloatTimeSeriesProperty("SensorA")
tsp_b = kernel.FloatTimeSeriesProperty("SensorB")
tsp_c = kernel.FloatTimeSeriesProperty("SensorC")
for i in arange(25):
tmptime = strftime("%Y-%m-%d %H:%M:%S", gmtime(mktime(gmtime()) + i))
tsp_a.addValue(tmptime, 1.0 * i * i)
tsp_b.addValue(tmptime, 2.0 * i * i)
tsp_c.addValue(tmptime, 3.0 * i * i)
wksp.mutableRun()["SensorA"] = tsp_a
wksp.mutableRun()["SensorB"] = tsp_b
wksp.mutableRun()["SensorC"] = tsp_c
return wksp
示例2: createTestWorkspace2
# 需要導入模塊: from mantid.simpleapi import CreateWorkspace [as 別名]
# 或者: from mantid.simpleapi.CreateWorkspace import mutableRun()["SensorA"] [as 別名]
def createTestWorkspace2(self):
""" Create a workspace for testing against with more situation
"""
from mantid.simpleapi import CreateWorkspace
from mantid.simpleapi import AddSampleLog
from time import gmtime, strftime, mktime
from datetime import datetime, timedelta
import numpy as np
# Create a matrix workspace
x = np.array([1.0, 2.0, 3.0, 4.0])
y = np.array([1.0, 2.0, 3.0])
e = np.sqrt(np.array([1.0, 2.0, 3.0]))
wksp = CreateWorkspace(DataX=x, DataY=y, DataE=e, NSpec=1, UnitX="TOF")
# Add run_start
year = 2014
month = 2
day = 15
hour = 13
minute = 34
second = 3
dtimesec = 0.0010
timefluc = 0.0001
# tmptime = strftime("%Y-%m-%d %H:%M:%S", gmtime(mktime(gmtime())))
runstart = datetime(year, month, day, hour, minute, second)
AddSampleLog(Workspace=wksp, LogName="run_start", LogText=str(runstart))
tsp_a = kernel.FloatTimeSeriesProperty("SensorA")
tsp_b = kernel.FloatTimeSeriesProperty("SensorB")
tsp_c = kernel.FloatTimeSeriesProperty("SensorC")
tsp_d = kernel.FloatTimeSeriesProperty("SensorD")
logs = [tsp_a, tsp_b, tsp_c, tsp_d]
dbbuf = ""
random.seed(0)
for i in arange(25):
# Randomly pick up log without records
# first iteration must have all the record
skiploglist = []
if i > 0:
numnorecord = random.randint(-1, 4)
if numnorecord > 0:
for j in xrange(numnorecord):
logindex = random.randint(0, 6)
skiploglist.append(logindex)
# ENDFOR (j)
# ENDIF (numnorecord)
# ENDIF (i)
dbbuf += "----------- %d -------------\n" % (i)
# Record
for j in xrange(4):
# Skip if selected
if j in skiploglist:
continue
# get random time shifts
timeshift = (random.random() - 0.5) * timefluc
if i == 0:
# first record should have the 'exactly' same time stamps
timeshift *= 0.0001
deltatime = timedelta(i * dtimesec + timeshift)
tmptime = str(runstart + deltatime)
tmpvalue = float(i * i * 6) + j
logs[j].addValue(tmptime, tmpvalue)
dbbuf += "%s: %s = %d\n" % (logs[j].name, tmptime, tmpvalue)
# ENDFOR (j)
# ENDFOR (i)
# print dbbuf
wksp.mutableRun()["SensorA"] = tsp_a
wksp.mutableRun()["SensorB"] = tsp_b
wksp.mutableRun()["SensorC"] = tsp_c
wksp.mutableRun()["SensorD"] = tsp_d
return wksp