當前位置: 首頁>>代碼示例>>Python>>正文


Python DirectEnergyConversion.get_ei方法代碼示例

本文整理匯總了Python中Direct.DirectEnergyConversion.DirectEnergyConversion.get_ei方法的典型用法代碼示例。如果您正苦於以下問題:Python DirectEnergyConversion.get_ei方法的具體用法?Python DirectEnergyConversion.get_ei怎麽用?Python DirectEnergyConversion.get_ei使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Direct.DirectEnergyConversion.DirectEnergyConversion的用法示例。


在下文中一共展示了DirectEnergyConversion.get_ei方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_sum_monitors

# 需要導入模塊: from Direct.DirectEnergyConversion import DirectEnergyConversion [as 別名]
# 或者: from Direct.DirectEnergyConversion.DirectEnergyConversion import get_ei [as 別名]
    def test_sum_monitors(self):
        # create test workspace
        monitor_ws=CreateSampleWorkspace(Function='Multiple Peaks', NumBanks=6, BankPixelWidth=1,\
                                            NumEvents=100000, XUnit='Energy', XMin=3, XMax=200, BinWidth=0.1)
        ConvertUnits(InputWorkspace=monitor_ws, OutputWorkspace='monitor_ws', Target='TOF')

        # Rebin to "formally" make common bin boundaries as it is not considered as such
        #any more after converting units (Is this a bug?)
        xx = monitor_ws.readX(0)
        x_min = min(xx[0],xx[-1])
        x_max= max(xx[0],xx[-1])
        x_step = (x_max-x_min)/(len(xx)-1)
        monitor_ws = Rebin(monitor_ws,Params=[x_min,x_step,x_max])
        monitor_ws = mtd['monitor_ws']
        #
        # keep this workspace for second test below -- clone and give
        # special name for RunDescriptor to recognize as monitor workspace for
        # fake data workspace we will provide.
        _TMPmonitor_ws_monitors = CloneWorkspace(monitor_ws)

        # Estimate energy from two monitors
        ei,mon1_peak,mon1_index,tzero = \
            GetEi(InputWorkspace=monitor_ws, Monitor1Spec=1,Monitor2Spec=4,
                  EnergyEstimate=62.2,FixEi=False)
        self.assertAlmostEqual(ei,62.1449,3)

        # Provide instrument parameter, necessary to define
        # DirectEnergyConversion class properly
        SetInstrumentParameter(monitor_ws,ParameterName='fix_ei',ParameterType='Number',Value='0')
        SetInstrumentParameter(monitor_ws,DetectorList=[1,2,3,6],ParameterName='DelayTime',\
                               ParameterType='Number',Value='0.5')
        SetInstrumentParameter(monitor_ws,ParameterName='mon2_norm_spec',\
                               ParameterType='Number',Value='1')

        # initiate test reducer
        tReducer = DirectEnergyConversion(monitor_ws.getInstrument())
        tReducer.prop_man.ei_mon_spectra= ([1,2,3],6)
        tReducer.prop_man.normalise_method = 'current'
        tReducer.prop_man.mon2_norm_spec = 2
        ei_mon_spectra  = tReducer.prop_man.ei_mon_spectra
        ei_mon_spectra,monitor_ws  = tReducer.sum_monitors_spectra(monitor_ws,ei_mon_spectra)
        #
        # Check GetEi with summed monitors. Try to run separately.
        ei1,mon1_peak,mon1_index,tzero = \
            GetEi(InputWorkspace=monitor_ws, Monitor1Spec=1,Monitor2Spec=6,
                  EnergyEstimate=62.2,FixEi=False)
        self.assertAlmostEqual(ei1,ei,2)

        # Second test Check get_ei as part of the reduction
        tReducer.prop_man.ei_mon_spectra= ([1,2,3],[4,5,6])
        tReducer.prop_man.fix_ei = False
        # DataWorkspace == monitor_ws data workspace is not used anyway. The only thing we
        # use it for is to retrieve monitor workspace from Mantid using its name
        ei2,mon1_peak2=tReducer.get_ei(monitor_ws,62.2)
        self.assertAlmostEqual(ei2,64.95,2)

        ei2b,mon1_peak2=tReducer.get_ei(monitor_ws,62.2)
        self.assertAlmostEqual(ei2b,64.95,2)
開發者ID:DanNixon,項目名稱:mantid,代碼行數:60,代碼來源:DirectEnergyConversionTest.py


注:本文中的Direct.DirectEnergyConversion.DirectEnergyConversion.get_ei方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。