Ticket #5339: Cs2CoCl4_slicing_15_05_2012.py

File Cs2CoCl4_slicing_15_05_2012.py, 6.1 KB (added by Martyn Gigg, 8 years ago)
Line 
1from mantidsimple import*
2
3def load_van(i):
4        LoadRaw(Filename='/babylon/Public/Gosuly/Cs2CoCl4_March_2012/Raw_data/WISH000'+str(i)+'.raw',OutputWorkspace=str(i),LoadLogFiles='0',LoadMonitors='Include')
5        NormaliseToMonitor(InputWorkspace=str(i),OutputWorkspace=str(i),MonitorID='4',IntegrationRangeMin='30000',IntegrationRangeMax='80000')
6        CropWorkspace(InputWorkspace=str(i),OutputWorkspace=str(i),XMin='6000',XMax='99000',StartWorkspaceIndex=5)
7        Rebin(InputWorkspace=str(i),OutputWorkspace=str(i),Params='6000,-0.004,99900')
8        SmoothNeighbours(InputWorkspace=str(i),OutputWorkspace=str(i)+'sn',RadiusUnits='NumberOfPixels',Radius='3',NumberOfNeighbours='25',PreserveEvents='0')
9        SmoothData(InputWorkspace=str(i)+'sn',OutputWorkspace=str(i)+'sn-smooth',NPoints='50')
10
11def load_run(i):
12        LoadRaw(Filename='/archive/ndxwish/Instrument/data/cycle_12_1/WISH000'+str(i)+'.raw',OutputWorkspace=str(i),LoadLogFiles='0',LoadMonitors='Include')
13        NormaliseToMonitor(InputWorkspace=str(i),OutputWorkspace=str(i),MonitorID='4',IntegrationRangeMin='30000',IntegrationRangeMax='80000')
14        CropWorkspace(InputWorkspace=str(i),OutputWorkspace=str(i),XMin='6000',XMax='99000',StartWorkspaceIndex=5)
15        Rebin(InputWorkspace=str(i),OutputWorkspace=str(i),Params='6000,-0.004,99900')
16        SmoothNeighbours(InputWorkspace=str(i),OutputWorkspace=str(i)+'sn',RadiusUnits='NumberOfPixels',Radius='3',NumberOfNeighbours='25',PreserveEvents='0')
17       
18       
19def slicing_unbgr(vanno,runno):
20        #-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
21        # Divide by Vanadium
22        Divide(LHSWorkspace=str(runno)+'sn',RHSWorkspace=str(vanno)+'sn-smooth',OutputWorkspace=str(runno)+'_div_'+str(vanno)+'_sn_smooth')
23        ReplaceSpecialValues(InputWorkspace=str(runno)+'_div_'+str(vanno)+'_sn_smooth',OutputWorkspace=str(runno)+'_div_'+str(vanno)+'_sn_smooth',NaNValue='0',InfinityValue='100000',BigNumberThreshold='99000')
24
25        # Prepare subtracted data for VATES + look at the data - no bgr subtraction
26        LoadIsawUB(InputWorkspace=str(runno)+'_div_'+str(vanno)+'_sn_smooth',Filename=r'/babylon/Public/Gosuly/Cs2CoCl4_March_2012/CsCoCl_rot51pt6.txt')
27        mtd[str(runno)+'_div_'+str(vanno)+'_sn_smooth'].setDistribution(False)
28        ConvertToDiffractionMDWorkspace(InputWorkspace=str(runno)+'_div_'+str(vanno)+'_sn_smooth',OutputWorkspace=str(runno)+'_div_'+str(vanno)+'_sn_smooth'+'_MD_HKL',OutputDimensions='HKL')
29
30        # for runs without bgr subtraction
31        BinToMDHistoWorkspace(InputWorkspace=str(runno)+'_div_'+str(vanno)+'_sn_smooth_MD_HKL',AlignedDim0='H,-0.53,-0.327,1',AlignedDim1='K,-1.525,1.525,120',AlignedDim2='L,2.2,3.7,1',OutputWorkspace='cut1_'+str(runno))
32        #-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
33
34def slicing_bgr(vanno,runno,runno_bgr):
35        #######################################################################################################################################################################
36        # Divide by Vanadium
37        Divide(LHSWorkspace=str(runno)+'sn',RHSWorkspace=str(vanno)+'sn-smooth',OutputWorkspace=str(runno)+'_div_'+str(vanno)+'_sn_smooth')
38        ReplaceSpecialValues(InputWorkspace=str(runno)+'_div_'+str(vanno)+'_sn_smooth',OutputWorkspace=str(runno)+'_div_'+str(vanno)+'_sn_smooth',NaNValue='0',InfinityValue='100000',BigNumberThreshold='99000')
39
40        Divide(LHSWorkspace=str(runno_bgr)+'sn',RHSWorkspace=str(vanno)+'sn-smooth',OutputWorkspace=str(runno_bgr)+'_div_'+str(vanno)+'_sn_smooth')
41        ReplaceSpecialValues(InputWorkspace=str(runno_bgr)+'_div_'+str(vanno)+'_sn_smooth',OutputWorkspace=str(runno_bgr)+'_div_'+str(vanno)+'_sn_smooth',NaNValue='0',InfinityValue='100000',BigNumberThreshold='99000')
42
43        # Subtract Background
44        Minus(LHSWorkspace=str(runno)+'_div_'+str(vanno)+'_sn_smooth',RHSWorkspace=str(runno_bgr)+'_div_'+str(vanno)+'_sn_smooth',OutputWorkspace=str(runno)+'minus'+str(runno_bgr)+'_smooth')
45
46        # Prepare subtracted data for VATES + look at the data - bgr subtraction
47        LoadIsawUB(InputWorkspace=str(runno)+'minus'+str(runno_bgr)+'_smooth',Filename=r'/babylon/Public/Gosuly/Cs2CoCl4_March_2012/CsCoCl_rot51pt6.txt')
48        mtd[str(runno)+'minus'+str(runno_bgr)+'_smooth'].setDistribution(False)
49        ConvertToDiffractionMDWorkspace(InputWorkspace=str(runno)+'minus'+str(runno_bgr)+'_smooth',OutputWorkspace=str(runno)+'minus'+str(runno_bgr)+'_smooth'+'_MD_HKL',OutputDimensions='HKL')
50
51        #BinToMDHistoWorkspace(InputWorkspace=str(runno)+'minus'+str(runno_bgr)+'_smooth_MD_HKL',AlignedDimX='H,-2.0,2.0,120',AlignedDimY='K,-1.525,1.525,120',AlignedDimZ='L,0.025,6.025,120',OutputWorkspace='test_rebin_'+str(runno)+'minus'+str(runno_bgr))
52        # for runs with bgr subtraction
53        BinToMDHistoWorkspace(InputWorkspace=str(runno)+'minus'+str(runno_bgr)+'_smooth_MD_HKL',AlignedDim0='H,-0.53,-0.327,1',AlignedDim1='K,-1.525,1.525,120',AlignedDim2='L,2.06,4.45,1',OutputWorkspace='cut_'+str(runno)+'minus'+str(runno_bgr))
54
55        # Integrate over K to get area
56        BinToMDHistoWorkspace(InputWorkspace=str(runno)+'minus'+str(runno_bgr)+'_smooth_MD_HKL',AlignedDim0='H,-0.53,-0.327,1',AlignedDim1='K,0.25,0.75,1',AlignedDim2='L,2.06,4.45,1',OutputWorkspace='cut_'+str(runno)+'minus'+str(runno_bgr)+'area')
57        ########################################################################################################################################################################
58
59############   
60vanno = 18589
61load_van(vanno)
62
63runno_bgr = 21103
64load_run(runno_bgr)
65
66# unsubtracted background
67for runno in range(21139,21146):
68        load_run(runno)
69        slicing_unbgr(vanno,runno)
70
71# subtract background
72for runno in range('','',''):
73        load_run(runno)
74        load_run(runno_bgr)
75        slicing_bgr(vanno,runno)
76
77
78
79
80
81