1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma version=5.0 |
---|
3 | #pragma IgorVersion=6.1 |
---|
4 | |
---|
5 | |
---|
6 | ////////////////////////////////// |
---|
7 | // |
---|
8 | // TODO -- January 2107 |
---|
9 | // |
---|
10 | // This is experimental, making the patch work with list boxes as "groups" of the Nexus file structure |
---|
11 | // |
---|
12 | // some of the groupings are more natural, some will need to be re-organized for the |
---|
13 | // more natural needs of what will typically be patched in the most common cases. |
---|
14 | // |
---|
15 | /////////////////////////////// |
---|
16 | |
---|
17 | // TODOs have been inserted to comment out all of the calls that don't compile and need to be replaced |
---|
18 | |
---|
19 | // TODO |
---|
20 | // x- not all of the functions here have been prefixed with "V_", especially the action procedures from the panel |
---|
21 | // so this cannot be opened with the SANS Reduction, or there will be clashes |
---|
22 | // -- same file load/reload issue as with other operations that read a field from the file. ANY read requires |
---|
23 | // that the entire file is read in, even just to check and see if it's raw data... then there is a local |
---|
24 | // copy present to confuse matters of what was actually written |
---|
25 | // |
---|
26 | // -- for the batch entering of fields, when all of the proper beam center values are determined, then |
---|
27 | // all (2 x 9 = 18) of these values will need to be entered in all of the data files that "match" this |
---|
28 | // "configuration" - however a configuration is to be defined and differentiated from other configurations. |
---|
29 | // |
---|
30 | // -- there may be other situations where batch entering needs are |
---|
31 | // different, and this may lead to different interface choices |
---|
32 | // |
---|
33 | // -- need to add some mechanism (new panel?) to enter: |
---|
34 | // -- box coordinates |
---|
35 | // -- ABS parameters |
---|
36 | // -- averaging options -- these will have new options versus SANS (binning panels, slit mode, etc.) |
---|
37 | // |
---|
38 | // |
---|
39 | // TODO: |
---|
40 | // V_fPatch_GroupID_catTable() |
---|
41 | // V_fPatch_Purpose_catTable() |
---|
42 | // V_fPatch_Intent_catTable() |
---|
43 | /// -- these three functions are part of a growing list for faster patching. edit the file catalog, and |
---|
44 | // write out the contents of the column (vs. filename) |
---|
45 | // -- make a simple panel w/buttons (like the sort panel) to call these functions |
---|
46 | // |
---|
47 | |
---|
48 | //************************** |
---|
49 | // |
---|
50 | //procedures required to allow patching of raw vSANS data headers |
---|
51 | //information for the Patch Panel is stored in the root:Packages:NIST:VSANS:Globals:Patch subfolder |
---|
52 | // |
---|
53 | // writes changes directly to the raw data headers as requested |
---|
54 | // * note that if a data file is currently in a work folder, the (real) header on disk |
---|
55 | // will be updated, but the data in the (WORK) folder will not reflect these changes, unless |
---|
56 | // the data folder is first cleared and the data is re-loaded |
---|
57 | // |
---|
58 | //************************** |
---|
59 | |
---|
60 | //main entry procedure for displaying the Patch Panel |
---|
61 | // |
---|
62 | Proc V_PatchFiles() |
---|
63 | |
---|
64 | DoWindow/F V_Patch_Panel |
---|
65 | If(V_flag == 0) |
---|
66 | V_InitializePatchPanel() |
---|
67 | //draw panel |
---|
68 | V_Patch_Panel() |
---|
69 | Endif |
---|
70 | End |
---|
71 | |
---|
72 | //initialization of the panel, creating the necessary data folder and global |
---|
73 | //variables if necessary - |
---|
74 | // |
---|
75 | // root:Packages:NIST:VSANS:Globals: |
---|
76 | Proc V_InitializePatchPanel() |
---|
77 | //create the global variables needed to run the Patch Panel |
---|
78 | //all are kept in root:Packages:NIST:VSANS:Globals:Patch |
---|
79 | If( ! (DataFolderExists("root:Packages:NIST:VSANS:Globals:Patch")) ) |
---|
80 | //create the data folder and the globals for BOTH the Patch and Trans panels |
---|
81 | NewDataFolder/O root:Packages:NIST:VSANS:Globals:Patch |
---|
82 | Endif |
---|
83 | V_CreatePatchGlobals() //re-create them every time (so text and radio buttons are correct) |
---|
84 | End |
---|
85 | |
---|
86 | //the data folder root:Packages:NIST:VSANS:Globals:Patch must exist |
---|
87 | // |
---|
88 | Proc V_CreatePatchGlobals() |
---|
89 | //ok, create the globals |
---|
90 | String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr = "*" |
---|
91 | String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchCurLabel = "no file selected" |
---|
92 | |
---|
93 | PathInfo catPathName |
---|
94 | If(V_flag==1) |
---|
95 | String dum = S_path |
---|
96 | String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = dum |
---|
97 | else |
---|
98 | String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = "no path selected" |
---|
99 | endif |
---|
100 | String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = "none" |
---|
101 | |
---|
102 | Variable/G root:Packages:NIST:VSANS:Globals:Patch:gRadioVal = 1 |
---|
103 | |
---|
104 | |
---|
105 | SetDataFolder root:Packages:NIST:VSANS:Globals:Patch: |
---|
106 | Make/O/T/N=(10,3) PP_ListWave |
---|
107 | Make/O/B/N=(10,3) PP_SelWave |
---|
108 | Make/O/T/N=3 PP_TitleWave |
---|
109 | |
---|
110 | PP_TitleWave = {"Ch?","Label","Value"} |
---|
111 | |
---|
112 | PP_SelWave[][0] = 2^5 // checkboxes |
---|
113 | PP_SelWave[][2] = 2^1 // 3rd column editable |
---|
114 | |
---|
115 | |
---|
116 | SetDataFolder root: |
---|
117 | |
---|
118 | End |
---|
119 | |
---|
120 | |
---|
121 | //panel recreation macro for the PatchPanel... |
---|
122 | // |
---|
123 | Proc V_Patch_Panel() |
---|
124 | PauseUpdate; Silent 1 // building window... |
---|
125 | NewPanel /W=(533,50,1140,588)/K=2 as "Patch Raw VSANS Data Files" |
---|
126 | DoWindow/C V_Patch_Panel |
---|
127 | // ShowTools/A |
---|
128 | SetDataFolder root:Packages:NIST:VSANS:Globals:Patch: |
---|
129 | |
---|
130 | |
---|
131 | ModifyPanel cbRGB=(11291,48000,3012) |
---|
132 | ModifyPanel fixedSize=1 |
---|
133 | SetDrawLayer UserBack |
---|
134 | DrawLine 7,30,422,30 |
---|
135 | |
---|
136 | |
---|
137 | SetVariable PathDisplay,pos={77,7},size={310,13},title="Path" |
---|
138 | SetVariable PathDisplay,help={"This is the path to the folder that will be used to find the SANS data while patching. If no files appear in the popup, make sure that this folder is set correctly"} |
---|
139 | SetVariable PathDisplay,font="Courier",fSize=10 |
---|
140 | SetVariable PathDisplay,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr |
---|
141 | Button PathButton,pos={2,3},size={70,20},proc=V_PickPathButton,title="Pick Path" |
---|
142 | Button PathButton,help={"Select the folder containing the raw SANS data files"} |
---|
143 | Button helpButton,pos={400,3},size={25,20},proc=V_ShowPatchHelp,title="?" |
---|
144 | Button helpButton,help={"Show the help file for patching raw data headers"} |
---|
145 | PopupMenu PatchPopup,pos={4,37},size={156,19},proc=V_PatchPopMenuProc,title="File(s) to Patch" |
---|
146 | PopupMenu PatchPopup,help={"The displayed file is the one that will be edited. The entire list will be edited if \"Change All..\" is selected. \r If no items, or the wrong items appear, click on the popup to refresh. \r List items are selected from the file based on MatchString"} |
---|
147 | PopupMenu PatchPopup,mode=1,popvalue="none",value= #"root:Packages:NIST:VSANS:Globals:Patch:gPatchList" |
---|
148 | |
---|
149 | Button CHButton,pos={314,37},size={110,20},proc=V_ChangeHeaderButtonProc,title="Change Header" |
---|
150 | Button CHButton,help={"This will change the checked values (ONLY) in the single file selected in the popup."} |
---|
151 | SetVariable PMStr,pos={6,63},size={174,13},proc=V_SetMatchStrProc,title="Match String" |
---|
152 | SetVariable PMStr,help={"Enter the search string to narrow the list of files. \"*\" is the wildcard character. After entering, \"pop\" the menu to refresh the file list."} |
---|
153 | SetVariable PMStr,font="Courier",fSize=10 |
---|
154 | SetVariable PMStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr |
---|
155 | Button ChAllButton,pos={245,60},size={180,20},proc=V_ChAllHeadersButtonProc,title="Change All Headers in List" |
---|
156 | Button ChAllButton,help={"This will change the checked values (ONLY) in ALL of the files in the popup list, not just the top file. If the \"change\" checkbox for the item is not checked, nothing will be changed for that item."} |
---|
157 | Button DoneButton,pos={450,60},size={110,20},proc=V_DoneButtonProc,title="Done Patching" |
---|
158 | Button DoneButton,help={"When done Patching files, this will close this control panel."} |
---|
159 | CheckBox check0,pos={18,80},size={40,15},title="Run #",value= 1,mode=1,proc=V_MatchCheckProc |
---|
160 | CheckBox check1,pos={78,80},size={40,15},title="Text",value= 0,mode=1,proc=V_MatchCheckProc |
---|
161 | CheckBox check2,pos={138,80},size={40,15},title="Group_ID",value= 0,mode=1,proc=V_MatchCheckProc |
---|
162 | |
---|
163 | SetVariable curStr,pos={50,112},size={350,20},title="File Label:" |
---|
164 | SetVariable curStr,help={"Label of current file in popup list"} |
---|
165 | SetVariable curStr,font="Courier",fSize=10 |
---|
166 | SetVariable curStr,limits={-Inf,Inf,0},value= root:Packages:NIST:VSANS:Globals:Patch:gPatchCurLabel |
---|
167 | |
---|
168 | PopupMenu popup_0,pos={450,112},size={109,20},title="Detector Panel",proc=V_PatchPopMenuProc |
---|
169 | PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;ML;MR;MT;MB;B;\"" |
---|
170 | |
---|
171 | |
---|
172 | TabControl PatchTab,pos={20,140},size={570,380} |
---|
173 | TabControl PatchTab,tabLabel(0)="Control",tabLabel(1)="Reduction",tabLabel(2)="Sample" |
---|
174 | TabControl PatchTab,tabLabel(3)="Instrument",tabLabel(4)="Detectors",tabLabel(5)="PolSANS" |
---|
175 | TabControl PatchTab,value=0,labelBack=(47748,57192,54093),proc=V_PatchTabProc |
---|
176 | |
---|
177 | |
---|
178 | ListBox list0,pos={30,170.00},size={550.00,330},proc=V_PatchListBoxProc,frame=1 |
---|
179 | ListBox list0,fSize=10,userColumnResize= 1,listWave=PP_ListWave,selWave=PP_SelWave,titleWave=PP_TitleWave |
---|
180 | ListBox list0,mode=2,widths={30,200} |
---|
181 | |
---|
182 | |
---|
183 | // put these in a tabbed? section for the 9 different panels |
---|
184 | // will it be able to patch all "FL" with the proper values, then all "FR", etc. to batchwise correct files? |
---|
185 | |
---|
186 | // TODO: add functions for these, make the intent a popup (since it's an enumerated type) |
---|
187 | |
---|
188 | // PopupMenu popup_1,pos={42,base+14*step},size={109,20},title="File intent" |
---|
189 | // PopupMenu popup_1,mode=1,popvalue="SCATTER",value= #"\"SCATTER;EMPTY;BLOCKED BEAM;TRANS;EMPTY BEAM;\"" |
---|
190 | |
---|
191 | |
---|
192 | |
---|
193 | SetDataFolder root: |
---|
194 | End |
---|
195 | |
---|
196 | // |
---|
197 | // function to control the display of the list box, based on the selection of the tab |
---|
198 | // |
---|
199 | Function V_PatchTabProc(name,tab) |
---|
200 | String name |
---|
201 | Variable tab |
---|
202 | |
---|
203 | // Print "name,number",name,tab |
---|
204 | SetDataFolder root:Packages:NIST:VSANS:Globals:Patch: |
---|
205 | |
---|
206 | Wave/T PP_listWave = PP_ListWave |
---|
207 | Wave PP_selWave = PP_selWave |
---|
208 | |
---|
209 | //clear the listWave and SelWave |
---|
210 | PP_ListWave = "" |
---|
211 | PP_SelWave = 0 |
---|
212 | |
---|
213 | Variable nRows=1 |
---|
214 | // switch based on the tab number |
---|
215 | switch(tab) |
---|
216 | case 0: |
---|
217 | //Print "tab 0 = CONTROL" |
---|
218 | |
---|
219 | V_FillListBox0(PP_ListWave,PP_SelWave) |
---|
220 | break |
---|
221 | case 1: |
---|
222 | //Print "tab 1 = REDUCTION" |
---|
223 | |
---|
224 | V_FillListBox1(PP_ListWave,PP_SelWave) |
---|
225 | break |
---|
226 | case 2: |
---|
227 | //Print "tab 2 = SAMPLE" |
---|
228 | |
---|
229 | V_FillListBox2(PP_ListWave,PP_SelWave) |
---|
230 | break |
---|
231 | case 3: |
---|
232 | //Print "tab 3 = INSTRUMENT" |
---|
233 | |
---|
234 | V_FillListBox3(PP_ListWave,PP_SelWave) |
---|
235 | break |
---|
236 | case 4: |
---|
237 | //Print "tab 4 = DETECTORS" |
---|
238 | |
---|
239 | V_FillListBox4(PP_ListWave,PP_SelWave) |
---|
240 | break |
---|
241 | case 5: |
---|
242 | //Print "tab 5 = POL_SANS" |
---|
243 | |
---|
244 | V_FillListBox5(PP_ListWave,PP_SelWave) |
---|
245 | break |
---|
246 | default: // optional default expression executed |
---|
247 | SetDataFolder root: |
---|
248 | Abort "No tab found -- PatchTabProc" // when no case matches |
---|
249 | endswitch |
---|
250 | |
---|
251 | |
---|
252 | SetDataFolder root: |
---|
253 | return(0) |
---|
254 | End |
---|
255 | |
---|
256 | // fill list boxes based on the tab |
---|
257 | // |
---|
258 | // *** if the number of elements is changed, then be sure that the variable nRows is updated |
---|
259 | // * this is the same procedure for all of the tabs |
---|
260 | // * then be sure that the new listWave assignments are properly indexed |
---|
261 | // |
---|
262 | // CONTROL |
---|
263 | // |
---|
264 | Function V_FillListBox0(listWave,selWave) |
---|
265 | Wave/T listWave |
---|
266 | Wave selWave |
---|
267 | |
---|
268 | // trust that I'm getting a valid raw data file name from the popup |
---|
269 | String fname |
---|
270 | ControlInfo/W=V_Patch_Panel PatchPopup |
---|
271 | If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0) |
---|
272 | Abort "no file selected in popup menu" //null selection |
---|
273 | else |
---|
274 | fname = S_value //selection not null |
---|
275 | Endif |
---|
276 | //prepend path for read routine |
---|
277 | PathInfo catPathName |
---|
278 | fname = S_path + fname |
---|
279 | |
---|
280 | Variable nRows = 3 |
---|
281 | Redimension/N=(nRows,3) ListWave |
---|
282 | Redimension/N=(nRows,3) selWave |
---|
283 | // clear the contents |
---|
284 | listWave = "" |
---|
285 | selWave = 0 |
---|
286 | SelWave[][0] = 2^5 // checkboxes |
---|
287 | SelWave[][2] = 2^1 // 3rd column editable |
---|
288 | |
---|
289 | |
---|
290 | |
---|
291 | listWave[0][1] = "count_time (s)" |
---|
292 | listWave[0][2] = num2str(V_getCount_time(fname)) |
---|
293 | |
---|
294 | listWave[1][1] = "detector_counts" |
---|
295 | listWave[1][2] = num2str(V_getDetector_counts(fname)) |
---|
296 | |
---|
297 | listWave[2][1] = "monitor_counts" |
---|
298 | // listWave[2][2] = num2str(V_getControlMonitorCount(fname)) |
---|
299 | listWave[2][2] = num2str(V_getBeamMonNormData(fname)) |
---|
300 | |
---|
301 | return(0) |
---|
302 | End |
---|
303 | |
---|
304 | // fill list boxes based on the tab |
---|
305 | // |
---|
306 | // REDUCTION items |
---|
307 | // |
---|
308 | Function V_FillListBox1(listWave,selWave) |
---|
309 | Wave/T listWave |
---|
310 | Wave selWave |
---|
311 | |
---|
312 | // trust that I'm getting a valid raw data file name from the popup |
---|
313 | String fname |
---|
314 | ControlInfo/W=V_Patch_Panel PatchPopup |
---|
315 | If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0) |
---|
316 | Abort "no file selected in popup menu" //null selection |
---|
317 | else |
---|
318 | fname = S_value //selection not null |
---|
319 | Endif |
---|
320 | //prepend path for read routine |
---|
321 | PathInfo catPathName |
---|
322 | fname = S_path + fname |
---|
323 | |
---|
324 | Variable nRows = 14 |
---|
325 | Redimension/N=(nRows,3) ListWave |
---|
326 | Redimension/N=(nRows,3) selWave |
---|
327 | // clear the contents |
---|
328 | listWave = "" |
---|
329 | selWave = 0 |
---|
330 | SelWave[][0] = 2^5 // checkboxes |
---|
331 | SelWave[][2] = 2^1 // 3rd column editable |
---|
332 | |
---|
333 | |
---|
334 | listWave[0][1] = "empty_beam_file_name" |
---|
335 | listWave[0][2] = V_getEmptyBeamFileName(fname) |
---|
336 | |
---|
337 | listWave[1][1] = "background_file_name" |
---|
338 | listWave[1][2] = V_getBackgroundFileName(fname) |
---|
339 | |
---|
340 | listWave[2][1] = "empty_file_name" |
---|
341 | listWave[2][2] = V_getEmptyFileName(fname) |
---|
342 | |
---|
343 | listWave[3][1] = "sensitivity_file_name" |
---|
344 | listWave[3][2] = V_getSensitivityFileName(fname) |
---|
345 | |
---|
346 | listWave[4][1] = "mask_file_name" |
---|
347 | listWave[4][2] = V_getMaskFileName(fname) |
---|
348 | |
---|
349 | listWave[5][1] = "transmission_file_name" |
---|
350 | listWave[5][2] = V_getTransmissionFileName(fname) |
---|
351 | |
---|
352 | listWave[6][1] = "intent" |
---|
353 | listWave[6][2] = V_getReduction_intent(fname) |
---|
354 | |
---|
355 | listWave[7][1] = "file_purpose" |
---|
356 | listWave[7][2] = V_getReduction_purpose(fname) |
---|
357 | |
---|
358 | listWave[8][1] = "group_id (sample)" |
---|
359 | listWave[8][2] = num2str(V_getSample_groupID(fname)) |
---|
360 | |
---|
361 | listWave[9][1] = "Box Coordinates" |
---|
362 | WAVE boxCoord = V_getBoxCoordinates(fname) |
---|
363 | listWave[9][2] = V_NumWave2List(boxCoord,";") |
---|
364 | |
---|
365 | listWave[10][1] = "box_count" |
---|
366 | listWave[10][2] = num2str(V_getBoxCounts(fname)) |
---|
367 | |
---|
368 | listWave[11][1] = "box_count_error" |
---|
369 | listWave[11][2] = num2str(V_getBoxCountsError(fname)) |
---|
370 | |
---|
371 | listWave[12][1] = "whole_trans" |
---|
372 | listWave[12][2] = num2str(V_getSampleTransWholeDetector(fname)) |
---|
373 | |
---|
374 | listWave[13][1] = "whole_trans_error" |
---|
375 | listWave[13][2] = num2str(V_getSampleTransWholeDetErr(fname)) |
---|
376 | |
---|
377 | |
---|
378 | |
---|
379 | return(0) |
---|
380 | End |
---|
381 | |
---|
382 | // fill list boxes based on the tab |
---|
383 | // |
---|
384 | // SAMPLE |
---|
385 | // |
---|
386 | Function V_FillListBox2(listWave,selWave) |
---|
387 | Wave/T listWave |
---|
388 | Wave selWave |
---|
389 | |
---|
390 | // trust that I'm getting a valid raw data file name from the popup |
---|
391 | String fname |
---|
392 | ControlInfo/W=V_Patch_Panel PatchPopup |
---|
393 | If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0) |
---|
394 | Abort "no file selected in popup menu" //null selection |
---|
395 | else |
---|
396 | fname = S_value //selection not null |
---|
397 | Endif |
---|
398 | //prepend path for read routine |
---|
399 | PathInfo catPathName |
---|
400 | fname = S_path + fname |
---|
401 | |
---|
402 | Variable nRows = 4 |
---|
403 | Redimension/N=(nRows,3) ListWave |
---|
404 | Redimension/N=(nRows,3) selWave |
---|
405 | // clear the contents |
---|
406 | listWave = "" |
---|
407 | selWave = 0 |
---|
408 | SelWave[][0] = 2^5 // checkboxes |
---|
409 | SelWave[][2] = 2^1 // 3rd column editable |
---|
410 | |
---|
411 | |
---|
412 | listWave[0][1] = "description" |
---|
413 | listWave[0][2] = V_getSampleDescription(fname) |
---|
414 | |
---|
415 | listWave[1][1] = "thickness (cm)" |
---|
416 | listWave[1][2] = num2str(V_getSampleThickness(fname)) |
---|
417 | |
---|
418 | listWave[2][1] = "transmission" |
---|
419 | listWave[2][2] = num2str(V_getSampleTransmission(fname)) |
---|
420 | |
---|
421 | listWave[3][1] = "transmission_error" |
---|
422 | listWave[3][2] = num2str(V_getSampleTransError(fname)) |
---|
423 | |
---|
424 | |
---|
425 | |
---|
426 | return(0) |
---|
427 | End |
---|
428 | |
---|
429 | // fill list boxes based on the tab |
---|
430 | // |
---|
431 | // INSTRUMENT |
---|
432 | // |
---|
433 | Function V_FillListBox3(listWave,selWave) |
---|
434 | Wave/T listWave |
---|
435 | Wave selWave |
---|
436 | |
---|
437 | // trust that I'm getting a valid raw data file name from the popup |
---|
438 | String fname |
---|
439 | ControlInfo/W=V_Patch_Panel PatchPopup |
---|
440 | If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0) |
---|
441 | Abort "no file selected in popup menu" //null selection |
---|
442 | else |
---|
443 | fname = S_value //selection not null |
---|
444 | Endif |
---|
445 | //prepend path for read routine |
---|
446 | PathInfo catPathName |
---|
447 | fname = S_path + fname |
---|
448 | |
---|
449 | Variable nRows = 13 |
---|
450 | Redimension/N=(nRows,3) ListWave |
---|
451 | Redimension/N=(nRows,3) selWave |
---|
452 | // clear the contents |
---|
453 | listWave = "" |
---|
454 | selWave = 0 |
---|
455 | SelWave[][0] = 2^5 // checkboxes |
---|
456 | SelWave[][2] = 2^1 // 3rd column editable |
---|
457 | |
---|
458 | |
---|
459 | listWave[0][1] = "attenuator_transmission" |
---|
460 | listWave[0][2] = num2str(V_getAttenuator_transmission(fname)) |
---|
461 | |
---|
462 | listWave[1][1] = "attenuator_transmission_error" |
---|
463 | listWave[1][2] = num2str(V_getAttenuator_trans_err(fname)) |
---|
464 | |
---|
465 | listWave[2][1] = "monochromator type" |
---|
466 | listWave[2][2] = V_getMonochromatorType(fname) |
---|
467 | |
---|
468 | listWave[3][1] = "wavelength (A)" |
---|
469 | listWave[3][2] = num2str(V_getWavelength(fname)) |
---|
470 | |
---|
471 | listWave[4][1] = "wavelength_spread" |
---|
472 | listWave[4][2] = num2str(V_getWavelength_spread(fname)) |
---|
473 | |
---|
474 | listWave[5][1] = "distance (source aperture to GV) (cm)" |
---|
475 | listWave[5][2] = num2str(V_getSourceAp_distance(fname)) |
---|
476 | |
---|
477 | listWave[6][1] = "source aperture size (mm)" |
---|
478 | listWave[6][2] = V_getSourceAp_size(fname) |
---|
479 | |
---|
480 | listWave[7][1] = "sample aperture size (internal) (mm)" |
---|
481 | listWave[7][2] = V_getSampleAp_size(fname) |
---|
482 | |
---|
483 | listWave[8][1] = "sample aperture(2) diam (external) (cm)" |
---|
484 | listWave[8][2] = num2str(V_getSampleAp2_size(fname)) |
---|
485 | |
---|
486 | listWave[9][1] = "beam stop diameter (Middle) (mm)" |
---|
487 | // listWave[9][2] = num2str(V_getBeamStopC2_size(fname)) |
---|
488 | listWave[9][2] = num2str(V_DeduceBeamstopDiameter(fname,"MR")) |
---|
489 | |
---|
490 | listWave[10][1] = "beam stop diameter (Back) (mm)" |
---|
491 | // listWave[10][2] = num2str(V_getBeamStopC3_size(fname)) |
---|
492 | listWave[10][2] = num2str(V_DeduceBeamstopDiameter(fname,"B")) |
---|
493 | |
---|
494 | listWave[11][1] = "sample aperture(2) to gate valve (cm)" |
---|
495 | listWave[11][2] = num2str(V_getSampleAp2_distance(fname)) |
---|
496 | |
---|
497 | listWave[12][1] = "sample to gate valve (cm)" |
---|
498 | listWave[12][2] = num2str(V_getSampleTableOffset(fname)) |
---|
499 | |
---|
500 | |
---|
501 | return(0) |
---|
502 | End |
---|
503 | |
---|
504 | |
---|
505 | // fill list boxes based on the tab |
---|
506 | // |
---|
507 | // TODO -- is this all of the fields that I want to edit? |
---|
508 | // |
---|
509 | // DETECTORS |
---|
510 | // |
---|
511 | Function V_FillListBox4(listWave,selWave) |
---|
512 | Wave/T listWave |
---|
513 | Wave selWave |
---|
514 | |
---|
515 | // trust that I'm getting a valid raw data file name from the popup |
---|
516 | String fname |
---|
517 | ControlInfo/W=V_Patch_Panel PatchPopup |
---|
518 | If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0) |
---|
519 | Abort "no file selected in popup menu" //null selection |
---|
520 | else |
---|
521 | fname = S_value //selection not null |
---|
522 | Endif |
---|
523 | //prepend path for read routine |
---|
524 | PathInfo catPathName |
---|
525 | fname = S_path + fname |
---|
526 | |
---|
527 | Variable nRows = 13 |
---|
528 | Redimension/N=(nRows,3) ListWave |
---|
529 | Redimension/N=(nRows,3) selWave |
---|
530 | // clear the contents |
---|
531 | listWave = "" |
---|
532 | selWave = 0 |
---|
533 | SelWave[][0] = 2^5 // checkboxes |
---|
534 | SelWave[][2] = 2^1 // 3rd column editable |
---|
535 | |
---|
536 | ControlInfo popup_0 // which detector panel? |
---|
537 | String detStr = S_value |
---|
538 | |
---|
539 | listWave[0][1] = "beam_center_x (cm)" |
---|
540 | listWave[0][2] = num2str(V_getDet_Beam_center_x(fname,detStr)) |
---|
541 | |
---|
542 | listWave[1][1] = "beam_center_y (cm)" |
---|
543 | listWave[1][2] = num2str(V_getDet_Beam_center_y(fname,detStr)) |
---|
544 | |
---|
545 | listWave[2][1] = "distance (nominal) (cm)" |
---|
546 | listWave[2][2] = num2str(V_getDet_NominalDistance(fname,detStr)) |
---|
547 | |
---|
548 | listWave[3][1] = "integrated_count" |
---|
549 | listWave[3][2] = num2str(V_getDet_IntegratedCount(fname,detStr)) |
---|
550 | |
---|
551 | listWave[4][1] = "pixel_fwhm_x (cm)" |
---|
552 | listWave[4][2] = num2str(V_getDet_pixel_fwhm_x(fname,detStr)) |
---|
553 | |
---|
554 | listWave[5][1] = "pixel_fwhm_y (cm)" |
---|
555 | listWave[5][2] = num2str(V_getDet_pixel_fwhm_y(fname,detStr)) |
---|
556 | |
---|
557 | listWave[6][1] = "pixel_num_x" |
---|
558 | listWave[6][2] = num2str(V_getDet_pixel_num_x(fname,detStr)) |
---|
559 | |
---|
560 | listWave[7][1] = "pixel_num_y" |
---|
561 | listWave[7][2] = num2str(V_getDet_pixel_num_y(fname,detStr)) |
---|
562 | |
---|
563 | listWave[8][1] = "setback (cm)" |
---|
564 | listWave[8][2] = num2str(V_getDet_TBSetback(fname,detStr)) |
---|
565 | |
---|
566 | if(cmpstr(detStr,"B") == 0 ||cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0 || cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0) |
---|
567 | listWave[9][1] = "lateral_offset (cm)" // "B" detector drops here |
---|
568 | listWave[9][2] = num2str(V_getDet_LateralOffset(fname,detStr)) |
---|
569 | else |
---|
570 | listWave[9][1] = "vertical_offset (cm)" |
---|
571 | listWave[9][2] = num2str(V_getDet_VerticalOffset(fname,detStr)) |
---|
572 | endif |
---|
573 | |
---|
574 | listWave[10][1] = "x_pixel_size (mm)" |
---|
575 | listWave[10][2] = num2str(V_getDet_x_pixel_size(fname,detStr)) |
---|
576 | |
---|
577 | listWave[11][1] = "y_pixel_size (mm)" |
---|
578 | listWave[11][2] = num2str(V_getDet_y_pixel_size(fname,detStr)) |
---|
579 | |
---|
580 | listWave[12][1] = "dead time (s) (back only)" |
---|
581 | listWave[12][2] = num2str(V_getDetector_deadtime_B(fname,detStr)) //returns 0 if not "B" |
---|
582 | |
---|
583 | return(0) |
---|
584 | End |
---|
585 | |
---|
586 | |
---|
587 | // fill list boxes based on the tab |
---|
588 | // |
---|
589 | // TODO -- this all needs to be filled in, once I figure out what is needed |
---|
590 | // |
---|
591 | // PolSANS |
---|
592 | // |
---|
593 | Function V_FillListBox5(listWave,selWave) |
---|
594 | Wave/T listWave |
---|
595 | Wave selWave |
---|
596 | |
---|
597 | // trust that I'm getting a valid raw data file name from the popup |
---|
598 | String fname |
---|
599 | ControlInfo/W=V_Patch_Panel PatchPopup |
---|
600 | If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0) |
---|
601 | Abort "no file selected in popup menu" //null selection |
---|
602 | else |
---|
603 | fname = S_value //selection not null |
---|
604 | Endif |
---|
605 | //prepend path for read routine |
---|
606 | PathInfo catPathName |
---|
607 | fname = S_path + fname |
---|
608 | |
---|
609 | Variable nRows = 3 |
---|
610 | Redimension/N=(nRows,3) ListWave |
---|
611 | Redimension/N=(nRows,3) selWave |
---|
612 | // clear the contents |
---|
613 | listWave = "" |
---|
614 | selWave = 0 |
---|
615 | SelWave[][0] = 2^5 // checkboxes |
---|
616 | SelWave[][2] = 2^1 // 3rd column editable |
---|
617 | |
---|
618 | |
---|
619 | listWave[0][1] = "count_time (s)" |
---|
620 | listWave[0][2] = num2str(V_getCount_time(fname)) |
---|
621 | |
---|
622 | return(0) |
---|
623 | End |
---|
624 | |
---|
625 | |
---|
626 | // TODO -- determine if I really need this --- I don't |
---|
627 | // think I really have any reason to respond to events from list box actions |
---|
628 | // or edits. the final action of patching is done with the button |
---|
629 | // |
---|
630 | Function V_PatchListBoxProc(lba) : ListBoxControl |
---|
631 | STRUCT WMListboxAction &lba |
---|
632 | |
---|
633 | Variable row = lba.row |
---|
634 | Variable col = lba.col |
---|
635 | WAVE/T/Z listWave = lba.listWave |
---|
636 | WAVE/Z selWave = lba.selWave |
---|
637 | |
---|
638 | switch( lba.eventCode ) |
---|
639 | case -1: // control being killed |
---|
640 | break |
---|
641 | case 1: // mouse down |
---|
642 | break |
---|
643 | case 3: // double click |
---|
644 | break |
---|
645 | case 4: // cell selection |
---|
646 | case 5: // cell selection plus shift key |
---|
647 | break |
---|
648 | case 6: // begin edit |
---|
649 | break |
---|
650 | case 7: // finish edit |
---|
651 | break |
---|
652 | case 13: // checkbox clicked (Igor 6.2 or later) |
---|
653 | break |
---|
654 | endswitch |
---|
655 | |
---|
656 | return 0 |
---|
657 | End |
---|
658 | |
---|
659 | |
---|
660 | |
---|
661 | |
---|
662 | |
---|
663 | |
---|
664 | //button action procedure to select the local path to the folder that |
---|
665 | //contains the vSANS data |
---|
666 | //sets catPathName, updates the path display and the popup of files (in that folder) |
---|
667 | // |
---|
668 | Function V_PickPathButton(PathButton) : ButtonControl |
---|
669 | String PathButton |
---|
670 | |
---|
671 | // call the main procedure to set the data path |
---|
672 | V_PickPath() |
---|
673 | |
---|
674 | //set the global string to the selected pathname |
---|
675 | //set a local copy of the path for Patch |
---|
676 | PathInfo/S catPathName |
---|
677 | String dum = S_path |
---|
678 | if (V_flag == 0) |
---|
679 | //path does not exist - no folder selected |
---|
680 | String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = "no folder selected" |
---|
681 | else |
---|
682 | String/G root:Packages:NIST:VSANS:Globals:Patch:gCatPathStr = dum |
---|
683 | endif |
---|
684 | |
---|
685 | //Update the pathStr variable box |
---|
686 | ControlUpdate/W=V_Patch_Panel $"PathDisplay" |
---|
687 | |
---|
688 | //then update the popup list |
---|
689 | // (don't update the list - not until someone enters a search critera) -- Jul09 |
---|
690 | // |
---|
691 | |
---|
692 | STRUCT WMSetVariableAction sva |
---|
693 | sva.eventCode = 2 |
---|
694 | V_SetMatchStrProc(sva) //this is equivalent to finding everything, typical startup case |
---|
695 | |
---|
696 | return(0) |
---|
697 | End |
---|
698 | |
---|
699 | // |
---|
700 | //returns a list of valid files (raw data, no version numbers, no averaged files) |
---|
701 | //that is semicolon delimited, and is suitable for display in a popup menu |
---|
702 | // |
---|
703 | Function/S V_xGetValidPatchPopupList() |
---|
704 | |
---|
705 | //make sure that path exists |
---|
706 | PathInfo catPathName |
---|
707 | String path = S_path |
---|
708 | if (V_flag == 0) |
---|
709 | Abort "folder path does not exist - use Pick Path button" |
---|
710 | Endif |
---|
711 | |
---|
712 | String newList = "" |
---|
713 | |
---|
714 | newList = V_GetRawDataFileList() |
---|
715 | |
---|
716 | //trim list to include only selected files |
---|
717 | SVAR match = root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr |
---|
718 | if(strlen(match) == 0) //if nothing is entered for a match string, return everything, rather than nothing |
---|
719 | match = "*" |
---|
720 | endif |
---|
721 | |
---|
722 | newlist = V_MyMatchList(match,newlist,";") |
---|
723 | |
---|
724 | newList = SortList(newList,";",0) |
---|
725 | Return(newList) |
---|
726 | End |
---|
727 | |
---|
728 | |
---|
729 | |
---|
730 | // |
---|
731 | // TODO: |
---|
732 | // -- test all of the filters to be sure they actually work properly. |
---|
733 | // Run # filter works |
---|
734 | // Text filter works |
---|
735 | // |
---|
736 | // -- SDD filter does not apply -- what is a better filter choice? |
---|
737 | // -- can I filter intent? group_id? |
---|
738 | // -- can't just search for "sample" - this returns everything |
---|
739 | // |
---|
740 | // |
---|
741 | // |
---|
742 | // |
---|
743 | // |
---|
744 | //returns a list of valid files (raw data, no version numbers, no averaged files) |
---|
745 | //that is semicolon delimited, and is suitable for display in a popup menu |
---|
746 | // |
---|
747 | // Uses Grep to look through the any text in the file, which includes the sample label |
---|
748 | // can be very slow across the network, as it re-pops the menu on a selection (since some folks don't hit |
---|
749 | // enter when inputing a filter string) |
---|
750 | // |
---|
751 | // - or - |
---|
752 | // a list or range of run numbers |
---|
753 | // - or - |
---|
754 | // a SDD (to within 0.001m) |
---|
755 | // - or - |
---|
756 | // * to get everything |
---|
757 | // |
---|
758 | // NVAR gRadioVal= root:Packages:NIST:VSANS:Globals:Patch:gRadioVal |
---|
759 | // 1== Run # (comma range OK) |
---|
760 | // 2== Grep the text (SLOW) |
---|
761 | // 3== filter by SDD (within 0.001 m) |
---|
762 | Function/S V_GetValidPatchPopupList() |
---|
763 | |
---|
764 | //make sure that path exists |
---|
765 | PathInfo catPathName |
---|
766 | String path = S_path |
---|
767 | if (V_flag == 0) |
---|
768 | Abort "folder path does not exist - use Pick Path button" |
---|
769 | Endif |
---|
770 | |
---|
771 | String newList = "" |
---|
772 | |
---|
773 | newList = V_GetRawDataFileList() |
---|
774 | |
---|
775 | //trim list to include only selected files |
---|
776 | SVAR match = root:Packages:NIST:VSANS:Globals:Patch:gPatchMatchStr |
---|
777 | if(strlen(match) == 0 || cmpstr(match,"*")==0) //if nothing or "*" entered for a match string, return everything, rather than nothing |
---|
778 | match = "*" |
---|
779 | // old way, with simply a wildcard |
---|
780 | newlist = V_MyMatchList(match,newlist,";") |
---|
781 | newList = SortList(newList,";",0) |
---|
782 | return(newList) |
---|
783 | endif |
---|
784 | |
---|
785 | //loop through all of the files as needed |
---|
786 | |
---|
787 | |
---|
788 | String list="",item="",fname,runList="",numStr="" |
---|
789 | Variable ii,num=ItemsInList(newList),val,group_id |
---|
790 | NVAR gRadioVal= root:Packages:NIST:VSANS:Globals:Patch:gRadioVal |
---|
791 | |
---|
792 | // run number list |
---|
793 | if(gRadioVal == 1) |
---|
794 | |
---|
795 | list = V_ExpandNumRanges(match) //now simply comma delimited |
---|
796 | num=ItemsInList(list,",") |
---|
797 | for(ii=0;ii<num;ii+=1) |
---|
798 | item = StringFromList(ii,list,",") |
---|
799 | val=str2num(item) |
---|
800 | |
---|
801 | runList += V_GetFileNameFromPathNoSemi(V_FindFileFromRunNumber(val)) + ";" |
---|
802 | endfor |
---|
803 | newlist = runList |
---|
804 | |
---|
805 | endif |
---|
806 | |
---|
807 | //grep through what text I can find in the VAX binary |
---|
808 | // Grep Note: the \\b sequences limit matches to a word boundary before and after |
---|
809 | // "boondoggle", so "boondoggles" and "aboondoggle" won't match. |
---|
810 | if(gRadioVal == 2) |
---|
811 | for(ii=0;ii<num;ii+=1) |
---|
812 | item=StringFromList(ii, newList , ";") |
---|
813 | // Grep/P=catPathName/Q/E=("(?i)\\b"+match+"\\b") item |
---|
814 | Grep/P=catPathName/Q/E=("(?i)"+match) item |
---|
815 | if( V_value ) // at least one instance was found |
---|
816 | // Print "found ", item,ii |
---|
817 | list += item + ";" |
---|
818 | endif |
---|
819 | endfor |
---|
820 | |
---|
821 | newList = list |
---|
822 | endif |
---|
823 | |
---|
824 | // group_id |
---|
825 | // replace this with: V_getSample_GroupID(fname) |
---|
826 | Variable pos |
---|
827 | String IDStr="" |
---|
828 | if(gRadioVal == 3) |
---|
829 | pos = strsearch(match, "*", 0) |
---|
830 | if(pos == -1) //no wildcard |
---|
831 | val = str2num(match) |
---|
832 | else |
---|
833 | val = str2num(match[0,pos-1]) |
---|
834 | endif |
---|
835 | |
---|
836 | // print val |
---|
837 | for(ii=0;ii<num;ii+=1) |
---|
838 | item=StringFromList(ii, newList , ";") |
---|
839 | fname = path + item |
---|
840 | group_id = V_getSample_GroupID(fname) |
---|
841 | if(group_id == val) |
---|
842 | list += item + ";" |
---|
843 | endif |
---|
844 | |
---|
845 | endfor |
---|
846 | |
---|
847 | newList = list |
---|
848 | endif |
---|
849 | |
---|
850 | newList = SortList(newList,";",0) |
---|
851 | Return(newList) |
---|
852 | End |
---|
853 | |
---|
854 | |
---|
855 | |
---|
856 | |
---|
857 | // -- no longer refreshes the list - this seems redundant, and can be slow if grepping |
---|
858 | // |
---|
859 | //updates the popup list when the menu is "popped" so the list is |
---|
860 | //always fresh, then automatically displays the header of the popped file |
---|
861 | //value of match string is used in the creation of the list - use * to get |
---|
862 | //all valid files |
---|
863 | // |
---|
864 | Function V_PatchPopMenuProc(PatchPopup,popNum,popStr) : PopupMenuControl |
---|
865 | String PatchPopup |
---|
866 | Variable popNum |
---|
867 | String popStr |
---|
868 | |
---|
869 | |
---|
870 | // String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = list |
---|
871 | // ControlUpdate PatchPopup |
---|
872 | V_ShowHeaderButtonProc("SHButton") |
---|
873 | |
---|
874 | return(0) |
---|
875 | End |
---|
876 | |
---|
877 | |
---|
878 | //when text is entered in the match string, the popup list is refined to |
---|
879 | //include only the selected files, useful for trimming a lengthy list, or selecting |
---|
880 | //a range of files to patch |
---|
881 | //only one wildcard (*) is allowed |
---|
882 | // |
---|
883 | //change the contents of gPatchList that is displayed |
---|
884 | //based on selected Path, match str, and |
---|
885 | //further trim list to include only RAW SANS files |
---|
886 | //this will exclude version numbers, .AVE, .ABS files, etc. from the popup (which can't be patched) |
---|
887 | Function V_SetMatchStrProc(sva) : SetVariableControl |
---|
888 | STRUCT WMSetVariableAction &sva |
---|
889 | |
---|
890 | switch( sva.eventCode ) |
---|
891 | case 1: // mouse up |
---|
892 | case 2: // Enter key |
---|
893 | case 8: // edit end |
---|
894 | Variable dval = sva.dval |
---|
895 | String sval = sva.sval |
---|
896 | |
---|
897 | String list = V_GetValidPatchPopupList() |
---|
898 | |
---|
899 | String/G root:Packages:NIST:VSANS:Globals:Patch:gPatchList = list |
---|
900 | ControlUpdate PatchPopup |
---|
901 | PopupMenu PatchPopup,mode=1 |
---|
902 | |
---|
903 | if(strlen(list) > 0) |
---|
904 | V_ShowHeaderButtonProc("SHButton") |
---|
905 | endif |
---|
906 | case 3: // Live update |
---|
907 | |
---|
908 | break |
---|
909 | case -1: // control being killed |
---|
910 | break |
---|
911 | endswitch |
---|
912 | |
---|
913 | return 0 |
---|
914 | End |
---|
915 | |
---|
916 | //displays the header of the selected file (top in the popup) when the button is clicked |
---|
917 | //sort of a redundant button, since the procedure is automatically called (as if it were |
---|
918 | //clicked) when a new file is chosen from the popup |
---|
919 | // |
---|
920 | // TODO - make sure this is tab-aware |
---|
921 | // |
---|
922 | Function V_ShowHeaderButtonProc(SHButton) : ButtonControl |
---|
923 | String SHButton |
---|
924 | |
---|
925 | //displays (editable) header information about current file in popup control |
---|
926 | //putting the values in the SetVariable displays (resetting the global variables) |
---|
927 | |
---|
928 | //get the popup string |
---|
929 | String partialName, tempName |
---|
930 | Variable ok |
---|
931 | ControlInfo/W=V_Patch_Panel PatchPopup |
---|
932 | If(strlen(S_value)==0 || cmpstr(S_Value,"none")==0) |
---|
933 | //null selection |
---|
934 | Abort "no file selected in popup menu" |
---|
935 | else |
---|
936 | //selection not null |
---|
937 | partialName = S_value |
---|
938 | //Print partialName |
---|
939 | Endif |
---|
940 | //get a valid file based on this partialName and catPathName |
---|
941 | tempName = V_FindValidFilename(partialName) |
---|
942 | |
---|
943 | //prepend path to tempName for read routine |
---|
944 | PathInfo catPathName |
---|
945 | tempName = S_path + tempName |
---|
946 | |
---|
947 | //make sure the file is really a RAW data file |
---|
948 | ok = V_CheckIfRawData(tempName) //--- This loads the whole file to read the instrument string |
---|
949 | if (!ok) |
---|
950 | Abort "this file is not recognized as a RAW SANS data file" |
---|
951 | Endif |
---|
952 | |
---|
953 | //Print tempName |
---|
954 | |
---|
955 | V_ReadHeaderForPatch(tempName) |
---|
956 | |
---|
957 | ControlUpdate/A/W=V_Patch_Panel |
---|
958 | |
---|
959 | // no matter what tab is selected, show the file label |
---|
960 | SVAR fileLabel = root:Packages:NIST:VSANS:Globals:Patch:gPatchCurLabel |
---|
961 | fileLabel = V_getSampleDescription(tempName) |
---|
962 | |
---|
963 | return(0) |
---|
964 | End |
---|
965 | |
---|
966 | |
---|
967 | |
---|
968 | //simple function to get the string value from the popup list of filenames |
---|
969 | //returned string is only the text in the popup, a partial name with no path |
---|
970 | //or VAX version number. |
---|
971 | // |
---|
972 | Function/S V_GetPatchPopupString() |
---|
973 | |
---|
974 | String str="" |
---|
975 | |
---|
976 | ControlInfo patchPopup |
---|
977 | If(cmpstr(S_value,"")==0) |
---|
978 | //null selection |
---|
979 | Abort "no file selected in popup menu" |
---|
980 | else |
---|
981 | //selection not null |
---|
982 | str = S_value |
---|
983 | //Print str |
---|
984 | Endif |
---|
985 | |
---|
986 | Return str |
---|
987 | End |
---|
988 | |
---|
989 | //Changes (writes to disk!) the specified changes to the (single) file selected in the popup |
---|
990 | //reads the checkboxes to determine which (if any) values need to be written |
---|
991 | // |
---|
992 | // This currently makes sure the name is valid, |
---|
993 | // determines the active tab, |
---|
994 | // and dispatches to the correct (numbered) writer |
---|
995 | // |
---|
996 | Function V_ChangeHeaderButtonProc(CHButton) : ButtonControl |
---|
997 | String CHButton |
---|
998 | |
---|
999 | String partialName="", tempName = "" |
---|
1000 | Variable ok |
---|
1001 | //get the popup string |
---|
1002 | partialName = V_GetPatchPopupString() |
---|
1003 | |
---|
1004 | //get a valid file based on this partialName and catPathName |
---|
1005 | tempName = V_FindValidFilename(partialName) |
---|
1006 | |
---|
1007 | //prepend path to tempName for read routine |
---|
1008 | PathInfo catPathName |
---|
1009 | tempName = S_path + tempName |
---|
1010 | |
---|
1011 | //make sure the file is really a RAW data file |
---|
1012 | ok = V_CheckIfRawData(tempName) |
---|
1013 | if (!ok) |
---|
1014 | Abort "this file is not recognized as a RAW SANS data file" |
---|
1015 | Endif |
---|
1016 | |
---|
1017 | // which tab is active? |
---|
1018 | ControlInfo/W=V_Patch_Panel PatchTab |
---|
1019 | |
---|
1020 | switch(V_Value) // numeric switch |
---|
1021 | case 0: // execute if case matches expression |
---|
1022 | V_WriteHeaderForPatch_0(tempName) //control |
---|
1023 | break // exit from switch |
---|
1024 | case 1: |
---|
1025 | V_WriteHeaderForPatch_1(tempName) //reduction |
---|
1026 | break |
---|
1027 | case 2: |
---|
1028 | V_WriteHeaderForPatch_2(tempName) // sample |
---|
1029 | break |
---|
1030 | case 3: |
---|
1031 | V_WriteHeaderForPatch_3(tempName) // instrument |
---|
1032 | break |
---|
1033 | case 4: |
---|
1034 | V_WriteHeaderForPatch_4(tempName) //detectors |
---|
1035 | break |
---|
1036 | case 5: |
---|
1037 | V_WriteHeaderForPatch_5(tempName) // polSANS |
---|
1038 | break |
---|
1039 | default: // optional default expression executed |
---|
1040 | Abort "Tab not found - V_ChangeHeaderButtonProc" |
---|
1041 | endswitch |
---|
1042 | |
---|
1043 | |
---|
1044 | //after writing the changes to the file |
---|
1045 | // clean up, to force a reload from disk |
---|
1046 | V_CleanupData_w_Progress(0,1) |
---|
1047 | |
---|
1048 | return(0) |
---|
1049 | End |
---|
1050 | |
---|
1051 | // |
---|
1052 | //*****this function actually writes the data to disk***** |
---|
1053 | // |
---|
1054 | // DONE x- re-write a series of these function to mirror the "fill" functions |
---|
1055 | // specific to each tab |
---|
1056 | // |
---|
1057 | // DONE x- clear out the old data and force a re-load from disk, or the old data |
---|
1058 | // will be read in from the RawVSANS folder, and it will look like nothing was written |
---|
1059 | // (done in the calling function) |
---|
1060 | // |
---|
1061 | // currently, all errors are printed out by the writer, but ignored here |
---|
1062 | // |
---|
1063 | Function V_WriteHeaderForPatch_0(fname) |
---|
1064 | String fname |
---|
1065 | |
---|
1066 | Variable val,err |
---|
1067 | String textstr |
---|
1068 | |
---|
1069 | Wave/T listWave = root:Packages:NIST:VSANS:Globals:Patch:PP_ListWave |
---|
1070 | Wave selWave = root:Packages:NIST:VSANS:Globals:Patch:PP_selWave |
---|
1071 | |
---|
1072 | // test bit 4 to see if the checkbox is selected |
---|
1073 | if ((selWave[0][0] & 2^4) != 0) // Test if bit 4 is set |
---|
1074 | val = str2num(listWave[0][2]) |
---|
1075 | err = V_writeCount_time(fname,val) // count_time |
---|
1076 | endif |
---|
1077 | |
---|
1078 | if ((selWave[1][0] & 2^4) != 0) // "detector_counts" |
---|
1079 | val = str2num(listWave[1][2]) |
---|
1080 | err = V_writeDetector_counts(fname,val) |
---|
1081 | endif |
---|
1082 | |
---|
1083 | if ((selWave[2][0] & 2^4) != 0) //"monitor_counts" |
---|
1084 | val = str2num(listWave[2][2]) |
---|
1085 | // err = V_writeControlMonitorCount(fname,val) |
---|
1086 | err = V_writeBeamMonNormData(fname,val) |
---|
1087 | endif |
---|
1088 | |
---|
1089 | |
---|
1090 | |
---|
1091 | |
---|
1092 | Return(0) |
---|
1093 | End |
---|
1094 | |
---|
1095 | // |
---|
1096 | // tab 1 |
---|
1097 | // |
---|
1098 | Function V_WriteHeaderForPatch_1(fname) |
---|
1099 | String fname |
---|
1100 | |
---|
1101 | Variable val,err |
---|
1102 | String str |
---|
1103 | |
---|
1104 | Wave/T listWave = root:Packages:NIST:VSANS:Globals:Patch:PP_ListWave |
---|
1105 | Wave selWave = root:Packages:NIST:VSANS:Globals:Patch:PP_selWave |
---|
1106 | |
---|
1107 | // test bit 4 to see if the checkbox is selected |
---|
1108 | if ((selWave[0][0] & 2^4) != 0) // Test if bit 4 is set |
---|
1109 | str = listWave[0][2] // empty_beam_file_name |
---|
1110 | err = V_writeEmptyBeamFileName(fname,str) |
---|
1111 | endif |
---|
1112 | |
---|
1113 | if ((selWave[1][0] & 2^4) != 0) // "background_file_name" |
---|
1114 | str = listWave[1][2] |
---|
1115 | err = V_writeBackgroundFileName(fname,str) |
---|
1116 | endif |
---|
1117 | |
---|
1118 | if ((selWave[2][0] & 2^4) != 0) //"empty_file_name" |
---|
1119 | str = listWave[2][2] |
---|
1120 | err = V_writeEmptyFileName(fname,str) |
---|
1121 | endif |
---|
1122 | |
---|
1123 | if ((selWave[3][0] & 2^4) != 0) //"sensitivity_file_name" |
---|
1124 | str = listWave[3][2] |
---|
1125 | err = V_writeSensitivityFileName(fname,str) |
---|
1126 | endif |
---|
1127 | |
---|
1128 | if ((selWave[4][0] & 2^4) != 0) //"mask_file_name" |
---|
1129 | str = listWave[4][2] |
---|
1130 | err = V_writeMaskFileName(fname,str) |
---|
1131 | endif |
---|
1132 | |
---|
1133 | if ((selWave[5][0] & 2^4) != 0) //"transmission_file_name" |
---|
1134 | str = listWave[5][2] |
---|
1135 | err = V_writeTransmissionFileName(fname,str) |
---|
1136 | endif |
---|
1137 | |
---|
1138 | if ((selWave[6][0] & 2^4) != 0) //"intent" |
---|
1139 | str = listWave[6][2] |
---|
1140 | err = V_writeReductionIntent(fname,str) |
---|
1141 | endif |
---|
1142 | |
---|
1143 | if ((selWave[7][0] & 2^4) != 0) //"file_purpose" |
---|
1144 | str = listWave[7][2] |
---|
1145 | err = V_writeReduction_purpose(fname,str) |
---|
1146 | endif |
---|
1147 | |
---|
1148 | if ((selWave[8][0] & 2^4) != 0) //"group_id (sample)" |
---|
1149 | val = str2num(listWave[8][2]) |
---|
1150 | err = V_writeSample_GroupID(fname,val) |
---|
1151 | endif |
---|
1152 | |
---|
1153 | |
---|
1154 | |
---|
1155 | if ((selWave[9][0] & 2^4) != 0) //"box coordinates" |
---|
1156 | str = listWave[9][2] |
---|
1157 | err = V_writeBoxCoordinates(fname,V_List2NumWave(str,";","inW")) |
---|
1158 | endif |
---|
1159 | |
---|
1160 | |
---|
1161 | |
---|
1162 | if ((selWave[10][0] & 2^4) != 0) //"box_count" |
---|
1163 | val = str2num(listWave[10][2]) |
---|
1164 | err = V_writeBoxCounts(fname,val) |
---|
1165 | endif |
---|
1166 | |
---|
1167 | if ((selWave[11][0] & 2^4) != 0) //"box_count_error" |
---|
1168 | val = str2num(listWave[11][2]) |
---|
1169 | err = V_writeBoxCountsError(fname,val) |
---|
1170 | endif |
---|
1171 | |
---|
1172 | if ((selWave[12][0] & 2^4) != 0) //"whole_trans" |
---|
1173 | val = str2num(listWave[12][2]) |
---|
1174 | err = V_writeSampleTransWholeDetector(fname,val) |
---|
1175 | endif |
---|
1176 | |
---|
1177 | if ((selWave[13][0] & 2^4) != 0) //"whole_trans_error" |
---|
1178 | val = str2num(listWave[13][2]) |
---|
1179 | err = V_writeSampleTransWholeDetErr(fname,val) |
---|
1180 | endif |
---|
1181 | |
---|
1182 | |
---|
1183 | |
---|
1184 | |
---|
1185 | return(0) |
---|
1186 | End |
---|
1187 | |
---|
1188 | // SAMPLE |
---|
1189 | Function V_WriteHeaderForPatch_2(fname) |
---|
1190 | String fname |
---|
1191 | |
---|
1192 | Variable val,err |
---|
1193 | String str |
---|
1194 | |
---|
1195 | Wave/T listWave = root:Packages:NIST:VSANS:Globals:Patch:PP_ListWave |
---|
1196 | Wave selWave = root:Packages:NIST:VSANS:Globals:Patch:PP_selWave |
---|
1197 | |
---|
1198 | // test bit 4 to see if the checkbox is selected |
---|
1199 | if ((selWave[0][0] & 2^4) != 0) // Test if bit 4 is set |
---|
1200 | str = listWave[0][2] // "description" |
---|
1201 | err = V_writeSampleDescription(fname,str) |
---|
1202 | endif |
---|
1203 | |
---|
1204 | if ((selWave[1][0] & 2^4) != 0) // "thickness" |
---|
1205 | val = str2num(listWave[1][2]) |
---|
1206 | err = V_writeSampleThickness(fname,val) |
---|
1207 | endif |
---|
1208 | |
---|
1209 | if ((selWave[2][0] & 2^4) != 0) //"transmission" |
---|
1210 | val = str2num(listWave[2][2]) |
---|
1211 | err = V_writeSampleTransmission(fname,val) |
---|
1212 | endif |
---|
1213 | |
---|
1214 | if ((selWave[3][0] & 2^4) != 0) //"transmission_error" |
---|
1215 | val = str2num(listWave[3][2]) |
---|
1216 | err = V_writeSampleTransError(fname,val) |
---|
1217 | endif |
---|
1218 | |
---|
1219 | return(0) |
---|
1220 | End |
---|
1221 | |
---|
1222 | // INSTRUMENT |
---|
1223 | Function V_WriteHeaderForPatch_3(fname) |
---|
1224 | String fname |
---|
1225 | |
---|
1226 | Variable val,err |
---|
1227 | String str |
---|
1228 | |
---|
1229 | Wave/T listWave = root:Packages:NIST:VSANS:Globals:Patch:PP_ListWave |
---|
1230 | Wave selWave = root:Packages:NIST:VSANS:Globals:Patch:PP_selWave |
---|
1231 | |
---|
1232 | // test bit 4 to see if the checkbox is selected |
---|
1233 | if ((selWave[0][0] & 2^4) != 0) // Test if bit 4 is set |
---|
1234 | val = str2num(listWave[0][2]) // "attenuator_transmission" |
---|
1235 | err = V_writeAttenuator_transmission(fname,val) |
---|
1236 | endif |
---|
1237 | |
---|
1238 | if ((selWave[1][0] & 2^4) != 0) // "attenuator_transmission_error" |
---|
1239 | val = str2num(listWave[1][2]) |
---|
1240 | err = V_writeAttenuator_trans_err(fname,val) |
---|
1241 | endif |
---|
1242 | |
---|
1243 | if ((selWave[2][0] & 2^4) != 0) //"monochromator type" |
---|
1244 | str = listWave[2][2] |
---|
1245 | err = V_writeMonochromatorType(fname,str) |
---|
1246 | endif |
---|
1247 | |
---|
1248 | if ((selWave[3][0] & 2^4) != 0) //"wavelength" |
---|
1249 | val = str2num(listWave[3][2]) |
---|
1250 | err = V_writeWavelength(fname,val) |
---|
1251 | endif |
---|
1252 | |
---|
1253 | if ((selWave[4][0] & 2^4) != 0) //"wavelength_spread" |
---|
1254 | val = str2num(listWave[4][2]) |
---|
1255 | err = V_writeWavelength_spread(fname,val) |
---|
1256 | endif |
---|
1257 | |
---|
1258 | if ((selWave[5][0] & 2^4) != 0) //"distance (source aperture)" |
---|
1259 | val = str2num(listWave[5][2]) |
---|
1260 | err = V_writeSourceAp_distance(fname,val) |
---|
1261 | endif |
---|
1262 | |
---|
1263 | if ((selWave[6][0] & 2^4) != 0) //"source aperture size (mm)" (a string with units) |
---|
1264 | str = listWave[6][2] |
---|
1265 | err = V_writeSourceAp_size(fname,str) |
---|
1266 | endif |
---|
1267 | |
---|
1268 | if ((selWave[7][0] & 2^4) != 0) //"sample aperture size (internal) (mm)" (a string with units) |
---|
1269 | str = listWave[7][2] |
---|
1270 | err = V_writeSampleAp_size(fname,str) |
---|
1271 | endif |
---|
1272 | |
---|
1273 | if ((selWave[8][0] & 2^4) != 0) //"sample aperture diam (external) (cm)" |
---|
1274 | val = str2num(listWave[8][2]) |
---|
1275 | err = V_writeSampleAp2_size(fname,val) |
---|
1276 | endif |
---|
1277 | |
---|
1278 | if ((selWave[9][0] & 2^4) != 0) //"beam stop diameter (Middle) (mm)" |
---|
1279 | val = str2num(listWave[9][2]) |
---|
1280 | err = V_writeBeamStopC2_size(fname,val) |
---|
1281 | endif |
---|
1282 | |
---|
1283 | if ((selWave[10][0] & 2^4) != 0) //"beam stop diameter (Back) (mm)" |
---|
1284 | val = str2num(listWave[10][2]) |
---|
1285 | err = V_writeBeamStopC3_size(fname,val) |
---|
1286 | endif |
---|
1287 | |
---|
1288 | if ((selWave[11][0] & 2^4) != 0) //"sample aperture to gate valve (cm)" |
---|
1289 | val = str2num(listWave[11][2]) |
---|
1290 | err = V_writeSampleAp_distance(fname,val) |
---|
1291 | endif |
---|
1292 | |
---|
1293 | if ((selWave[12][0] & 2^4) != 0) //"sample to gate valve (cm)" |
---|
1294 | val = str2num(listWave[12][2]) |
---|
1295 | err = V_writeSampleTableOffset(fname,val) |
---|
1296 | endif |
---|
1297 | |
---|
1298 | return(0) |
---|
1299 | End |
---|
1300 | |
---|
1301 | // DETECTOR |
---|
1302 | Function V_WriteHeaderForPatch_4(fname) |
---|
1303 | String fname |
---|
1304 | |
---|
1305 | Variable val,err |
---|
1306 | String str |
---|
1307 | |
---|
1308 | Wave/T listWave = root:Packages:NIST:VSANS:Globals:Patch:PP_ListWave |
---|
1309 | Wave selWave = root:Packages:NIST:VSANS:Globals:Patch:PP_selWave |
---|
1310 | |
---|
1311 | ControlInfo popup_0 |
---|
1312 | String detStr = S_Value |
---|
1313 | |
---|
1314 | // test bit 4 to see if the checkbox is selected |
---|
1315 | if ((selWave[0][0] & 2^4) != 0) // Test if bit 4 is set |
---|
1316 | val = str2num(listWave[0][2]) // "beam_center_x" |
---|
1317 | err = V_writeDet_beam_center_x(fname,detStr,val) |
---|
1318 | endif |
---|
1319 | |
---|
1320 | if ((selWave[1][0] & 2^4) != 0) // "beam_center_y" |
---|
1321 | val = str2num(listWave[1][2]) |
---|
1322 | err = V_writeDet_beam_center_y(fname,detStr,val) |
---|
1323 | endif |
---|
1324 | |
---|
1325 | if ((selWave[2][0] & 2^4) != 0) //"distance (nominal)" |
---|
1326 | val = str2num(listWave[2][2]) |
---|
1327 | err = V_writeDet_distance(fname,detStr,val) |
---|
1328 | endif |
---|
1329 | |
---|
1330 | if ((selWave[3][0] & 2^4) != 0) //"integrated_count" |
---|
1331 | val = str2num(listWave[3][2]) |
---|
1332 | err = V_writeDet_IntegratedCount(fname,detStr,val) |
---|
1333 | endif |
---|
1334 | |
---|
1335 | if ((selWave[4][0] & 2^4) != 0) //"pixel_fwhm_x" |
---|
1336 | val = str2num(listWave[4][2]) |
---|
1337 | err = V_writeDet_pixel_fwhm_x(fname,detStr,val) |
---|
1338 | endif |
---|
1339 | |
---|
1340 | if ((selWave[5][0] & 2^4) != 0) //"pixel_fwhm_y" |
---|
1341 | val = str2num(listWave[5][2]) |
---|
1342 | err = V_writeDet_pixel_fwhm_y(fname,detStr,val) |
---|
1343 | endif |
---|
1344 | |
---|
1345 | if ((selWave[6][0] & 2^4) != 0) //"pixel_num_x" |
---|
1346 | val = str2num(listWave[6][2]) |
---|
1347 | err = V_writeDet_pixel_num_x(fname,detStr,val) |
---|
1348 | endif |
---|
1349 | |
---|
1350 | if ((selWave[7][0] & 2^4) != 0) //"pixel_num_y" |
---|
1351 | val = str2num(listWave[7][2]) |
---|
1352 | err = V_writeDet_pixel_num_y(fname,detStr,val) |
---|
1353 | endif |
---|
1354 | |
---|
1355 | if ((selWave[8][0] & 2^4) != 0) //"setback" -- only for TB detectors |
---|
1356 | val = str2num(listWave[8][2]) |
---|
1357 | if(cmpstr(detStr,"FT") == 0 || cmpstr(detStr,"FB") == 0 || cmpstr(detStr,"MT") == 0 || cmpstr(detStr,"MB") == 0) |
---|
1358 | err = V_writeDet_TBSetback(fname,detStr,val) |
---|
1359 | endif |
---|
1360 | endif |
---|
1361 | |
---|
1362 | if ((selWave[9][0] & 2^4) != 0) //"lateral_offset" or "vertical_offset" |
---|
1363 | val = str2num(listWave[9][2]) |
---|
1364 | if(cmpstr(detStr,"B") == 0 ||cmpstr(detStr,"FR") == 0 || cmpstr(detStr,"FL") == 0 || cmpstr(detStr,"MR") == 0 || cmpstr(detStr,"ML") == 0) |
---|
1365 | err = V_writeDet_LateralOffset(fname,detStr,val) |
---|
1366 | else |
---|
1367 | err = V_writeDet_VerticalOffset(fname,detStr,val) |
---|
1368 | endif |
---|
1369 | endif |
---|
1370 | |
---|
1371 | if ((selWave[10][0] & 2^4) != 0) //"x_pixel_size" |
---|
1372 | val = str2num(listWave[10][2]) |
---|
1373 | err = V_writeDet_x_pixel_size(fname,detStr,val) |
---|
1374 | endif |
---|
1375 | |
---|
1376 | if ((selWave[11][0] & 2^4) != 0) //"y_pixel_size" |
---|
1377 | val = str2num(listWave[11][2]) |
---|
1378 | err = V_writeDet_y_pixel_size(fname,detStr,val) |
---|
1379 | endif |
---|
1380 | |
---|
1381 | if ((selWave[12][0] & 2^4) != 0) //"dead time, "B" only" |
---|
1382 | val = str2num(listWave[12][2]) |
---|
1383 | if(cmpstr(detStr,"B") == 0) |
---|
1384 | err = V_writeDetector_deadtime_B(fname,detStr,val) |
---|
1385 | endif |
---|
1386 | endif |
---|
1387 | |
---|
1388 | |
---|
1389 | return(0) |
---|
1390 | End |
---|
1391 | |
---|
1392 | // TODO -- not yet implemented |
---|
1393 | Function V_WriteHeaderForPatch_5(fname) |
---|
1394 | String fname |
---|
1395 | |
---|
1396 | return(0) |
---|
1397 | End |
---|
1398 | |
---|
1399 | |
---|
1400 | // control the display of the radio buttons |
---|
1401 | Function V_MatchCheckProc(name,value) |
---|
1402 | String name |
---|
1403 | Variable value |
---|
1404 | |
---|
1405 | NVAR gRadioVal= root:Packages:NIST:VSANS:Globals:Patch:gRadioVal |
---|
1406 | |
---|
1407 | strswitch (name) |
---|
1408 | case "check0": |
---|
1409 | gRadioVal= 1 |
---|
1410 | break |
---|
1411 | case "check1": |
---|
1412 | gRadioVal= 2 |
---|
1413 | break |
---|
1414 | case "check2": |
---|
1415 | gRadioVal= 3 |
---|
1416 | break |
---|
1417 | endswitch |
---|
1418 | CheckBox check0,value= gRadioVal==1 |
---|
1419 | CheckBox check1,value= gRadioVal==2 |
---|
1420 | CheckBox check2,value= gRadioVal==3 |
---|
1421 | return(0) |
---|
1422 | End |
---|
1423 | |
---|
1424 | //This function will read only the selected values editable in the patch panel |
---|
1425 | // |
---|
1426 | // DONE |
---|
1427 | // x- re-write this to be tab-aware. ShowHeaderForPatch() calls this, but does nothing |
---|
1428 | // to update the tab content. Figure out which function is in charge, and update the content. |
---|
1429 | // |
---|
1430 | Function V_ReadHeaderForPatch(fname) |
---|
1431 | String fname |
---|
1432 | |
---|
1433 | |
---|
1434 | // figure out which is the active tab, then let PatchTabProc fill it in |
---|
1435 | ControlInfo/W=V_Patch_Panel PatchTab |
---|
1436 | V_PatchTabProc("",V_Value) |
---|
1437 | |
---|
1438 | Return 0 |
---|
1439 | End |
---|
1440 | |
---|
1441 | Function V_ShowPatchHelp(ctrlName) : ButtonControl |
---|
1442 | String ctrlName |
---|
1443 | // DisplayHelpTopic/Z/K=1 "VSANS Data Reduction Tutorial[Patch File Headers]" |
---|
1444 | // if(V_flag !=0) |
---|
1445 | DoAlert 0,"The VSANS Data Reduction Tutorial Help file could not be found" |
---|
1446 | // endif |
---|
1447 | return(0) |
---|
1448 | End |
---|
1449 | |
---|
1450 | //button action procedure to change the selected information (checked values) |
---|
1451 | //in each file in the popup list. This will change multiple files, and as such, |
---|
1452 | //the user is given a chance to bail out before the whole list of files |
---|
1453 | //is modified |
---|
1454 | //useful for patching a series of runs with the same beamcenters, or transmissions |
---|
1455 | // |
---|
1456 | Function V_ChAllHeadersButtonProc(ctrlName) : ButtonControl |
---|
1457 | String ctrlName |
---|
1458 | |
---|
1459 | String msg |
---|
1460 | msg = "Do you really want to write all of these values to each data file in the popup list? " |
---|
1461 | msg += "- clicking NO will leave all files unchanged" |
---|
1462 | DoAlert 1,msg |
---|
1463 | If(V_flag == 2) |
---|
1464 | Abort "no files were changed" |
---|
1465 | Endif |
---|
1466 | |
---|
1467 | //this will change (checked) values in ALL of the headers in the popup list |
---|
1468 | SVAR list = root:Packages:NIST:VSANS:Globals:Patch:gPatchList |
---|
1469 | Variable numitems,ii |
---|
1470 | String partialName="", tempName = "" |
---|
1471 | Variable ok |
---|
1472 | |
---|
1473 | numitems = ItemsInList(list,";") |
---|
1474 | |
---|
1475 | if(numitems == 0) |
---|
1476 | Abort "no items in list for multiple patch" |
---|
1477 | Endif |
---|
1478 | |
---|
1479 | // loop through all of the files |
---|
1480 | ii=0 |
---|
1481 | do |
---|
1482 | //get current item in the list |
---|
1483 | partialName = StringFromList(ii, list, ";") |
---|
1484 | |
---|
1485 | //get a valid file based on this partialName and catPathName |
---|
1486 | tempName = V_FindValidFilename(partialName) |
---|
1487 | |
---|
1488 | //prepend path to tempName for read routine |
---|
1489 | PathInfo catPathName |
---|
1490 | tempName = S_path + tempName |
---|
1491 | |
---|
1492 | //make sure the file is really a RAW data file |
---|
1493 | ok = V_CheckIfRawData(tempName) |
---|
1494 | if (!ok) |
---|
1495 | Print "this file is not recognized as a RAW SANS data file = ",tempName |
---|
1496 | else |
---|
1497 | //go write the changes to the file |
---|
1498 | // which tab is active? |
---|
1499 | ControlInfo/W=V_Patch_Panel PatchTab |
---|
1500 | |
---|
1501 | switch(V_Value) // numeric switch |
---|
1502 | case 0: // execute if case matches expression |
---|
1503 | V_WriteHeaderForPatch_0(tempName) |
---|
1504 | break // exit from switch |
---|
1505 | case 1: |
---|
1506 | V_WriteHeaderForPatch_1(tempName) |
---|
1507 | break |
---|
1508 | case 2: |
---|
1509 | V_WriteHeaderForPatch_2(tempName) |
---|
1510 | break |
---|
1511 | case 3: |
---|
1512 | V_WriteHeaderForPatch_3(tempName) |
---|
1513 | break |
---|
1514 | case 4: |
---|
1515 | V_WriteHeaderForPatch_4(tempName) |
---|
1516 | break |
---|
1517 | case 5: |
---|
1518 | V_WriteHeaderForPatch_5(tempName) |
---|
1519 | break |
---|
1520 | default: // optional default expression executed |
---|
1521 | Abort "Tab not found - V_ChAllHeadersButtonProc" |
---|
1522 | endswitch |
---|
1523 | Endif |
---|
1524 | |
---|
1525 | ii+=1 |
---|
1526 | while(ii<numitems) |
---|
1527 | |
---|
1528 | |
---|
1529 | //after writing the changes to the file |
---|
1530 | // clean up, to force a reload from disk |
---|
1531 | V_CleanupData_w_Progress(0,1) |
---|
1532 | |
---|
1533 | return(0) |
---|
1534 | End |
---|
1535 | |
---|
1536 | |
---|
1537 | //simple action for button to close the panel |
---|
1538 | // |
---|
1539 | // cleans out the RawVSANS folder on closing |
---|
1540 | // |
---|
1541 | Function V_DoneButtonProc(ctrlName) : ButtonControl |
---|
1542 | String ctrlName |
---|
1543 | |
---|
1544 | DoWindow/K V_Patch_Panel |
---|
1545 | |
---|
1546 | // V_CleanOutRawVSANS() |
---|
1547 | // present a progress window |
---|
1548 | V_CleanupData_w_Progress(0,1) |
---|
1549 | |
---|
1550 | return(0) |
---|
1551 | End |
---|
1552 | |
---|
1553 | |
---|
1554 | |
---|
1555 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
1556 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
1557 | /////////////// |
---|
1558 | // |
---|
1559 | // this is a block to patch DEADTIME waves to the file headers, and can patch multiple files |
---|
1560 | // |
---|
1561 | // uses a simple panel to show what the table of values is. |
---|
1562 | // "read" will read only the first run number contents. |
---|
1563 | // |
---|
1564 | // TODO -- need to clear out the contents from RawVSANS, or else re-reading to check the values |
---|
1565 | // will read locally, and it will look like nothing was written. Executing "save" will also |
---|
1566 | // trigger a cleanout. |
---|
1567 | // |
---|
1568 | // TODO -- link this to a panel somewhere - a button? menu item? will there be a lot more of these little panels? |
---|
1569 | // |
---|
1570 | // TODO -- currently, this does not patch the deadtime for the back "B" detector. it is a single |
---|
1571 | // value, not a wave see V_WritePerfectDeadTime(filename) for how the perfect (fake) values is written. |
---|
1572 | // |
---|
1573 | // |
---|
1574 | Proc V_PatchDetectorDeadtime(firstFile,lastFile,detStr,deadtimeStr) |
---|
1575 | Variable firstFile=1,lastFile=100 |
---|
1576 | String detStr = "FL",deadtimeStr="deadTimeWave" |
---|
1577 | |
---|
1578 | V_fPatchDetectorDeadtime(firstFile,lastFile,detStr,$deadtimeStr) |
---|
1579 | |
---|
1580 | End |
---|
1581 | |
---|
1582 | Proc V_ReadDetectorDeadtime(firstFile,lastFile,detStr) |
---|
1583 | Variable firstFile=1,lastFile=100 |
---|
1584 | String detStr = "FL" |
---|
1585 | |
---|
1586 | V_fReadDetectorDeadtime(firstFile,lastFile,detStr) |
---|
1587 | |
---|
1588 | End |
---|
1589 | |
---|
1590 | // simple utility to patch the detector deadtime in the file headers |
---|
1591 | // lo is the first file number |
---|
1592 | // hi is the last file number (inclusive) |
---|
1593 | // |
---|
1594 | Function V_fPatchDetectorDeadtime(lo,hi,detStr,deadtimeW) |
---|
1595 | Variable lo,hi |
---|
1596 | String detStr |
---|
1597 | Wave deadtimeW |
---|
1598 | |
---|
1599 | Variable ii |
---|
1600 | String fname |
---|
1601 | |
---|
1602 | // check the dimensions of the deadtimeW/N=48 |
---|
1603 | if (DimSize(deadtimeW, 0) != 48 ) |
---|
1604 | Abort "dead time wave is not of proper dimension (48)" |
---|
1605 | endif |
---|
1606 | |
---|
1607 | //loop over all files |
---|
1608 | for(ii=lo;ii<=hi;ii+=1) |
---|
1609 | fname = V_FindFileFromRunNumber(ii) |
---|
1610 | if(strlen(fname) != 0) |
---|
1611 | V_writeDetector_deadtime(fname,detStr,deadtimeW) |
---|
1612 | else |
---|
1613 | printf "run number %d not found\r",ii |
---|
1614 | endif |
---|
1615 | endfor |
---|
1616 | |
---|
1617 | return(0) |
---|
1618 | End |
---|
1619 | |
---|
1620 | // simple utility to read the detector deadtime stored in the file header |
---|
1621 | Function V_fReadDetectorDeadtime(lo,hi,detStr) |
---|
1622 | Variable lo,hi |
---|
1623 | String detStr |
---|
1624 | |
---|
1625 | String fname |
---|
1626 | Variable ii |
---|
1627 | |
---|
1628 | for(ii=lo;ii<=hi;ii+=1) |
---|
1629 | fname = V_FindFileFromRunNumber(ii) |
---|
1630 | if(strlen(fname) != 0) |
---|
1631 | Wave deadtimeW = V_getDetector_deadtime(fname,detStr) |
---|
1632 | Duplicate/O deadTimeW root:Packages:NIST:VSANS:Globals:Patch:deadtimeWave |
---|
1633 | // printf "File %d: Detector Dead time (s) = %g\r",ii,deadtime |
---|
1634 | else |
---|
1635 | printf "run number %d not found\r",ii |
---|
1636 | endif |
---|
1637 | endfor |
---|
1638 | |
---|
1639 | return(0) |
---|
1640 | End |
---|
1641 | |
---|
1642 | |
---|
1643 | |
---|
1644 | Proc V_PatchDetectorDeadtimePanel() |
---|
1645 | DoWindow/F DeadtimePanel |
---|
1646 | if(V_flag==0) |
---|
1647 | |
---|
1648 | NewDataFolder/O/S root:Packages:NIST:VSANS:Globals:Patch |
---|
1649 | |
---|
1650 | Make/O/D/N=48 deadTimeWave |
---|
1651 | Variable/G gFileNum_Lo,gFileNum_Hi |
---|
1652 | |
---|
1653 | SetDataFolder root: |
---|
1654 | |
---|
1655 | Execute "V_DeadtimePatchPanel()" |
---|
1656 | endif |
---|
1657 | End |
---|
1658 | |
---|
1659 | |
---|
1660 | // TODO: |
---|
1661 | // x- add method for generating "perfect" dead time to write |
---|
1662 | // x- check deadtime wave dimension before writing (check for bad paste operation) |
---|
1663 | // -- load from file? different ways to import? |
---|
1664 | // -- Dead time constants for "B" are different, and not handled here (yet) |
---|
1665 | // -- add help button/file |
---|
1666 | // -- add done button |
---|
1667 | // -- adjust after user testing |
---|
1668 | // |
---|
1669 | Proc V_DeadtimePatchPanel() : Panel |
---|
1670 | PauseUpdate; Silent 1 // building window... |
---|
1671 | |
---|
1672 | |
---|
1673 | NewPanel /W=(600,400,1000,1000)/N=DeadtimePanel /K=1 |
---|
1674 | // ShowTools/A |
---|
1675 | ModifyPanel cbRGB=(16266,47753,2552,23355) |
---|
1676 | |
---|
1677 | SetDrawLayer UserBack |
---|
1678 | DrawText 85,99,"Current Values" |
---|
1679 | DrawText 21,258,"Write to all files (inlcusive)" |
---|
1680 | SetDrawEnv fsize= 14,fstyle= 1 |
---|
1681 | DrawText 209,30,"Dead Time Constants" |
---|
1682 | DrawText 20,133,"Run Number(s)" |
---|
1683 | |
---|
1684 | PopupMenu popup_0,pos={20,40},size={109,20},title="Detector Panel" |
---|
1685 | PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;ML;MR;MT;MB;\"" |
---|
1686 | |
---|
1687 | Button button0,pos={20,81},size={50.00,20.00},proc=V_ReadDTButtonProc,title="Read" |
---|
1688 | Button button0_1,pos={20,220},size={50.00,20.00},proc=V_WriteDTButtonProc,title="Write" |
---|
1689 | Button button0_2,pos={18.00,336.00},size={140.00,20.00},proc=V_GeneratePerfDTButton,title="Perfect Dead Time" |
---|
1690 | Button button0_3,pos={18.00,370.00},size={140.00,20.00},proc=V_LoadCSVDTButton,title="Load Dead Time CSV" |
---|
1691 | Button button0_4,pos={18.00,400.00},size={140.00,20.00},proc=V_WriteCSVDTButton,title="Write Dead Time CSV" |
---|
1692 | |
---|
1693 | SetVariable setvar0,pos={20,141},size={100.00,14.00},title="first" |
---|
1694 | SetVariable setvar0,value= root:Packages:NIST:VSANS:Globals:Patch:gFileNum_Lo |
---|
1695 | SetVariable setvar1,pos={20.00,167},size={100.00,14.00},title="last" |
---|
1696 | SetVariable setvar1,value= root:Packages:NIST:VSANS:Globals:Patch:gFileNum_Hi |
---|
1697 | |
---|
1698 | |
---|
1699 | // display the wave |
---|
1700 | Edit/W=(180,40,380,550)/HOST=# root:Packages:NIST:VSANS:Globals:Patch:deadTimeWave |
---|
1701 | ModifyTable width(Point)=40 |
---|
1702 | ModifyTable width(root:Packages:NIST:VSANS:Globals:Patch:deadTimeWave)=120 |
---|
1703 | RenameWindow #,T0 |
---|
1704 | SetActiveSubwindow ## |
---|
1705 | |
---|
1706 | |
---|
1707 | EndMacro |
---|
1708 | |
---|
1709 | |
---|
1710 | Function V_LoadCSVDTButton(ba) : ButtonControl |
---|
1711 | STRUCT WMButtonAction &ba |
---|
1712 | |
---|
1713 | switch( ba.eventCode ) |
---|
1714 | case 2: // mouse up |
---|
1715 | // click code here |
---|
1716 | |
---|
1717 | LoadWave/J/A/D/O/W/E=1/K=0 //will prompt for the file, auto name |
---|
1718 | |
---|
1719 | break |
---|
1720 | case -1: // control being killed |
---|
1721 | break |
---|
1722 | endswitch |
---|
1723 | |
---|
1724 | return 0 |
---|
1725 | End |
---|
1726 | |
---|
1727 | //TODO |
---|
1728 | // -- currently this skips detector "B", since its dead time is not like the tubes |
---|
1729 | // -- fails miserably if the deadtime_** waves don't exist |
---|
1730 | // -- the writing may take a long time. Warn the user. |
---|
1731 | // -- if the data files are not "cleaned up", re-reading will pick up the rawVSANS copy and it |
---|
1732 | // will look like nothing was written |
---|
1733 | // |
---|
1734 | // writes the entire content of the CSV file (all 8 panels) to each detector entry in each data file |
---|
1735 | // as specified by the run number range |
---|
1736 | // |
---|
1737 | Function V_WriteCSVDTButton(ba) : ButtonControl |
---|
1738 | STRUCT WMButtonAction &ba |
---|
1739 | |
---|
1740 | Variable ii |
---|
1741 | String detStr |
---|
1742 | |
---|
1743 | switch( ba.eventCode ) |
---|
1744 | case 2: // mouse up |
---|
1745 | // click code here |
---|
1746 | |
---|
1747 | // ControlInfo popup_0 |
---|
1748 | // String detStr = S_Value |
---|
1749 | ControlInfo setvar0 |
---|
1750 | Variable lo=V_Value |
---|
1751 | ControlInfo setvar1 |
---|
1752 | Variable hi=V_Value |
---|
1753 | Wave deadTimeW = root:Packages:NIST:VSANS:Globals:Patch:deadTimeWave |
---|
1754 | |
---|
1755 | for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) |
---|
1756 | detStr = StringFromList(ii, ksDetectorListNoB, ";") |
---|
1757 | Wave tmpW = $("root:deadtime_"+detStr) |
---|
1758 | deadTimeW = tmpW |
---|
1759 | V_fPatchDetectorDeadtime(lo,hi,detStr,deadtimeW) |
---|
1760 | endfor |
---|
1761 | |
---|
1762 | break |
---|
1763 | case -1: // control being killed |
---|
1764 | break |
---|
1765 | endswitch |
---|
1766 | |
---|
1767 | // TODO |
---|
1768 | // -- clear out the data folders (from lo to hi?) |
---|
1769 | // |
---|
1770 | // root:Packages:NIST:VSANS:RawVSANS:sans1301: |
---|
1771 | for(ii=lo;ii<=hi;ii+=1) |
---|
1772 | KillDataFolder/Z $("root:Packages:NIST:VSANS:RawVSANS:sans"+num2istr(ii)) |
---|
1773 | endfor |
---|
1774 | return 0 |
---|
1775 | End |
---|
1776 | |
---|
1777 | |
---|
1778 | Function V_GeneratePerfDTButton(ba) : ButtonControl |
---|
1779 | STRUCT WMButtonAction &ba |
---|
1780 | |
---|
1781 | switch( ba.eventCode ) |
---|
1782 | case 2: // mouse up |
---|
1783 | // click code here |
---|
1784 | |
---|
1785 | WAVE deadTimeWave = root:Packages:NIST:VSANS:Globals:Patch:deadTimeWave |
---|
1786 | ControlInfo popup_0 |
---|
1787 | strswitch(S_Value) |
---|
1788 | case "FR": |
---|
1789 | case "FL": |
---|
1790 | case "MR": |
---|
1791 | case "ML": |
---|
1792 | case "FT": |
---|
1793 | case "FB": |
---|
1794 | case "MT": |
---|
1795 | case "MB": |
---|
1796 | deadTimeWave = 1e-18 |
---|
1797 | |
---|
1798 | break |
---|
1799 | default: |
---|
1800 | Print "Det type not found: V_GeneratePerfDTButton()" |
---|
1801 | endswitch |
---|
1802 | |
---|
1803 | break |
---|
1804 | case -1: // control being killed |
---|
1805 | break |
---|
1806 | endswitch |
---|
1807 | |
---|
1808 | return 0 |
---|
1809 | End |
---|
1810 | |
---|
1811 | |
---|
1812 | |
---|
1813 | |
---|
1814 | Function V_ReadDTButtonProc(ba) : ButtonControl |
---|
1815 | STRUCT WMButtonAction &ba |
---|
1816 | |
---|
1817 | switch( ba.eventCode ) |
---|
1818 | case 2: // mouse up |
---|
1819 | // click code here |
---|
1820 | |
---|
1821 | ControlInfo popup_0 |
---|
1822 | String detStr = S_Value |
---|
1823 | ControlInfo setvar0 |
---|
1824 | Variable lo=V_Value |
---|
1825 | Variable hi=lo |
---|
1826 | |
---|
1827 | V_fReadDetectorDeadtime(lo,hi,detStr) |
---|
1828 | |
---|
1829 | break |
---|
1830 | case -1: // control being killed |
---|
1831 | break |
---|
1832 | endswitch |
---|
1833 | |
---|
1834 | return 0 |
---|
1835 | End |
---|
1836 | |
---|
1837 | Function V_WriteDTButtonProc(ba) : ButtonControl |
---|
1838 | STRUCT WMButtonAction &ba |
---|
1839 | |
---|
1840 | switch( ba.eventCode ) |
---|
1841 | case 2: // mouse up |
---|
1842 | // click code here |
---|
1843 | |
---|
1844 | ControlInfo popup_0 |
---|
1845 | String detStr = S_Value |
---|
1846 | ControlInfo setvar0 |
---|
1847 | Variable lo=V_Value |
---|
1848 | ControlInfo setvar1 |
---|
1849 | Variable hi=V_Value |
---|
1850 | Wave deadTimeW = root:Packages:NIST:VSANS:Globals:Patch:deadTimeWave |
---|
1851 | |
---|
1852 | V_fPatchDetectorDeadtime(lo,hi,detStr,deadtimeW) |
---|
1853 | |
---|
1854 | break |
---|
1855 | case -1: // control being killed |
---|
1856 | break |
---|
1857 | endswitch |
---|
1858 | |
---|
1859 | return 0 |
---|
1860 | End |
---|
1861 | |
---|
1862 | ////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
1863 | ////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
1864 | // this is a block to patch CALIBRATION waves to the file headers, and can patch multiple files |
---|
1865 | // |
---|
1866 | // uses a simple panel to show what the table of values is. |
---|
1867 | // "read" will read only the first run number contents. |
---|
1868 | // |
---|
1869 | // TODO -- need to clear out the contents from RawVSANS, or else re-reading to check the values |
---|
1870 | // will read locally, and it will look like nothing was written. Executing "save" will also |
---|
1871 | // trigger a cleanout. |
---|
1872 | // |
---|
1873 | // TODO -- link this to a panel somewhere - a button? menu item? will there be a lot more of these little panels? |
---|
1874 | // |
---|
1875 | // TODO -- currently this does not handle the back detector "B". see V_WritePerfectSpatialCalib(filename) |
---|
1876 | // for how fake data is written to the files |
---|
1877 | // |
---|
1878 | // TODO -- verify that the calibration waves are not transposed |
---|
1879 | // |
---|
1880 | Proc V_PatchDetectorCalibration(firstFile,lastFile,detStr,calibStr) |
---|
1881 | Variable firstFile=1,lastFile=100 |
---|
1882 | String detStr = "FL",calibStr="calibrationWave" |
---|
1883 | |
---|
1884 | V_fPatchDetectorCalibration(firstFile,lastFile,detStr,$calibStr) |
---|
1885 | |
---|
1886 | End |
---|
1887 | |
---|
1888 | Proc V_ReadDetectorCalibration(firstFile,lastFile,detStr) |
---|
1889 | Variable firstFile=1,lastFile=100 |
---|
1890 | String detStr = "FL" |
---|
1891 | |
---|
1892 | V_fReadDetectorCalibration(firstFile,lastFile,detStr) |
---|
1893 | End |
---|
1894 | |
---|
1895 | // simple utility to patch the detector calibration wave in the file headers |
---|
1896 | // lo is the first file number |
---|
1897 | // hi is the last file number (inclusive) |
---|
1898 | // |
---|
1899 | Function V_fPatchDetectorCalibration(lo,hi,detStr,calibW) |
---|
1900 | Variable lo,hi |
---|
1901 | String detStr |
---|
1902 | Wave calibW |
---|
1903 | |
---|
1904 | Variable ii |
---|
1905 | String fname |
---|
1906 | |
---|
1907 | // check the dimensions of the calibW (3,48) |
---|
1908 | if (DimSize(calibW, 0) != 3 || DimSize(calibW, 1) != 48 ) |
---|
1909 | Abort "Calibration wave is not of proper dimension (3,48)" |
---|
1910 | endif |
---|
1911 | |
---|
1912 | //loop over all files |
---|
1913 | for(ii=lo;ii<=hi;ii+=1) |
---|
1914 | fname = V_FindFileFromRunNumber(ii) |
---|
1915 | if(strlen(fname) != 0) |
---|
1916 | V_writeDetTube_spatialCalib(fname,detStr,calibW) |
---|
1917 | else |
---|
1918 | printf "run number %d not found\r",ii |
---|
1919 | endif |
---|
1920 | endfor |
---|
1921 | |
---|
1922 | return(0) |
---|
1923 | End |
---|
1924 | |
---|
1925 | // simple utility to read the detector deadtime stored in the file header |
---|
1926 | Function V_fReadDetectorCalibration(lo,hi,detStr) |
---|
1927 | Variable lo,hi |
---|
1928 | String detStr |
---|
1929 | |
---|
1930 | String fname |
---|
1931 | Variable ii |
---|
1932 | |
---|
1933 | for(ii=lo;ii<=hi;ii+=1) |
---|
1934 | fname = V_FindFileFromRunNumber(ii) |
---|
1935 | if(strlen(fname) != 0) |
---|
1936 | Wave calibW = V_getDetTube_spatialCalib(fname,detStr) |
---|
1937 | Duplicate/O calibW root:Packages:NIST:VSANS:Globals:Patch:calibrationWave |
---|
1938 | else |
---|
1939 | printf "run number %d not found\r",ii |
---|
1940 | endif |
---|
1941 | endfor |
---|
1942 | |
---|
1943 | return(0) |
---|
1944 | End |
---|
1945 | |
---|
1946 | |
---|
1947 | Proc V_PatchDetectorCalibrationPanel() |
---|
1948 | DoWindow/F CalibrationPanel |
---|
1949 | if(V_flag==0) |
---|
1950 | |
---|
1951 | NewDataFolder/O/S root:Packages:NIST:VSANS:Globals:Patch |
---|
1952 | |
---|
1953 | Make/O/D/N=(3,48) calibrationWave |
---|
1954 | |
---|
1955 | Variable/G gFileNum_Lo,gFileNum_Hi |
---|
1956 | SetDataFolder root: |
---|
1957 | |
---|
1958 | Execute "V_CalibrationPatchPanel()" |
---|
1959 | endif |
---|
1960 | End |
---|
1961 | |
---|
1962 | |
---|
1963 | // |
---|
1964 | // TODO: |
---|
1965 | // x- add method for generating "perfect" calibration to write |
---|
1966 | // x- check Nx3 dimension before writing (check for bad paste operation) |
---|
1967 | // -- load from file? different ways to import? |
---|
1968 | // -- calibration constants for "B" are different, and not handled here (yet) |
---|
1969 | // -- add help button/file |
---|
1970 | // -- add done button |
---|
1971 | // -- adjust after user testing |
---|
1972 | // |
---|
1973 | Proc V_CalibrationPatchPanel() : Panel |
---|
1974 | PauseUpdate; Silent 1 // building window... |
---|
1975 | |
---|
1976 | |
---|
1977 | NewPanel /W=(600,400,1200,1000)/N=CalibrationPanel /K=1 |
---|
1978 | // ShowTools/A |
---|
1979 | ModifyPanel cbRGB=(16266,47753,2552,23355) |
---|
1980 | |
---|
1981 | SetDrawLayer UserBack |
---|
1982 | DrawText 85,99,"Current Values" |
---|
1983 | DrawText 21,258,"Write to all files (inlcusive)" |
---|
1984 | SetDrawEnv fsize= 14,fstyle= 1 |
---|
1985 | DrawText 227,28,"Quadratic Calibration Constants per Tube" |
---|
1986 | DrawText 20,133,"Run Number(s)" |
---|
1987 | |
---|
1988 | PopupMenu popup_0,pos={20,40},size={109,20},title="Detector Panel" |
---|
1989 | PopupMenu popup_0,mode=1,popvalue="FL",value= #"\"FL;FR;FT;FB;ML;MR;MT;MB;\"" |
---|
1990 | |
---|
1991 | Button button0,pos={20,81},size={50.00,20.00},proc=V_ReadCalibButtonProc,title="Read" |
---|
1992 | Button button0_1,pos={20,220},size={50.00,20.00},proc=V_WriteCalibButtonProc,title="Write" |
---|
1993 | Button button0_2,pos={18.00,336.00},size={140.00,20.00},proc=V_GeneratePerfCalibButton,title="Perfect Calibration" |
---|
1994 | Button button0_3,pos={18.00,370.00},size={140.00,20.00},proc=V_LoadCSVCalibButton,title="Load Calibration CSV" |
---|
1995 | Button button0_4,pos={18.00,400.00},size={140.00,20.00},proc=V_WriteCSVCalibButton,title="Write Calibration CSV" |
---|
1996 | |
---|
1997 | SetVariable setvar0,pos={20,141},size={100.00,14.00},title="first" |
---|
1998 | SetVariable setvar0,value= root:Packages:NIST:VSANS:Globals:Patch:gFileNum_Lo |
---|
1999 | SetVariable setvar1,pos={20.00,167},size={100.00,14.00},title="last" |
---|
2000 | SetVariable setvar1,value= root:Packages:NIST:VSANS:Globals:Patch:gFileNum_Hi |
---|
2001 | |
---|
2002 | |
---|
2003 | // display the wave |
---|
2004 | Edit/W=(180,40,580,550)/HOST=# root:Packages:NIST:VSANS:Globals:Patch:calibrationWave |
---|
2005 | ModifyTable width(Point)=40 |
---|
2006 | ModifyTable width(root:Packages:NIST:VSANS:Globals:Patch:calibrationWave)=110 |
---|
2007 | // the elements() command transposes the view in the table, but does not transpose the wave |
---|
2008 | ModifyTable elements(root:Packages:NIST:VSANS:Globals:Patch:calibrationWave) = (-3, -2) |
---|
2009 | RenameWindow #,T0 |
---|
2010 | SetActiveSubwindow ## |
---|
2011 | |
---|
2012 | |
---|
2013 | EndMacro |
---|
2014 | |
---|
2015 | |
---|
2016 | Function V_LoadCSVCalibButton(ba) : ButtonControl |
---|
2017 | STRUCT WMButtonAction &ba |
---|
2018 | |
---|
2019 | switch( ba.eventCode ) |
---|
2020 | case 2: // mouse up |
---|
2021 | // click code here |
---|
2022 | |
---|
2023 | LoadWave/J/A/D/O/W/E=1/K=0 //will prompt for the file, auto name |
---|
2024 | |
---|
2025 | break |
---|
2026 | case -1: // control being killed |
---|
2027 | break |
---|
2028 | endswitch |
---|
2029 | |
---|
2030 | return 0 |
---|
2031 | End |
---|
2032 | |
---|
2033 | //TODO |
---|
2034 | // -- currently this skips detector "B", since its calibration is not like the tubes |
---|
2035 | // -- fails miserably if the a,b,c_** waves don't exist |
---|
2036 | // -- the writing may take a long time. Warn the user. |
---|
2037 | // -- if the data files are not "cleaned up", re-reading will pick up the rawVSANS copy and it |
---|
2038 | // will look like nothing was written |
---|
2039 | // |
---|
2040 | // writes the entire content of the CSV file (all 8 panels) to each detector entry in each data file |
---|
2041 | // as specified by the run number range |
---|
2042 | // |
---|
2043 | Function V_WriteCSVCalibButton(ba) : ButtonControl |
---|
2044 | STRUCT WMButtonAction &ba |
---|
2045 | |
---|
2046 | Variable ii |
---|
2047 | String detStr |
---|
2048 | |
---|
2049 | switch( ba.eventCode ) |
---|
2050 | case 2: // mouse up |
---|
2051 | // click code here |
---|
2052 | |
---|
2053 | // ControlInfo popup_0 |
---|
2054 | // String detStr = S_Value |
---|
2055 | ControlInfo setvar0 |
---|
2056 | Variable lo=V_Value |
---|
2057 | ControlInfo setvar1 |
---|
2058 | Variable hi=V_Value |
---|
2059 | WAVE calibrationWave = root:Packages:NIST:VSANS:Globals:Patch:calibrationWave |
---|
2060 | |
---|
2061 | for(ii=0;ii<ItemsInList(ksDetectorListNoB);ii+=1) |
---|
2062 | detStr = StringFromList(ii, ksDetectorListNoB, ";") |
---|
2063 | Wave tmp_a = $("root:a_"+detStr) |
---|
2064 | Wave tmp_b = $("root:b_"+detStr) |
---|
2065 | Wave tmp_c = $("root:c_"+detStr) |
---|
2066 | calibrationWave[0][] = tmp_a[q] |
---|
2067 | calibrationWave[1][] = tmp_b[q] |
---|
2068 | calibrationWave[2][] = tmp_c[q] |
---|
2069 | V_fPatchDetectorCalibration(lo,hi,detStr,calibrationWave) |
---|
2070 | endfor |
---|
2071 | |
---|
2072 | break |
---|
2073 | case -1: // control being killed |
---|
2074 | break |
---|
2075 | endswitch |
---|
2076 | |
---|
2077 | // TODO |
---|
2078 | // -- clear out the data folders (from lo to hi?) |
---|
2079 | // |
---|
2080 | // root:Packages:NIST:VSANS:RawVSANS:sans1301: |
---|
2081 | for(ii=lo;ii<=hi;ii+=1) |
---|
2082 | KillDataFolder/Z $("root:Packages:NIST:VSANS:RawVSANS:sans"+num2istr(ii)) |
---|
2083 | endfor |
---|
2084 | return 0 |
---|
2085 | End |
---|
2086 | |
---|
2087 | |
---|
2088 | |
---|
2089 | // // and for the back detector "B" |
---|
2090 | // Make/O/D/N=3 tmpCalib |
---|
2091 | // tmpCalib[0] = 1 |
---|
2092 | // tmpCalib[1] = 1 |
---|
2093 | // tmpcalib[2] = 10000 |
---|
2094 | // V_writeDet_cal_x(filename,"B",tmpCalib) |
---|
2095 | // V_writeDet_cal_y(filename,"B",tmpCalib) |
---|
2096 | // |
---|
2097 | // "Perfect" values here are from Phil (2/2018) |
---|
2098 | // |
---|
2099 | Function V_GeneratePerfCalibButton(ba) : ButtonControl |
---|
2100 | STRUCT WMButtonAction &ba |
---|
2101 | |
---|
2102 | switch( ba.eventCode ) |
---|
2103 | case 2: // mouse up |
---|
2104 | // click code here |
---|
2105 | |
---|
2106 | WAVE calibrationWave = root:Packages:NIST:VSANS:Globals:Patch:calibrationWave |
---|
2107 | ControlInfo popup_0 |
---|
2108 | strswitch(S_Value) |
---|
2109 | case "FR": |
---|
2110 | case "FL": |
---|
2111 | case "MR": |
---|
2112 | case "ML": |
---|
2113 | // // for the "tall" L/R banks |
---|
2114 | calibrationWave[0][] = -521 |
---|
2115 | calibrationWave[1][] = 8.14 |
---|
2116 | calibrationWave[2][] = 0 |
---|
2117 | break |
---|
2118 | case "FT": |
---|
2119 | case "FB": |
---|
2120 | case "MT": |
---|
2121 | case "MB": |
---|
2122 | // // for the "short" T/B banks |
---|
2123 | calibrationWave[0][] = -266 |
---|
2124 | calibrationWave[1][] = 4.16 |
---|
2125 | calibrationWave[2][] = 0 |
---|
2126 | |
---|
2127 | break |
---|
2128 | default: |
---|
2129 | Print "Det type not found: V_GeneratePerfCalibButton()" |
---|
2130 | endswitch |
---|
2131 | |
---|
2132 | |
---|
2133 | |
---|
2134 | break |
---|
2135 | case -1: // control being killed |
---|
2136 | break |
---|
2137 | endswitch |
---|
2138 | |
---|
2139 | return 0 |
---|
2140 | End |
---|
2141 | |
---|
2142 | |
---|
2143 | Function V_ReadCalibButtonProc(ba) : ButtonControl |
---|
2144 | STRUCT WMButtonAction &ba |
---|
2145 | |
---|
2146 | switch( ba.eventCode ) |
---|
2147 | case 2: // mouse up |
---|
2148 | // click code here |
---|
2149 | |
---|
2150 | ControlInfo popup_0 |
---|
2151 | String detStr = S_Value |
---|
2152 | ControlInfo setvar0 |
---|
2153 | Variable lo=V_Value |
---|
2154 | Variable hi=lo |
---|
2155 | |
---|
2156 | V_fReadDetectorCalibration(lo,hi,detStr) |
---|
2157 | |
---|
2158 | break |
---|
2159 | case -1: // control being killed |
---|
2160 | break |
---|
2161 | endswitch |
---|
2162 | |
---|
2163 | return 0 |
---|
2164 | End |
---|
2165 | |
---|
2166 | Function V_WriteCalibButtonProc(ba) : ButtonControl |
---|
2167 | STRUCT WMButtonAction &ba |
---|
2168 | |
---|
2169 | switch( ba.eventCode ) |
---|
2170 | case 2: // mouse up |
---|
2171 | // click code here |
---|
2172 | |
---|
2173 | ControlInfo popup_0 |
---|
2174 | String detStr = S_Value |
---|
2175 | ControlInfo setvar0 |
---|
2176 | Variable lo=V_Value |
---|
2177 | ControlInfo setvar1 |
---|
2178 | Variable hi=V_Value |
---|
2179 | Wave calibW = root:Packages:NIST:VSANS:Globals:Patch:calibrationWave |
---|
2180 | |
---|
2181 | V_fPatchDetectorCalibration(lo,hi,detStr,calibW) |
---|
2182 | |
---|
2183 | break |
---|
2184 | case -1: // control being killed |
---|
2185 | break |
---|
2186 | endswitch |
---|
2187 | |
---|
2188 | return 0 |
---|
2189 | End |
---|
2190 | |
---|
2191 | |
---|
2192 | |
---|
2193 | ////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
2194 | ////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
2195 | |
---|
2196 | |
---|
2197 | |
---|
2198 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
2199 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
2200 | /////////////// |
---|
2201 | // |
---|
2202 | // this is a block to patch beam centers to the file headers |
---|
2203 | // it will patch the headers for all 9 detectors |
---|
2204 | // and can patch multiple files |
---|
2205 | // |
---|
2206 | // uses a simple panel to show what the table of values is. |
---|
2207 | // "read" will read only the first run number contents. this is the "good" set of XY |
---|
2208 | // that you want to write out to other files. |
---|
2209 | // |
---|
2210 | // TODO -- need to clear out the contents from RawVSANS, or else re-reading to check the values |
---|
2211 | // will read locally, and it will look like nothing was written. Executing "save" will also |
---|
2212 | // trigger a cleanout. |
---|
2213 | // |
---|
2214 | // TODO - link this to a panel somewhere - a button? menu item? will there be a lot more of these little panels? |
---|
2215 | // |
---|
2216 | Proc V_PatchDet_xyCenters(firstFile,lastFile) |
---|
2217 | Variable firstFile=1,lastFile=100 |
---|
2218 | |
---|
2219 | V_fPatchDet_xyCenters(firstFile,lastFile) |
---|
2220 | |
---|
2221 | End |
---|
2222 | |
---|
2223 | Proc V_ReadDet_xyCenters(firstFile,lastFile) |
---|
2224 | Variable firstFile=1,lastFile=100 |
---|
2225 | |
---|
2226 | |
---|
2227 | V_fReadDet_xyCenters(firstFile,lastFile) |
---|
2228 | End |
---|
2229 | |
---|
2230 | // simple utility to patch the xy center in the file headers |
---|
2231 | // lo is the first file number |
---|
2232 | // hi is the last file number (inclusive) |
---|
2233 | // |
---|
2234 | Function V_fPatchDet_xyCenters(lo,hi) |
---|
2235 | Variable lo,hi |
---|
2236 | |
---|
2237 | |
---|
2238 | Variable ii,jj |
---|
2239 | String fname,detStr |
---|
2240 | |
---|
2241 | Wave xCtr_cm = root:Packages:NIST:VSANS:Globals:Patch:xCtr_cm |
---|
2242 | Wave yCtr_cm = root:Packages:NIST:VSANS:Globals:Patch:yCtr_cm |
---|
2243 | Wave/T panelW = root:Packages:NIST:VSANS:Globals:Patch:panelW |
---|
2244 | |
---|
2245 | // check the dimensions of the waves (9) |
---|
2246 | if (DimSize(xCtr_cm, 0) != 9 || DimSize(yCtr_cm, 0) != 9 || DimSize(panelW, 0) != 9) |
---|
2247 | Abort "waves are not of proper dimension (9)" |
---|
2248 | endif |
---|
2249 | |
---|
2250 | //loop over all files |
---|
2251 | for(jj=lo;jj<=hi;jj+=1) |
---|
2252 | fname = V_FindFileFromRunNumber(jj) |
---|
2253 | if(strlen(fname) != 0) |
---|
2254 | |
---|
2255 | for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) |
---|
2256 | detStr = panelW[ii] |
---|
2257 | V_writeDet_beam_center_x(fname,detStr,xCtr_cm[ii]) |
---|
2258 | V_writeDet_beam_center_y(fname,detStr,yCtr_cm[ii]) |
---|
2259 | endfor |
---|
2260 | |
---|
2261 | else |
---|
2262 | printf "run number %d not found\r",jj |
---|
2263 | endif |
---|
2264 | endfor |
---|
2265 | |
---|
2266 | return(0) |
---|
2267 | End |
---|
2268 | |
---|
2269 | // simple utility to read the detector xy centers stored in the file header |
---|
2270 | Function V_fReadDet_xyCenters(lo,hi) |
---|
2271 | Variable lo,hi |
---|
2272 | |
---|
2273 | |
---|
2274 | String fname,detStr |
---|
2275 | Variable ii,jj |
---|
2276 | |
---|
2277 | Wave xCtr_cm = root:Packages:NIST:VSANS:Globals:Patch:xCtr_cm |
---|
2278 | Wave yCtr_cm = root:Packages:NIST:VSANS:Globals:Patch:yCtr_cm |
---|
2279 | Wave/T panelW = root:Packages:NIST:VSANS:Globals:Patch:panelW |
---|
2280 | |
---|
2281 | for(jj=lo;jj<=hi;jj+=1) |
---|
2282 | fname = V_FindFileFromRunNumber(jj) |
---|
2283 | if(strlen(fname) != 0) |
---|
2284 | |
---|
2285 | for(ii=0;ii<ItemsInList(ksDetectorListAll);ii+=1) |
---|
2286 | detStr = StringFromList(ii, ksDetectorListAll, ";") |
---|
2287 | panelW[ii] = detStr |
---|
2288 | xCtr_cm[ii] = V_getDet_beam_center_x(fname,detStr) //these values are in cm, not pixels |
---|
2289 | yCtr_cm[ii] = V_getDet_beam_center_y(fname,detStr) |
---|
2290 | endfor |
---|
2291 | |
---|
2292 | |
---|
2293 | else |
---|
2294 | printf "run number %d not found\r",jj |
---|
2295 | endif |
---|
2296 | |
---|
2297 | endfor |
---|
2298 | |
---|
2299 | |
---|
2300 | return(0) |
---|
2301 | End |
---|
2302 | |
---|
2303 | |
---|
2304 | |
---|
2305 | Proc V_PatchDet_xyCenters_Panel() |
---|
2306 | DoWindow/F Patch_XY_Panel |
---|
2307 | if(V_flag==0) |
---|
2308 | |
---|
2309 | NewDataFolder/O/S root:Packages:NIST:VSANS:Globals:Patch |
---|
2310 | |
---|
2311 | Make/O/D/N=9 xCtr_cm,yCtr_cm |
---|
2312 | Make/O/T/N=9 panelW |
---|
2313 | |
---|
2314 | Variable/G gFileNum_Lo,gFileNum_Hi |
---|
2315 | |
---|
2316 | SetDataFolder root: |
---|
2317 | |
---|
2318 | Execute "V_Patch_xyCtr_Panel()" |
---|
2319 | endif |
---|
2320 | End |
---|
2321 | |
---|
2322 | |
---|
2323 | // TODO: |
---|
2324 | // -- add method to read (import) from beam center panel |
---|
2325 | // x- check wave dimensions before writing (check for bad paste operation) |
---|
2326 | // -- load from file? different ways to import? |
---|
2327 | // -- add help button/file |
---|
2328 | // -- add done button |
---|
2329 | // -- adjust after user testing |
---|
2330 | // |
---|
2331 | Proc V_Patch_xyCtr_Panel() : Panel |
---|
2332 | PauseUpdate; Silent 1 // building window... |
---|
2333 | |
---|
2334 | |
---|
2335 | NewPanel /W=(600,400,1150,800)/N=Patch_XY_Panel /K=1 |
---|
2336 | // ShowTools/A |
---|
2337 | |
---|
2338 | ModifyPanel cbRGB=(16266,47753,2552,23355) |
---|
2339 | |
---|
2340 | SetDrawLayer UserBack |
---|
2341 | DrawText 85,99,"Current Values" |
---|
2342 | DrawText 21,258,"Write to all files (inlcusive)" |
---|
2343 | SetDrawEnv fsize= 14,fstyle= 1 |
---|
2344 | DrawText 262,30,"Beam Center (cm)" |
---|
2345 | DrawText 20,133,"Run Number(s)" |
---|
2346 | |
---|
2347 | Button button0,pos={20,81},size={50.00,20.00},proc=V_ReadXYButtonProc,title="Read" |
---|
2348 | Button button0_1,pos={20,220},size={50.00,20.00},proc=V_WriteXYButtonProc,title="Write" |
---|
2349 | SetVariable setvar0,pos={20,141},size={100.00,14.00},title="first" |
---|
2350 | SetVariable setvar0,value= root:Packages:NIST:VSANS:Globals:Patch:gFileNum_Lo |
---|
2351 | SetVariable setvar1,pos={20.00,167},size={100.00,14.00},title="last" |
---|
2352 | SetVariable setvar1,value= root:Packages:NIST:VSANS:Globals:Patch:gFileNum_Hi |
---|
2353 | |
---|
2354 | |
---|
2355 | SetDataFolder root:Packages:NIST:VSANS:Globals:Patch |
---|
2356 | // display the wave |
---|
2357 | Edit/W=(180,40,500,370)/HOST=# panelW,xCtr_cm,yCtr_cm |
---|
2358 | ModifyTable width(Point)=0 |
---|
2359 | ModifyTable width(panelW)=80 |
---|
2360 | ModifyTable width(xCtr_cm)=100 |
---|
2361 | ModifyTable width(yCtr_cm)=100 |
---|
2362 | RenameWindow #,T0 |
---|
2363 | SetActiveSubwindow ## |
---|
2364 | |
---|
2365 | SetDataFolder root: |
---|
2366 | |
---|
2367 | EndMacro |
---|
2368 | |
---|
2369 | |
---|
2370 | Function V_ReadXYButtonProc(ba) : ButtonControl |
---|
2371 | STRUCT WMButtonAction &ba |
---|
2372 | |
---|
2373 | switch( ba.eventCode ) |
---|
2374 | case 2: // mouse up |
---|
2375 | // click code here |
---|
2376 | |
---|
2377 | // ControlInfo popup_0 |
---|
2378 | // String detStr = S_Value |
---|
2379 | ControlInfo setvar0 |
---|
2380 | Variable lo=V_Value |
---|
2381 | Variable hi=lo |
---|
2382 | |
---|
2383 | V_fReadDet_xyCenters(lo,hi) |
---|
2384 | |
---|
2385 | break |
---|
2386 | case -1: // control being killed |
---|
2387 | break |
---|
2388 | endswitch |
---|
2389 | |
---|
2390 | return 0 |
---|
2391 | End |
---|
2392 | |
---|
2393 | Function V_WriteXYButtonProc(ba) : ButtonControl |
---|
2394 | STRUCT WMButtonAction &ba |
---|
2395 | |
---|
2396 | switch( ba.eventCode ) |
---|
2397 | case 2: // mouse up |
---|
2398 | // click code here |
---|
2399 | |
---|
2400 | // ControlInfo popup_0 |
---|
2401 | // String detStr = S_Value |
---|
2402 | ControlInfo setvar0 |
---|
2403 | Variable lo=V_Value |
---|
2404 | ControlInfo setvar1 |
---|
2405 | Variable hi=V_Value |
---|
2406 | // Wave deadTimeW = root:Packages:NIST:VSANS:Globals:Patch:deadTimeWave |
---|
2407 | |
---|
2408 | V_fPatchDet_xyCenters(lo,hi) |
---|
2409 | |
---|
2410 | break |
---|
2411 | case -1: // control being killed |
---|
2412 | break |
---|
2413 | endswitch |
---|
2414 | |
---|
2415 | return 0 |
---|
2416 | End |
---|
2417 | |
---|
2418 | ////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
2419 | ////////////////////////////////////////////////////////////////////////////////////////////////// |
---|
2420 | |
---|
2421 | |
---|
2422 | Proc V_PatchDet_Offset(lo,hi) |
---|
2423 | Variable lo,hi |
---|
2424 | |
---|
2425 | V_fPatchDet_Offset(lo,hi) |
---|
2426 | End |
---|
2427 | |
---|
2428 | Proc V_MarkLeftRightFlip_Done(lo,hi) |
---|
2429 | Variable lo,hi |
---|
2430 | |
---|
2431 | V_fWriteFlipState(lo,hi,1) // value == 1 means flip done |
---|
2432 | End |
---|
2433 | |
---|
2434 | Proc V_MarkLeftRightFlip_Not_Done(lo,hi) |
---|
2435 | Variable lo,hi |
---|
2436 | |
---|
2437 | V_fWriteFlipState(lo,hi,-999999) // value == -999999 means flip not done |
---|
2438 | End |
---|
2439 | |
---|
2440 | |
---|
2441 | Proc V_Patch_GroupID_catTable() |
---|
2442 | V_fPatch_GroupID_catTable() |
---|
2443 | end |
---|
2444 | |
---|
2445 | Proc V_Patch_Purpose_catTable() |
---|
2446 | V_fPatch_Purpose_catTable() |
---|
2447 | end |
---|
2448 | |
---|
2449 | Proc V_Patch_Intent_catTable() |
---|
2450 | V_fPatch_Intent_catTable() |
---|
2451 | end |
---|
2452 | |
---|
2453 | Proc V_PatchDet_Gap(lo,hi) |
---|
2454 | Variable lo,hi |
---|
2455 | |
---|
2456 | V_fPatchDet_Gap(lo,hi) |
---|
2457 | End |
---|
2458 | |
---|
2459 | Proc V_ReadDet_Gap(lo,hi) |
---|
2460 | Variable lo,hi |
---|
2461 | |
---|
2462 | V_fReadDet_Gap(lo,hi) |
---|
2463 | End |
---|
2464 | |
---|
2465 | Proc V_PatchDet_Distance(lo,hi,dist_f,dist_m,dist_b) |
---|
2466 | Variable lo,hi,dist_f=400,dist_m=1900,dist_b=2200 |
---|
2467 | |
---|
2468 | V_fPatchDet_distance(lo,hi,dist_f,dist_m,dist_b) |
---|
2469 | End |
---|
2470 | |
---|
2471 | Proc V_Patch_Back_Detector(lo,hi) |
---|
2472 | Variable lo,hi |
---|
2473 | |
---|
2474 | V_fPatch_BackDetector(lo,hi) |
---|
2475 | End |
---|
2476 | |
---|
2477 | |
---|
2478 | Proc V_Patch_XYPixelSize(lo,hi) |
---|
2479 | Variable lo,hi |
---|
2480 | |
---|
2481 | V_fPatch_XYPixelSize(lo,hi) |
---|
2482 | End |
---|
2483 | |
---|
2484 | // simple utility to patch the offset values in the file headers |
---|
2485 | // |
---|
2486 | // Swaps only the L/R detector values |
---|
2487 | // lo is the first file number |
---|
2488 | // hi is the last file number (inclusive) |
---|
2489 | // |
---|
2490 | // V_getLeftRightFlipDone(fname) |
---|
2491 | // |
---|
2492 | // |
---|
2493 | // updated the function to check for the "already done" flag |
---|
2494 | // - if already done, report this and do nothing. |
---|
2495 | // - if not done, do the flip and set the flag |
---|
2496 | // |
---|
2497 | Function V_fPatchDet_Offset(lo,hi) |
---|
2498 | Variable lo,hi |
---|
2499 | |
---|
2500 | |
---|
2501 | Variable ii,jj,flipDone=0 |
---|
2502 | String fname,detStr |
---|
2503 | |
---|
2504 | Variable offset_ML,offset_MR,offset_FL,offset_FR |
---|
2505 | |
---|
2506 | |
---|
2507 | //loop over all files |
---|
2508 | for(jj=lo;jj<=hi;jj+=1) |
---|
2509 | fname = V_FindFileFromRunNumber(jj) |
---|
2510 | if(strlen(fname) != 0) |
---|
2511 | |
---|
2512 | flipDone = V_getLeftRightFlipDone(fname) |
---|
2513 | if(flipDone == 1) |
---|
2514 | printf "run number %d already flipped - nothing done\r",jj |
---|
2515 | else |
---|
2516 | offset_FL = V_getDet_LateralOffset(fname,"FL") |
---|
2517 | offset_FR = V_getDet_LateralOffset(fname,"FR") |
---|
2518 | |
---|
2519 | offset_ML = V_getDet_LateralOffset(fname,"ML") |
---|
2520 | offset_MR = V_getDet_LateralOffset(fname,"MR") |
---|
2521 | |
---|
2522 | // swap L/R offset values |
---|
2523 | V_WriteDet_LateralOffset(fname,"FL",-offset_FR) |
---|
2524 | V_WriteDet_LateralOffset(fname,"FR",-offset_FL) |
---|
2525 | |
---|
2526 | V_WriteDet_LateralOffset(fname,"ML",-offset_MR) |
---|
2527 | V_WriteDet_LateralOffset(fname,"MR",-offset_ML) |
---|
2528 | |
---|
2529 | // set the flag |
---|
2530 | V_writeLeftRightFlipDone(fname,1) // value == 1 means the flip was done |
---|
2531 | Print fname |
---|
2532 | Print "swapped FL, FR = ",-offset_FR,-offset_FL |
---|
2533 | Print "swapped ML, MR = ",-offset_MR,-offset_ML |
---|
2534 | |
---|
2535 | endif |
---|
2536 | |
---|
2537 | else |
---|
2538 | printf "run number %d not found\r",jj |
---|
2539 | endif |
---|
2540 | |
---|
2541 | endfor |
---|
2542 | |
---|
2543 | return(0) |
---|
2544 | End |
---|
2545 | |
---|
2546 | // utility to reset the flip state in the file headers |
---|
2547 | // |
---|
2548 | // lo is the first file number |
---|
2549 | // hi is the last file number (inclusive) |
---|
2550 | // |
---|
2551 | // setting value == 1 means done |
---|
2552 | // setting value == -999999 means not done (mimics a missing /entry) |
---|
2553 | // |
---|
2554 | Function V_fWriteFlipState(lo,hi,val) |
---|
2555 | Variable lo,hi,val |
---|
2556 | |
---|
2557 | |
---|
2558 | Variable ii,jj,flipDone=0 |
---|
2559 | String fname,detStr |
---|
2560 | |
---|
2561 | Variable offset_ML,offset_MR,offset_FL,offset_FR |
---|
2562 | |
---|
2563 | //loop over all files |
---|
2564 | for(jj=lo;jj<=hi;jj+=1) |
---|
2565 | fname = V_FindFileFromRunNumber(jj) |
---|
2566 | if(strlen(fname) != 0) |
---|
2567 | |
---|
2568 | // set the flag |
---|
2569 | V_writeLeftRightFlipDone(fname,val) // |
---|
2570 | Print fname |
---|
2571 | printf "run number %d flag reset to %d\r",jj,val |
---|
2572 | |
---|
2573 | else |
---|
2574 | printf "run number %d not found\r",jj |
---|
2575 | endif |
---|
2576 | |
---|
2577 | endfor |
---|
2578 | |
---|
2579 | return(0) |
---|
2580 | End |
---|
2581 | |
---|
2582 | |
---|
2583 | |
---|
2584 | // simple utility to read the detector offset stored in the file header |
---|
2585 | Function V_fReadDet_Offset(lo,hi) |
---|
2586 | Variable lo,hi |
---|
2587 | |
---|
2588 | String fname,detStr |
---|
2589 | Variable jj |
---|
2590 | Variable offset_ML,offset_MR,offset_FL,offset_FR |
---|
2591 | |
---|
2592 | for(jj=lo;jj<=hi;jj+=1) |
---|
2593 | fname = V_FindFileFromRunNumber(jj) |
---|
2594 | if(strlen(fname) != 0) |
---|
2595 | |
---|
2596 | offset_FL = V_getDet_LateralOffset(fname,"FL") |
---|
2597 | offset_FR = V_getDet_LateralOffset(fname,"FR") |
---|
2598 | |
---|
2599 | offset_ML = V_getDet_LateralOffset(fname,"ML") |
---|
2600 | offset_MR = V_getDet_LateralOffset(fname,"MR") |
---|
2601 | |
---|
2602 | Print fname |
---|
2603 | Print "FL, FR = ",offset_FL,offset_FR |
---|
2604 | Print "ML, MR = ",offset_ML,offset_MR |
---|
2605 | |
---|
2606 | |
---|
2607 | else |
---|
2608 | printf "run number %d not found\r",jj |
---|
2609 | endif |
---|
2610 | |
---|
2611 | endfor |
---|
2612 | |
---|
2613 | |
---|
2614 | return(0) |
---|
2615 | End |
---|
2616 | |
---|
2617 | |
---|
2618 | // patches the group_ID, based on whatever is in the catTable |
---|
2619 | // |
---|
2620 | Function V_fPatch_GroupID_catTable() |
---|
2621 | Variable lo,hi |
---|
2622 | |
---|
2623 | |
---|
2624 | Variable ii,jj,num |
---|
2625 | |
---|
2626 | Wave id = root:Packages:NIST:VSANS:CatVSHeaderInfo:Group_ID |
---|
2627 | Wave/T fileNameW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames |
---|
2628 | |
---|
2629 | num = numpnts(id) |
---|
2630 | //loop over all files |
---|
2631 | for(jj=0;jj<num;jj+=1) |
---|
2632 | Print "update file ",jj,fileNameW[jj] |
---|
2633 | V_writeSample_GroupID(fileNameW[jj],id[jj]) |
---|
2634 | endfor |
---|
2635 | |
---|
2636 | return(0) |
---|
2637 | End |
---|
2638 | |
---|
2639 | |
---|
2640 | // patches the Purpose, based on whatever is in the catTable |
---|
2641 | // |
---|
2642 | Function V_fPatch_Purpose_catTable() |
---|
2643 | Variable lo,hi |
---|
2644 | |
---|
2645 | |
---|
2646 | Variable ii,jj,num |
---|
2647 | |
---|
2648 | Wave/T purpose = root:Packages:NIST:VSANS:CatVSHeaderInfo:Purpose |
---|
2649 | Wave/T fileNameW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames |
---|
2650 | |
---|
2651 | num = numpnts(purpose) |
---|
2652 | //loop over all files |
---|
2653 | for(jj=0;jj<num;jj+=1) |
---|
2654 | Print "update file ",jj,fileNameW[jj] |
---|
2655 | V_writeReduction_Purpose(fileNameW[jj],purpose[jj]) |
---|
2656 | endfor |
---|
2657 | |
---|
2658 | return(0) |
---|
2659 | End |
---|
2660 | |
---|
2661 | // patches the Intent, based on whatever is in the catTable |
---|
2662 | // |
---|
2663 | Function V_fPatch_Intent_catTable() |
---|
2664 | Variable lo,hi |
---|
2665 | |
---|
2666 | |
---|
2667 | Variable ii,jj,num |
---|
2668 | |
---|
2669 | Wave/T intent = root:Packages:NIST:VSANS:CatVSHeaderInfo:Intent |
---|
2670 | Wave/T fileNameW = root:Packages:NIST:VSANS:CatVSHeaderInfo:Filenames |
---|
2671 | |
---|
2672 | num = numpnts(intent) |
---|
2673 | //loop over all files |
---|
2674 | for(jj=0;jj<num;jj+=1) |
---|
2675 | Print "update file ",jj,fileNameW[jj] |
---|
2676 | V_writeReductionIntent(fileNameW[jj],intent[jj]) |
---|
2677 | endfor |
---|
2678 | |
---|
2679 | return(0) |
---|
2680 | End |
---|
2681 | |
---|
2682 | |
---|
2683 | |
---|
2684 | // simple utility to patch the detector gap values in the file headers |
---|
2685 | // |
---|
2686 | // values are measured values in [mm], not estimated |
---|
2687 | // |
---|
2688 | // lo is the first file number |
---|
2689 | // hi is the last file number (inclusive) |
---|
2690 | // |
---|
2691 | Function V_fPatchDet_Gap(lo,hi) |
---|
2692 | Variable lo,hi |
---|
2693 | |
---|
2694 | |
---|
2695 | Variable ii,jj |
---|
2696 | String fname,detStr |
---|
2697 | |
---|
2698 | //loop over all files |
---|
2699 | for(jj=lo;jj<=hi;jj+=1) |
---|
2700 | fname = V_FindFileFromRunNumber(jj) |
---|
2701 | if(strlen(fname) != 0) |
---|
2702 | |
---|
2703 | // write gap values |
---|
2704 | V_writeDet_panel_gap(fname,"FL",3.5) |
---|
2705 | V_writeDet_panel_gap(fname,"FR",3.5) |
---|
2706 | |
---|
2707 | V_writeDet_panel_gap(fname,"FT",3.3) |
---|
2708 | V_writeDet_panel_gap(fname,"FB",3.3) |
---|
2709 | |
---|
2710 | V_writeDet_panel_gap(fname,"ML",5.9) |
---|
2711 | V_writeDet_panel_gap(fname,"MR",5.9) |
---|
2712 | |
---|
2713 | V_writeDet_panel_gap(fname,"MT",18.3) |
---|
2714 | V_writeDet_panel_gap(fname,"MB",18.3) |
---|
2715 | |
---|
2716 | else |
---|
2717 | printf "run number %d not found\r",jj |
---|
2718 | endif |
---|
2719 | endfor |
---|
2720 | |
---|
2721 | return(0) |
---|
2722 | End |
---|
2723 | |
---|
2724 | // simple utility to read the detector gap values stored in the file header |
---|
2725 | Function V_fReadDet_Gap(lo,hi) |
---|
2726 | Variable lo,hi |
---|
2727 | |
---|
2728 | String fname,detStr |
---|
2729 | Variable jj |
---|
2730 | Variable gap_FL,gap_FR,gap_FT,gap_FB,gap_ML,gap_MR,gap_MT,gap_MB |
---|
2731 | |
---|
2732 | for(jj=lo;jj<=hi;jj+=1) |
---|
2733 | fname = V_FindFileFromRunNumber(jj) |
---|
2734 | if(strlen(fname) != 0) |
---|
2735 | |
---|
2736 | gap_FL = V_getDet_panel_gap(fname,"FL") |
---|
2737 | gap_FR = V_getDet_panel_gap(fname,"FR") |
---|
2738 | gap_FT = V_getDet_panel_gap(fname,"FT") |
---|
2739 | gap_FB = V_getDet_panel_gap(fname,"FB") |
---|
2740 | |
---|
2741 | gap_ML = V_getDet_panel_gap(fname,"ML") |
---|
2742 | gap_MR = V_getDet_panel_gap(fname,"MR") |
---|
2743 | gap_MT = V_getDet_panel_gap(fname,"MT") |
---|
2744 | gap_MB = V_getDet_panel_gap(fname,"MB") |
---|
2745 | |
---|
2746 | print fname |
---|
2747 | Print "FL, FR, FT, FB = ",gap_FL,gap_FR,gap_FT,gap_FB |
---|
2748 | Print "ML, MR, MT, MB = ",gap_ML,gap_MR,gap_MT,gap_MB |
---|
2749 | |
---|
2750 | |
---|
2751 | else |
---|
2752 | printf "run number %d not found\r",jj |
---|
2753 | endif |
---|
2754 | |
---|
2755 | endfor |
---|
2756 | |
---|
2757 | |
---|
2758 | return(0) |
---|
2759 | End |
---|
2760 | |
---|
2761 | |
---|
2762 | // simple utility to patch the detector distance values in the file headers |
---|
2763 | // |
---|
2764 | // values are in [cm] |
---|
2765 | // |
---|
2766 | // lo is the first file number |
---|
2767 | // hi is the last file number (inclusive) |
---|
2768 | // |
---|
2769 | Function V_fPatchDet_distance(lo,hi,d_f,d_m,d_b) |
---|
2770 | Variable lo,hi,d_f,d_m,d_b |
---|
2771 | |
---|
2772 | |
---|
2773 | Variable ii,jj |
---|
2774 | String fname,detStr |
---|
2775 | |
---|
2776 | //loop over all files |
---|
2777 | for(jj=lo;jj<=hi;jj+=1) |
---|
2778 | fname = V_FindFileFromRunNumber(jj) |
---|
2779 | if(strlen(fname) != 0) |
---|
2780 | |
---|
2781 | // write gap values |
---|
2782 | V_writeDet_distance(fname,"FL",d_f) |
---|
2783 | V_writeDet_distance(fname,"FR",d_f) |
---|
2784 | V_writeDet_distance(fname,"FT",d_f) |
---|
2785 | V_writeDet_distance(fname,"FB",d_f) |
---|
2786 | |
---|
2787 | V_writeDet_distance(fname,"ML",d_m) |
---|
2788 | V_writeDet_distance(fname,"MR",d_m) |
---|
2789 | V_writeDet_distance(fname,"MT",d_m) |
---|
2790 | V_writeDet_distance(fname,"MB",d_m) |
---|
2791 | |
---|
2792 | V_writeDet_distance(fname,"B",d_b) |
---|
2793 | |
---|
2794 | else |
---|
2795 | printf "run number %d not found\r",jj |
---|
2796 | endif |
---|
2797 | endfor |
---|
2798 | |
---|
2799 | return(0) |
---|
2800 | End |
---|
2801 | |
---|
2802 | |
---|
2803 | // |
---|
2804 | // simple utility to patch all of the values associated with the back detector |
---|
2805 | // |
---|
2806 | // |
---|
2807 | // |
---|
2808 | // |
---|
2809 | // |
---|
2810 | // lo is the first file number |
---|
2811 | // hi is the last file number (inclusive) |
---|
2812 | // |
---|
2813 | Function V_fPatch_BackDetector(lo,hi) |
---|
2814 | Variable lo,hi |
---|
2815 | |
---|
2816 | |
---|
2817 | Variable ii,jj |
---|
2818 | String fname,detStr |
---|
2819 | |
---|
2820 | detStr = "B" |
---|
2821 | |
---|
2822 | Make/O/D/N=3 cal_x,cal_y |
---|
2823 | cal_x[0] = VCALC_getPixSizeX(detStr) // pixel size in VCALC_getPixSizeX(detStr) is [cm] |
---|
2824 | cal_x[1] = 1 |
---|
2825 | cal_x[2] = 10000 |
---|
2826 | cal_y[0] = VCALC_getPixSizeY(detStr) // pixel size in VCALC_getPixSizeX(detStr) is [cm] |
---|
2827 | cal_y[1] = 1 |
---|
2828 | cal_y[2] = 10000 |
---|
2829 | |
---|
2830 | Make/O/I/N=(680,1656) tmpData=1 |
---|
2831 | |
---|
2832 | //loop over all files |
---|
2833 | for(jj=lo;jj<=hi;jj+=1) |
---|
2834 | fname = V_FindFileFromRunNumber(jj) |
---|
2835 | if(strlen(fname) != 0) |
---|
2836 | |
---|
2837 | // patch cal_x and cal_y |
---|
2838 | V_writeDet_cal_x(fname,detStr,cal_x) |
---|
2839 | V_writeDet_cal_y(fname,detStr,cal_y) |
---|
2840 | |
---|
2841 | // patch n_pix_x and y |
---|
2842 | V_writeDet_pixel_num_x(fname,detStr,680) |
---|
2843 | V_writeDet_pixel_num_y(fname,detStr,1656) |
---|
2844 | |
---|
2845 | // patch pixel size x and y [cm] |
---|
2846 | V_writeDet_x_pixel_size(fname,detStr,0.034) |
---|
2847 | V_writeDet_y_pixel_size(fname,detStr,0.034) |
---|
2848 | |
---|
2849 | // patch dead time |
---|
2850 | // TODO: enter a proper value here once it's actually measured |
---|
2851 | V_writeDetector_deadtime_B(fname,detStr,1e-20) |
---|
2852 | |
---|
2853 | // patch fwhm_x and y |
---|
2854 | // TODO: verify the values once they are measured, and also the UNITS!!! [cm]??? |
---|
2855 | V_writeDet_pixel_fwhm_x(fname,detStr,0.034) |
---|
2856 | V_writeDet_pixel_fwhm_y(fname,detStr,0.034) |
---|
2857 | |
---|
2858 | // patch beam center (nominal x,y) [cm] values |
---|
2859 | V_writeDet_beam_center_x(fname,detStr,11) |
---|
2860 | V_writeDet_beam_center_y(fname,detStr,25) |
---|
2861 | |
---|
2862 | // fake data |
---|
2863 | V_writeDetectorData(fname,detStr,tmpData) |
---|
2864 | |
---|
2865 | |
---|
2866 | else |
---|
2867 | printf "run number %d not found\r",jj |
---|
2868 | endif |
---|
2869 | endfor |
---|
2870 | |
---|
2871 | KillWaves/Z cal_x,cal_y,tmpData |
---|
2872 | return(0) |
---|
2873 | End |
---|
2874 | |
---|
2875 | // |
---|
2876 | // simple utility to patch all of the pixel sizes |
---|
2877 | // - in the header, the Y size for LR panels was grossly wrong (4 mm) |
---|
2878 | // and all of the values are slightly off from the true values |
---|
2879 | // |
---|
2880 | // data collected after 10/3/18 should not need this patch since the |
---|
2881 | // config.js file was updated |
---|
2882 | // |
---|
2883 | // |
---|
2884 | // |
---|
2885 | // lo is the first file number |
---|
2886 | // hi is the last file number (inclusive) |
---|
2887 | // |
---|
2888 | Function V_fPatch_XYPixelSize(lo,hi) |
---|
2889 | Variable lo,hi |
---|
2890 | |
---|
2891 | |
---|
2892 | Variable ii,jj |
---|
2893 | String fname,detStr |
---|
2894 | |
---|
2895 | |
---|
2896 | //loop over all files |
---|
2897 | for(jj=lo;jj<=hi;jj+=1) |
---|
2898 | fname = V_FindFileFromRunNumber(jj) |
---|
2899 | if(strlen(fname) != 0) |
---|
2900 | |
---|
2901 | // patch pixel size x and y [cm] L/R panels |
---|
2902 | V_writeDet_x_pixel_size(fname,"FL",8.4) |
---|
2903 | V_writeDet_y_pixel_size(fname,"FL",8.14) |
---|
2904 | |
---|
2905 | V_writeDet_x_pixel_size(fname,"FR",8.4) |
---|
2906 | V_writeDet_y_pixel_size(fname,"FR",8.14) |
---|
2907 | |
---|
2908 | V_writeDet_x_pixel_size(fname,"ML",8.4) |
---|
2909 | V_writeDet_y_pixel_size(fname,"ML",8.14) |
---|
2910 | |
---|
2911 | V_writeDet_x_pixel_size(fname,"MR",8.4) |
---|
2912 | V_writeDet_y_pixel_size(fname,"MR",8.14) |
---|
2913 | |
---|
2914 | // patch pixel size x and y [cm] T/B panels |
---|
2915 | V_writeDet_x_pixel_size(fname,"FT",4.16) |
---|
2916 | V_writeDet_y_pixel_size(fname,"FT",8.4) |
---|
2917 | |
---|
2918 | V_writeDet_x_pixel_size(fname,"FB",4.16) |
---|
2919 | V_writeDet_y_pixel_size(fname,"FB",8.4) |
---|
2920 | |
---|
2921 | V_writeDet_x_pixel_size(fname,"MT",4.16) |
---|
2922 | V_writeDet_y_pixel_size(fname,"MT",8.4) |
---|
2923 | |
---|
2924 | V_writeDet_x_pixel_size(fname,"MB",4.16) |
---|
2925 | V_writeDet_y_pixel_size(fname,"MB",8.4) |
---|
2926 | |
---|
2927 | else |
---|
2928 | printf "run number %d not found\r",jj |
---|
2929 | endif |
---|
2930 | endfor |
---|
2931 | |
---|
2932 | return(0) |
---|
2933 | End |
---|
2934 | |
---|
2935 | |
---|
2936 | Proc V_Patch_Guide_SSD_Aperture(lo,hi,numGuides,sourceDiam_mm) |
---|
2937 | Variable lo,hi,numGuides=0,sourceDiam_mm=30 |
---|
2938 | |
---|
2939 | V_fPatch_Guide_SSD_Aperture(lo,hi,numGuides,sourceDiam_mm) |
---|
2940 | End |
---|
2941 | |
---|
2942 | // simple utility to patch all three at once, since they are all linked and typically |
---|
2943 | /// are all incorrectly entered by NICE if the number of guides can't be determined |
---|
2944 | // |
---|
2945 | // Number of guides |
---|
2946 | // source aperture to gate valve distance [cm] |
---|
2947 | // source aperture diameter [mm] |
---|
2948 | // |
---|
2949 | // the source aperture is assumed to be circular and the diameter in mm |
---|
2950 | // |
---|
2951 | // the value for the A1_to_GV is from tabulated values. (see VC_calcSSD) |
---|
2952 | // This is the Source aperture to Gate Valve distance |
---|
2953 | // |
---|
2954 | // |
---|
2955 | // lo is the first file number |
---|
2956 | // hi is the last file number (inclusive) |
---|
2957 | // |
---|
2958 | Function V_fPatch_Guide_SSD_Aperture(lo,hi,numGuides,sourceDiam_mm) |
---|
2959 | Variable lo,hi,numGuides,sourceDiam_mm |
---|
2960 | |
---|
2961 | |
---|
2962 | Variable ii,jj,A1_to_GV |
---|
2963 | String fname,detStr |
---|
2964 | |
---|
2965 | switch(numGuides) |
---|
2966 | case 0: |
---|
2967 | A1_to_GV = 2441 |
---|
2968 | break |
---|
2969 | case 1: |
---|
2970 | A1_to_GV = 2157 |
---|
2971 | break |
---|
2972 | case 2: |
---|
2973 | A1_to_GV = 1976 |
---|
2974 | break |
---|
2975 | case 3: |
---|
2976 | A1_to_GV = 1782 |
---|
2977 | break |
---|
2978 | case 4: |
---|
2979 | A1_to_GV = 1582 |
---|
2980 | break |
---|
2981 | case 5: |
---|
2982 | A1_to_GV = 1381 |
---|
2983 | break |
---|
2984 | case 6: |
---|
2985 | A1_to_GV = 1181 |
---|
2986 | break |
---|
2987 | case 7: |
---|
2988 | A1_to_GV = 980 |
---|
2989 | break |
---|
2990 | case 8: |
---|
2991 | A1_to_GV = 780 |
---|
2992 | break |
---|
2993 | case 9: |
---|
2994 | A1_to_GV = 579 |
---|
2995 | break |
---|
2996 | default: |
---|
2997 | Print "Error - using default A1_to_GV value" |
---|
2998 | A1_to_GV = 2441 |
---|
2999 | endswitch |
---|
3000 | |
---|
3001 | |
---|
3002 | //loop over all files |
---|
3003 | for(jj=lo;jj<=hi;jj+=1) |
---|
3004 | fname = V_FindFileFromRunNumber(jj) |
---|
3005 | if(strlen(fname) != 0) |
---|
3006 | |
---|
3007 | // write values |
---|
3008 | V_writeNumberOfGuides(fname,num2str(numGuides)) |
---|
3009 | |
---|
3010 | V_writeSourceAp_distance(fname,A1_to_GV) |
---|
3011 | |
---|
3012 | V_writeSourceAp_shape(fname,"CIRCLE") |
---|
3013 | V_writeSourceAp_size(fname,num2str(sourceDiam_mm)) |
---|
3014 | |
---|
3015 | else |
---|
3016 | printf "run number %d not found\r",jj |
---|
3017 | endif |
---|
3018 | endfor |
---|
3019 | |
---|
3020 | return(0) |
---|
3021 | End |
---|
3022 | |
---|
3023 | |
---|
3024 | // |
---|
3025 | // pick the carriage, beamstop number, beamstop shape, and beamstop diameter |
---|
3026 | // or height and width |
---|
3027 | Proc V_Patch_BeamStop(lo,hi,carriageStr,bs_num,bsShapeStr,bs_diam,bs_width,bs_height) |
---|
3028 | Variable lo,hi |
---|
3029 | String carriageStr="B" |
---|
3030 | Variable bs_num=2 |
---|
3031 | String bsShapeStr="CIRCLE" |
---|
3032 | Variable bs_diam=12,bs_width=12,bs_height=300 |
---|
3033 | |
---|
3034 | V_fPatch_BeamStop(lo,hi,carriageStr,bs_num,bsShapeStr,bs_diam,bs_width,bs_height) |
---|
3035 | End |
---|
3036 | |
---|
3037 | |
---|
3038 | // |
---|
3039 | // lo is the first file number |
---|
3040 | // hi is the last file number (inclusive) |
---|
3041 | // |
---|
3042 | Function V_fPatch_BeamStop(lo,hi,carriageStr,bs_num,bsShapeStr,bs_diam,bs_width,bs_height) |
---|
3043 | Variable lo,hi |
---|
3044 | String carriageStr |
---|
3045 | Variable bs_num |
---|
3046 | String bsShapeStr |
---|
3047 | Variable bs_diam,bs_width,bs_height |
---|
3048 | |
---|
3049 | |
---|
3050 | Variable ii,jj,A1_to_GV |
---|
3051 | String fname,detStr |
---|
3052 | |
---|
3053 | |
---|
3054 | //loop over all files |
---|
3055 | for(jj=lo;jj<=hi;jj+=1) |
---|
3056 | fname = V_FindFileFromRunNumber(jj) |
---|
3057 | if(strlen(fname) != 0) |
---|
3058 | |
---|
3059 | if(cmpstr("F",carriageStr) == 0) |
---|
3060 | Print "front carriage has no beamstops" |
---|
3061 | endif |
---|
3062 | |
---|
3063 | if(cmpstr("M",carriageStr) == 0) |
---|
3064 | // middle carriage (2) |
---|
3065 | V_writeBeamStopC2num_stop(fname,bs_num) |
---|
3066 | V_writeBeamStopC2_shape(fname,bsShapeStr) |
---|
3067 | if(cmpstr("CIRCLE",bsShapeStr)==0) |
---|
3068 | V_writeBeamStopC2_size(fname,bs_diam) |
---|
3069 | else |
---|
3070 | V_writeBeamStopC2_height(fname,bs_height) |
---|
3071 | V_writeBeamStopC2_width(fname,bs_width) |
---|
3072 | endif |
---|
3073 | endif |
---|
3074 | |
---|
3075 | if(cmpstr("B",carriageStr) == 0) |
---|
3076 | // back carriage (3) |
---|
3077 | V_writeBeamStopC3num_stop(fname,bs_num) |
---|
3078 | V_writeBeamStopC3_shape(fname,bsShapeStr) |
---|
3079 | if(cmpstr("CIRCLE",bsShapeStr)==0) |
---|
3080 | V_writeBeamStopC3_size(fname,bs_diam) |
---|
3081 | else |
---|
3082 | V_writeBeamStopC3_height(fname,bs_height) |
---|
3083 | V_writeBeamStopC3_width(fname,bs_width) |
---|
3084 | endif |
---|
3085 | endif |
---|
3086 | |
---|
3087 | else |
---|
3088 | printf "run number %d not found\r",jj |
---|
3089 | endif |
---|
3090 | endfor |
---|
3091 | |
---|
3092 | |
---|
3093 | return(0) |
---|
3094 | End |
---|
3095 | |
---|
3096 | |
---|
3097 | |
---|