本文整理匯總了Python中Direct.DirectEnergyConversion.DirectEnergyConversion.multirep_tof_specta_list方法的典型用法代碼示例。如果您正苦於以下問題:Python DirectEnergyConversion.multirep_tof_specta_list方法的具體用法?Python DirectEnergyConversion.multirep_tof_specta_list怎麽用?Python DirectEnergyConversion.multirep_tof_specta_list使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Direct.DirectEnergyConversion.DirectEnergyConversion
的用法示例。
在下文中一共展示了DirectEnergyConversion.multirep_tof_specta_list方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_multirep_mode
# 需要導入模塊: from Direct.DirectEnergyConversion import DirectEnergyConversion [as 別名]
# 或者: from Direct.DirectEnergyConversion.DirectEnergyConversion import multirep_tof_specta_list [as 別名]
def test_multirep_mode(self):
# create test workspace
run_monitors=CreateSampleWorkspace(Function='Multiple Peaks', NumBanks=4, BankPixelWidth=1,\
NumEvents=100000,XUnit='Energy', XMin=3, XMax=200, BinWidth=0.1)
LoadInstrument(run_monitors,InstrumentName='MARI', RewriteSpectraMap=True)
ConvertUnits(InputWorkspace='run_monitors', OutputWorkspace='run_monitors', Target='TOF')
run_monitors = mtd['run_monitors']
tof = run_monitors.dataX(3)
tMin = tof[0]
tMax = tof[-1]
run = CreateSampleWorkspace( Function='Multiple Peaks',WorkspaceType='Event',NumBanks=8, BankPixelWidth=1,\
NumEvents=100000, XUnit='TOF',xMin=tMin,xMax=tMax)
LoadInstrument(run,InstrumentName='MARI', RewriteSpectraMap=True)
MoveInstrumentComponent(Workspace='run', ComponentName='Detector', DetectorID=1102,Z=1)
# MoveInstrumentComponent(Workspace='run', ComponentName='Detector', DetectorID=1103,Z=4)
# MoveInstrumentComponent(Workspace='run', ComponentName='Detector', DetectorID=1104,Z=5)
# do second
run2 = CloneWorkspace(run)
run2_monitors = CloneWorkspace(run_monitors)
wb_ws = Rebin(run,Params=[tMin,1,tMax],PreserveEvents=False)
# Run multirep
tReducer = DirectEnergyConversion(run.getInstrument())
tReducer.prop_man.run_diagnostics=True
tReducer.hard_mask_file=None
tReducer.map_file=None
tReducer.save_format=None
tReducer.multirep_tof_specta_list = [4,5]
result = tReducer.convert_to_energy(wb_ws,run,[67.,122.],[-2,0.02,0.8])
self.assertEqual(len(result),2)
ws1=result[0]
self.assertEqual(ws1.getAxis(0).getUnit().unitID(),'DeltaE')
x = ws1.readX(0)
self.assertAlmostEqual(x[0],-2*67.)
self.assertAlmostEqual(x[-1],0.8*67.)
ws2=result[1]
self.assertEqual(ws2.getAxis(0).getUnit().unitID(),'DeltaE')
x = ws2.readX(0)
self.assertAlmostEqual(x[0],-2*122.)
self.assertAlmostEqual(x[-1],0.8*122.)
# test another ws
# rename samples from previous workspace to avoid deleting them on current run
for ind,item in enumerate(result):
result[ind]=RenameWorkspace(item,OutputWorkspace='SampleRez#'+str(ind))
#
result2 = tReducer.convert_to_energy(None,run2,[67.,122.],[-2,0.02,0.8])
rez = CompareWorkspaces(result[0],result2[0])
self.assertTrue(rez[0])
rez = CompareWorkspaces(result[1],result2[1])
self.assertTrue(rez[0])