1 | from mantid.simpleapi import * |
---|
2 | import numpy as n |
---|
3 | import os.path |
---|
4 | import sys |
---|
5 | |
---|
6 | def PEARL_startup(usern="matt",thiscycle='11_1'): |
---|
7 | global attenfile |
---|
8 | global currentdatadir |
---|
9 | global livedatadir |
---|
10 | global userdataprocessed |
---|
11 | global calfile |
---|
12 | global groupfile |
---|
13 | global vabsorbfile |
---|
14 | global vanfile |
---|
15 | global tofbinning |
---|
16 | global mode |
---|
17 | global tt_mode |
---|
18 | global mtdplt |
---|
19 | global cycle |
---|
20 | global instver |
---|
21 | import sys |
---|
22 | # sys.path.append('/home/'+usern+'/Scripts/') |
---|
23 | # import Mantid_plotting as mtdplt |
---|
24 | # The lines below set the default value for the rest of the focussing routines |
---|
25 | # currentdatadir="C:\PEARL\RAW\\" |
---|
26 | # currentdatadir="X:\data\cycle_11_1\\" |
---|
27 | currentdatadir="X:/data/cycle_13_4/" |
---|
28 | livedatadir="X:/data/cycle_13_4/" |
---|
29 | # calfile="C:\PEARL\\pearl_offset_11_2.cal" |
---|
30 | calfile="pearl_offset_11_2.cal" |
---|
31 | groupfile="pearl_group_11_2_TT88.cal" |
---|
32 | # groupfile="P:\Mantid\\Calibration\\test_cal_group_mods_11_1.cal" |
---|
33 | vabsorbfile="pearl_absorp_sphere_10mm_newinst_long.nxs" |
---|
34 | vanfile="van_spline_all_cycle_11_1.nxs" |
---|
35 | attenfile="P:\Mantid\\Attentuation\\PRL985_WC_HOYBIDE_NK_10MM_FF.OUT" |
---|
36 | mode="all" |
---|
37 | tt_mode="TT88" |
---|
38 | tofbinning="1500,-0.0006,19900" |
---|
39 | PEARL_setdatadir(currentdatadir) |
---|
40 | print "Raw Data in : ", currentdatadir |
---|
41 | cycle=thiscycle |
---|
42 | instver="new2" |
---|
43 | userdataprocessed="P:\users\\"+"Cycle_"+thiscycle+"\\"+usern+"\\" |
---|
44 | # sys.path.append(userdataprocessed) |
---|
45 | # userdataprocessed="C:\PEARL\\" |
---|
46 | # PEARL_setuserdir(directory=userdataprocessed) |
---|
47 | print "Cycle is set to", cycle |
---|
48 | print "Instrument version is set to ",instver |
---|
49 | print "Processed Data in : ",userdataprocessed |
---|
50 | print "Offset file set to :",calfile |
---|
51 | print "Grouping file set to :",groupfile |
---|
52 | print "Vanadium file is :",vanfile |
---|
53 | print "The default focusing mode is :",mode |
---|
54 | print "Time of flight binning set to :",tofbinning |
---|
55 | print |
---|
56 | return |
---|
57 | |
---|
58 | def PEARL_getlambdarange(): |
---|
59 | return 0.03,6.00 |
---|
60 | |
---|
61 | def PEARL_gettofrange(): |
---|
62 | return 150,19900 |
---|
63 | |
---|
64 | |
---|
65 | def PEARL_getmonitorspectrum(runno): |
---|
66 | |
---|
67 | if (runno < 71009): |
---|
68 | if (mode == "trans"): |
---|
69 | mspectra=1081 |
---|
70 | elif (mode == "all"): |
---|
71 | mspectra=2721 |
---|
72 | elif (mode == "novan"): |
---|
73 | mspectra=2721 |
---|
74 | else: |
---|
75 | print "Sorry mode not supported" |
---|
76 | sys.exit(0) |
---|
77 | else: |
---|
78 | mspectra=1 |
---|
79 | |
---|
80 | print "Monitor spectrum is", mspectra |
---|
81 | |
---|
82 | return mspectra |
---|
83 | |
---|
84 | def PEARL_getcycle(number): |
---|
85 | |
---|
86 | global cycle |
---|
87 | global instver |
---|
88 | global datadir |
---|
89 | |
---|
90 | if type(number) is int: |
---|
91 | runno=number |
---|
92 | else: |
---|
93 | num=number.split("_") |
---|
94 | runno=int(num[0]) |
---|
95 | |
---|
96 | print "The run number is get cycle is", runno |
---|
97 | if (runno < 71009): |
---|
98 | cycle="10_2" |
---|
99 | print "cycle is set to", cycle |
---|
100 | instver="old" |
---|
101 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
102 | PEARL_setdatadir(datadir) |
---|
103 | elif (runno < 71084): |
---|
104 | cycle="11_1" |
---|
105 | print "cycle is set to", cycle |
---|
106 | instver="new" |
---|
107 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
108 | PEARL_setdatadir(datadir) |
---|
109 | elif (runno < 71991): |
---|
110 | cycle="11_2" |
---|
111 | print "cycle is set to", cycle |
---|
112 | instver="new" |
---|
113 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
114 | PEARL_setdatadir(datadir) |
---|
115 | elif (runno < 73064): |
---|
116 | cycle="11_3" |
---|
117 | print "cycle is set to", cycle |
---|
118 | instver="new" |
---|
119 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
120 | PEARL_setdatadir(datadir) |
---|
121 | elif (runno < 73984): |
---|
122 | cycle="11_4" |
---|
123 | print "cycle is set to", cycle |
---|
124 | instver="new" |
---|
125 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
126 | PEARL_setdatadir(datadir) |
---|
127 | elif (runno < 74757): |
---|
128 | cycle="11_5" |
---|
129 | print "cycle is set to", cycle |
---|
130 | instver="new" |
---|
131 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
132 | PEARL_setdatadir(datadir) |
---|
133 | elif (runno < 75552): |
---|
134 | cycle="12_1" |
---|
135 | print "cycle is set to", cycle |
---|
136 | instver="new2" |
---|
137 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
138 | PEARL_setdatadir(datadir) |
---|
139 | elif (runno < 76662): |
---|
140 | cycle="12_2" |
---|
141 | print "cycle is set to", cycle |
---|
142 | instver="new2" |
---|
143 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
144 | PEARL_setdatadir(datadir) |
---|
145 | elif (runno < 77677): |
---|
146 | cycle="12_3" |
---|
147 | print "cycle is set to", cycle |
---|
148 | instver="new2" |
---|
149 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
150 | PEARL_setdatadir(datadir) |
---|
151 | elif (runno < 78610): |
---|
152 | cycle="12_4" |
---|
153 | print "cycle is set to", cycle |
---|
154 | instver="new2" |
---|
155 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
156 | PEARL_setdatadir(datadir) |
---|
157 | elif (runno < 80073): |
---|
158 | cycle="12_5" |
---|
159 | print "cycle is set to", cycle |
---|
160 | instver="new2" |
---|
161 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
162 | PEARL_setdatadir(datadir) |
---|
163 | elif (runno < 80812): |
---|
164 | cycle="13_1" |
---|
165 | print "cycle is set to", cycle |
---|
166 | instver="new2" |
---|
167 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
168 | PEARL_setdatadir(datadir) |
---|
169 | elif (runno < 81280): |
---|
170 | cycle="13_2" |
---|
171 | print "cycle is set to", cycle |
---|
172 | instver="new2" |
---|
173 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
174 | PEARL_setdatadir(datadir) |
---|
175 | elif (runno < 82317): |
---|
176 | cycle="13_3" |
---|
177 | print "cycle is set to", cycle |
---|
178 | instver="new2" |
---|
179 | datadir="X:\data\cycle_"+cycle+"\\" |
---|
180 | PEARL_setdatadir(datadir) |
---|
181 | else: |
---|
182 | cycle="13_4" |
---|
183 | print "cycle is set to", cycle |
---|
184 | instver="new2" |
---|
185 | datadir=""#r"\\isis\inst$/NDXPEARL/Instrument/data/cycle_13_4/" |
---|
186 | |
---|
187 | PEARL_setdatadir(currentdatadir) |
---|
188 | |
---|
189 | |
---|
190 | print "ISIS cycle is set to", cycle |
---|
191 | |
---|
192 | return |
---|
193 | |
---|
194 | |
---|
195 | |
---|
196 | def PEARL_getcalibfiles(): |
---|
197 | global calfile |
---|
198 | global groupfile |
---|
199 | global vabsorbfile |
---|
200 | global vanfile |
---|
201 | |
---|
202 | print "Setting calibration for cycle", cycle |
---|
203 | |
---|
204 | if (cycle=="13_4"): |
---|
205 | instver="new2" |
---|
206 | calfile="pearl_offset_13_4.cal" |
---|
207 | vabsorbfile="pearl_absorp_sphere_10mm_newinst2_long.nxs" |
---|
208 | |
---|
209 | if (tt_mode=="TT88"): |
---|
210 | groupfile="pearl_group_12_1_TT88.cal" |
---|
211 | vanfile="van_spline_TT88_cycle_13_3.nxs" |
---|
212 | elif (tt_mode=="TT70"): |
---|
213 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT70.cal" |
---|
214 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_13_3.nxs" |
---|
215 | elif (tt_mode=="TT35"): |
---|
216 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT35.cal" |
---|
217 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_13_3.nxs" |
---|
218 | else: |
---|
219 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
220 | groupfile="pearl_group_12_1_TT88.cal" |
---|
221 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_13_3.nxs" |
---|
222 | elif (cycle=="13_3"): |
---|
223 | instver="new2" |
---|
224 | calfile="P:\Mantid\\Calibration\\pearl_offset_13_3.cal" |
---|
225 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_newinst2_long.nxs" |
---|
226 | |
---|
227 | if (tt_mode=="TT88"): |
---|
228 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
229 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_13_3.nxs" |
---|
230 | elif (tt_mode=="TT70"): |
---|
231 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT70.cal" |
---|
232 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_13_3.nxs" |
---|
233 | elif (tt_mode=="TT35"): |
---|
234 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT35.cal" |
---|
235 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_13_3.nxs" |
---|
236 | else: |
---|
237 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
238 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
239 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_13_3.nxs" |
---|
240 | elif (cycle=="13_2"): |
---|
241 | instver="new2" |
---|
242 | calfile="P:\Mantid\\Calibration\\pearl_offset_13_2.cal" |
---|
243 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_newinst2_long.nxs" |
---|
244 | |
---|
245 | if (tt_mode=="TT88"): |
---|
246 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
247 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_13_2.nxs" |
---|
248 | elif (tt_mode=="TT70"): |
---|
249 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT70.cal" |
---|
250 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_13_2.nxs" |
---|
251 | elif (tt_mode=="TT35"): |
---|
252 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT35.cal" |
---|
253 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_13_2.nxs" |
---|
254 | else: |
---|
255 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
256 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
257 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_13_2.nxs" |
---|
258 | elif (cycle=="13_1"): |
---|
259 | instver="new2" |
---|
260 | calfile="P:\Mantid\\Calibration\\pearl_offset_13_1.cal" |
---|
261 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_newinst2_long.nxs" |
---|
262 | |
---|
263 | if (tt_mode=="TT88"): |
---|
264 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
265 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_13_1.nxs" |
---|
266 | elif (tt_mode=="TT70"): |
---|
267 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT70.cal" |
---|
268 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_13_1.nxs" |
---|
269 | elif (tt_mode=="TT35"): |
---|
270 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT35.cal" |
---|
271 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_13_1.nxs" |
---|
272 | else: |
---|
273 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
274 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
275 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_13_1.nxs" |
---|
276 | elif (cycle=="12_5"): |
---|
277 | instver="new2" |
---|
278 | calfile="P:\Mantid\\Calibration\\pearl_offset_12_5.cal" |
---|
279 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_newinst2_long.nxs" |
---|
280 | |
---|
281 | if (tt_mode=="TT88"): |
---|
282 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
283 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_12_5.nxs" |
---|
284 | elif (tt_mode=="TT70"): |
---|
285 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT70.cal" |
---|
286 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_12_5.nxs" |
---|
287 | elif (tt_mode=="TT35"): |
---|
288 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT35.cal" |
---|
289 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_12_5.nxs" |
---|
290 | else: |
---|
291 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
292 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
293 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_12_5.nxs" |
---|
294 | elif (cycle=="12_4"): |
---|
295 | instver="new2" |
---|
296 | calfile="P:\Mantid\\Calibration\\pearl_offset_12_4.cal" |
---|
297 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_newinst2_long.nxs" |
---|
298 | |
---|
299 | if (tt_mode=="TT88"): |
---|
300 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
301 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_12_4.nxs" |
---|
302 | elif (tt_mode=="TT70"): |
---|
303 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT70.cal" |
---|
304 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_12_4.nxs" |
---|
305 | elif (tt_mode=="TT35"): |
---|
306 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT35.cal" |
---|
307 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_12_4.nxs" |
---|
308 | else: |
---|
309 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
310 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
311 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_12_4.nxs" |
---|
312 | elif (cycle=="12_3"): |
---|
313 | instver="new2" |
---|
314 | calfile="P:\Mantid\\Calibration\\pearl_offset_12_3.cal" |
---|
315 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_newinst2_long.nxs" |
---|
316 | |
---|
317 | if (tt_mode=="TT88"): |
---|
318 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
319 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_12_3.nxs" |
---|
320 | elif (tt_mode=="TT70"): |
---|
321 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT70.cal" |
---|
322 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_12_3.nxs" |
---|
323 | elif (tt_mode=="TT35"): |
---|
324 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT35.cal" |
---|
325 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_12_3.nxs" |
---|
326 | else: |
---|
327 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
328 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
329 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_12_3.nxs" |
---|
330 | elif (cycle=="12_2"): |
---|
331 | instver="new2" |
---|
332 | calfile="P:\Mantid\\Calibration\\pearl_offset_12_2.cal" |
---|
333 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_newinst2_long.nxs" |
---|
334 | |
---|
335 | if (tt_mode=="TT88"): |
---|
336 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
337 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_12_2.nxs" |
---|
338 | elif (tt_mode=="TT70"): |
---|
339 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT70.cal" |
---|
340 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_12_2.nxs" |
---|
341 | elif (tt_mode=="TT35"): |
---|
342 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT35.cal" |
---|
343 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_12_2.nxs" |
---|
344 | else: |
---|
345 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
346 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
347 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_12_2.nxs" |
---|
348 | elif (cycle=="12_1"): |
---|
349 | instver="new2" |
---|
350 | calfile="P:\Mantid\\Calibration\\pearl_offset_12_1.cal" |
---|
351 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_newinst2_long.nxs" |
---|
352 | |
---|
353 | if (tt_mode=="TT88"): |
---|
354 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
355 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_12_1.nxs" |
---|
356 | elif (tt_mode=="TT70"): |
---|
357 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT70.cal" |
---|
358 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_12_1.nxs" |
---|
359 | elif (tt_mode=="TT35"): |
---|
360 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT35.cal" |
---|
361 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_12_1.nxs" |
---|
362 | else: |
---|
363 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
364 | groupfile="P:\Mantid\\Calibration\\pearl_group_12_1_TT88.cal" |
---|
365 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_12_1.nxs" |
---|
366 | elif (cycle=="11_5"): |
---|
367 | instver="new" |
---|
368 | calfile="P:\Mantid\\Calibration\\pearl_offset_11_5.cal" |
---|
369 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_newinst_long.nxs" |
---|
370 | |
---|
371 | if (tt_mode=="TT88"): |
---|
372 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT88.cal" |
---|
373 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_11_5.nxs" |
---|
374 | elif (tt_mode=="TT70"): |
---|
375 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT70.cal" |
---|
376 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_11_5.nxs" |
---|
377 | elif (tt_mode=="TT35"): |
---|
378 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT35.cal" |
---|
379 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_11_5.nxs" |
---|
380 | else: |
---|
381 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
382 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT88.cal" |
---|
383 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_11_5.nxs" |
---|
384 | elif (cycle=="11_4"): |
---|
385 | instver="new" |
---|
386 | calfile="P:\Mantid\\Calibration\\pearl_offset_11_4.cal" |
---|
387 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_newinst_long.nxs" |
---|
388 | |
---|
389 | if (tt_mode=="TT88"): |
---|
390 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT88.cal" |
---|
391 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_11_4.nxs" |
---|
392 | elif (tt_mode=="TT70"): |
---|
393 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT70.cal" |
---|
394 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_11_4.nxs" |
---|
395 | elif (tt_mode=="TT35"): |
---|
396 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT35.cal" |
---|
397 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_11_4.nxs" |
---|
398 | else: |
---|
399 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
400 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT88.cal" |
---|
401 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_11_4.nxs" |
---|
402 | elif (cycle=="11_3"): |
---|
403 | instver="new" |
---|
404 | calfile="P:\Mantid\\Calibration\\pearl_offset_11_3.cal" |
---|
405 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_newinst_long.nxs" |
---|
406 | |
---|
407 | if (tt_mode=="TT88"): |
---|
408 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT88.cal" |
---|
409 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_11_3.nxs" |
---|
410 | elif (tt_mode=="TT70"): |
---|
411 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT70.cal" |
---|
412 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_11_3.nxs" |
---|
413 | elif (tt_mode=="TT35"): |
---|
414 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT35.cal" |
---|
415 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_11_3.nxs" |
---|
416 | else: |
---|
417 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
418 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT88.cal" |
---|
419 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_11_3.nxs" |
---|
420 | elif (cycle=="11_2"): |
---|
421 | instver="new" |
---|
422 | calfile="P:\Mantid\\Calibration\\pearl_offset_11_2.cal" |
---|
423 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_newinst.nxs" |
---|
424 | vanfile="P:\Mantid\\Calibration\\van_spline_mods_cycle_11_2.nxs" |
---|
425 | if (tt_mode=="TT88"): |
---|
426 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT88.cal" |
---|
427 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_11_2.nxs" |
---|
428 | elif (tt_mode=="TT70"): |
---|
429 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT70.cal" |
---|
430 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_11_2.nxs" |
---|
431 | elif (tt_mode=="TT35"): |
---|
432 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT35.cal" |
---|
433 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_11_2.nxs" |
---|
434 | else: |
---|
435 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
436 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT88.cal" |
---|
437 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_11_2.nxs" |
---|
438 | elif (cycle=="11_1"): |
---|
439 | instver="new" |
---|
440 | calfile="P:\Mantid\\Calibration\\pearl_offset_11_2.cal" |
---|
441 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_newinst_11_1.nxs" |
---|
442 | vanfile="P:\Mantid\\Calibration\\van_spline_mods_cycle_11_1.nxs" |
---|
443 | if (tt_mode=="TT88"): |
---|
444 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT88.cal" |
---|
445 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_11_1.nxs" |
---|
446 | elif (tt_mode=="TT70"): |
---|
447 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT70.cal" |
---|
448 | vanfile="P:\Mantid\\Calibration\\van_spline_TT70_cycle_11_1.nxs" |
---|
449 | elif (tt_mode=="TT35"): |
---|
450 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT35.cal" |
---|
451 | vanfile="P:\Mantid\\Calibration\\van_spline_TT35_cycle_11_1.nxs" |
---|
452 | else: |
---|
453 | print "Sorry I don't know that Two Theta mode so assuming T88" |
---|
454 | groupfile="P:\Mantid\\Calibration\\pearl_group_11_2_TT88.cal" |
---|
455 | vanfile="P:\Mantid\\Calibration\\van_spline_TT88_cycle_11_1.nxs" |
---|
456 | elif (cycle=="10_2"): |
---|
457 | instver="old" |
---|
458 | calfile="P:\Mantid\\Calibration\\pearl_offset_10_2.cal" |
---|
459 | groupfile="P:\Mantid\\Calibration\\pearl_group_10_2.cal" |
---|
460 | vabsorbfile="P:\Mantid\\Calibration\\pearl_absorp_sphere_10mm_all.nxs" |
---|
461 | vanfile="P:\Mantid\\Calibration\\test_van_new_cycle_10_2.nxs" |
---|
462 | else: |
---|
463 | print "Sorry that cycle has not been defined yet" |
---|
464 | return |
---|
465 | |
---|
466 | def PEARL_setdatadir(directory="C:\PEARL\RAW\\"): |
---|
467 | global pearl_datadir |
---|
468 | pearl_datadir=directory |
---|
469 | return |
---|
470 | |
---|
471 | def PEARL_setattenfile(new_atten="P:\Mantid\\Attentuation\\PRL985_WC_HOYBIDE_NK_10MM_FF.OUT"): |
---|
472 | global attenfile |
---|
473 | attenfile=new_atten |
---|
474 | print "Set attenuation file to ",attenfile |
---|
475 | return |
---|
476 | |
---|
477 | def PEARL_datadir(): |
---|
478 | return pearl_datadir |
---|
479 | |
---|
480 | def PEARL_getfilename(run_number,ext): |
---|
481 | global livedatadir |
---|
482 | |
---|
483 | if (ext[0]!='s'): |
---|
484 | data_dir=PEARL_datadir() |
---|
485 | else: |
---|
486 | data_dir=livedatadir |
---|
487 | digit=len(str(run_number)) |
---|
488 | |
---|
489 | if (run_number < 71009): |
---|
490 | numdigits=5 |
---|
491 | # |
---|
492 | # filename=data_dir+"PRL" |
---|
493 | # |
---|
494 | filename="PRL" |
---|
495 | else: |
---|
496 | numdigits=8 |
---|
497 | # |
---|
498 | # filename=data_dir+"PEARL" |
---|
499 | # |
---|
500 | filename="PEARL" |
---|
501 | |
---|
502 | for i in range(0,numdigits-digit): |
---|
503 | filename=filename+"0" |
---|
504 | |
---|
505 | filename+=str(run_number)+"."+ext |
---|
506 | |
---|
507 | full_filename=filename |
---|
508 | # |
---|
509 | # Check if file exists in default data folder & if not use alternate folder stored in "datadir"... |
---|
510 | # |
---|
511 | #if (os.path.exists(full_filename) == False): |
---|
512 | |
---|
513 | # print "No such file as ",full_filename,"; trying X-drive folder..." |
---|
514 | |
---|
515 | # full_filename=datadir+filename |
---|
516 | |
---|
517 | return full_filename |
---|
518 | |
---|
519 | def PearlLoad(files,ext,outname): |
---|
520 | |
---|
521 | if type(files) is int: |
---|
522 | infile=PEARL_getfilename(files,ext) |
---|
523 | print "loading ",infile,"into ",outname |
---|
524 | print "--DEBUGGING: ",LoadRaw.func_code.co_filename |
---|
525 | LoadRaw(Filename=infile,OutputWorkspace=outname,LoadLogFiles="0") |
---|
526 | else: |
---|
527 | loop=0 |
---|
528 | num=files.split("_") |
---|
529 | frange=range(int(num[0]),int(num[1])+1) |
---|
530 | for i in frange: |
---|
531 | infile=PEARL_getfilename(i,ext) |
---|
532 | print "loading ",infile |
---|
533 | outwork="run"+str(i) |
---|
534 | LoadRaw(Filename=infile,OutputWorkspace=outwork,LoadLogFiles="0") |
---|
535 | loop=loop+1 |
---|
536 | if loop == 2: |
---|
537 | firstwk="run"+str(i-1) |
---|
538 | secondwk="run"+str(i) |
---|
539 | Plus(LHSWorkspace=firstwk,RHSWorkspace=secondwk,OutputWorkspace=outname) |
---|
540 | mtd.remove(firstwk) |
---|
541 | mtd.remove(secondwk) |
---|
542 | elif loop > 2: |
---|
543 | secondwk="run"+str(i) |
---|
544 | Plus(LHSWorkspace=outname,RHSWorkspace=secondwk,OutputWorkspace=outname) |
---|
545 | mtd.remove(secondwk) |
---|
546 | return |
---|
547 | |
---|
548 | def PearlLoadMon(files,ext,outname): |
---|
549 | |
---|
550 | if type(files) is int: |
---|
551 | infile=PEARL_getfilename(files,ext) |
---|
552 | mspectra=PEARL_getmonitorspectrum(files) |
---|
553 | print "loading ",infile,"into ",outname |
---|
554 | LoadRaw(Filename=infile,OutputWorkspace=outname,SpectrumMin=mspectra,SpectrumMax=mspectra,LoadLogFiles="0") |
---|
555 | else: |
---|
556 | loop=0 |
---|
557 | num=files.split("_") |
---|
558 | frange=range(int(num[0]),int(num[1])+1) |
---|
559 | mspectra=PEARL_getmonitorspectrum(int(num[0])) |
---|
560 | for i in frange: |
---|
561 | infile=PEARL_getfilename(i,ext) |
---|
562 | print "loading ",infile |
---|
563 | outwork="mon"+str(i) |
---|
564 | LoadRaw(Filename=infile,OutputWorkspace=outwork,SpectrumMin=mspectra,SpectrumMax=mspectra,LoadLogFiles="0") |
---|
565 | loop=loop+1 |
---|
566 | if loop == 2: |
---|
567 | firstwk="mon"+str(i-1) |
---|
568 | secondwk="mon"+str(i) |
---|
569 | Plus(LHSWorkspace=firstwk,RHSWorkspace=secondwk,OutputWorkspace=outname) |
---|
570 | mtd.remove(firstwk) |
---|
571 | mtd.remove(secondwk) |
---|
572 | elif loop > 2: |
---|
573 | secondwk="mon"+str(i) |
---|
574 | Plus(LHSWorkspace=outname,RHSWorkspace=secondwk,OutputWorkspace=outname) |
---|
575 | mtd.remove(secondwk) |
---|
576 | return |
---|
577 | |
---|
578 | |
---|
579 | |
---|
580 | def PEARL_getmonitor(number,ext,spline_terms=20,debug=False): |
---|
581 | |
---|
582 | works="monitor"+str(number) |
---|
583 | PearlLoadMon(number,ext,works) |
---|
584 | ConvertUnits(InputWorkspace=works,OutputWorkspace=works,Target="Wavelength") |
---|
585 | lmin,lmax=PEARL_getlambdarange() |
---|
586 | CropWorkspace(InputWorkspace=works,OutputWorkspace=works,XMin=lmin,XMax=lmax) |
---|
587 | ex_regions=n.zeros((2,4)) |
---|
588 | ex_regions[:,0]=[3.45,3.7] |
---|
589 | ex_regions[:,1]=[2.96,3.2] |
---|
590 | ex_regions[:,2]=[2.1,2.26] |
---|
591 | ex_regions[:,3]=[1.73,1.98] |
---|
592 | #ConvertToDistribution(works) |
---|
593 | if (debug): |
---|
594 | print "The masked regions are" |
---|
595 | for i in range(0,4): |
---|
596 | print ex_regions[0,i],ex_regions[1,i] |
---|
597 | #x,y,z=mtdplt.getnarray(works,0) |
---|
598 | #p.plot(x,y) |
---|
599 | |
---|
600 | for reg in range(0,4): |
---|
601 | MaskBins(InputWorkspace=works,OutputWorkspace=works,XMin=ex_regions[0,reg],XMax=ex_regions[1,reg]) |
---|
602 | |
---|
603 | if (debug): |
---|
604 | CloneWorkspace(InputWorkspace=works,OutputWorkspace="mask") |
---|
605 | #x,y,z=mtdplt.getnarray(works,0) |
---|
606 | #p.plot(x,y) |
---|
607 | SplineBackground(InputWorkspace=works,OutputWorkspace=works,WorkspaceIndex=0,NCoeff=spline_terms) |
---|
608 | #if (debug): |
---|
609 | #x,y,z=mtdplt.getnarray(works,0) |
---|
610 | #p.plot(x,y) |
---|
611 | #p.show() |
---|
612 | #SmoothData(works,works,50) |
---|
613 | #ConvertFromDistribution(works) |
---|
614 | return works |
---|
615 | |
---|
616 | |
---|
617 | def PEARL_read(number,ext,outname): |
---|
618 | PearlLoad(number,ext,outname) |
---|
619 | ConvertUnits(InputWorkspace=outname,OutputWorkspace=outname,Target="Wavelength") |
---|
620 | #lmin,lmax=WISH_getlambdarange() |
---|
621 | #CropWorkspace(output,output,XMin=lmin,XMax=lmax) |
---|
622 | monitor=PEARL_getmonitor(number,ext,spline_terms=20,debug=False) |
---|
623 | #NormaliseToMonitor(InputWorkspace=outname,OutputWorkspace=outname,MonitorWorkspace=monitor) |
---|
624 | NormaliseToMonitor(InputWorkspace=outname,OutputWorkspace=outname,MonitorWorkspace=monitor,IntegrationRangeMin=0.6,IntegrationRangeMax=5.0) |
---|
625 | ConvertUnits(InputWorkspace=outname,OutputWorkspace=outname,Target="TOF") |
---|
626 | mtd.remove(monitor) |
---|
627 | #ReplaceSpecialValues(output,output,NaNValue=0.0,NaNError=0.0,InfinityValue=0.0,InfinityError=0.0) |
---|
628 | return |
---|
629 | |
---|
630 | def PEARL_align(work,focus): |
---|
631 | PEARL_getcalibfiles() |
---|
632 | AlignDetectors(InputWorkspace=work,OutputWorkspace=work,CalibrationFile=calfile) |
---|
633 | #mtd.remove(work) |
---|
634 | return focus |
---|
635 | |
---|
636 | def PEARL_focus(number,ext="raw",fmode="trans",ttmode="TT70",atten=True,van_norm=True,debug=False): |
---|
637 | global instver |
---|
638 | |
---|
639 | PEARL_getcycle(number) |
---|
640 | |
---|
641 | print "Instrument version is:",instver |
---|
642 | if (instver=="new2"): |
---|
643 | outwork=PEARL_focus_v2(number,ext,fmode,ttmode,atten,van_norm,debug) |
---|
644 | else: |
---|
645 | outwork=PEARL_focus_v1(number,ext,fmode,ttmode,atten,van_norm,debug) |
---|
646 | |
---|
647 | |
---|
648 | return outwork |
---|
649 | |
---|
650 | def PEARL_focus_v1(number,ext="raw",fmode="trans",ttmode="TT70",atten=True,van_norm=True,debug=False): |
---|
651 | |
---|
652 | global mode |
---|
653 | global tt_mode |
---|
654 | tt_mode=ttmode |
---|
655 | mode=fmode |
---|
656 | PEARL_getcycle(number) |
---|
657 | PEARL_getcalibfiles() |
---|
658 | print "Focussing mode is:",mode |
---|
659 | print "Two theta mode is:",tt_mode |
---|
660 | print "Group file is", groupfile |
---|
661 | print "Calibration file is", calfile |
---|
662 | print "Tof binning", tofbinning |
---|
663 | work="work" |
---|
664 | focus="focus" |
---|
665 | if type(number) is int: |
---|
666 | outfile=userdataprocessed+"PRL"+str(number)+".nxs" |
---|
667 | gssfile=userdataprocessed+"PRL"+str(number)+".gss" |
---|
668 | tof_xye_file=userdataprocessed+"PRL"+str(number)+"_tof_xye.dat" |
---|
669 | d_xye_file=userdataprocessed+"PRL"+str(number)+"_d_xye.dat" |
---|
670 | outwork="PRL"+str(number) |
---|
671 | else: |
---|
672 | outfile=userdataprocessed+"PRL"+number+".nxs" |
---|
673 | gssfile=userdataprocessed+"PRL"+number+".gss" |
---|
674 | tof_xye_file=userdataprocessed+"PRL"+number+"_tof_xye.dat" |
---|
675 | d_xye_file=userdataprocessed+"PRL"+number+"_d_xye.dat" |
---|
676 | |
---|
677 | outwork="PRL"+number |
---|
678 | |
---|
679 | PEARL_read(number,ext,work) |
---|
680 | Rebin(InputWorkspace=work,OutputWorkspace=work,Params=tofbinning) |
---|
681 | AlignDetectors(InputWorkspace=work,OutputWorkspace=work,CalibrationFile=calfile) |
---|
682 | DiffractionFocussing(InputWorkspace=work,OutputWorkspace=focus,GroupingFileName=groupfile) |
---|
683 | |
---|
684 | |
---|
685 | |
---|
686 | if (debug!=True): |
---|
687 | mtd.remove(work) |
---|
688 | |
---|
689 | for i in range(0,12): |
---|
690 | output="mod"+str(i+1) |
---|
691 | van="van"+str(i+1) |
---|
692 | rdata="rdata"+str(i+1) |
---|
693 | if (van_norm): |
---|
694 | print "Using vanadium file",vanfile |
---|
695 | LoadNexus(Filename=vanfile,OutputWorkspace=van,EntryNumber=i+1) |
---|
696 | ExtractSingleSpectrum(InputWorkspace=focus,OutputWorkspace=rdata,WorkspaceIndex=i) |
---|
697 | #ConvertUnits(van,van,"TOF") |
---|
698 | Rebin(InputWorkspace=van,OutputWorkspace=van,Params=tofbinning) |
---|
699 | ConvertUnits(InputWorkspace=rdata,OutputWorkspace=rdata,Target="TOF") |
---|
700 | Rebin(InputWorkspace=rdata,OutputWorkspace=rdata,Params=tofbinning) |
---|
701 | Divide(LHSWorkspace=rdata,RHSWorkspace=van,OutputWorkspace=output) |
---|
702 | CropWorkspace(InputWorkspace=output,OutputWorkspace=output,XMin=0.1) |
---|
703 | Scale(InputWorkspace=output,OutputWorkspace=output,Factor=10) |
---|
704 | else: |
---|
705 | print "Not Using vanadium file" |
---|
706 | #LoadNexus(Filename=vanfile,OutputWorkspace=van,EntryNumber=i+1) |
---|
707 | ExtractSingleSpectrum(InputWorkspace=focus,OutputWorkspace=rdata,WorkspaceIndex=i) |
---|
708 | #ConvertUnits(van,van,"TOF") |
---|
709 | #Rebin(van,van,tofbinning) |
---|
710 | ConvertUnits(InputWorkspace=rdata,OutputWorkspace=rdata,Target="TOF") |
---|
711 | Rebin(InputWorkspace=rdata,OutputWorkspace=output,Params=tofbinning) |
---|
712 | #Divide(rdata,van,output) |
---|
713 | CropWorkspace(InputWorkspace=output,OutputWorkspace=output,XMin=0.1) |
---|
714 | if (debug!=True): |
---|
715 | mtd.remove(focus) |
---|
716 | |
---|
717 | if (mode=="all"): |
---|
718 | CloneWorkspace(InputWorkspace="mod1",OutputWorkspace="bank1") |
---|
719 | for i in range(1,9): |
---|
720 | toadd="mod"+str(i+1) |
---|
721 | Plus(LHSWorkspace="bank1",RHSWorkspace=toadd,OutputWorkspace="bank1") |
---|
722 | Scale(InputWorkspace="bank1",OutputWorkspace="bank1",Factor=0.111111111111111) |
---|
723 | SaveGSS(InputWorkspace="bank1",Filename=gssfile,Append=False,Bank=1) |
---|
724 | ConvertUnits(InputWorkspace="bank1",OutputWorkspace="bank1",Target="dSpacing") |
---|
725 | SaveNexus(Filename=outfile,InputWorkspace="bank1",Append=False) |
---|
726 | for i in range(0,3): |
---|
727 | tosave="mod"+str(i+10) |
---|
728 | SaveGSS(InputWorkspace=tosave,Filename=gssfile,Append=True,Bank=i+2) |
---|
729 | ConvertUnits(InputWorkspace=tosave,OutputWorkspace=tosave,Target="dSpacing") |
---|
730 | SaveNexus(Filename=outfile,InputWorkspace=tosave,Append=True) |
---|
731 | |
---|
732 | if (debug!=True): |
---|
733 | for i in range(0,12): |
---|
734 | output="mod"+str(i+1) |
---|
735 | van="van"+str(i+1) |
---|
736 | rdata="rdata"+str(i+1) |
---|
737 | mtd.remove(rdata) |
---|
738 | mtd.remove(van) |
---|
739 | mtd.remove(output) |
---|
740 | mtd.remove("bank1") |
---|
741 | |
---|
742 | elif (mode=="groups"): |
---|
743 | CloneWorkspace(InputWorkspace="mod1",OutputWorkspace="group1") |
---|
744 | CloneWorkspace(InputWorkspace="mod4",OutputWorkspace="group2") |
---|
745 | CloneWorkspace(InputWorkspace="mod7",OutputWorkspace="group3") |
---|
746 | for i in range(1,3): |
---|
747 | toadd="mod"+str(i+1) |
---|
748 | Plus(LHSWorkspace="group1",RHSWorkspace=toadd,OutputWorkspace="group1") |
---|
749 | Scale(InputWorkspace="group1",OutputWorkspace="group1",Factor=0.333333333333) |
---|
750 | for i in range(1,3): |
---|
751 | toadd="mod"+str(i+4) |
---|
752 | Plus(LHSWorkspace="group2",RHSWorkspace=toadd,OutputWorkspace="group2") |
---|
753 | Scale(InputWorkspace="group2",OutputWorkspace="group2",Factor=0.333333333333) |
---|
754 | for i in range(1,3): |
---|
755 | toadd="mod"+str(i+7) |
---|
756 | Plus(LHSWorkspace="group3",RHSWorkspace=toadd,OutputWorkspace="group3") |
---|
757 | Scale(InputWorkspace="group3",OutputWorkspace="group3",Factor=0.333333333333) |
---|
758 | Plus(LHSWorkspace="group2",RHSWorkspace="group3",OutputWorkspace="group23") |
---|
759 | Scale(InputWorkspace="group23",OutputWorkspace="group23",Factor=0.5) |
---|
760 | SaveGSS(InputWorkspace="group1",Filename=gssfile,Append=False,Bank=1) |
---|
761 | ConvertUnits(InputWorkspace="group1",OutputWorkspace="group1",Target="dSpacing") |
---|
762 | SaveNexus(Filename=outfile,InputWorkspace="group1",Append=False) |
---|
763 | SaveGSS(InputWorkspace="group2",Filename=gssfile,Append=True,Bank=2) |
---|
764 | ConvertUnits(InputWorkspace="group2",OutputWorkspace="group2",Target="dSpacing") |
---|
765 | SaveNexus(Filename=outfile,InputWorkspace="group2",Append=True) |
---|
766 | SaveGSS(InputWorkspace="group3",Filename=gssfile,Append=True,Bank=3) |
---|
767 | ConvertUnits(InputWorkspace="group3",OutputWorkspace="group3",Target="dSpacing") |
---|
768 | SaveNexus(Filename=outfile,InputWorkspace="group3",Append=True) |
---|
769 | SaveGSS(InputWorkspace="group23",Filename=gssfile,Append=True,Bank=4) |
---|
770 | ConvertUnits(InputWorkspace="group23",OutputWorkspace="group23",Target="dSpacing") |
---|
771 | SaveNexus(Filename=outfile,InputWorkspace="group23",Append=True) |
---|
772 | for i in range(0,3): |
---|
773 | tosave="mod"+str(i+10) |
---|
774 | SaveGSS(InputWorkspace=tosave,Filename=gssfile,Append=True,Bank=i+5) |
---|
775 | ConvertUnits(InputWorkspace=tosave,OutputWorkspace=tosave,Target="dSpacing") |
---|
776 | SaveNexus(Filename=outfile,InputWorkspace=tosave,Append=True) |
---|
777 | if (debug!=True): |
---|
778 | for i in range(0,12): |
---|
779 | output="mod"+str(i+1) |
---|
780 | van="van"+str(i+1) |
---|
781 | rdata="rdata"+str(i+1) |
---|
782 | mtd.remove(rdata) |
---|
783 | mtd.remove(van) |
---|
784 | mtd.remove(output) |
---|
785 | mtd.remove("group1") |
---|
786 | mtd.remove("group2") |
---|
787 | mtd.remove("group3") |
---|
788 | mtd.remove("group23") |
---|
789 | |
---|
790 | elif (mode=="trans"): |
---|
791 | CloneWorkspace(InputWorkspace="mod1",OutputWorkspace="bank1") |
---|
792 | for i in range(1,9): |
---|
793 | toadd="mod"+str(i+1) |
---|
794 | Plus(LHSWorkspace="bank1",RHSWorkspace=toadd,OutputWorkspace="bank1") |
---|
795 | Scale(InputWorkspace="bank1",OutputWorkspace="bank1",Factor=0.111111111111111) |
---|
796 | if (atten): |
---|
797 | ConvertUnits(InputWorkspace="bank1",OutputWorkspace="bank1",Target="dSpacing") |
---|
798 | CloneWorkspace(InputWorkspace="bank1",OutputWorkspace=outwork+"_noatten") |
---|
799 | PEARL_atten("bank1","bank1") |
---|
800 | ConvertUnits(InputWorkspace="bank1",OutputWorkspace="bank1",Target="TOF") |
---|
801 | |
---|
802 | SaveGSS(InputWorkspace="bank1",Filename=gssfile,Append=False,Bank=1) |
---|
803 | |
---|
804 | SaveFocusedXYE(InputWorkspace="bank1",Filename=tof_xye_file,Append=False,IncludeHeader=False) |
---|
805 | ConvertUnits(InputWorkspace="bank1",OutputWorkspace="bank1",Target="dSpacing") |
---|
806 | SaveFocusedXYE(InputWorkspace="bank1",Filename=d_xye_file,Append=False,IncludeHeader=False) |
---|
807 | SaveNexus(Filename=outfile,InputWorkspace="bank1",Append=False) |
---|
808 | |
---|
809 | for i in range(0,9): |
---|
810 | tosave="mod"+str(i+1) |
---|
811 | #SaveGSS(tosave,Filename=gssfile,Append=True,Bank=i+2) |
---|
812 | ConvertUnits(InputWorkspace=tosave,OutputWorkspace=tosave,Target="dSpacing") |
---|
813 | SaveNexus(Filename=outfile,InputWorkspace=tosave,Append=True) |
---|
814 | |
---|
815 | if (debug!=True): |
---|
816 | for i in range(0,12): |
---|
817 | output="mod"+str(i+1) |
---|
818 | van="van"+str(i+1) |
---|
819 | rdata="rdata"+str(i+1) |
---|
820 | mtd.remove(rdata) |
---|
821 | mtd.remove(van) |
---|
822 | mtd.remove(output) |
---|
823 | mtd.remove("bank1") |
---|
824 | |
---|
825 | elif (mode=="mods"): |
---|
826 | for i in range(0,12): |
---|
827 | output="mod"+str(i+1) |
---|
828 | van="van"+str(i+1) |
---|
829 | rdata="rdata"+str(i+1) |
---|
830 | if (i==0): |
---|
831 | SaveGSS(InputWorkspace=output,Filename=gssfile,Append=False,Bank=i+1) |
---|
832 | ConvertUnits(InputWorkspace=output,OutputWorkspace=output,Target="dSpacing") |
---|
833 | SaveNexus(Filename=outfile,InputWorkspace=output,Append=False) |
---|
834 | else: |
---|
835 | SaveGSS(InputWorkspace=output,Filename=gssfile,Append=True,Bank=i+1) |
---|
836 | ConvertUnits(InputWorkspace=output,OutputWorkspace=output,Target="dSpacing") |
---|
837 | SaveNexus(Filename=outfile,InputWorkspace=output,Append=True) |
---|
838 | if (debug!=True): |
---|
839 | mtd.remove(rdata) |
---|
840 | mtd.remove(van) |
---|
841 | mtd.remove(output) |
---|
842 | |
---|
843 | else: |
---|
844 | print "Sorry I don't know that mode", mode |
---|
845 | return |
---|
846 | |
---|
847 | LoadNexus(Filename=outfile,OutputWorkspace=outwork) |
---|
848 | return outwork |
---|
849 | |
---|
850 | def PEARL_focus_v2(number,ext="raw",fmode="trans",ttmode="TT70",atten=True,van_norm=True,debug=False): |
---|
851 | |
---|
852 | global mode |
---|
853 | global tt_mode |
---|
854 | tt_mode=ttmode |
---|
855 | mode=fmode |
---|
856 | PEARL_getcycle(number) |
---|
857 | PEARL_getcalibfiles() |
---|
858 | print "Focussing mode is:",mode |
---|
859 | print "Two theta mode is:",tt_mode |
---|
860 | print "Group file is", groupfile |
---|
861 | print "Calibration file is", calfile |
---|
862 | print "Tof binning", tofbinning |
---|
863 | work="work" |
---|
864 | focus="focus" |
---|
865 | if type(number) is int: |
---|
866 | outfile=userdataprocessed+"PRL"+str(number)+".nxs" |
---|
867 | gssfile=userdataprocessed+"PRL"+str(number)+".gss" |
---|
868 | tof_xye_file=userdataprocessed+"PRL"+str(number)+"_tof_xye.dat" |
---|
869 | d_xye_file=userdataprocessed+"PRL"+str(number)+"_d_xye.dat" |
---|
870 | outwork="PRL"+str(number) |
---|
871 | else: |
---|
872 | outfile=userdataprocessed+"PRL"+number+".nxs" |
---|
873 | gssfile=userdataprocessed+"PRL"+number+".gss" |
---|
874 | tof_xye_file=userdataprocessed+"PRL"+number+"_tof_xye.dat" |
---|
875 | d_xye_file=userdataprocessed+"PRL"+number+"_d_xye.dat" |
---|
876 | |
---|
877 | outwork="PRL"+number |
---|
878 | |
---|
879 | PEARL_read(number,ext,work) |
---|
880 | Rebin(InputWorkspace=work,OutputWorkspace=work,Params=tofbinning) |
---|
881 | AlignDetectors(InputWorkspace=work,OutputWorkspace=work,CalibrationFile=calfile) |
---|
882 | DiffractionFocussing(InputWorkspace=work,OutputWorkspace=focus,GroupingFileName=groupfile) |
---|
883 | |
---|
884 | |
---|
885 | |
---|
886 | if (debug!=True): |
---|
887 | mtd.remove(work) |
---|
888 | |
---|
889 | for i in range(0,14): |
---|
890 | output="mod"+str(i+1) |
---|
891 | van="van"+str(i+1) |
---|
892 | rdata="rdata"+str(i+1) |
---|
893 | if (van_norm): |
---|
894 | print "Using vanadium file",vanfile |
---|
895 | LoadNexus(Filename=vanfile,OutputWorkspace=van,EntryNumber=i+1) |
---|
896 | ExtractSingleSpectrum(InputWorkspace=focus,OutputWorkspace=rdata,WorkspaceIndex=i) |
---|
897 | #ConvertUnits(van,van,"TOF") |
---|
898 | Rebin(InputWorkspace=van,OutputWorkspace=van,Params=tofbinning) |
---|
899 | ConvertUnits(InputWorkspace=rdata,OutputWorkspace=rdata,Target="TOF") |
---|
900 | Rebin(InputWorkspace=rdata,OutputWorkspace=rdata,Params=tofbinning) |
---|
901 | Divide(LHSWorkspace=rdata,RHSWorkspace=van,OutputWorkspace=output) |
---|
902 | CropWorkspace(InputWorkspace=output,OutputWorkspace=output,XMin=0.1) |
---|
903 | Scale(InputWorkspace=output,OutputWorkspace=output,Factor=10) |
---|
904 | else: |
---|
905 | print "Not Using vanadium file" |
---|
906 | #LoadNexus(Filename=vanfile,OutputWorkspace=van,EntryNumber=i+1) |
---|
907 | ExtractSingleSpectrum(InputWorkspace=focus,OutputWorkspace=rdata,WorkspaceIndex=i) |
---|
908 | #ConvertUnits(van,van,"TOF") |
---|
909 | #Rebin(van,van,tofbinning) |
---|
910 | ConvertUnits(InputWorkspace=rdata,OutputWorkspace=rdata,Target="TOF") |
---|
911 | Rebin(InputWorkspace=rdata,OutputWorkspace=output,Params=tofbinning) |
---|
912 | #Divide(rdata,van,output) |
---|
913 | CropWorkspace(InputWorkspace=output,OutputWorkspace=output,XMin=0.1) |
---|
914 | if (debug!=True): |
---|
915 | mtd.remove(focus) |
---|
916 | |
---|
917 | if (mode=="all"): |
---|
918 | CloneWorkspace(InputWorkspace="mod1",OutputWorkspace="bank1") |
---|
919 | for i in range(1,9): |
---|
920 | toadd="mod"+str(i+1) |
---|
921 | Plus(LHSWorkspace="bank1",RHSWorkspace=toadd,OutputWorkspace="bank1") |
---|
922 | Scale(InputWorkspace="bank1",OutputWorkspace="bank1",Factor=0.111111111111111) |
---|
923 | SaveGSS(InputWorkspace="bank1",Filename=gssfile,Append=False,Bank=1) |
---|
924 | ConvertUnits(InputWorkspace="bank1",OutputWorkspace="bank1",Target="dSpacing") |
---|
925 | SaveNexus(Filename=outfile,InputWorkspace="bank1",Append=False) |
---|
926 | for i in range(0,5): |
---|
927 | tosave="mod"+str(i+10) |
---|
928 | SaveGSS(InputWorkspace=tosave,Filename=gssfile,Append=True,Bank=i+2) |
---|
929 | ConvertUnits(InputWorkspace=tosave,OutputWorkspace=tosave,Target="dSpacing") |
---|
930 | SaveNexus(Filename=outfile,InputWorkspace=tosave,Append=True) |
---|
931 | |
---|
932 | if (debug!=True): |
---|
933 | for i in range(0,14): |
---|
934 | output="mod"+str(i+1) |
---|
935 | van="van"+str(i+1) |
---|
936 | rdata="rdata"+str(i+1) |
---|
937 | mtd.remove(rdata) |
---|
938 | mtd.remove(van) |
---|
939 | mtd.remove(output) |
---|
940 | mtd.remove("bank1") |
---|
941 | |
---|
942 | elif (mode=="groups"): |
---|
943 | CloneWorkspace(InputWorkspace="mod1",OutputWorkspace="group1") |
---|
944 | CloneWorkspace(InputWorkspace="mod4",OutputWorkspace="group2") |
---|
945 | CloneWorkspace(InputWorkspace="mod7",OutputWorkspace="group3") |
---|
946 | for i in range(1,3): |
---|
947 | toadd="mod"+str(i+1) |
---|
948 | Plus(LHSWorkspace="group1",RHSWorkspace=toadd,OutputWorkspace="group1") |
---|
949 | Scale(InputWorkspace="group1",OutputWorkspace="group1",Factor=0.333333333333) |
---|
950 | for i in range(1,3): |
---|
951 | toadd="mod"+str(i+4) |
---|
952 | Plus(LHSWorkspace="group2",RHSWorkspace=toadd,OutputWorkspace="group2") |
---|
953 | Scale(InputWorkspace="group2",OutputWorkspace="group2",Factor=0.333333333333) |
---|
954 | for i in range(1,3): |
---|
955 | toadd="mod"+str(i+7) |
---|
956 | Plus(LHSWorkspace="group3",RHSWorkspace=toadd,OutputWorkspace="group3") |
---|
957 | Scale(InputWorkspace="group3",OutputWorkspace="group3",Factor=0.333333333333) |
---|
958 | Plus(LHSWorkspace="group2",RHSWorkspace="group3",OutputWorkspace="group23") |
---|
959 | Scale(InputWorkspace="group23",OutputWorkspace="group23",Factor=0.5) |
---|
960 | SaveGSS(InputWorkspace="group1",Filename=gssfile,Append=False,Bank=1) |
---|
961 | ConvertUnits(InputWorkspace="group1",OutputWorkspace="group1",Target="dSpacing") |
---|
962 | SaveNexus(Filename=outfile,InputWorkspace="group1",Append=False) |
---|
963 | SaveGSS(InputWorkspace="group2",Filename=gssfile,Append=True,Bank=2) |
---|
964 | ConvertUnits(InputWorkspace="group2",OutputWorkspace="group2",Target="dSpacing") |
---|
965 | SaveNexus(Filename=outfile,InputWorkspace="group2",Append=True) |
---|
966 | SaveGSS(InputWorkspace="group3",Filename=gssfile,Append=True,Bank=3) |
---|
967 | ConvertUnits(InputWorkspace="group3",OutputWorkspace="group3",Target="dSpacing") |
---|
968 | SaveNexus(Filename=outfile,InputWorkspace="group3",Append=True) |
---|
969 | SaveGSS(InputWorkspace="group23",Filename=gssfile,Append=True,Bank=4) |
---|
970 | ConvertUnits(InputWorkspace="group23",OutputWorkspace="group23",Target="dSpacing") |
---|
971 | SaveNexus(Filename=outfile,InputWorkspace="group23",Append=True) |
---|
972 | for i in range(0,3): |
---|
973 | tosave="mod"+str(i+10) |
---|
974 | SaveGSS(InputWorkspace=tosave,Filename=gssfile,Append=True,Bank=i+5) |
---|
975 | ConvertUnits(InputWorkspace=tosave,OutputWorkspace=tosave,Target="dSpacing") |
---|
976 | SaveNexus(Filename=outfile,InputWorkspace=tosave,Append=True) |
---|
977 | if (debug!=True): |
---|
978 | for i in range(0,14): |
---|
979 | output="mod"+str(i+1) |
---|
980 | van="van"+str(i+1) |
---|
981 | rdata="rdata"+str(i+1) |
---|
982 | mtd.remove(rdata) |
---|
983 | mtd.remove(van) |
---|
984 | mtd.remove(output) |
---|
985 | mtd.remove("group1") |
---|
986 | mtd.remove("group2") |
---|
987 | mtd.remove("group3") |
---|
988 | mtd.remove("group23") |
---|
989 | |
---|
990 | elif (mode=="trans"): |
---|
991 | CloneWorkspace(InputWorkspace="mod1",OutputWorkspace="bank1") |
---|
992 | for i in range(1,9): |
---|
993 | toadd="mod"+str(i+1) |
---|
994 | Plus(LHSWorkspace="bank1",RHSWorkspace=toadd,OutputWorkspace="bank1") |
---|
995 | Scale(InputWorkspace="bank1",OutputWorkspace="bank1",Factor=0.111111111111111) |
---|
996 | if (atten): |
---|
997 | ConvertUnits(InputWorkspace="bank1",OutputWorkspace="bank1",Target="dSpacing") |
---|
998 | CloneWorkspace(InputWorkspace="bank1",OutputWorkspace=outwork+"_noatten") |
---|
999 | PEARL_atten("bank1","bank1") |
---|
1000 | ConvertUnits(InputWorkspace="bank1",OutputWorkspace="bank1",Target="TOF") |
---|
1001 | |
---|
1002 | SaveGSS(InputWorkspace="bank1",Filename=gssfile,Append=False,Bank=1) |
---|
1003 | SaveFocusedXYE(InputWorkspace="bank1",Filename=tof_xye_file,Append=False,IncludeHeader=False) |
---|
1004 | ConvertUnits(InputWorkspace="bank1",OutputWorkspace="bank1",Target="dSpacing") |
---|
1005 | SaveFocusedXYE(InputWorkspace="bank1",Filename=d_xye_file,Append=False,IncludeHeader=False) |
---|
1006 | SaveNexus(Filename=outfile,InputWorkspace="bank1",Append=False) |
---|
1007 | for i in range(0,9): |
---|
1008 | tosave="mod"+str(i+1) |
---|
1009 | #SaveGSS(tosave,Filename=gssfile,Append=True,Bank=i+2) |
---|
1010 | ConvertUnits(InputWorkspace=tosave,OutputWorkspace=tosave,Target="dSpacing") |
---|
1011 | SaveNexus(Filename=outfile,InputWorkspace=tosave,Append=True) |
---|
1012 | |
---|
1013 | if (debug!=True): |
---|
1014 | for i in range(0,14): |
---|
1015 | output="mod"+str(i+1) |
---|
1016 | van="van"+str(i+1) |
---|
1017 | rdata="rdata"+str(i+1) |
---|
1018 | mtd.remove(rdata) |
---|
1019 | mtd.remove(van) |
---|
1020 | mtd.remove(output) |
---|
1021 | mtd.remove("bank1") |
---|
1022 | |
---|
1023 | elif (mode=="mods"): |
---|
1024 | for i in range(0,12): |
---|
1025 | output="mod"+str(i+1) |
---|
1026 | van="van"+str(i+1) |
---|
1027 | rdata="rdata"+str(i+1) |
---|
1028 | if (i==0): |
---|
1029 | SaveGSS(InputWorkspace=output,Filename=gssfile,Append=False,Bank=i+1) |
---|
1030 | ConvertUnits(InputWorkspace=output,OutputWorkspace=output,Target="dSpacing") |
---|
1031 | SaveNexus(Filename=outfile,InputWorkspace=output,Append=False) |
---|
1032 | else: |
---|
1033 | SaveGSS(InputWorkspace=output,Filename=gssfile,Append=True,Bank=i+1) |
---|
1034 | ConvertUnits(InputWorkspace=output,OutputWorkspace=output,Target="dSpacing") |
---|
1035 | SaveNexus(Filename=outfile,InputWorkspace=output,Append=True) |
---|
1036 | if (debug!=True): |
---|
1037 | mtd.remove(rdata) |
---|
1038 | mtd.remove(van) |
---|
1039 | mtd.remove(output) |
---|
1040 | |
---|
1041 | else: |
---|
1042 | print "Sorry I don't know that mode", mode |
---|
1043 | return |
---|
1044 | |
---|
1045 | LoadNexus(Filename=outfile,OutputWorkspace=outwork) |
---|
1046 | return outwork |
---|
1047 | |
---|
1048 | |
---|
1049 | def PEARL_createvan(van,empty,ext="raw",fmode="all",ttmode="TT88",nvanfile="P:\Mantid\\Calibration\\van_spline_all_cycle_11_1.nxs",nspline=60,absorb=True,debug=False): |
---|
1050 | global mode |
---|
1051 | global tt_mode |
---|
1052 | mode=fmode |
---|
1053 | tt_mode=ttmode |
---|
1054 | |
---|
1055 | PEARL_getcycle(van) |
---|
1056 | PEARL_getcalibfiles() |
---|
1057 | wvan="wvan" |
---|
1058 | wempty="wempty" |
---|
1059 | print "Creating ", nvanfile |
---|
1060 | PEARL_read(van,"raw",wvan) |
---|
1061 | PEARL_read(empty,"raw",wempty) |
---|
1062 | Minus(LHSWorkspace=wvan,RHSWorkspace=wempty,OutputWorkspace=wvan) |
---|
1063 | print "read van and empty" |
---|
1064 | if (debug!=True): |
---|
1065 | mtd.remove(wempty) |
---|
1066 | |
---|
1067 | if(absorb==True): |
---|
1068 | print "Correcting Vanadium for absorbtion" |
---|
1069 | ConvertUnits(InputWorkspace=wvan,OutputWorkspace=wvan,Target="Wavelength") |
---|
1070 | print "This will create", vabsorbfile |
---|
1071 | # Comment out 3 lines below if absorbtion file exists and uncomment the load line |
---|
1072 | #CreateSampleShape(wvan,'<sphere id="sphere_1"> <centre x="0" y="0" z= "0" /> <radius val="0.005" /> </sphere>') |
---|
1073 | #AbsorptionCorrection(InputWorkspace=wvan,OutputWorkspace="T",AttenuationXSection="5.08", ScatteringXSection="5.1",SampleNumberDensity="0.072",NumberOfWavelengthPoints="25",ElementSize="0.05") |
---|
1074 | #SaveNexus(Filename=vabsorbfile,InputWorkspace="T",Append=False) |
---|
1075 | LoadNexus(Filename=vabsorbfile,OutputWorkspace="T") |
---|
1076 | RebinToWorkspace(WorkspaceToRebin=wvan,WorkspaceToMatch="T",OutputWorkspace=wvan) |
---|
1077 | Divide(LHSWorkspace=wvan,RHSWorkspace="T",OutputWorkspace=wvan) |
---|
1078 | if (debug!=True): |
---|
1079 | mtd.remove("T") |
---|
1080 | |
---|
1081 | ConvertUnits(InputWorkspace=wvan,OutputWorkspace=wvan,Target="TOF") |
---|
1082 | trange="100,-0.0006,19990" |
---|
1083 | print "Cropping TOF range to ",trange |
---|
1084 | Rebin(InputWorkspace=wvan,OutputWorkspace=wvan,Params=trange) |
---|
1085 | #tmin,tmax=PEARL_gettofrange() |
---|
1086 | #print "Cropping TOF range to ",tmin,tmax |
---|
1087 | #CropWorkspace(wvan,wvan,XMin=tmin,XMax=tmax) |
---|
1088 | if (debug==True): |
---|
1089 | print "About to focus" |
---|
1090 | vanfoc="vanfoc_"+cycle |
---|
1091 | AlignDetectors(InputWorkspace=wvan,OutputWorkspace=wvan,CalibrationFile=calfile) |
---|
1092 | DiffractionFocussing(InputWorkspace=wvan,OutputWorkspace=vanfoc,GroupingFileName=groupfile) |
---|
1093 | ConvertUnits(InputWorkspace=vanfoc,OutputWorkspace=vanfoc,Target="TOF") |
---|
1094 | trange="150,-0.0006,19900" |
---|
1095 | print "Cropping TOF range to ",trange |
---|
1096 | Rebin(InputWorkspace=vanfoc,OutputWorkspace=vanfoc,Params=trange) |
---|
1097 | ConvertUnits(InputWorkspace=vanfoc,OutputWorkspace=vanfoc,Target="dSpacing") |
---|
1098 | |
---|
1099 | if (debug!=True): |
---|
1100 | mtd.remove(wvan) |
---|
1101 | |
---|
1102 | |
---|
1103 | |
---|
1104 | |
---|
1105 | |
---|
1106 | if (instver=="new2"): |
---|
1107 | ConvertUnits(InputWorkspace=vanfoc,OutputWorkspace="vanmask",Target="dSpacing") |
---|
1108 | if (debug!=True): |
---|
1109 | mtd.remove(vanfoc) |
---|
1110 | |
---|
1111 | #remove bragg peaks before spline |
---|
1112 | |
---|
1113 | print "About to strip Work=0" |
---|
1114 | StripPeaks(InputWorkspace="vanmask",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=0) |
---|
1115 | print "About to strip Work=1" |
---|
1116 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=1) |
---|
1117 | print "About to strip Work=2" |
---|
1118 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=2) |
---|
1119 | print "About to strip Work=3" |
---|
1120 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=3) |
---|
1121 | print "About to strip Work=4" |
---|
1122 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=4) |
---|
1123 | print "About to strip Work=5" |
---|
1124 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=5) |
---|
1125 | print "About to strip Work=6" |
---|
1126 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=6) |
---|
1127 | print "About to strip Work=7" |
---|
1128 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=7) |
---|
1129 | print "About to strip Work=8" |
---|
1130 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=8) |
---|
1131 | print "About to strip Work=9" |
---|
1132 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=9) |
---|
1133 | print "About to strip Work=10" |
---|
1134 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=10) |
---|
1135 | print "About to strip Work=11" |
---|
1136 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=11) |
---|
1137 | print "About to strip Work=12" |
---|
1138 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=100, Tolerance=10, WorkspaceIndex=12) |
---|
1139 | print "About to strip Work=13" |
---|
1140 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=60, Tolerance=10, WorkspaceIndex=13) |
---|
1141 | |
---|
1142 | #run twice on low angle as peaks are very broad |
---|
1143 | print "About to strip Work=12 (again)" |
---|
1144 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=100, Tolerance=10, WorkspaceIndex=12) |
---|
1145 | print "About to strip Work=13 (again)" |
---|
1146 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=60, Tolerance=10, WorkspaceIndex=13) |
---|
1147 | |
---|
1148 | print "Finished striping-out peaks..." |
---|
1149 | |
---|
1150 | if (debug!=True): |
---|
1151 | mtd.remove("vanmask") |
---|
1152 | |
---|
1153 | if (debug!=True): |
---|
1154 | print "Not in debug mode so will delete all temporary workspaces" |
---|
1155 | |
---|
1156 | ConvertUnits(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",Target="TOF") |
---|
1157 | |
---|
1158 | print "Starting splines..." |
---|
1159 | |
---|
1160 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline1",WorkspaceIndex=0,NCoeff=nspline) |
---|
1161 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline2",WorkspaceIndex=1,NCoeff=nspline) |
---|
1162 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline3",WorkspaceIndex=2,NCoeff=nspline) |
---|
1163 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline4",WorkspaceIndex=3,NCoeff=nspline) |
---|
1164 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline5",WorkspaceIndex=4,NCoeff=nspline) |
---|
1165 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline6",WorkspaceIndex=5,NCoeff=nspline) |
---|
1166 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline7",WorkspaceIndex=6,NCoeff=nspline) |
---|
1167 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline8",WorkspaceIndex=7,NCoeff=nspline) |
---|
1168 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline9",WorkspaceIndex=8,NCoeff=nspline) |
---|
1169 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline10",WorkspaceIndex=9,NCoeff=nspline) |
---|
1170 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline11",WorkspaceIndex=10,NCoeff=nspline) |
---|
1171 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline12",WorkspaceIndex=11,NCoeff=nspline) |
---|
1172 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline13",WorkspaceIndex=12,NCoeff=nspline) |
---|
1173 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline14",WorkspaceIndex=13,NCoeff=nspline) |
---|
1174 | |
---|
1175 | #ConvertUnits("spline1","spline1","TOF") |
---|
1176 | #ConvertUnits("spline2","spline2","TOF") |
---|
1177 | #ConvertUnits("spline3","spline3","TOF") |
---|
1178 | #ConvertUnits("spline4","spline4","TOF") |
---|
1179 | #ConvertUnits("spline5","spline5","TOF") |
---|
1180 | #ConvertUnits("spline6","spline6","TOF") |
---|
1181 | #ConvertUnits("spline7","spline7","TOF") |
---|
1182 | #ConvertUnits("spline8","spline8","TOF") |
---|
1183 | #ConvertUnits("spline9","spline9","TOF") |
---|
1184 | #ConvertUnits("spline10","spline10","TOF") |
---|
1185 | #ConvertUnits("spline11","spline11","TOF") |
---|
1186 | #ConvertUnits("spline12","spline12","TOF") |
---|
1187 | SaveNexus(Filename=nvanfile,InputWorkspace="spline1",Append=False) |
---|
1188 | SaveNexus(Filename=nvanfile,InputWorkspace="spline2",Append=True) |
---|
1189 | SaveNexus(Filename=nvanfile,InputWorkspace="spline3",Append=True) |
---|
1190 | SaveNexus(Filename=nvanfile,InputWorkspace="spline4",Append=True) |
---|
1191 | SaveNexus(Filename=nvanfile,InputWorkspace="spline5",Append=True) |
---|
1192 | SaveNexus(Filename=nvanfile,InputWorkspace="spline6",Append=True) |
---|
1193 | SaveNexus(Filename=nvanfile,InputWorkspace="spline7",Append=True) |
---|
1194 | SaveNexus(Filename=nvanfile,InputWorkspace="spline8",Append=True) |
---|
1195 | SaveNexus(Filename=nvanfile,InputWorkspace="spline9",Append=True) |
---|
1196 | SaveNexus(Filename=nvanfile,InputWorkspace="spline10",Append=True) |
---|
1197 | SaveNexus(Filename=nvanfile,InputWorkspace="spline11",Append=True) |
---|
1198 | SaveNexus(Filename=nvanfile,InputWorkspace="spline12",Append=True) |
---|
1199 | SaveNexus(Filename=nvanfile,InputWorkspace="spline13",Append=True) |
---|
1200 | SaveNexus(Filename=nvanfile,InputWorkspace="spline14",Append=True) |
---|
1201 | if (debug!=True): |
---|
1202 | mtd.remove("vanstrip") |
---|
1203 | mtd.remove("spline1") |
---|
1204 | mtd.remove("spline2") |
---|
1205 | mtd.remove("spline3") |
---|
1206 | mtd.remove("spline4") |
---|
1207 | mtd.remove("spline5") |
---|
1208 | mtd.remove("spline6") |
---|
1209 | mtd.remove("spline7") |
---|
1210 | mtd.remove("spline8") |
---|
1211 | mtd.remove("spline9") |
---|
1212 | mtd.remove("spline10") |
---|
1213 | mtd.remove("spline11") |
---|
1214 | mtd.remove("spline12") |
---|
1215 | mtd.remove("spline13") |
---|
1216 | mtd.remove("spline14") |
---|
1217 | elif (instver=="new"): |
---|
1218 | ConvertUnits(InputWorkspace=vanfoc,OutputWorkspace="vanmask",Target="dSpacing") |
---|
1219 | if (debug!=True): |
---|
1220 | mtd.remove(vanfoc) |
---|
1221 | |
---|
1222 | #remove bragg peaks before spline |
---|
1223 | StripPeaks(InputWorkspace="vanmask",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=0) |
---|
1224 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=1) |
---|
1225 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=2) |
---|
1226 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=3) |
---|
1227 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=4) |
---|
1228 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=5) |
---|
1229 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=6) |
---|
1230 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=7) |
---|
1231 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=8) |
---|
1232 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=9) |
---|
1233 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=10) |
---|
1234 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=8, WorkspaceIndex=11) |
---|
1235 | |
---|
1236 | if (debug!=True): |
---|
1237 | mtd.remove("vanmask") |
---|
1238 | |
---|
1239 | if (debug!=True): |
---|
1240 | print "Not in debug mode so will delete all temporary workspaces" |
---|
1241 | |
---|
1242 | ConvertUnits(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",Target="TOF") |
---|
1243 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline1",WorkspaceIndex=0,NCoeff=nspline) |
---|
1244 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline2",WorkspaceIndex=1,NCoeff=nspline) |
---|
1245 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline3",WorkspaceIndex=2,NCoeff=nspline) |
---|
1246 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline4",WorkspaceIndex=3,NCoeff=nspline) |
---|
1247 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline5",WorkspaceIndex=4,NCoeff=nspline) |
---|
1248 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline6",WorkspaceIndex=5,NCoeff=nspline) |
---|
1249 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline7",WorkspaceIndex=6,NCoeff=nspline) |
---|
1250 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline8",WorkspaceIndex=7,NCoeff=nspline) |
---|
1251 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline9",WorkspaceIndex=8,NCoeff=nspline) |
---|
1252 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline10",WorkspaceIndex=9,NCoeff=nspline) |
---|
1253 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline11",WorkspaceIndex=10,NCoeff=nspline) |
---|
1254 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline12",WorkspaceIndex=11,NCoeff=nspline) |
---|
1255 | #ConvertUnits("spline1","spline1","TOF") |
---|
1256 | #ConvertUnits("spline2","spline2","TOF") |
---|
1257 | #ConvertUnits("spline3","spline3","TOF") |
---|
1258 | #ConvertUnits("spline4","spline4","TOF") |
---|
1259 | #ConvertUnits("spline5","spline5","TOF") |
---|
1260 | #ConvertUnits("spline6","spline6","TOF") |
---|
1261 | #ConvertUnits("spline7","spline7","TOF") |
---|
1262 | #ConvertUnits("spline8","spline8","TOF") |
---|
1263 | #ConvertUnits("spline9","spline9","TOF") |
---|
1264 | #ConvertUnits("spline10","spline10","TOF") |
---|
1265 | #ConvertUnits("spline11","spline11","TOF") |
---|
1266 | #ConvertUnits("spline12","spline12","TOF") |
---|
1267 | SaveNexus(Filename=nvanfile,InputWorkspace="spline1",Append=False) |
---|
1268 | SaveNexus(Filename=nvanfile,InputWorkspace="spline2",Append=True) |
---|
1269 | SaveNexus(Filename=nvanfile,InputWorkspace="spline3",Append=True) |
---|
1270 | SaveNexus(Filename=nvanfile,InputWorkspace="spline4",Append=True) |
---|
1271 | SaveNexus(Filename=nvanfile,InputWorkspace="spline5",Append=True) |
---|
1272 | SaveNexus(Filename=nvanfile,InputWorkspace="spline6",Append=True) |
---|
1273 | SaveNexus(Filename=nvanfile,InputWorkspace="spline7",Append=True) |
---|
1274 | SaveNexus(Filename=nvanfile,InputWorkspace="spline8",Append=True) |
---|
1275 | SaveNexus(Filename=nvanfile,InputWorkspace="spline9",Append=True) |
---|
1276 | SaveNexus(Filename=nvanfile,InputWorkspace="spline10",Append=True) |
---|
1277 | SaveNexus(Filename=nvanfile,InputWorkspace="spline11",Append=True) |
---|
1278 | SaveNexus(Filename=nvanfile,InputWorkspace="spline12",Append=True) |
---|
1279 | if (debug!=True): |
---|
1280 | mtd.remove("vanstrip") |
---|
1281 | mtd.remove("spline1") |
---|
1282 | mtd.remove("spline2") |
---|
1283 | mtd.remove("spline3") |
---|
1284 | mtd.remove("spline4") |
---|
1285 | mtd.remove("spline5") |
---|
1286 | mtd.remove("spline6") |
---|
1287 | mtd.remove("spline7") |
---|
1288 | mtd.remove("spline8") |
---|
1289 | mtd.remove("spline9") |
---|
1290 | mtd.remove("spline10") |
---|
1291 | mtd.remove("spline11") |
---|
1292 | mtd.remove("spline12") |
---|
1293 | elif (instver=="old"): |
---|
1294 | ConvertUnits(InputWorkspace=vanfoc,OutputWorkspace="vanmask",Target="dSpacing") |
---|
1295 | if (debug!=True): |
---|
1296 | mtd.remove(vanfoc) |
---|
1297 | |
---|
1298 | #remove bragg peaks before spline |
---|
1299 | StripPeaks(InputWorkspace="vanmask",OutputWorkspace="vanstrip",FWHM=15, Tolerance=6, WorkspaceIndex=0) |
---|
1300 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=6, WorkspaceIndex=2) |
---|
1301 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=15, Tolerance=6, WorkspaceIndex=3) |
---|
1302 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=40, Tolerance=12, WorkspaceIndex=1) |
---|
1303 | StripPeaks(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",FWHM=60, Tolerance=12, WorkspaceIndex=1) |
---|
1304 | |
---|
1305 | |
---|
1306 | |
---|
1307 | if (debug!=True): |
---|
1308 | mtd.remove("vanmask") |
---|
1309 | |
---|
1310 | #Mask low d region that is zero before spline |
---|
1311 | for reg in range(0,4): |
---|
1312 | if (reg==1): |
---|
1313 | MaskBins(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",XMin=0,XMax=0.14, SpectraList=reg) |
---|
1314 | else: |
---|
1315 | MaskBins(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",XMin=0,XMax=0.06, SpectraList=reg) |
---|
1316 | |
---|
1317 | if (debug!=True): |
---|
1318 | print "Not in debug mode so will delete all temporary workspaces" |
---|
1319 | |
---|
1320 | ConvertUnits(InputWorkspace="vanstrip",OutputWorkspace="vanstrip",Target="TOF") |
---|
1321 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline1",WorkspaceIndex=0,NCoeff=100) |
---|
1322 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline2",WorkspaceIndex=1,NCoeff=80) |
---|
1323 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline3",WorkspaceIndex=2,NCoeff=100) |
---|
1324 | SplineBackground(InputWorkspace="vanstrip",OutputWorkspace="spline4",WorkspaceIndex=3,NCoeff=100) |
---|
1325 | #ConvertUnits("spline1","spline1","TOF") |
---|
1326 | #ConvertUnits("spline2","spline2","TOF") |
---|
1327 | #ConvertUnits("spline3","spline3","TOF") |
---|
1328 | #ConvertUnits("spline4","spline4","TOF") |
---|
1329 | SaveNexus(Filename=nvanfile,InputWorkspace="spline1",Append=False) |
---|
1330 | SaveNexus(Filename=nvanfile,InputWorkspace="spline2",Append=True) |
---|
1331 | SaveNexus(Filename=nvanfile,InputWorkspace="spline3",Append=True) |
---|
1332 | SaveNexus(Filename=nvanfile,InputWorkspace="spline4",Append=True) |
---|
1333 | if (debug!=True): |
---|
1334 | mtd.remove("vanstrip") |
---|
1335 | mtd.remove("spline1") |
---|
1336 | mtd.remove("spline2") |
---|
1337 | mtd.remove("spline3") |
---|
1338 | mtd.remove("spline4") |
---|
1339 | else: |
---|
1340 | print "Sorry I don't know that mode" |
---|
1341 | return |
---|
1342 | |
---|
1343 | |
---|
1344 | LoadNexus(Filename=nvanfile,OutputWorkspace="Van_data") |
---|
1345 | |
---|
1346 | return |
---|
1347 | |
---|
1348 | def PEARL_createcal(calruns, noffsetfile="C:\PEARL\\pearl_offset_11_2.cal"): |
---|
1349 | |
---|
1350 | PEARL_getcycle(calruns) |
---|
1351 | |
---|
1352 | print "Instrument version is ",instver |
---|
1353 | |
---|
1354 | if (instver=="new2"): |
---|
1355 | wcal="cal_raw" |
---|
1356 | PEARL_read(calruns,"raw",wcal) |
---|
1357 | Rebin(InputWorkspace=wcal,OutputWorkspace=wcal,Params="100,-0.0006,19950") |
---|
1358 | ConvertUnits(InputWorkspace=wcal,OutputWorkspace="cal_inD",Target="dSpacing") |
---|
1359 | Rebin(InputWorkspace="cal_inD",OutputWorkspace="cal_Drebin",Params="1.8,0.002,2.1") |
---|
1360 | CrossCorrelate(InputWorkspace="cal_Drebin",OutputWorkspace="crosscor",ReferenceSpectra=20,WorkspaceIndexMin=9,WorkspaceIndexMax=1063,XMin=1.8,XMax=2.1) |
---|
1361 | #Ceo Cell refeined to 5.4102(3) so 220 is 1.912795 |
---|
1362 | GetDetectorOffsets(InputWorkspace="crosscor",OutputWorkspace="OutputOffsets",Step=0.002,DReference=1.912795,XMin=-200,XMax=200,GroupingFileName=noffsetfile) |
---|
1363 | AlignDetectors(InputWorkspace=wcal,OutputWorkspace="cal_aligned",CalibrationFile=noffsetfile) |
---|
1364 | DiffractionFocussing(InputWorkspace="cal_aligned",OutputWorkspace="cal_grouped",GroupingFileName=groupfile) |
---|
1365 | elif (instver=="new"): |
---|
1366 | wcal="cal_raw" |
---|
1367 | PEARL_read(calruns,"raw",wcal) |
---|
1368 | Rebin(InputWorkspace=wcal,OutputWorkspace=wcal,Params="100,-0.0006,19950") |
---|
1369 | ConvertUnits(InputWorkspace=wcal,OutputWorkspace="cal_inD",Target="dSpacing") |
---|
1370 | Rebin(InputWorkspace="cal_inD",OutputWorkspace="cal_Drebin",Params="1.8,0.002,2.1") |
---|
1371 | CrossCorrelate(InputWorkspace="cal_Drebin",OutputWorkspace="crosscor",ReferenceSpectra=20,WorkspaceIndexMin=9,WorkspaceIndexMax=943,XMin=1.8,XMax=2.1) |
---|
1372 | #Ceo Cell refeined to 5.4102(3) so 220 is 1.912795 |
---|
1373 | GetDetectorOffsets(InputWorkspace="crosscor",OutputWorkspace="OutputOffsets",Step=0.002,DReference=1.912795,XMin=-200,XMax=200,GroupingFileName=noffsetfile) |
---|
1374 | AlignDetectors(InputWorkspace=wcal,OutputWorkspace="cal_aligned",CalibrationFile=noffsetfile) |
---|
1375 | DiffractionFocussing(InputWorkspace="cal_aligned",OutputWorkspace="cal_grouped",GroupingFileName=groupfile) |
---|
1376 | else: |
---|
1377 | wcal="cal_raw" |
---|
1378 | PEARL_read(calruns,"raw",wcal) |
---|
1379 | ConvertUnits(InputWorkspace=wcal,OutputWorkspace="cal_inD",Target="dSpacing") |
---|
1380 | Rebin(InputWorkspace="cal_inD",OutputWorkspace="cal_Drebin",Params="1.8,0.002,2.1") |
---|
1381 | CrossCorrelate(InputWorkspace="cal_Drebin",OutputWorkspace="crosscor",ReferenceSpectra=500,WorkspaceIndexMin=1,WorkspaceIndexMax=1440,XMin=1.8,XMax=2.1) |
---|
1382 | #Ceo Cell refeined to 5.4102(3) so 220 is 1.912795 |
---|
1383 | GetDetectorOffsets(InputWorkspace="crosscor",OutputWorkspace="OutputOffsets",Step=0.002,DReference=1.912795,XMin=-200,XMax=200,GroupingFileName=noffsetfile) |
---|
1384 | AlignDetectors(InputWorkspace=wcal,OutputWorkspace="cal_aligned",CalibrationFile=noffsetfile) |
---|
1385 | DiffractionFocussing(InputWorkspace="cal_aligned",OutputWorkspace="cal_grouped",GroupingFileName=groupfile) |
---|
1386 | |
---|
1387 | return |
---|
1388 | |
---|
1389 | def PEARL_createcal_Si(calruns, noffsetfile="C:\PEARL\\pearl_offset_11_2.cal"): |
---|
1390 | |
---|
1391 | PEARL_getcycle(calruns) |
---|
1392 | |
---|
1393 | if (instver=="new2"): |
---|
1394 | wcal="cal_raw" |
---|
1395 | PEARL_read(calruns,"raw",wcal) |
---|
1396 | Rebin(InputWorkspace=wcal,OutputWorkspace=wcal,Params="100,-0.0006,19950") |
---|
1397 | ConvertUnits(InputWorkspace=wcal,OutputWorkspace="cal_inD",Target="dSpacing") |
---|
1398 | Rebin(InputWorkspace="cal_inD",OutputWorkspace="cal_Drebin",Params="1.71,0.002,2.1") |
---|
1399 | CrossCorrelate(InputWorkspace="cal_Drebin",OutputWorkspace="crosscor",ReferenceSpectra=20,WorkspaceIndexMin=9,WorkspaceIndexMax=1063,XMin=1.71,XMax=2.1) |
---|
1400 | GetDetectorOffsets(InputWorkspace="crosscor",OutputWorkspace="OutputOffsets",Step=0.002,DReference=1.920127251,XMin=-200,XMax=200,GroupingFileName=noffsetfile) |
---|
1401 | AlignDetectors(InputWorkspace=wcal,OutputWorkspace="cal_aligned",CalibrationFile=noffsetfile) |
---|
1402 | DiffractionFocussing(InputWorkspace="cal_aligned",OutputWorkspace="cal_grouped",GroupingFileName=groupfile) |
---|
1403 | elif (instver=="new"): |
---|
1404 | wcal="cal_raw" |
---|
1405 | PEARL_read(calruns,"raw",wcal) |
---|
1406 | Rebin(InputWorkspace=wcal,OutputWorkspace=wcal,Params="100,-0.0006,19950") |
---|
1407 | ConvertUnits(InputWorkspace=wcal,OutputWorkspace="cal_inD",Target="dSpacing") |
---|
1408 | Rebin(InputWorkspace="cal_inD",OutputWorkspace="cal_Drebin",Params="1.85,0.002,2.05") |
---|
1409 | CrossCorrelate(InputWorkspace="cal_Drebin",OutputWorkspace="crosscor",ReferenceSpectra=20,WorkspaceIndexMin=9,WorkspaceIndexMax=943,XMin=1.85,XMax=2.05) |
---|
1410 | GetDetectorOffsets(InputWorkspace="crosscor",OutputWorkspace="OutputOffsets",Step=0.002,DReference=1.920127251,XMin=-200,XMax=200,GroupingFileName=noffsetfile) |
---|
1411 | AlignDetectors(InputWorkspace=wcal,OutputWorkspace="cal_aligned",CalibrationFile=noffsetfile) |
---|
1412 | DiffractionFocussing(InputWorkspace="cal_aligned",OutputWorkspace="cal_grouped",GroupingFileName=groupfile) |
---|
1413 | else: |
---|
1414 | wcal="cal_raw" |
---|
1415 | PEARL_read(calruns,"raw",wcal) |
---|
1416 | ConvertUnits(InputWorkspace=wcal,OutputWorkspace="cal_inD",Target="dSpacing") |
---|
1417 | Rebin(InputWorkspace="cal_inD",OutputWorkspace="cal_Drebin",Params="3,0.002,3.2") |
---|
1418 | CrossCorrelate(InputWorkspace="cal_Drebin",OutputWorkspace="crosscor",ReferenceSpectra=500,WorkspaceIndexMin=1,WorkspaceIndexMax=1440,XMin=3,XMax=3.2) |
---|
1419 | GetDetectorOffsets(InputWorkspace="crosscor",OutputWorkspace="OutputOffsets",Step=0.002,DReference=1.920127251,XMin=-200,XMax=200,GroupingFileName=noffsetfile) |
---|
1420 | AlignDetectors(InputWorkspace=wcal,OutputWorkspace="cal_aligned",CalibrationFile=noffsetfile) |
---|
1421 | DiffractionFocussing(InputWorkspace="cal_aligned",OutputWorkspace="cal_grouped",GroupingFileName=groupfile) |
---|
1422 | |
---|
1423 | return |
---|
1424 | |
---|
1425 | def PEARL_creategroup(calruns, ngroupfile="C:\PEARL\\test_cal_group_11_1.cal", ngroup="bank1,bank2,bank3,bank4"): |
---|
1426 | |
---|
1427 | wcal="cal_raw" |
---|
1428 | PEARL_read(calruns,"raw",wcal) |
---|
1429 | ConvertUnits(InputWorkspace=wcal,OutputWorkspace="cal_inD",Target="dSpacing") |
---|
1430 | CreateCalFileByNames(InstrumentWorkspace=wcal,GroupingFileName=ngroupfile,GroupNames=ngroup) |
---|
1431 | return |
---|
1432 | |
---|
1433 | |
---|
1434 | def PEARL_sumspec(number,ext,mintof=500,maxtof=1000,minspec=0,maxspec=943): |
---|
1435 | |
---|
1436 | PEARL_getcycle(number) |
---|
1437 | if (instver=="old"): |
---|
1438 | maxspec=2720 |
---|
1439 | elif (instver=="new"): |
---|
1440 | maxspec=943 |
---|
1441 | else: |
---|
1442 | maxspec=1063 |
---|
1443 | |
---|
1444 | PearlLoad(number,ext,"work") |
---|
1445 | NormaliseByCurrent(InputWorkspace="work",OutputWorkspace="work") |
---|
1446 | Integration(InputWorkspace="work",OutputWorkspace="integral",RangeLower=mintof,RangeUpper=maxtof,StartWorkspaceIndex=minspec,EndWorkspaceIndex=maxspec) |
---|
1447 | mtd.remove("work") |
---|
1448 | #sumplot=plotBin("integral",0) |
---|
1449 | return |
---|
1450 | |
---|
1451 | def PEARL_sumspec_lam(number,ext,minlam=0.1,maxlam=4,minspec=8,maxspec=943): |
---|
1452 | |
---|
1453 | PEARL_getcycle(number) |
---|
1454 | if (instver=="old"): |
---|
1455 | maxspec=2720 |
---|
1456 | elif (instver=="new"): |
---|
1457 | maxspec=943 |
---|
1458 | else: |
---|
1459 | maxspec=1063 |
---|
1460 | |
---|
1461 | PearlLoad(number,ext,"work") |
---|
1462 | NormaliseByCurrent(InputWorkspace="work",OutputWorkspace="work") |
---|
1463 | AlignDetectors(InputWorkspace="work",OutputWorkspace="work",CalibrationFile=calfile) |
---|
1464 | ConvertUnits(InputWorkspace="worl",OutputWorkspace="work",Target="Wavelength") |
---|
1465 | Integration(InputWorkspace="work",OutputWorkspace="integral",RangeLower=minlam,RangeUpper=maxlam,StartWorkspaceIndex=minspec,EndWorkspaceIndex=maxspec) |
---|
1466 | mtd.remove("work") |
---|
1467 | #sumplot=plotBin("integral",0) |
---|
1468 | return |
---|
1469 | |
---|
1470 | def PEARL_atten(work,outwork,debug=False): |
---|
1471 | |
---|
1472 | #attenfile="P:\Mantid\\Attentuation\\PRL985_WC_HOYBIDE_NK_10MM_FF.OUT" |
---|
1473 | print "Correct for attenuation using", attenfile |
---|
1474 | wc_atten=PearlMCAbsorption(attenfile) |
---|
1475 | ConvertToHistogram(InputWorkspace="wc_atten",OutputWorkspace="wc_atten") |
---|
1476 | RebinToWorkspace(WorkspaceToRebin="wc_atten",WorkspaceToMatch=work,OutputWorkspace="wc_atten") |
---|
1477 | Divide(LHSWorkspace=work,RHSWorkspace="wc_atten",OutputWorkspace=outwork) |
---|
1478 | if (debug!=True): |
---|
1479 | mtd.remove("wc_atten") |
---|
1480 | return |
---|
1481 | |
---|
1482 | def PEARL_add(a_name,a_spectra,a_outname,atten=True): |
---|
1483 | |
---|
1484 | w_add_out=a_outname |
---|
1485 | gssfile=userdataprocessed+a_outname+".gss" |
---|
1486 | nxsfile=userdataprocessed+a_outname+".nxs" |
---|
1487 | |
---|
1488 | loop=0 |
---|
1489 | for i in a_spectra[:]: |
---|
1490 | loop=loop+1 |
---|
1491 | if loop ==1: |
---|
1492 | w_add1="PRL"+a_name+"_"+str(i) |
---|
1493 | elif loop ==2: |
---|
1494 | w_add2="PRL"+a_name+"_"+str(i) |
---|
1495 | Plus(LHSWorkspace=w_add1,RHSWorkspace=w_add2,OutputWorkspace=w_add_out) |
---|
1496 | else: |
---|
1497 | w_add2="PRL"+a_name+"_"+str(i) |
---|
1498 | Plus(LHSWorkspace=w_add_out,RHSWorkspace=w_add2,OutputWorkspace=w_add_out) |
---|
1499 | if (atten): |
---|
1500 | PEARL_atten(w_add_out,w_add_out) |
---|
1501 | |
---|
1502 | SaveNexus(Filename=nxsfile,InputWorkspace=w_add_out,Append=False) |
---|
1503 | ConvertUnits(InputWorkspace=w_add_out,OutputWorkspace=w_add_out,Target="TOF") |
---|
1504 | SaveGSS(InputWorkspace=w_add_out,Filename=gssfile,Append=False,Bank=i+1) |
---|
1505 | ConvertUnits(InputWorkspace=w_add_out,OutputWorkspace=w_add_out,Target="dSpacing") |
---|
1506 | |
---|
1507 | return |
---|