當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。