| 1 | from mantid.simpleapi import * |
|---|
| 2 | import math |
|---|
| 3 | import sys |
|---|
| 4 | |
|---|
| 5 | #=================== helper functions =============================== |
|---|
| 6 | |
|---|
| 7 | def 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 | |
|---|
| 18 | def 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: |
|---|
| 29 | data_dir = '/data/Software/VATES_testing/Sr122_tests/' |
|---|
| 30 | #LoadSQW(Filename=data_dir + 'sr122_minimal_mantid_check_mantidpar.sqw',OutputWorkspace='sr122_tobyfit_mt') |
|---|
| 31 | LoadSQW(Filename=data_dir + 'sr122_tobyfit_moderator.sqw',OutputWorkspace='sr122_tobyfit_moderator') |
|---|
| 32 | LoadSQW(Filename=data_dir + 'sr122_tobyfit_aperture.sqw',OutputWorkspace='sr122_tobyfit_aperture') |
|---|
| 33 | LoadSQW(Filename=data_dir + 'sr122_tobyfit_chopper.sqw',OutputWorkspace='sr122_tobyfit_chopper') |
|---|
| 34 | LoadSQW(Filename=data_dir + 'sr122_tobyfit_jitter.sqw',OutputWorkspace='sr122_tobyfit_jitter') |
|---|
| 35 | LoadSQW(Filename=data_dir + 'sr122_tobyfit_volume.sqw',OutputWorkspace='sr122_tobyfit_volume') |
|---|
| 36 | LoadSQW(Filename=data_dir + 'sr122_tobyfit_area.sqw',OutputWorkspace='sr122_tobyfit_area') |
|---|
| 37 | LoadSQW(Filename=data_dir + 'sr122_tobyfit_depth.sqw',OutputWorkspace='sr122_tobyfit_depth') |
|---|
| 38 | LoadSQW(Filename=data_dir + 'sr122_tobyfit_time.sqw',OutputWorkspace='sr122_tobyfit_time') |
|---|
| 39 | LoadSQW(Filename=data_dir + 'sr122_tobyfit_mosaic.sqw',OutputWorkspace='sr122_tobyfit_mosaic') |
|---|
| 40 | LoadSQW(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 | |
|---|
| 51 | BinMD(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 | |
|---|
| 57 | BinMD(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 | |
|---|
| 63 | BinMD(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 | |
|---|
| 69 | BinMD(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 | |
|---|
| 75 | BinMD(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 | |
|---|
| 81 | BinMD(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 | |
|---|
| 87 | BinMD(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 | |
|---|
| 93 | BinMD(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 | |
|---|
| 99 | BinMD(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 | |
|---|
| 105 | BinMD(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 | |
|---|
| 114 | BinMD(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 | |
|---|
| 120 | BinMD(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 | |
|---|
| 126 | BinMD(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 | |
|---|
| 132 | BinMD(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 | |
|---|
| 138 | BinMD(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 | |
|---|
| 144 | BinMD(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 | |
|---|
| 150 | BinMD(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 | |
|---|
| 156 | BinMD(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 | |
|---|
| 162 | BinMD(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 | |
|---|
| 171 | all_table=QueryMDWorkspace('sr122_tobyfit_all_cut') |
|---|
| 172 | all_sim=ConvertTableToMatrixWorkspace('all_table',ColumnX='qy/A^-1',ColumnY='Signal/none') |
|---|
| 173 | |
|---|
| 174 | mod_table=QueryMDWorkspace('sr122_tobyfit_moderator_cut') |
|---|
| 175 | mod_sim=ConvertTableToMatrixWorkspace('mod_table',ColumnX='qy/A^-1',ColumnY='Signal/none') |
|---|
| 176 | |
|---|
| 177 | chop_table=QueryMDWorkspace('sr122_tobyfit_chopper_cut') |
|---|
| 178 | chop_sim=ConvertTableToMatrixWorkspace('chop_table',ColumnX='qy/A^-1',ColumnY='Signal/none') |
|---|
| 179 | |
|---|
| 180 | aperture_table=QueryMDWorkspace('sr122_tobyfit_aperture_cut') |
|---|
| 181 | aperture_sim=ConvertTableToMatrixWorkspace('aperture_table',ColumnX='qy/A^-1',ColumnY='Signal/none') |
|---|
| 182 | |
|---|
| 183 | jitter_table=QueryMDWorkspace('sr122_tobyfit_jitter_cut') |
|---|
| 184 | jitter_sim=ConvertTableToMatrixWorkspace('jitter_table',ColumnX='qy/A^-1',ColumnY='Signal/none') |
|---|
| 185 | |
|---|
| 186 | volume_table=QueryMDWorkspace('sr122_tobyfit_volume_cut') |
|---|
| 187 | volume_sim=ConvertTableToMatrixWorkspace('volume_table',ColumnX='qy/A^-1',ColumnY='Signal/none') |
|---|
| 188 | |
|---|
| 189 | area_table=QueryMDWorkspace('sr122_tobyfit_area_cut') |
|---|
| 190 | area_sim=ConvertTableToMatrixWorkspace('area_table',ColumnX='qy/A^-1',ColumnY='Signal/none') |
|---|
| 191 | |
|---|
| 192 | depth_table=QueryMDWorkspace('sr122_tobyfit_depth_cut') |
|---|
| 193 | depth_sim=ConvertTableToMatrixWorkspace('depth_table',ColumnX='qy/A^-1',ColumnY='Signal/none') |
|---|
| 194 | |
|---|
| 195 | time_table=QueryMDWorkspace('sr122_tobyfit_time_cut') |
|---|
| 196 | time_sim=ConvertTableToMatrixWorkspace('time_table',ColumnX='qy/A^-1',ColumnY='Signal/none') |
|---|
| 197 | |
|---|
| 198 | mosaic_table=QueryMDWorkspace('sr122_tobyfit_mosaic_cut') |
|---|
| 199 | mosaic_sim=ConvertTableToMatrixWorkspace('mosaic_table',ColumnX='qy/A^-1',ColumnY='Signal/none') |
|---|
| 200 | |
|---|
| 201 | ########## |
|---|
| 202 | |
|---|
| 203 | mt_mod_table=QueryMDWorkspace('simulated_mod_cut') |
|---|
| 204 | mt_mod_sim=ConvertTableToMatrixWorkspace('mt_mod_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none') |
|---|
| 205 | |
|---|
| 206 | mt_chop_table=QueryMDWorkspace('simulated_chopper_cut') |
|---|
| 207 | mt_chop_sim=ConvertTableToMatrixWorkspace('mt_chop_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none') |
|---|
| 208 | |
|---|
| 209 | mt_ap_table=QueryMDWorkspace('simulated_aperture_cut') |
|---|
| 210 | mt_ap_sim=ConvertTableToMatrixWorkspace('mt_ap_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none') |
|---|
| 211 | |
|---|
| 212 | mt_vol_table=QueryMDWorkspace('simulated_vol_cut') |
|---|
| 213 | mt_vol_sim=ConvertTableToMatrixWorkspace('mt_vol_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none') |
|---|
| 214 | |
|---|
| 215 | mt_jitter_table=QueryMDWorkspace('simulated_jitter_cut') |
|---|
| 216 | mt_jitter_sim=ConvertTableToMatrixWorkspace('mt_jitter_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none') |
|---|
| 217 | |
|---|
| 218 | mt_area_table=QueryMDWorkspace('simulated_area_cut') |
|---|
| 219 | mt_area_sim=ConvertTableToMatrixWorkspace('mt_area_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none') |
|---|
| 220 | |
|---|
| 221 | mt_depth_table=QueryMDWorkspace('simulated_depth_cut') |
|---|
| 222 | mt_depth_sim=ConvertTableToMatrixWorkspace('mt_depth_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none') |
|---|
| 223 | |
|---|
| 224 | mt_time_table=QueryMDWorkspace('simulated_time_cut') |
|---|
| 225 | mt_time_sim=ConvertTableToMatrixWorkspace('mt_time_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none') |
|---|
| 226 | |
|---|
| 227 | mt_mosaic_table=QueryMDWorkspace('simulated_mosaic_cut') |
|---|
| 228 | mt_mosaic_sim=ConvertTableToMatrixWorkspace('mt_mosaic_table',ColumnX='[0,K,0]/A^-1',ColumnY='Signal/none') |
|---|
| 229 | |
|---|