当前位置: 首页>>代码示例>>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;未经允许,请勿转载。