当前位置: 首页>>代码示例>>Python>>正文


Python CreateWorkspace.readE方法代码示例

本文整理汇总了Python中mantid.simpleapi.CreateWorkspace.readE方法的典型用法代码示例。如果您正苦于以下问题:Python CreateWorkspace.readE方法的具体用法?Python CreateWorkspace.readE怎么用?Python CreateWorkspace.readE使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mantid.simpleapi.CreateWorkspace的用法示例。


在下文中一共展示了CreateWorkspace.readE方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_with_1D_numpy_array

# 需要导入模块: from mantid.simpleapi import CreateWorkspace [as 别名]
# 或者: from mantid.simpleapi.CreateWorkspace import readE [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")
开发者ID:DanNixon,项目名称:mantid,代码行数:22,代码来源:CreateWorkspaceTest.py

示例2: test_with_data_from_other_workspace

# 需要导入模块: from mantid.simpleapi import CreateWorkspace [as 别名]
# 或者: from mantid.simpleapi.CreateWorkspace import readE [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")
开发者ID:DanNixon,项目名称:mantid,代码行数:26,代码来源:CreateWorkspaceTest.py

示例3: test_create_with_2D_numpy_array

# 需要导入模块: from mantid.simpleapi import CreateWorkspace [as 别名]
# 或者: from mantid.simpleapi.CreateWorkspace import readE [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")
开发者ID:DanNixon,项目名称:mantid,代码行数:20,代码来源:CreateWorkspaceTest.py

示例4: test_with_data_from_other_workspace

# 需要导入模块: from mantid.simpleapi import CreateWorkspace [as 别名]
# 或者: from mantid.simpleapi.CreateWorkspace import readE [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")
开发者ID:trnielsen,项目名称:mantid,代码行数:24,代码来源:CreateWorkspaceTest.py


注:本文中的mantid.simpleapi.CreateWorkspace.readE方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。