1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma Version=2.20 |
---|
3 | #pragma IgorVersion=6.1 |
---|
4 | |
---|
5 | //////////////////////////// |
---|
6 | // 101001 Vers. 1 |
---|
7 | // |
---|
8 | // procedures to plot the sma, emp, and cor data |
---|
9 | // - user interaction is through control bar on COR_Graph |
---|
10 | // - provides user with feedback about peak angle, transmissions |
---|
11 | // - asks for information about BKG and EMP levels |
---|
12 | // - asks for sample thickness |
---|
13 | // - interactively selects range of data to save (and type) |
---|
14 | // - dispatches to routines to determine transmissions and correct the data |
---|
15 | // - dispatches to save routines |
---|
16 | // |
---|
17 | ///////////////////////////// |
---|
18 | |
---|
19 | |
---|
20 | //plot all that is available in the root:Graph folder |
---|
21 | // no distinction as to what the status of the data really is |
---|
22 | // "Clr" buttons on the USANS_Panel will clear the graph.. |
---|
23 | // |
---|
24 | Function DoCORGraph() |
---|
25 | |
---|
26 | SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder |
---|
27 | |
---|
28 | DoWindow/F COR_Graph |
---|
29 | if(V_flag==0) |
---|
30 | //draw the blank window and the control bar |
---|
31 | Display /W=(5,42,450,550) /K=1 |
---|
32 | DoWindow/C COR_Graph |
---|
33 | ControlBar 150 |
---|
34 | SetVariable gTransWide,pos={210,12},size={135,15},title="Trans - Wide",format="%5.4f" |
---|
35 | SetVariable gTransWide,help={"Average counts on transmssion detector at wide angles"} |
---|
36 | SetVariable gTransWide,limits={0,1,0.001},value= $(USANSFolder+":Globals:MainPanel:gTransWide") |
---|
37 | SetVariable gTransRock,pos={210,27},size={135,15},title="Trans - Rock",format="%5.4f" |
---|
38 | SetVariable gTransRock,help={"Transmission counts at the zero-angle peak"} |
---|
39 | SetVariable gTransRock,limits={0,1,0.001},value= $(USANSFolder+":Globals:MainPanel:gTransRock") |
---|
40 | SetVariable gEmpCts,pos={210,42},size={135,15},title="EMP Level",format="%7.4f" |
---|
41 | SetVariable gEmpCts,limits={-Inf,Inf,0.1},value= $(USANSFolder+":Globals:MainPanel:gEmpCts") |
---|
42 | SetVariable gEmpCts,help={"High q limit of empty cell scattering normalized to 1.0e6 monitor counts"} |
---|
43 | SetVariable gBkgCts,pos={210,57},size={135,15},title="BKG Level",format="%7.4f" |
---|
44 | SetVariable gBkgCts,limits={-Inf,Inf,0.1},value= $(USANSFolder+":Globals:MainPanel:gBkgCts") |
---|
45 | SetVariable gBkgCts,help={"Background scattering level normalized to 1.0e6 monitor counts"} |
---|
46 | SetVariable gThick,pos={210,72},size={135,15},title="SAM Thick(cm)",format="%5.4f" |
---|
47 | SetVariable gThick,help={"Thickness of the sample in centimeters"} |
---|
48 | SetVariable gThick,limits={0,5,0.01},value= $(USANSFolder+":Globals:MainPanel:gThick") |
---|
49 | Button UpdateButton,pos={125,15},size={70,40},proc=UpdateButtonProc,title="Update\rTrans" |
---|
50 | Button UpdateButton,help={"Updates both the wide and rocking transmission values based on the raw data files"} |
---|
51 | Button CorrectButton,pos={125,60},size={70,40},proc=CorrectButtonProc,title="Correct\rData" |
---|
52 | Button CorrectButton,help={"Corrects the sample data by subtracting empty cell and backgrond scattering"} |
---|
53 | Button SaveDataButton,pos={355,3},size={85,20},proc=SaveButtonProc,title="Save Data..." |
---|
54 | Button SaveDataButton,help={"Saves the selected data type to disk in ASCII format"} |
---|
55 | CheckBox useCrsrCheck,pos={360,27},size={119,14},proc=UseCrsrCheckProc,title="Use Cursors?" |
---|
56 | CheckBox useCrsrCheck,value= 0 |
---|
57 | CheckBox useCrsrCheck,help={"Adds cursors to the datset to select the range of data points to save"} |
---|
58 | CheckBox CORCheck,pos={380,44},size={40,14},title="COR",value=1,proc=TypeToggleCheckProc,mode=1 |
---|
59 | CheckBox CORCheck,help={"Selects COR data as the saved type"} |
---|
60 | CheckBox SAMCheck,pos={380,60},size={40,14},title="SAM",value=0,proc=TypeToggleCheckProc,mode=1 |
---|
61 | CheckBox SAMCheck,help={"Selects SAM data s the saved type"} |
---|
62 | CheckBox EMPCheck,pos={380,76},size={40,14},title="EMP",value= 0,proc=TypeToggleCheckProc,mode=1 |
---|
63 | CheckBox EMPCheck,help={"Selects EMP data as the saved type"} |
---|
64 | Button qpkButton,pos={12,61},size={90,20},proc=QpkButtonProc,title="Change Qpk" |
---|
65 | Button qpkButton,help={"Use this to override the automatically determined peak locations in SAM or EMP datasets"} |
---|
66 | ValDisplay valdispSAM,pos={10,15},size={100,14},title="Qpk SAM",format="%1.3f" |
---|
67 | ValDisplay valdispSAM,limits={0,0,0},barmisc={0,1000},value=QpkFromNote("SAM") |
---|
68 | ValDisplay valdispSAM,help={"Displays the peak angle the raw SAM data, determined automatically"} |
---|
69 | ValDisplay valdispEMP,pos={10,36},size={100,14},title="Qpk EMP",format="%1.3f" |
---|
70 | ValDisplay valdispEMP,limits={0,0,0},barmisc={0,1000},value=QpkFromNote("EMP") |
---|
71 | ValDisplay valdispEMP,help={"Displays the peak angle the raw EMP data, determined automatically"} |
---|
72 | |
---|
73 | CheckBox check0 title="Log X-axis",proc=LogLinToggleCheckProc |
---|
74 | CheckBox check0 pos={12,100},value=0,mode=0 |
---|
75 | SetVariable setvar0,pos={210,100},size={120,20},title="Trock/Twide",format="%5.4f" |
---|
76 | SetVariable setVar0,help={"fraction of unscattered neutrons"} |
---|
77 | SetVariable setVar0,limits={0,2,0},value= $(USANSFolder+":Globals:MainPanel:gTransRatio") |
---|
78 | |
---|
79 | Legend |
---|
80 | Endif |
---|
81 | // add each data type to the graph, if possible (each checks on its own) |
---|
82 | //SAM |
---|
83 | GraphSAM() |
---|
84 | //EMP |
---|
85 | GraphEMP() |
---|
86 | //COR |
---|
87 | GraphCOR() |
---|
88 | //EMP and BKG levels |
---|
89 | GraphEMPBKGLevels() |
---|
90 | |
---|
91 | ControlUpdate/A/W=COR_Graph |
---|
92 | |
---|
93 | ModifyGraph log(left)=1,mirror=2,grid=1,standoff=0 |
---|
94 | ModifyGraph tickUnit=1 |
---|
95 | Label left "(Counts/sec)/(MON)*10\\S6\\M" |
---|
96 | Label bottom "q (A\\S-1\\M)" |
---|
97 | |
---|
98 | return(0) |
---|
99 | End |
---|
100 | |
---|
101 | // add SAM data to the graph if it exists and is not already on the graph |
---|
102 | // |
---|
103 | Function GraphSAM() |
---|
104 | |
---|
105 | SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder |
---|
106 | |
---|
107 | //is it already on the graph? |
---|
108 | SetDataFolder $(USANSFolder+":Graph") |
---|
109 | String list="" |
---|
110 | list = Wavelist("DetCts_SAM*",";","WIN:COR_Graph") |
---|
111 | if(strlen(list)!=0) |
---|
112 | //Print "SAM already on graph" |
---|
113 | SetDataFolder root: |
---|
114 | return(0) |
---|
115 | Endif |
---|
116 | //append the data if it exists |
---|
117 | If(waveExists($"DetCts_SAM")==1) |
---|
118 | DoWindow/F COR_Graph |
---|
119 | AppendToGraph DetCts_SAM vs Qvals_SAM |
---|
120 | ModifyGraph rgb(DetCts_SAM)=(1,12815,52428) |
---|
121 | ModifyGraph mode(DetCts_SAM)=3,marker(DetCts_SAM)=19,msize(DetCts_SAM)=2 |
---|
122 | ModifyGraph tickUnit=1 |
---|
123 | ErrorBars/T=0 DetCts_SAM Y,wave=(ErrDetCts_SAM,ErrDetCts_SAM) |
---|
124 | endif |
---|
125 | SetDataFolder root: |
---|
126 | End |
---|
127 | |
---|
128 | // add EMP data to the graph if it exists and is not already on the graph |
---|
129 | // |
---|
130 | Function GraphEMP() |
---|
131 | |
---|
132 | SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder |
---|
133 | |
---|
134 | SetDataFolder $(USANSFolder+":Graph") |
---|
135 | String list="" |
---|
136 | list = Wavelist("DetCts_EMP*",";","WIN:COR_Graph") |
---|
137 | if(strlen(list)!=0) |
---|
138 | // Print "EMP already on graph" |
---|
139 | SetDataFolder root: |
---|
140 | return(0) |
---|
141 | Endif |
---|
142 | //append the data if it exists |
---|
143 | If(waveExists($"DetCts_EMP")==1) |
---|
144 | DoWindow/F COR_Graph |
---|
145 | AppendToGraph DetCts_EMP vs Qvals_EMP |
---|
146 | ModifyGraph msize(DetCts_EMP)=2,rgb(DetCts_EMP)=(1,39321,19939) |
---|
147 | ModifyGraph mode(DetCts_EMP)=3,marker(DetCts_EMP)=19 |
---|
148 | ModifyGraph tickUnit=1 |
---|
149 | ErrorBars/T=0 DetCts_EMP Y,wave=(ErrDetCts_EMP,ErrDetCts_EMP) |
---|
150 | endif |
---|
151 | SetDataFolder root: |
---|
152 | return(0) |
---|
153 | End |
---|
154 | |
---|
155 | // add COR data to the graph if it exists and is not already on the graph |
---|
156 | // |
---|
157 | Function GraphCOR() |
---|
158 | SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder |
---|
159 | |
---|
160 | SetDataFolder $(USANSFolder+":Graph") |
---|
161 | |
---|
162 | String list="" |
---|
163 | list = Wavelist("DetCts_COR*",";","WIN:COR_Graph") |
---|
164 | if(strlen(list)!=0) |
---|
165 | // Print "COR already on graph" |
---|
166 | SetDataFolder root: |
---|
167 | return(0) |
---|
168 | Endif |
---|
169 | //append the data if it exists |
---|
170 | If(waveExists($"DetCts_COR")==1) |
---|
171 | DoWindow/F COR_Graph |
---|
172 | AppendToGraph DetCts_COR vs Qvals_COR |
---|
173 | ModifyGraph msize(DetCts_COR)=2,rgb(DetCts_COR)=(52428,34958,1) |
---|
174 | ModifyGraph mode(DetCts_COR)=3,marker(DetCts_COR)=19 |
---|
175 | ModifyGraph tickUnit=1 |
---|
176 | ErrorBars/T=0 DetCts_COR Y,wave=(ErrDetCts_COR,ErrDetCts_COR) |
---|
177 | endif |
---|
178 | |
---|
179 | SetDataFolder root: |
---|
180 | return(0) |
---|
181 | End |
---|
182 | |
---|
183 | // add horizoontal lines for the background and empty cell levels |
---|
184 | Function GraphEMPBKGLevels() |
---|
185 | |
---|
186 | SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder |
---|
187 | |
---|
188 | //if the data is on the graph, remove them and replot, to properly reset the scale |
---|
189 | DoUpdate |
---|
190 | String list = TraceNameList("COR_Graph",";",1) |
---|
191 | //Print list |
---|
192 | DoWindow/F COR_Graph |
---|
193 | if(stringmatch(list,"*empLevel*")==1) |
---|
194 | //remove |
---|
195 | RemoveFromGraph empLevel,bkgLevel |
---|
196 | Endif |
---|
197 | DoUpdate |
---|
198 | AppendToGraph $(USANSFolder+":EMP:EMPLevel"),$(USANSFolder+":BKG:BKGLevel") |
---|
199 | ModifyGraph rgb(empLevel)=(0,0,0),lsize(bkgLevel)=2,rgb(bkgLevel)=(52428,1,1) |
---|
200 | ModifyGraph lsize(empLevel)=2,offset={0,0} |
---|
201 | ModifyGraph tickUnit=1 |
---|
202 | GetAxis/W=COR_Graph/Q bottom |
---|
203 | SetScale/I x V_min,V_max,"",$(USANSFolder+":EMP:EMPLevel"),$(USANSFolder+":BKG:BKGLevel") |
---|
204 | return(0) |
---|
205 | End |
---|
206 | |
---|
207 | // polls the control bar for proper selections of SavePath |
---|
208 | // checks for selected dataset from radio buttons |
---|
209 | // obtains the poin numbers from the cursors, if selected |
---|
210 | // dispatches to save routine |
---|
211 | // |
---|
212 | Function SaveButtonProc(ctrlName) : ButtonControl |
---|
213 | String ctrlName |
---|
214 | |
---|
215 | SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder |
---|
216 | NVAR useXMLOutput = root:Packages:NIST:gXML_Write |
---|
217 | |
---|
218 | |
---|
219 | PathInfo/S savePathName |
---|
220 | if(V_Flag==0) |
---|
221 | DoAlert 0,"Pick a \"SavePath...\"\rNo data file has been written" |
---|
222 | return(1) |
---|
223 | Endif |
---|
224 | |
---|
225 | String type="" |
---|
226 | Variable useCrsrs=0,ptA=0,ptB=0 |
---|
227 | |
---|
228 | //check for data save type (controlled by radio buttons) |
---|
229 | NVAR gRadioVal=$(USANSFolder+":Globals:MainPanel:gTypeCheck") //1=COR,2=SAM,3=EMP |
---|
230 | switch(gRadioVal) |
---|
231 | case 1: //COR |
---|
232 | type="COR" |
---|
233 | break |
---|
234 | case 2: //SAM |
---|
235 | type="SAM" |
---|
236 | break |
---|
237 | case 3: //EMP |
---|
238 | type="EMP" |
---|
239 | break |
---|
240 | default: |
---|
241 | DoAlert 0,"No Radio button selected\rNo data file written" |
---|
242 | return(1) |
---|
243 | endswitch |
---|
244 | |
---|
245 | //check for data save between cursors |
---|
246 | ControlInfo UseCrsrCheck |
---|
247 | useCrsrs = V_Value //1 if checked |
---|
248 | //if so, read off the point range (cursors should be on the same wave as the save type) |
---|
249 | if(useCrsrs) |
---|
250 | Wave xwave=$(USANSFolder+":Graph:Qvals_"+type) |
---|
251 | ptA=x2pnt(xwave,xcsr(A)) |
---|
252 | ptB=x2pnt(xwave,xcsr(B)) |
---|
253 | if(ptA>ptB) |
---|
254 | ptA=x2pnt(xwave,xcsr(B)) |
---|
255 | ptB=x2pnt(xwave,xcsr(A)) |
---|
256 | endif |
---|
257 | ptA=trunc(ptA) //make sure it's integer |
---|
258 | ptB=trunc(ptB) |
---|
259 | //Print ptA,ptB |
---|
260 | endif |
---|
261 | |
---|
262 | //fill in the blanks and dispatch to save routine |
---|
263 | if (useXMLOutput == 1) |
---|
264 | WriteXMLUSANSWaves(type,"",ptA,ptB,1) |
---|
265 | else |
---|
266 | WriteUSANSWaves(type,"",ptA,ptB,1) |
---|
267 | endif |
---|
268 | |
---|
269 | return(0) |
---|
270 | End |
---|
271 | |
---|
272 | //show/hide cursors depending on the checkbox selection |
---|
273 | //put cursors on the selected save data type |
---|
274 | Function UseCrsrCheckProc(ctrlName,checked) : CheckBoxControl |
---|
275 | String ctrlName |
---|
276 | Variable checked |
---|
277 | |
---|
278 | SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder |
---|
279 | |
---|
280 | NVAR gRadioVal=$(USANSFolder+":Globals:MainPanel:gTypeCheck") //1=COR,2=SAM,3=EMP |
---|
281 | String type="" |
---|
282 | switch(gRadioVal) |
---|
283 | case 1: //COR |
---|
284 | type="COR" |
---|
285 | break |
---|
286 | case 2: //SAM |
---|
287 | type="SAM" |
---|
288 | break |
---|
289 | case 3: //EMP |
---|
290 | type="EMP" |
---|
291 | break |
---|
292 | default: |
---|
293 | DoAlert 0,"No Radio button selected\rCan't place cursors" |
---|
294 | return(1) |
---|
295 | endswitch |
---|
296 | if(checked) |
---|
297 | //show info and cursors, if the wave in on the graph |
---|
298 | String str,yname |
---|
299 | str=TraceNameList("", ";", 1) |
---|
300 | yname="DetCts_"+type |
---|
301 | Variable ok=WhichListItem(yname, str,";",0) |
---|
302 | if(ok != -1) |
---|
303 | Wave ywave=$(USANSFolder+":Graph:DetCts_"+type) |
---|
304 | Showinfo/W=COR_Graph |
---|
305 | Cursor/A=1/P/S=1 A,$yname,0 |
---|
306 | Cursor/A=0/P/S=1 B,$yname,numpnts(ywave)-1 |
---|
307 | else |
---|
308 | //trace is not on graph |
---|
309 | CheckBox $ctrlName, value=0 //not checked |
---|
310 | HideInfo/W=COR_Graph |
---|
311 | Cursor/K/W=COR_Graph A |
---|
312 | Cursor/K/W=COR_Graph B |
---|
313 | DoAlert 0,type+" data is not on the graph" |
---|
314 | endif |
---|
315 | else |
---|
316 | //hide info and cursors, if there are any displayed |
---|
317 | HideInfo/W=COR_Graph |
---|
318 | Cursor/K/W=COR_Graph A |
---|
319 | Cursor/K/W=COR_Graph B |
---|
320 | CheckBox useCrsrCheck,win=COR_Graph,value= 0 |
---|
321 | endif |
---|
322 | DoUpdate |
---|
323 | End |
---|
324 | |
---|
325 | //radio button control of save type |
---|
326 | //sets global, so buttons don't need to be polled |
---|
327 | Function TypeToggleCheckProc(ctrlName,checked) : CheckBoxControl |
---|
328 | String ctrlName |
---|
329 | Variable checked |
---|
330 | |
---|
331 | SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder |
---|
332 | |
---|
333 | NVAR gRadioVal=$(USANSFolder+":Globals:MainPanel:gTypeCheck") |
---|
334 | |
---|
335 | strswitch(ctrlName) |
---|
336 | case "CORCheck": |
---|
337 | gRadioVal=1 |
---|
338 | break |
---|
339 | case "SAMCheck": |
---|
340 | gRadioVal=2 |
---|
341 | break |
---|
342 | case "EMPCheck": |
---|
343 | gRadioVal=3 |
---|
344 | break |
---|
345 | endswitch |
---|
346 | CheckBox CORCheck,win=COR_Graph,value= (gRadioVal==1) |
---|
347 | CheckBox SAMCheck,win=COR_Graph,value= (gRadioVal==2) |
---|
348 | CheckBox EMPCheck,win=COR_Graph,value= (gRadioVal==3) |
---|
349 | |
---|
350 | //move the cursors to the correct trace on the graph |
---|
351 | ControlInfo useCrsrCheck |
---|
352 | checked=V_Value |
---|
353 | UseCrsrCheckProc("useCrsrCheck",V_Value) |
---|
354 | End |
---|
355 | |
---|
356 | //updates the trans values and the bkg/empty values on the graph, if necessary |
---|
357 | //calculate the T_Wide and T_Rock from the wave notes |
---|
358 | // if there is an error in the wave notes, "NaN" will typically be returned |
---|
359 | // |
---|
360 | Function UpdateButtonProc(ctrlName) : ButtonControl |
---|
361 | String ctrlName |
---|
362 | |
---|
363 | SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder |
---|
364 | |
---|
365 | Wave/Z samCts=$(USANSFolder+":SAM:DetCts") |
---|
366 | Wave/Z empCts=$(USANSFolder+":EMP:DetCts") |
---|
367 | if((WaveExists(samCts)==0) || (WaveExists(empCts)==0)) |
---|
368 | DoAlert 0,"Sample and Empty data must both be plotted before you can calculate the transmission" |
---|
369 | Variable/G $(USANSFolder+":Globals:MainPanel:gTransWide")=NaN //error |
---|
370 | Variable/G $(USANSFolder+":Globals:MainPanel:gTransRock")=NaN |
---|
371 | return(1) |
---|
372 | Endif |
---|
373 | //get the wave notes, and the transCt values |
---|
374 | String samNote=note(samCts),empNote=note(empCts) |
---|
375 | Variable samWide,empWide,samRock,empRock |
---|
376 | samWide = NumberByKey("TWIDE",samNote,":",";") |
---|
377 | empWide = NumberByKey("TWIDE",empNote,":",";") |
---|
378 | samRock = NumberByKey("PEAKVAL",samNote,":",";") |
---|
379 | empRock = NumberByKey("PEAKVAL",empNote,":",";") |
---|
380 | Variable/G $(USANSFolder+":Globals:MainPanel:gTransWide")=samWide/empWide |
---|
381 | Variable/G $(USANSFolder+":Globals:MainPanel:gTransRock")=samRock/empRock |
---|
382 | |
---|
383 | TransRatio() //calculate the ratio and update |
---|
384 | |
---|
385 | return(0) |
---|
386 | End |
---|
387 | |
---|
388 | // dispatches to the function to perform the data correction |
---|
389 | // |
---|
390 | Function CorrectButtonProc(ctrlName) : ButtonControl |
---|
391 | String ctrlName |
---|
392 | |
---|
393 | DoCorrectData() |
---|
394 | return(0) |
---|
395 | End |
---|
396 | |
---|
397 | //button to present a simple input dialog to ask the user for the data type |
---|
398 | // (either SAM or EMP) and the new value of the peak angle to use. |
---|
399 | // |
---|
400 | // rarely needed, but sometimes the data can fool IGOR, and no peak can be found |
---|
401 | // in some cases, data may not cover the primary beam. In both of these cases it |
---|
402 | // is necessary to manually override the peak angle |
---|
403 | // |
---|
404 | // calls RePlotWithUserAngle to "re-do" everything |
---|
405 | // |
---|
406 | Function QpkButtonProc(ctrlName) : ButtonControl |
---|
407 | String ctrlName |
---|
408 | |
---|
409 | Variable newPkAngle=0 |
---|
410 | String dataSet="SAM;EMP;",type="" |
---|
411 | |
---|
412 | Prompt type,"Select Data Set",popup,dataSet |
---|
413 | Prompt newPkAngle, "Enter new peak ANGLE, in Degrees" |
---|
414 | DoPrompt "Override the peak angle",type,newPkAngle |
---|
415 | //Print newPkAngle,type |
---|
416 | if(V_Flag==1) //user cancel, exit |
---|
417 | return(1) |
---|
418 | endif |
---|
419 | //with the new information (type and angle) re-do the whole mess |
---|
420 | //...as if the "plot" button was hit, except that the angle is known... |
---|
421 | |
---|
422 | RePlotWithUserAngle(type,newPkAngle) |
---|
423 | End |
---|
424 | |
---|
425 | Function TransRatio() |
---|
426 | NVAR tr = root:Packages:NIST:USANS:Globals:MainPanel:gTransRock |
---|
427 | NVAR tw = root:Packages:NIST:USANS:Globals:MainPanel:gTransWide |
---|
428 | NVAR rat = root:Packages:NIST:USANS:Globals:MainPanel:gTransRatio |
---|
429 | |
---|
430 | rat = tr/tw |
---|
431 | if(rat < 0.9) |
---|
432 | SetVariable setVar0 labelBack=(65535,32768,32768) |
---|
433 | else |
---|
434 | SetVariable setVar0 labelBack=0 |
---|
435 | endif |
---|
436 | return(0) |
---|
437 | End |
---|
438 | |
---|
439 | Function LogLinToggleCheckProc(cba) : CheckBoxControl |
---|
440 | STRUCT WMCheckboxAction &cba |
---|
441 | |
---|
442 | switch( cba.eventCode ) |
---|
443 | case 2: // mouse up |
---|
444 | Variable checked = cba.checked |
---|
445 | if(checked) |
---|
446 | ModifyGraph log(bottom)=1 |
---|
447 | else |
---|
448 | ModifyGraph log(bottom)=0 |
---|
449 | endif |
---|
450 | break |
---|
451 | endswitch |
---|
452 | |
---|
453 | return 0 |
---|
454 | End |
---|
455 | |
---|
456 | |
---|
457 | //returns the peak location found (and used) for zero angle |
---|
458 | //displayed on the COR_Graph |
---|
459 | Function QpkFromNote(type) |
---|
460 | String type |
---|
461 | |
---|
462 | SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder |
---|
463 | |
---|
464 | Wave/Z detCts=$(USANSFolder+":Graph:DetCts_"+type) |
---|
465 | if(!WaveExists(detCts)) |
---|
466 | return(NaN) |
---|
467 | Endif |
---|
468 | String str=note(detcts) |
---|
469 | Variable val |
---|
470 | |
---|
471 | val=NumberByKey("PEAKANG", str,":",";") |
---|
472 | return(val) |
---|
473 | End |
---|
474 | |
---|
475 | //nearly identical to PlotSelectedSAMButtonProc |
---|
476 | // - re-loads the data and goes through all the steps as it they were new datsets |
---|
477 | // - DOES NOT try to find the peak angle, instead uses the input zeroAngle |
---|
478 | // - replaces the PEAKANG:value with the input zeroAngle |
---|
479 | // updates the plot with the corrected angle |
---|
480 | // |
---|
481 | Function RePlotWithUserAngle(type,zeroAngle) |
---|
482 | String type |
---|
483 | Variable zeroAngle |
---|
484 | |
---|
485 | SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder |
---|
486 | |
---|
487 | //SETS the wave note with the PEAKANG value |
---|
488 | |
---|
489 | //loads each of the data files |
---|
490 | //normalizes each file to countrate immediately |
---|
491 | //appends them to the individual waves in "SAM" folder |
---|
492 | //sorts by angle |
---|
493 | //converts to Q-values USING SUPPLIED ANGLE |
---|
494 | // |
---|
495 | //get selected files from listbox (everything) |
---|
496 | //use the listBox wave directly |
---|
497 | |
---|
498 | Wave/T listW=$(USANSFolder+":Globals:MainPanel:"+type+"Wave") |
---|
499 | Variable ii,num=numpnts(listW) |
---|
500 | String fname="",fpath="",str="" |
---|
501 | PathInfo bt5PathName |
---|
502 | fpath = S_Path |
---|
503 | |
---|
504 | //load, normalize, and append |
---|
505 | //loop over the number of items in the list |
---|
506 | for(ii=0;ii<num;ii+=1) |
---|
507 | fname = fpath + listw[ii] |
---|
508 | LoadBT5File(fname,"SWAP") //overwrite what's in the SWAP folder |
---|
509 | Convert2Countrate("SWAP",1) |
---|
510 | if(ii==0) //first time, overwrite |
---|
511 | NewDataWaves("SWAP",type) |
---|
512 | else //append to waves in TYPE folder |
---|
513 | AppendDataWaves("SWAP",type) |
---|
514 | endif |
---|
515 | endfor |
---|
516 | //sort after all loaded |
---|
517 | DoAngleSort(type) |
---|
518 | |
---|
519 | //find the peak and convert to Q-values |
---|
520 | //Variable zeroAngle = FindZeroAngle("SAM") |
---|
521 | //if(zeroAngle == -9999) |
---|
522 | //DoAlert 0,"Couldn't find a peak - using zero as zero angle" |
---|
523 | // zeroAngle = 0 |
---|
524 | //Endif |
---|
525 | |
---|
526 | //find the peak value at the supplied angle, rather than automatic... |
---|
527 | Wave tmpangle = $(USANSFolder+":"+type+":Angle") |
---|
528 | Wave tmpdetCts = $(USANSFolder+":"+type+":DetCts") |
---|
529 | Variable pkHt=0 |
---|
530 | pkHt = interp(zeroAngle,tmpangle,tmpdetcts) |
---|
531 | |
---|
532 | if(numtype(pkHt) != 0) // bad but it warns, useful if only positive angles are available, use the smallest |
---|
533 | str = "Can't find peak at angle = "+num2str(zeroAngle)+" Using the value at angle = "+num2str(tmpAngle[0]) |
---|
534 | pkHt = tmpDetCts[0] |
---|
535 | endif |
---|
536 | |
---|
537 | str=note(tmpDetCts) |
---|
538 | str = ReplaceNumberByKey("PEAKANG",str,zeroAngle,":",";") |
---|
539 | str = ReplaceNumberByKey("PEAKVAL",str,pkHt,":",";") |
---|
540 | Note/K tmpDetCts |
---|
541 | Note tmpdetCts,str |
---|
542 | |
---|
543 | ConvertAngle2Qvals(type,zeroAngle) |
---|
544 | //find the Trans Cts for T_Wide |
---|
545 | FindTWideCts(type) |
---|
546 | // |
---|
547 | //copy the data to plot to the root:Graph directory, and give clear names |
---|
548 | if(WaveExists($(USANSFolder+":"+type+":Qvals"))) |
---|
549 | Duplicate/O $(USANSFolder+":"+type+":Qvals"),$(USANSFolder+":Graph:Qvals_"+type) |
---|
550 | Endif |
---|
551 | Duplicate/O $(USANSFolder+":"+type+":Angle"),$(USANSFolder+":Graph:Angle_"+type) |
---|
552 | Duplicate/O $(USANSFolder+":"+type+":DetCts"),$(USANSFolder+":Graph:DetCts_"+type) |
---|
553 | Duplicate/O $(USANSFolder+":"+type+":ErrDetCts"),$(USANSFolder+":Graph:ErrDetCts_"+type) |
---|
554 | |
---|
555 | //now plot the data (or just bring the graph to the front) |
---|
556 | DoCORGraph() |
---|
557 | |
---|
558 | //update the valDisplays |
---|
559 | ControlUpdate/A/W=COR_Graph //overkill, does them all |
---|
560 | End |
---|