1 | #pragma TextEncoding = "MacRoman" |
---|
2 | #pragma rtGlobals=3 // Use modern global access method and strict wave access. |
---|
3 | #pragma IgorVersion = 7.00 |
---|
4 | |
---|
5 | |
---|
6 | // Isolation of a single detector panel for inspection, verifying the corrections, troubleshooting, etc. |
---|
7 | |
---|
8 | |
---|
9 | // show: |
---|
10 | // graph (raw + corrected?) |
---|
11 | // all the fields pertinent to the detector |
---|
12 | // all of the tables of parameters (one at a time?) |
---|
13 | // + a way to edit them if possible? or leave this to patch? |
---|
14 | // way to toggle corrections on/off |
---|
15 | // draw arcs to show concentric rings around the beam center |
---|
16 | |
---|
17 | |
---|
18 | // TODO |
---|
19 | // -- verify the flow of operations - that is, what is the state of what is displayed? After doing |
---|
20 | // the corrections, popping the detector panel will display from RAW, but really should display from ADJ |
---|
21 | // -- need labels on images to know what they are |
---|
22 | // -- does it mean anything to "not" do the non-linear correction. I think I always calculate it in the background |
---|
23 | // when the RAW data is loaded, and always use the corrected real-space distances for the calculation of q-values |
---|
24 | // (so there is no visible effect on pixels)... |
---|
25 | // -- interaction with the main data display will allow seeing the whole set of detectors. What is the benefit of |
---|
26 | // this isolation? Should I make a bigger, more visible detector image? |
---|
27 | // x- link the function to the Isolate button on the main panel |
---|
28 | // |
---|
29 | // -- figure out how to (better?) re-plot the images when swapping between LR and TB panels |
---|
30 | // -- graphically show the beam center / radius of where it is in relation to the panel |
---|
31 | // |
---|
32 | // -- when selecting the detector, set the x/y pixel sizes -- un-do this? |
---|
33 | // -- The xPixels, yPixels axis labels are not correct. The axes are scaled to the beam center, through |
---|
34 | // a call to V_RestorePanels() when the raw data is loaded. The BeamCenter panel removes this wave scaling |
---|
35 | // so that the data can be presented (and fit) purely as pixels. On the isolate panel, the scaling has not |
---|
36 | // been removed and is confusing, especially on T/B panels. |
---|
37 | // -- add a checkbox or button to remove/replace the wave scaling to the beam center. this is in a sense, |
---|
38 | // a correction to toggle. |
---|
39 | // |
---|
40 | // |
---|
41 | |
---|
42 | |
---|
43 | Function V_DetectorIsolate() |
---|
44 | DoWindow/F IsolateDetector |
---|
45 | if(V_flag==0) |
---|
46 | |
---|
47 | Execute "VC_Initialize_Space()" // initializes VCALC space, so that dummy values are present for MSK and DIV |
---|
48 | |
---|
49 | Execute "V_IsolateDetectorPanel()" |
---|
50 | endif |
---|
51 | End |
---|
52 | |
---|
53 | |
---|
54 | // |
---|
55 | // TODO - may need to adjust the display for the different pixel dimensions |
---|
56 | // ModifyGraph width={Plan,1,bottom,left} |
---|
57 | // |
---|
58 | Proc V_IsolateDetectorPanel() : Panel |
---|
59 | PauseUpdate; Silent 1 // building window... |
---|
60 | |
---|
61 | |
---|
62 | NewPanel /W=(662,418,1586,960)/N=IsolateDetector /K=1 |
---|
63 | // ShowTools/A |
---|
64 | |
---|
65 | PopupMenu popup_0,pos={169,18},size={109,20},proc=V_isoSetDetPanelPopMenuProc,title="Detector Panel" |
---|
66 | PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;ML;MR;MT;MB;B;\"" |
---|
67 | // PopupMenu popup_1,pos={200,20},size={157,20},proc=DetModelPopMenuProc,title="Model Function" |
---|
68 | // PopupMenu popup_1,mode=1,popvalue="BroadPeak",value= #"\"BroadPeak;other;\"" |
---|
69 | PopupMenu popup_2,pos={20,18},size={109,20},title="Data Source",proc=V_SetFldrPopMenuProc |
---|
70 | PopupMenu popup_2,mode=1,popvalue="RAW",value= #"\"RAW;SAM;EMP;BGD;DIV;MSK;\"" |
---|
71 | |
---|
72 | Button button_0,pos={541,79},size={130,20},proc=V_isoCorrectButtonProc,title="Apply Corrections" |
---|
73 | // Button button_1,pos={651,79},size={80,20},proc=V_isoDetFitGuessButtonProc,title="Guess" |
---|
74 | Button button_2,pos={821,20},size={80,20},proc=V_isoHelpButtonProc,title="Help" |
---|
75 | |
---|
76 | |
---|
77 | |
---|
78 | CheckBox check_0,pos={542.00,131.00},size={110.00,16.00},title="non-linear correction" |
---|
79 | CheckBox check_0,value= 0 |
---|
80 | CheckBox check_1,pos={542.00,159.00},size={110.00,16.00},title="dead time correction" |
---|
81 | CheckBox check_1,value= 0 |
---|
82 | CheckBox check_2,pos={542.00,187.00},size={110.00,16.00},title="solid angle correction" |
---|
83 | CheckBox check_2,value= 0 |
---|
84 | CheckBox check_3,pos={542.00,215.00},size={110.00,16.00},title="sensitivity (DIV) correction" |
---|
85 | CheckBox check_3,value= 0 |
---|
86 | CheckBox check_4,pos={542.00,243.00},size={110.00,16.00},title="transmission correction" |
---|
87 | CheckBox check_4,value= 0 |
---|
88 | CheckBox check_5,pos={542.00,271.00},size={110.00,16.00},title="tube shadow correction" |
---|
89 | CheckBox check_5,value= 0 |
---|
90 | CheckBox check_6,pos={542.00,300.00},size={110.00,16.00},title="monitor normalization" |
---|
91 | CheckBox check_6,value= 0 |
---|
92 | |
---|
93 | |
---|
94 | |
---|
95 | // SetDataFolder root:Packages:NIST:VSANS:Globals:Isolate |
---|
96 | |
---|
97 | // duplicate/O root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FL:data curDispPanel |
---|
98 | // SetScale/P x 0,1, curDispPanel |
---|
99 | // SetScale/P y 0,1, curDispPanel |
---|
100 | // Duplicate/O curDispPanel correctedPanel |
---|
101 | |
---|
102 | // SetDataFolder root: |
---|
103 | |
---|
104 | V_CopyHDFToWorkFolder("RAW","ADJ") |
---|
105 | |
---|
106 | // draw the correct images |
---|
107 | V_isoDrawDetPanel("FL") |
---|
108 | |
---|
109 | |
---|
110 | |
---|
111 | // edit the fit coefficients |
---|
112 | // Edit/W=(550,80,880,370)/HOST=# parameters_PeakPix2D,coef_PeakPix2D |
---|
113 | // ModifyTable width(Point)=0 |
---|
114 | // ModifyTable width(parameters_PeakPix2D)=120 |
---|
115 | // ModifyTable width(coef_PeakPix2D)=100 |
---|
116 | // RenameWindow #,T0 |
---|
117 | // SetActiveSubwindow ## |
---|
118 | |
---|
119 | |
---|
120 | EndMacro |
---|
121 | |
---|
122 | |
---|
123 | // |
---|
124 | // function to choose which detector panel to display, and then to actually display it |
---|
125 | // |
---|
126 | Function V_isoSetDetPanelPopMenuProc(pa) : PopupMenuControl |
---|
127 | STRUCT WMPopupAction &pa |
---|
128 | |
---|
129 | switch( pa.eventCode ) |
---|
130 | case 2: // mouse up |
---|
131 | Variable popNum = pa.popNum |
---|
132 | String popStr = pa.popStr |
---|
133 | |
---|
134 | // remove the old image (it may not be the right shape) |
---|
135 | // -- but make sure it exists first... |
---|
136 | String childList = ChildWindowList("IsolateDetector") |
---|
137 | Variable flag |
---|
138 | |
---|
139 | flag = WhichListItem("DetData", ChildList) //returns -1 if not in list, 0+ otherwise |
---|
140 | if(flag != -1) |
---|
141 | KillWindow IsolateDetector#DetData |
---|
142 | endif |
---|
143 | |
---|
144 | flag = WhichListItem("ModelData", ChildList) |
---|
145 | if(flag != -1) |
---|
146 | KillWindow IsolateDetector#ModelData |
---|
147 | endif |
---|
148 | |
---|
149 | // draw the correct images |
---|
150 | V_isoDrawDetPanel(popStr) |
---|
151 | |
---|
152 | break |
---|
153 | case -1: // control being killed |
---|
154 | break |
---|
155 | endswitch |
---|
156 | |
---|
157 | return 0 |
---|
158 | End |
---|
159 | |
---|
160 | |
---|
161 | // TODO - currently is hard-wired for the simulation path! |
---|
162 | // need to make it more generic, especially for RAW data |
---|
163 | // |
---|
164 | // -- need to adjust the size of the image subwindows to keep the model |
---|
165 | // calculation from spilling over onto the table (maybe just move the table) |
---|
166 | // -- need to do something for panel "B". currently ignored |
---|
167 | // -- currently the pixel sizes for "real" data is incorrect in the file |
---|
168 | // and this is why the plots are incorrectly sized |
---|
169 | // -- need to be able to display MASK and DIV data (or any data without a full set of metadata) |
---|
170 | // |
---|
171 | // |
---|
172 | // draw the selected panel and the model calculation, adjusting for the |
---|
173 | // orientation of the panel and the number of pixels, and pixel sizes |
---|
174 | // |
---|
175 | // str input is the panelStr ("FL" for example) |
---|
176 | Function V_isoDrawDetPanel(str) |
---|
177 | String str |
---|
178 | |
---|
179 | // from the selection, find the path to the data |
---|
180 | |
---|
181 | |
---|
182 | Variable xDim,yDim |
---|
183 | Variable left,top,right,bottom |
---|
184 | Variable height, width |
---|
185 | Variable left2,top2,right2,bottom2 |
---|
186 | Variable nPix_X,nPix_Y,pixSize_X,pixSize_Y |
---|
187 | |
---|
188 | |
---|
189 | // Wave dispW=root:Packages:NIST:VSANS:Globals:Isolate:curDispPanel |
---|
190 | // Wave corrW=root:Packages:NIST:VSANS:Globals:Isolate:correctedPanel |
---|
191 | |
---|
192 | //plot it in the subwindow with the proper aspect and positioning |
---|
193 | // for 48x256 (8mm x 4mm), aspect = (256/2)/48 = 2.67 (LR panels) |
---|
194 | // for 128x48 (4mm x 8 mm), aspect = 48/(128/2) = 0.75 (TB panels) |
---|
195 | |
---|
196 | |
---|
197 | // using two switches -- one to set the panel-specific dimensions |
---|
198 | // and the other to set the "common" values, some of which are based on the panel dimensions |
---|
199 | |
---|
200 | // set the source of the data. not always VCALC anymore |
---|
201 | String folder |
---|
202 | ControlInfo popup_2 |
---|
203 | folder = S_Value |
---|
204 | |
---|
205 | Variable VC_nPix_X,VC_nPix_Y,VC_pixSize_X,VC_pixSize_Y |
---|
206 | // TODO -- fix all of this mess |
---|
207 | strswitch(folder) |
---|
208 | case "VCALC": |
---|
209 | // VC_nPix_X = VCALC_get_nPix_X(str) |
---|
210 | // VC_nPix_Y = VCALC_get_nPix_Y(str) |
---|
211 | // VC_pixSize_X = VCALC_getPixSizeX(str) |
---|
212 | // VC_pixSize_Y = VCALC_getPixSizeY(str) |
---|
213 | // wave dispW = $("root:Packages:NIST:VSANS:VCALC:entry:instrument:detector_"+str+":det_"+str) |
---|
214 | // nPix_X = VC_nPix_X |
---|
215 | // nPix_Y = VC_nPix_Y |
---|
216 | // pixSize_X = VC_pixSize_X |
---|
217 | // pixSize_Y = VC_pixSize_Y |
---|
218 | |
---|
219 | break |
---|
220 | |
---|
221 | case "DIV": |
---|
222 | case "MSK": |
---|
223 | // TODO |
---|
224 | // -- this takes fake data from VCALC, which is very likely wrong for DIV data |
---|
225 | VC_nPix_X = VCALC_get_nPix_X(str) |
---|
226 | VC_nPix_Y = VCALC_get_nPix_Y(str) |
---|
227 | VC_pixSize_X = VCALC_getPixSizeX(str) |
---|
228 | VC_pixSize_Y = VCALC_getPixSizeY(str) |
---|
229 | wave dispW = $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+str+":data") |
---|
230 | nPix_X = VC_nPix_X |
---|
231 | nPix_Y = VC_nPix_Y |
---|
232 | pixSize_X = VC_pixSize_X |
---|
233 | pixSize_Y = VC_pixSize_Y |
---|
234 | break |
---|
235 | |
---|
236 | case "RAW": |
---|
237 | case "ADJ": |
---|
238 | case "SAM": |
---|
239 | case "EMP": |
---|
240 | case "BGD": |
---|
241 | wave dispW = $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+str+":data") |
---|
242 | |
---|
243 | nPix_X = V_getDet_pixel_num_x(folder,str) |
---|
244 | nPix_Y = V_getDet_pixel_num_Y(folder,str) |
---|
245 | pixSize_X = V_getDet_x_pixel_size(folder,str)/10 |
---|
246 | pixSize_Y = V_getDet_y_pixel_size(folder,str)/10 |
---|
247 | break |
---|
248 | |
---|
249 | default: |
---|
250 | return(0) |
---|
251 | endswitch |
---|
252 | |
---|
253 | |
---|
254 | // and the ADJusted wave to display |
---|
255 | wave corrW = $("root:Packages:NIST:VSANS:ADJ:entry:instrument:detector_"+str+":data") |
---|
256 | |
---|
257 | Variable scale = 5 |
---|
258 | |
---|
259 | // common values (panel position, etc) |
---|
260 | // TODO -- units are absolute, based on pixels in cm. make sure this is always correct |
---|
261 | strswitch(str) |
---|
262 | case "FL": |
---|
263 | case "FR": |
---|
264 | case "ML": |
---|
265 | case "MR": |
---|
266 | width = trunc(nPix_X*pixSize_X *scale*1.15) //48 tubes @ 8 mm |
---|
267 | height = trunc(nPix_Y*pixSize_Y *scale*0.8) //128 pixels @ 8 mm |
---|
268 | |
---|
269 | left = 20 |
---|
270 | top = 80 |
---|
271 | right = left+width |
---|
272 | bottom = top+height |
---|
273 | |
---|
274 | left2 = right + 20 |
---|
275 | right2 = left2 + width |
---|
276 | top2 = top |
---|
277 | bottom2 = bottom |
---|
278 | |
---|
279 | break |
---|
280 | case "FT": |
---|
281 | case "FB": |
---|
282 | case "MT": |
---|
283 | case "MB": |
---|
284 | width = trunc(nPix_X*pixSize_X *scale*1.) //128 pix @ 4 mm |
---|
285 | height = trunc(nPix_Y*pixSize_Y *scale) // 48 tubes @ 8 mm |
---|
286 | |
---|
287 | left = 20 |
---|
288 | top = 80 |
---|
289 | right = left+width |
---|
290 | bottom = top+height |
---|
291 | |
---|
292 | left2 = left |
---|
293 | right2 = right |
---|
294 | top2 = top + height + 20 |
---|
295 | bottom2 = bottom + height + 20 |
---|
296 | |
---|
297 | break |
---|
298 | case "B": |
---|
299 | return(0) //just exit |
---|
300 | break |
---|
301 | default: |
---|
302 | return(0) //just exit |
---|
303 | endswitch |
---|
304 | |
---|
305 | |
---|
306 | |
---|
307 | // SetDataFolder root:Packages:NIST:VSANS:Globals:Isolate |
---|
308 | // generate the new panel display and corrected panel (just a copy right now) |
---|
309 | // duplicate/O newW curDispPanel |
---|
310 | // SetScale/P x 0,1, curDispPanel |
---|
311 | // SetScale/P y 0,1, curDispPanel |
---|
312 | // Duplicate/O curDispPanel correctedPanel |
---|
313 | |
---|
314 | // need to be in the same folder as the data |
---|
315 | SetDataFolder $("root:Packages:NIST:VSANS:"+folder+":entry:instrument:detector_"+str) |
---|
316 | Wave data1 = data |
---|
317 | |
---|
318 | //draw the detector panel |
---|
319 | Display/W=(left,top,right,bottom)/HOST=# |
---|
320 | RenameWindow #,DetData |
---|
321 | AppendImage/W=IsolateDetector#DetData data1 |
---|
322 | ModifyImage/W=IsolateDetector#DetData '' ctab= {*,*,ColdWarm,0} |
---|
323 | Label left "Y pixels" |
---|
324 | Label bottom "X pixels" |
---|
325 | SetActiveSubwindow ## |
---|
326 | |
---|
327 | |
---|
328 | SetDataFolder $("root:Packages:NIST:VSANS:ADJ:entry:instrument:detector_"+str) |
---|
329 | Wave data2 = data |
---|
330 | |
---|
331 | //draw the corrected detector panel |
---|
332 | // see the main display of RAW data for example of multiple 'data' images |
---|
333 | Display/W=(left2,top2,right2,bottom2)/HOST=# |
---|
334 | RenameWindow #,ModelData |
---|
335 | AppendImage/W=IsolateDetector#ModelData data2 |
---|
336 | ModifyImage/W=IsolateDetector#ModelData '' ctab= {*,*,ColdWarm,0} // the image is called '' even though the local ref is data2 |
---|
337 | Label left "Y pixels" |
---|
338 | Label bottom "X pixels" |
---|
339 | |
---|
340 | SetActiveSubwindow ## |
---|
341 | |
---|
342 | |
---|
343 | SetDataFolder root: |
---|
344 | |
---|
345 | DoUpdate |
---|
346 | |
---|
347 | return(0) |
---|
348 | End |
---|
349 | |
---|
350 | |
---|
351 | |
---|
352 | // |
---|
353 | Function V_isoCorrectButtonProc(ba) : ButtonControl |
---|
354 | STRUCT WMButtonAction &ba |
---|
355 | |
---|
356 | Variable sav0,sav1,sav2,sav3,sav4,sav5,sav6 |
---|
357 | |
---|
358 | switch( ba.eventCode ) |
---|
359 | case 2: // mouse up |
---|
360 | // click code here |
---|
361 | |
---|
362 | // save the state of the global flags |
---|
363 | // poll the state of the checkboxes |
---|
364 | // temporarily set the global (preference) flags |
---|
365 | |
---|
366 | // CheckBox check_0,pos={542.00,131.00},size={110.00,16.00},title="non-linear correction" |
---|
367 | NVAR gDoNonLinearCor = root:Packages:NIST:VSANS:Globals:gDoNonLinearCor |
---|
368 | sav0 = gDoNonLinearCor |
---|
369 | ControlInfo check_0 |
---|
370 | gDoNonLinearCor = V_Value |
---|
371 | |
---|
372 | // CheckBox check_1,pos={542.00,159.00},size={110.00,16.00},title="dead time correction" |
---|
373 | NVAR gDoDeadTimeCor = root:Packages:NIST:VSANS:Globals:gDoDeadTimeCor |
---|
374 | sav1 = gDoDeadTimeCor |
---|
375 | ControlInfo check_1 |
---|
376 | gDoDeadTimeCor = V_Value |
---|
377 | |
---|
378 | // CheckBox check_2,pos={542.00,187.00},size={110.00,16.00},title="solid angle correction" |
---|
379 | NVAR gDoSolidAngleCor = root:Packages:NIST:VSANS:Globals:gDoSolidAngleCor |
---|
380 | sav2 = gDoSolidAngleCor |
---|
381 | ControlInfo check_2 |
---|
382 | gDoSolidAngleCor = V_Value |
---|
383 | |
---|
384 | // CheckBox check_3,pos={542.00,215.00},size={110.00,16.00},title="sensitivity (DIV) correction" |
---|
385 | NVAR gDoDIVCor = root:Packages:NIST:VSANS:Globals:gDoDIVCor |
---|
386 | sav3 = gDoDIVCor |
---|
387 | ControlInfo check_3 |
---|
388 | gDoDIVCor = V_Value |
---|
389 | |
---|
390 | // CheckBox check_4,pos={542.00,243.00},size={110.00,16.00},title="transmission correction" |
---|
391 | NVAR gDoTrans = root:Packages:NIST:VSANS:Globals:gDoTransmissionCor |
---|
392 | sav4 = gDoTrans |
---|
393 | ControlInfo check_4 |
---|
394 | gDoTrans = V_Value |
---|
395 | |
---|
396 | // CheckBox check_5,pos={542.00,271.00},size={110.00,16.00},title="tube shadow correction" |
---|
397 | NVAR gDoTubeShadowCor = root:Packages:NIST:VSANS:Globals:gDoTubeShadowCor |
---|
398 | sav5 = gDoTubeShadowCor |
---|
399 | ControlInfo check_5 |
---|
400 | gDoTubeShadowCor = V_Value |
---|
401 | |
---|
402 | // CheckBox check_6,pos={542.00,300.00},size={110.00,16.00},title="monitor normalization" |
---|
403 | NVAR gDoMonitorNormalization = root:Packages:NIST:VSANS:Globals:gDoMonitorNormalization |
---|
404 | sav6 = gDoMonitorNormalization |
---|
405 | ControlInfo check_6 |
---|
406 | gDoMonitorNormalization = V_Value |
---|
407 | |
---|
408 | |
---|
409 | |
---|
410 | // raw_to_work to apply the selected corrections |
---|
411 | // TODO -- verify that this works correctly, since ADJ has waves in use and the folder |
---|
412 | // can't be directly killed. Copy is the first step - so verify. |
---|
413 | V_Raw_to_work("ADJ") |
---|
414 | |
---|
415 | |
---|
416 | |
---|
417 | // set the globals back the the prior state |
---|
418 | gDoNonlinearCor = sav0 |
---|
419 | gDoDeadTimeCor = sav1 |
---|
420 | gDoSolidAngleCor = sav2 |
---|
421 | gDoDIVCor = sav3 |
---|
422 | gDoTrans = sav4 |
---|
423 | gDoTubeShadowCor = sav5 |
---|
424 | gDoMonitorNormalization = sav6 |
---|
425 | |
---|
426 | |
---|
427 | |
---|
428 | break |
---|
429 | case -1: // control being killed |
---|
430 | break |
---|
431 | endswitch |
---|
432 | |
---|
433 | return 0 |
---|
434 | End |
---|
435 | |
---|
436 | |
---|
437 | |
---|
438 | |
---|
439 | //// |
---|
440 | // copies the data from the popped folder (either RAW or VCALC) to ADJ |
---|
441 | // |
---|
442 | Function V_SetFldrPopMenuProc(pa) : PopupMenuControl |
---|
443 | STRUCT WMPopupAction &pa |
---|
444 | |
---|
445 | switch( pa.eventCode ) |
---|
446 | case 2: // mouse up |
---|
447 | Variable popNum = pa.popNum |
---|
448 | String popStr = pa.popStr |
---|
449 | |
---|
450 | V_CopyHDFToWorkFolder(popStr,"ADJ") |
---|
451 | |
---|
452 | break |
---|
453 | case -1: // control being killed |
---|
454 | break |
---|
455 | endswitch |
---|
456 | |
---|
457 | return 0 |
---|
458 | End |
---|
459 | |
---|
460 | |
---|
461 | Function V_isoHelpButtonProc(ba) : ButtonControl |
---|
462 | STRUCT WMButtonAction &ba |
---|
463 | |
---|
464 | switch( ba.eventCode ) |
---|
465 | case 2: // mouse up |
---|
466 | // click code here |
---|
467 | |
---|
468 | DoAlert 0,"Help file not written yet..." |
---|
469 | |
---|
470 | break |
---|
471 | case -1: // control being killed |
---|
472 | break |
---|
473 | endswitch |
---|
474 | |
---|
475 | return 0 |
---|
476 | End |
---|
477 | |
---|