Ticket #7548: Sr122_individual_components_plots.py

File Sr122_individual_components_plots.py, 9.6 KB (added by Martyn Gigg, 7 years ago)
Line 
1from mantid.simpleapi import *
2import math
3import sys
4
5#=================== helper functions ===============================
6
7def create_cuboid_xml(xlength,ylength,zlength):
8    xml = """<cuboid id="sample0">
9<left-front-bottom-point x="%(xpt)f" y="-%(ypt)f" z="-%(zpt)f"  />
10<left-front-top-point  x="%(xpt)f" y="-%(ypt)f" z="%(zpt)f"  />
11<left-back-bottom-point  x="-%(xpt)f" y="-%(ypt)f" z="-%(zpt)f"  />
12<right-front-bottom-point  x="%(xpt)f" y="%(ypt)f" z="-%(zpt)f"  />
13</cuboid>
14<algebra val="sample0" />
15"""
16    return xml % {"xpt": xlength/2.0,"ypt":ylength/2.0,"zpt":zlength/2.0}
17 
18def plot_slice(in_ws, out_ws):
19        BinMD(InputWorkspace=in_ws, OutputWorkspace=out_ws,
20                AlignedDim0='[H,0,0], -12.000000, 9.000000, 100',
21                AlignedDim1='[0,K,0], -6.000000, 7.000000, 100',
22                AlignedDim2='[0,0,L], 0.000000, 6.000000, 1',
23                AlignedDim3='DeltaE, 100.000000, 150.000000, 1')
24        plotSlice(out_ws,colormax=180,normalization=0)
25       
26#===============================
27
28#Load  the equivalent SQW files:
29data_dir = '/data/Software/VATES_testing/Sr122_tests/'
30#LoadSQW(Filename=data_dir + 'sr122_minimal_mantid_check_mantidpar.sqw',OutputWorkspace='sr122_tobyfit_mt')
31LoadSQW(Filename=data_dir + 'sr122_tobyfit_moderator.sqw',OutputWorkspace='sr122_tobyfit_moderator')
32LoadSQW(Filename=data_dir + 'sr122_tobyfit_aperture.sqw',OutputWorkspace='sr122_tobyfit_aperture')
33LoadSQW(Filename=data_dir + 'sr122_tobyfit_chopper.sqw',OutputWorkspace='sr122_tobyfit_chopper')
34LoadSQW(Filename=data_dir + 'sr122_tobyfit_jitter.sqw',OutputWorkspace='sr122_tobyfit_jitter')
35LoadSQW(Filename=data_dir + 'sr122_tobyfit_volume.sqw',OutputWorkspace='sr122_tobyfit_volume')
36LoadSQW(Filename=data_dir + 'sr122_tobyfit_area.sqw',OutputWorkspace='sr122_tobyfit_area')
37LoadSQW(Filename=data_dir + 'sr122_tobyfit_depth.sqw',OutputWorkspace='sr122_tobyfit_depth')
38LoadSQW(Filename=data_dir + 'sr122_tobyfit_time.sqw',OutputWorkspace='sr122_tobyfit_time')
39LoadSQW(Filename=data_dir + 'sr122_tobyfit_mosaic.sqw',OutputWorkspace='sr122_tobyfit_mosaic')
40LoadSQW(Filename=data_dir + 'sr122_tobyfit_all.sqw',OutputWorkspace='sr122_tobyfit_all')
41
42
43#Want to work through the sqw/tobyfit and mantid simulations to compare for each resolution component:
44               
45#BinMD(InputWorkspace="sr122_tobyfit_mt", OutputWorkspace="sr122_tobyfit_mt_cut",
46#               AlignedDim0=r'qx, 1, 1.3, 1',
47#               AlignedDim1=r'qy, -1, 1, 41',
48#               AlignedDim2=r'qz, -100, 100, 1',
49#               AlignedDim3='en, 65, 75, 1')           
50
51BinMD(InputWorkspace="sr122_tobyfit_moderator", OutputWorkspace="sr122_tobyfit_moderator_cut",
52                AlignedDim0=r'qx, 1, 1.3, 1',
53                AlignedDim1=r'qy, -1, 1, 41',
54                AlignedDim2=r'qz, -100, 100, 1',
55                AlignedDim3='en, 65, 75, 1')           
56
57BinMD(InputWorkspace="sr122_tobyfit_aperture", OutputWorkspace="sr122_tobyfit_aperture_cut",
58                AlignedDim0=r'qx, 1, 1.3, 1',
59                AlignedDim1=r'qy, -1, 1, 41',
60                AlignedDim2=r'qz, -100, 100, 1',
61                AlignedDim3='en, 65, 75, 1')           
62               
63BinMD(InputWorkspace="sr122_tobyfit_chopper", OutputWorkspace="sr122_tobyfit_chopper_cut",
64                AlignedDim0=r'qx, 1, 1.3, 1',
65                AlignedDim1=r'qy, -1, 1, 41',
66                AlignedDim2=r'qz, -100, 100, 1',
67                AlignedDim3='en, 65, 75, 1')           
68               
69BinMD(InputWorkspace="sr122_tobyfit_jitter", OutputWorkspace="sr122_tobyfit_jitter_cut",
70                AlignedDim0=r'qx, 1, 1.3, 1',
71                AlignedDim1=r'qy, -1, 1, 41',
72                AlignedDim2=r'qz, -100, 100, 1',
73                AlignedDim3='en, 65, 75, 1')           
74               
75BinMD(InputWorkspace="sr122_tobyfit_volume", OutputWorkspace="sr122_tobyfit_volume_cut",
76                AlignedDim0=r'qx, 1, 1.3, 1',
77                AlignedDim1=r'qy, -1, 1, 41',
78                AlignedDim2=r'qz, -100, 100, 1',
79                AlignedDim3='en, 65, 75, 1')           
80               
81BinMD(InputWorkspace="sr122_tobyfit_area", OutputWorkspace="sr122_tobyfit_area_cut",
82                AlignedDim0=r'qx, 1, 1.3, 1',
83                AlignedDim1=r'qy, -1, 1, 41',
84                AlignedDim2=r'qz, -100, 100, 1',
85                AlignedDim3='en, 65, 75, 1')           
86               
87BinMD(InputWorkspace="sr122_tobyfit_depth", OutputWorkspace="sr122_tobyfit_depth_cut",
88                AlignedDim0=r'qx, 1, 1.3, 1',
89                AlignedDim1=r'qy, -1, 1, 41',
90                AlignedDim2=r'qz, -100, 100, 1',
91                AlignedDim3='en, 65, 75, 1')           
92               
93BinMD(InputWorkspace="sr122_tobyfit_time", OutputWorkspace="sr122_tobyfit_time_cut",
94                AlignedDim0=r'qx, 1, 1.3, 1',
95                AlignedDim1=r'qy, -1, 1, 41',
96                AlignedDim2=r'qz, -100, 100, 1',
97                AlignedDim3='en, 65, 75, 1')           
98               
99BinMD(InputWorkspace="sr122_tobyfit_mosaic", OutputWorkspace="sr122_tobyfit_mosaic_cut",
100                AlignedDim0=r'qx, 1, 1.3, 1',
101                AlignedDim1=r'qy, -1, 1, 41',
102                AlignedDim2=r'qz, -100, 100, 1',
103                AlignedDim3='en, 65, 75, 1')   
104
105BinMD(InputWorkspace="sr122_tobyfit_all", OutputWorkspace="sr122_tobyfit_all_cut",
106                AlignedDim0=r'qx, 1, 1.3, 1',
107                AlignedDim1=r'qy, -1, 1, 41',
108                AlignedDim2=r'qz, -100, 100, 1',
109                AlignedDim3='en, 65, 75, 1')   
110
111###############
112#Mantid equivalents:
113
114BinMD(InputWorkspace="simulated_mod", OutputWorkspace="simulated_mod_cut",
115                AlignedDim0='[H,0,0], 1, 1.3, 1',
116                AlignedDim1='[0,K,0], -1, 1, 41',
117                AlignedDim2='[0,0,L], -100, 100, 1',
118                AlignedDim3='DeltaE, 65, 75.000000, 1')
119
120BinMD(InputWorkspace="simulated_aperture", OutputWorkspace="simulated_aperture_cut",
121                AlignedDim0='[H,0,0], 1, 1.3, 1',
122                AlignedDim1='[0,K,0], -1, 1, 41',
123                AlignedDim2='[0,0,L], -100, 100, 1',
124                AlignedDim3='DeltaE, 65, 75.000000, 1')
125
126BinMD(InputWorkspace="simulated_chopper", OutputWorkspace="simulated_chopper_cut",
127                AlignedDim0='[H,0,0], 1, 1.3, 1',
128                AlignedDim1='[0,K,0], -1, 1, 41',
129                AlignedDim2='[0,0,L], -100, 100, 1',
130                AlignedDim3='DeltaE, 65, 75.000000, 1')
131
132BinMD(InputWorkspace="simulated_jitter", OutputWorkspace="simulated_jitter_cut",
133                AlignedDim0='[H,0,0], 1, 1.3, 1',
134                AlignedDim1='[0,K,0], -1, 1, 41',
135                AlignedDim2='[0,0,L], -100, 100, 1',
136                AlignedDim3='DeltaE, 65, 75.000000, 1')
137
138BinMD(InputWorkspace="simulated_vol", OutputWorkspace="simulated_vol_cut",
139                AlignedDim0='[H,0,0], 1, 1.3, 1',
140                AlignedDim1='[0,K,0], -1, 1, 41',
141                AlignedDim2='[0,0,L], -100, 100, 1',
142                AlignedDim3='DeltaE, 65, 75.000000, 1')
143
144BinMD(InputWorkspace="simulated_area", OutputWorkspace="simulated_area_cut",
145                AlignedDim0='[H,0,0], 1, 1.3, 1',
146                AlignedDim1='[0,K,0], -1, 1, 41',
147                AlignedDim2='[0,0,L], -100, 100, 1',
148                AlignedDim3='DeltaE, 65, 75.000000, 1')
149
150BinMD(InputWorkspace="simulated_depth", OutputWorkspace="simulated_depth_cut",
151                AlignedDim0='[H,0,0], 1, 1.3, 1',
152                AlignedDim1='[0,K,0], -1, 1, 41',
153                AlignedDim2='[0,0,L], -100, 100, 1',
154                AlignedDim3='DeltaE, 65, 75.000000, 1')
155
156BinMD(InputWorkspace="simulated_time", OutputWorkspace="simulated_time_cut",
157                AlignedDim0='[H,0,0], 1, 1.3, 1',
158                AlignedDim1='[0,K,0], -1, 1, 41',
159                AlignedDim2='[0,0,L], -100, 100, 1',
160                AlignedDim3='DeltaE, 65, 75.000000, 1')
161
162BinMD(InputWorkspace="simulated_mosaic", OutputWorkspace="simulated_mosaic_cut",
163                AlignedDim0='[H,0,0], 1, 1.3, 1',
164                AlignedDim1='[0,K,0], -1, 1, 41',
165                AlignedDim2='[0,0,L], -100, 100, 1',
166                AlignedDim3='DeltaE, 65, 75.000000, 1')
167
168#####
169#Plot comparisons
170
171all_table=QueryMDWorkspace('sr122_tobyfit_all_cut')
172all_sim=ConvertTableToMatrixWorkspace('all_table',ColumnX='qy/A^-1',ColumnY='Signal/none')
173
174mod_table=QueryMDWorkspace('sr122_tobyfit_moderator_cut')
175mod_sim=ConvertTableToMatrixWorkspace('mod_table',ColumnX='qy/A^-1',ColumnY='Signal/none')
176
177chop_table=QueryMDWorkspace('sr122_tobyfit_chopper_cut')
178chop_sim=ConvertTableToMatrixWorkspace('chop_table',ColumnX='qy/A^-1',ColumnY='Signal/none')
179
180aperture_table=QueryMDWorkspace('sr122_tobyfit_aperture_cut')
181aperture_sim=ConvertTableToMatrixWorkspace('aperture_table',ColumnX='qy/A^-1',ColumnY='Signal/none')
182
183jitter_table=QueryMDWorkspace('sr122_tobyfit_jitter_cut')
184jitter_sim=ConvertTableToMatrixWorkspace('jitter_table',ColumnX='qy/A^-1',ColumnY='Signal/none')
185
186volume_table=QueryMDWorkspace('sr122_tobyfit_volume_cut')
187volume_sim=ConvertTableToMatrixWorkspace('volume_table',ColumnX='qy/A^-1',ColumnY='Signal/none')
188
189area_table=QueryMDWorkspace('sr122_tobyfit_area_cut')
190area_sim=ConvertTableToMatrixWorkspace('area_table',ColumnX='qy/A^-1',ColumnY='Signal/none')
191
192depth_table=QueryMDWorkspace('sr122_tobyfit_depth_cut')
193depth_sim=ConvertTableToMatrixWorkspace('depth_table',ColumnX='qy/A^-1',ColumnY='Signal/none')
194
195time_table=QueryMDWorkspace('sr122_tobyfit_time_cut')
196time_sim=ConvertTableToMatrixWorkspace('time_table',ColumnX='qy/A^-1',ColumnY='Signal/none')
197
198mosaic_table=QueryMDWorkspace('sr122_tobyfit_mosaic_cut')
199mosaic_sim=ConvertTableToMatrixWorkspace('mosaic_table',ColumnX='qy/A^-1',ColumnY='Signal/none')
200
201##########
202
203mt_mod_table=QueryMDWorkspace('simulated_mod_cut')
204mt_mod_sim=ConvertTableToMatrixWorkspace('mt_mod_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none')
205
206mt_chop_table=QueryMDWorkspace('simulated_chopper_cut')
207mt_chop_sim=ConvertTableToMatrixWorkspace('mt_chop_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none')
208
209mt_ap_table=QueryMDWorkspace('simulated_aperture_cut')
210mt_ap_sim=ConvertTableToMatrixWorkspace('mt_ap_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none')
211
212mt_vol_table=QueryMDWorkspace('simulated_vol_cut')
213mt_vol_sim=ConvertTableToMatrixWorkspace('mt_vol_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none')
214
215mt_jitter_table=QueryMDWorkspace('simulated_jitter_cut')
216mt_jitter_sim=ConvertTableToMatrixWorkspace('mt_jitter_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none')
217
218mt_area_table=QueryMDWorkspace('simulated_area_cut')
219mt_area_sim=ConvertTableToMatrixWorkspace('mt_area_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none')
220
221mt_depth_table=QueryMDWorkspace('simulated_depth_cut')
222mt_depth_sim=ConvertTableToMatrixWorkspace('mt_depth_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none')
223
224mt_time_table=QueryMDWorkspace('simulated_time_cut')
225mt_time_sim=ConvertTableToMatrixWorkspace('mt_time_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none')
226
227mt_mosaic_table=QueryMDWorkspace('simulated_mosaic_cut')
228mt_mosaic_sim=ConvertTableToMatrixWorkspace('mt_mosaic_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none')
229