本文整理匯總了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)