本文整理匯總了Python中mantid.simpleapi.CreateWorkspace.readY方法的典型用法代碼示例。如果您正苦於以下問題:Python CreateWorkspace.readY方法的具體用法?Python CreateWorkspace.readY怎麽用?Python CreateWorkspace.readY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mantid.simpleapi.CreateWorkspace
的用法示例。
在下文中一共展示了CreateWorkspace.readY方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_create_with_1D_numpy_array
# 需要導入模塊: from mantid.simpleapi import CreateWorkspace [as 別名]
# 或者: from mantid.simpleapi.CreateWorkspace import readY [as 別名]
def test_create_with_1D_numpy_array(self):
x = np.array([1.,2.,3.,4.])
y = np.array([1.,2.,3.])
e = np.sqrt(np.array([1.,2.,3.]))
wksp = CreateWorkspace(DataX=x, DataY=y,DataE=e,NSpec=1,UnitX='TOF')
self.assertTrue(isinstance(wksp, MatrixWorkspace))
self.assertEquals(wksp.getNumberHistograms(), 1)
self.assertEquals(len(wksp.readY(0)), len(y))
self.assertEquals(len(wksp.readX(0)), len(x))
self.assertEquals(len(wksp.readE(0)), len(e))
for index in range(len(y)):
self.assertEquals(wksp.readY(0)[index], y[index])
self.assertEquals(wksp.readE(0)[index], e[index])
self.assertEquals(wksp.readX(0)[index], x[index])
# Last X value
self.assertEquals(wksp.readX(0)[len(x)-1], x[len(x)-1])
AnalysisDataService.remove("wksp")
示例2: test_with_data_from_other_workspace
# 需要導入模塊: from mantid.simpleapi import CreateWorkspace [as 別名]
# 或者: from mantid.simpleapi.CreateWorkspace import readY [as 別名]
def test_with_data_from_other_workspace(self):
wsname = 'LOQ'
x1 = np.array([1.,2.,3.,4.])
y1 = np.array([[1.,2.,3.],[4.,5.,6.]])
e1 = np.sqrt(y1)
loq = CreateWorkspace(DataX=x1, DataY=y1,DataE=e1,NSpec=2,UnitX='Wavelength')
x2 = loq.extractX()
y2 = loq.extractY()
e2 = loq.extractE()
wksp = CreateWorkspace(DataX=x2, DataY=y2,DataE=e2,NSpec=2,UnitX='Wavelength')
self.assertTrue(isinstance(wksp, MatrixWorkspace))
self.assertEquals(wksp.getNumberHistograms(), 2)
for i in [0,1]:
for j in range(len(y2[0])):
self.assertEquals(wksp.readY(i)[j], loq.readY(i)[j])
self.assertEquals(wksp.readE(i)[j], loq.readE(i)[j])
self.assertEquals(wksp.readX(i)[j], loq.readX(i)[j])
# Last X value
self.assertEquals(wksp.readX(i)[len(x2)-1], loq.readX(i)[len(x2)-1])
AnalysisDataService.remove("wksp")
示例3: test_create_with_2D_numpy_array
# 需要導入模塊: from mantid.simpleapi import CreateWorkspace [as 別名]
# 或者: from mantid.simpleapi.CreateWorkspace import readY [as 別名]
def test_create_with_2D_numpy_array(self):
x = np.array([1.,2.,3.,4.])
y = np.array([[1.,2.,3.],[4.,5.,6.]])
e = np.sqrt(y)
wksp = CreateWorkspace(DataX=x, DataY=y,DataE=e,NSpec=2,UnitX='TOF')
self.assertTrue(isinstance(wksp, MatrixWorkspace))
self.assertEquals(wksp.getNumberHistograms(), 2)
for i in [0,1]:
for j in range(len(y[0])):
self.assertEquals(wksp.readY(i)[j], y[i][j])
self.assertEquals(wksp.readE(i)[j], e[i][j])
self.assertEquals(wksp.readX(i)[j], x[j])
# Last X value
self.assertEquals(wksp.readX(i)[len(x)-1], x[len(x)-1])
AnalysisDataService.remove("wksp")
示例4: test_with_data_from_other_workspace
# 需要導入模塊: from mantid.simpleapi import CreateWorkspace [as 別名]
# 或者: from mantid.simpleapi.CreateWorkspace import readY [as 別名]
def test_with_data_from_other_workspace(self):
wsname = 'LOQ'
alg = run_algorithm('Load', Filename='LOQ48127.raw', OutputWorkspace=wsname, SpectrumMax=2, child=True)
loq = alg.getProperty("OutputWorkspace").value
x = loq.extractX()
y = loq.extractY()
e = loq.extractE()
wksp = CreateWorkspace(DataX=x, DataY=y,DataE=e,NSpec=2,UnitX='Wavelength')
self.assertTrue(isinstance(wksp, MatrixWorkspace))
self.assertEquals(wksp.getNumberHistograms(), 2)
for i in [0,1]:
for j in range(len(y[0])):
self.assertEquals(wksp.readY(i)[j], loq.readY(i)[j])
self.assertEquals(wksp.readE(i)[j], loq.readE(i)[j])
self.assertEquals(wksp.readX(i)[j], loq.readX(i)[j])
# Last X value
self.assertEquals(wksp.readX(i)[len(x)-1], loq.readX(i)[len(x)-1])
AnalysisDataService.remove("wksp")