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


Python DirectEnergyConversion.find_tof_range_for_multirep方法代码示例

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


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

示例1: test_tof_range

# 需要导入模块: from Direct.DirectEnergyConversion import DirectEnergyConversion [as 别名]
# 或者: from Direct.DirectEnergyConversion.DirectEnergyConversion import find_tof_range_for_multirep [as 别名]
    def test_tof_range(self):

        run = CreateSampleWorkspace(
            Function="Multiple Peaks",
            NumBanks=6,
            BankPixelWidth=1,
            NumEvents=10,
            XUnit="Energy",
            XMin=5,
            XMax=75,
            BinWidth=0.2,
        )
        LoadInstrument(run, InstrumentName="MARI", RewriteSpectraMap=True)

        red = DirectEnergyConversion(run.getInstrument())

        red.prop_man.incident_energy = 26.2
        red.prop_man.energy_bins = [-20, 0.1, 20]
        red.prop_man.multirep_tof_specta_list = [4, 5, 6]
        MoveInstrumentComponent(Workspace="run", ComponentName="Detector", DetectorID=1102, Z=3)
        MoveInstrumentComponent(Workspace="run", ComponentName="Detector", DetectorID=1103, Z=6)

        run_tof = ConvertUnits(run, Target="TOF", EMode="Elastic")

        tof_range = red.find_tof_range_for_multirep(run_tof)

        self.assertEqual(len(tof_range), 3)

        x = run_tof.readX(3)
        dx = abs(x[1:] - x[:-1])
        xMin = min(x)
        dt = min(dx)
        x = run_tof.readX(5)
        xMax = max(x)

        self.assertTrue(tof_range[0] > xMin)
        # self.assertAlmostEqual(tof_range[1],dt)
        self.assertTrue(tof_range[2] < xMax)

        # check another working mode
        red.prop_man.multirep_tof_specta_list = 4
        red.prop_man.incident_energy = 47.505
        red.prop_man.energy_bins = [-20, 0.1, 45]

        tof_range1 = red.find_tof_range_for_multirep(run_tof)

        self.assertTrue(tof_range1[0] > xMin)
        self.assertTrue(tof_range1[2] < xMax)

        self.assertTrue(tof_range1[2] < tof_range[2])
        self.assertTrue(tof_range1[0] < tof_range[0])
        self.assertTrue(tof_range1[1] < tof_range[1])
开发者ID:spaceyatom,项目名称:mantid,代码行数:54,代码来源:DirectEnergyConversionTest.py


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