本文整理汇总了Python中Direct.DirectEnergyConversion.DirectEnergyConversion.get_TOF_for_energies方法的典型用法代码示例。如果您正苦于以下问题:Python DirectEnergyConversion.get_TOF_for_energies方法的具体用法?Python DirectEnergyConversion.get_TOF_for_energies怎么用?Python DirectEnergyConversion.get_TOF_for_energies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Direct.DirectEnergyConversion.DirectEnergyConversion
的用法示例。
在下文中一共展示了DirectEnergyConversion.get_TOF_for_energies方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_energy_to_TOF_range
# 需要导入模块: from Direct.DirectEnergyConversion import DirectEnergyConversion [as 别名]
# 或者: from Direct.DirectEnergyConversion.DirectEnergyConversion import get_TOF_for_energies [as 别名]
def test_energy_to_TOF_range(self):
ws = Load(Filename='MAR11001.raw',LoadMonitors='Include')
en_range = [0.8*13,13,1.2*13]
detIDs=[1,2,3,10]
red = DirectEnergyConversion()
TRange = red.get_TOF_for_energies(ws,en_range,detIDs)
for ind,detID in enumerate(detIDs):
tof = TRange[ind]
y = [1]*(len(tof)-1)
ind = ws.getIndexFromSpectrumNumber(detID)
ExtractSingleSpectrum(InputWorkspace=ws, OutputWorkspace='_ws_template', WorkspaceIndex=ind)
CreateWorkspace(OutputWorkspace='TOF_WS',NSpec = 1,DataX=tof,DataY=y,UnitX='TOF',ParentWorkspace='_ws_template')
EnWs=ConvertUnits(InputWorkspace='TOF_WS',Target='Energy',EMode='Elastic')
eni = EnWs.dataX(0)
for samp,rez in zip(eni,en_range): self.assertAlmostEqual(samp,rez)
# Now Test shifted:
ei,mon1_peak,mon1_index,tzero = GetEi(InputWorkspace=ws, Monitor1Spec=int(2), Monitor2Spec=int(3),EnergyEstimate=13)
ScaleX(InputWorkspace='ws',OutputWorkspace='ws',Operation="Add",Factor=-mon1_peak,InstrumentParameter="DelayTime",Combine=True)
ws = mtd['ws']
mon1_det = ws.getDetector(1)
mon1_pos = mon1_det.getPos()
src_name = ws.getInstrument().getSource().getName()
MoveInstrumentComponent(Workspace='ws',ComponentName= src_name, X=mon1_pos.getX(), Y=mon1_pos.getY(), Z=mon1_pos.getZ(), RelativePosition=False)
# Does not work for monitor 2 as it has been moved to mon2 position and there all tof =0
detIDs=[1,3,10]
TRange1 = red.get_TOF_for_energies(ws,en_range,detIDs)
for ind,detID in enumerate(detIDs):
tof = TRange1[ind]
y = [1]*(len(tof)-1)
ind = ws.getIndexFromSpectrumNumber(detID)
ExtractSingleSpectrum(InputWorkspace=ws, OutputWorkspace='_ws_template', WorkspaceIndex=ind)
CreateWorkspace(OutputWorkspace='TOF_WS',NSpec = 1,DataX=tof,DataY=y,UnitX='TOF',ParentWorkspace='_ws_template')
EnWs=ConvertUnits(InputWorkspace='TOF_WS',Target='Energy',EMode='Elastic')
eni = EnWs.dataX(0)
for samp,rez in zip(eni,en_range): self.assertAlmostEqual(samp,rez)