source: sans/Release/trunk/NCNR_User_Procedures/SANS/Analysis/Models/Packages/Invariant/Invariant_v40.ipf @ 381

Last change on this file since 381 was 381, checked in by srkline, 14 years ago

Merging Dev/trunk revision 374+ into Release/trunk for version 6.004

File size: 18.3 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion=6.0
3
4// 07 JAN 05 SRK
5// updated procedures (from SS 2002) to be used as a package
6// with the SANS analysis routines
7//
8// need to:
9// - verify accuracy (see John)
10
11// this is the main entry point for the panel
12Proc Make_Invariant_Panel()
13        DoWindow/F Invariant_Panel
14        if(V_flag==0)
15                //create global variables in root:myGlobals:invariant
16                Init_Invariant()
17                Invariant_Panel()
18        endif
19        //pop the file menu
20        Inv_FilePopMenuProc("",1,"")
21End
22
23//create the globals
24Proc Init_Invariant()
25        NewDataFolder/O root:Packages
26        NewDataFolder/O root:Packages:NIST
27        NewDataFolder/O/S root:Packages:NIST:invariant
28        Variable/G gNumLow=10
29        Variable/G gNumHigh=10
30       
31        Variable/G gInvMeas=0
32        Variable/G gInvLowQ=0
33        Variable/G gInvHighQ=0
34        Variable/G gInvTotal=0
35        String/G gDataPopList = "none"
36        Variable/G gIsSlitSmeared=0
37        Variable/G gDqv = 0.117         //default value for USANS slit height (re-read from file)
38               
39        SetDataFolder root:
40End
41
42// for testing - compare to the "perfect" value. This macro
43// calculates the invariant based on the contrast and volume fraction
44// - the extrapolated/integrated value should match this...
45Macro PrintModelInvariant(delta_rho,phi)
46        Variable delta_rho=3e-6,phi=0.1
47        // delta_rho [=] 1/A^2
48        Variable inv
49        inv = 2*pi*pi*delta_rho*delta_rho*phi*(1-phi)*1e8
50       
51        Printf "The model invariant is %g A^-3 cm^-1\r\r",inv
52End
53
54
55//integrates only over the given q-range, does no interpolation
56Function Invariant(qw,iw)
57        Wave qw,iw
58       
59        Variable num,invar
60        Duplicate/O qw integrand
61        integrand = qw*qw*iw
62//      integrand /= 1e8                //convert 1/cm to 1/A
63       
64        num = numpnts(qw)
65        invar = areaXY(qw,integrand,qw[0],qw[num-1])
66       
67        return(invar)           //units of A^-3 cm^-1
68End
69
70//integrates only over the given q-range, does no interpolation
71// function is for slit smeared data
72Function Invariant_SlitSmeared(qw,iw)
73        Wave qw,iw
74       
75        Variable num,invar
76        NVAR dQv = root:Packages:NIST:invariant:gDqv
77       
78        Duplicate/O qw integrand
79        integrand = qw*iw
80//      integrand /= 1e8                //convert 1/cm to 1/A
81       
82        num = numpnts(qw)
83        invar = areaXY(qw,integrand,qw[0],qw[num-1])
84       
85        invar *= dQv            //correct for the effects of slit-smearing
86               
87        return(invar)           //units of A^-3 cm^-1
88End
89
90Function Guinier_Fit(w,x) : FitFunc
91        Wave w
92        Variable x
93       
94        //fit data to I(q) = A*exp(B*q^2)
95        // (B will be negative)
96        //two parameters
97        Variable a,b,ans
98        a=w[0]
99        b=w[1]
100        ans = a*exp(b*x*x)
101        return(ans)
102End
103
104
105//pass the wave with the q-values
106Function SetExtrWaves(w)
107        Wave w
108
109        Variable num_extr=100
110       
111        Make/O/D/N=(num_extr) extr_hqq,extr_hqi,extr_lqq,extr_lqi
112        extr_lqi=1
113        extr_hqi=1              //default values
114        //set the q-range
115        Variable qmax,qmin,num
116        qmax=10
117        qmin=0
118        num=numpnts(w)
119       
120        extr_hqq = w[num-1] + x * (qmax-w[num-1])/num_extr
121        extr_lqq = qmin + x * (w[0]-qmin)/num_extr
122       
123        return(0)
124End
125
126Function DoExtrapolate(qw,iw,sw,nbeg,nend)
127        Wave qw,iw,sw
128        Variable nbeg,nend
129       
130        Wave extr_lqi=extr_lqi
131        Wave extr_lqq=extr_lqq
132        Wave extr_hqi=extr_hqi
133        Wave extr_hqq=extr_hqq
134        Variable/G V_FitMaxIters=300
135        Variable num=numpnts(iw)
136       
137        Make/O/D G_coef={100,-100}              //input
138        FuncFit Guinier_Fit G_coef iw[0,(nbeg-1)] /X=qw /W=sw /D
139        extr_lqi= Guinier_Fit(G_coef,extr_lqq)
140       
141        Printf "I(q=0) = %g (1/cm)\r",G_coef[0]
142        Printf "Rg = %g (A)\r",sqrt(-3*G_coef[1])
143       
144        Make/O/D P_coef={0,1,-4}                        //input
145        //(set background to zero and hold fixed)
146        CurveFit/H="100" Power kwCWave=P_coef  iw[(num-1-nend),(num-1)] /X=qw /W=sw /D
147        extr_hqi=P_coef[0]+P_coef[1]*extr_hqq^P_coef[2]
148       
149        Printf "Power law exponent = %g\r",P_coef[2]
150        Printf "Pre-exponential = %g\r",P_coef[1]
151       
152        return(0)
153End
154
155//plot based on the wave selelctions
156Function Plot_Inv_Data(ctrlName) : ButtonControl
157        String ctrlName
158       
159        //access the global strings representing the last data file read in
160        SVAR QWave = root:Packages:NIST:invariant:QWave
161        SVAR IWave = root:Packages:NIST:invariant:IWave
162        SVAR SWave = root:Packages:NIST:invariant:SWave
163       
164        Wave qw=$QWave
165        Wave iw=$IWave
166        Wave sw=$SWave
167       
168        String str="",item=""
169        Variable num=0,ii
170       
171        //not used - just kill and re-draw
172        //remove everything from the graph and graph it again
173//      str = TraceNameList("",";",1)
174//      num=ItemsInList(str)
175//      for(ii=0;ii<num;ii+=1)
176//              item=StringFromList(ii, str  ,";")
177//              Print item
178//              RemoveFromGraph $item
179//      endfor
180
181        DoWindow/F invariant_graph
182        if(V_flag==1)
183                DoWindow/K invariant_graph
184        endif
185        Display /W=(5,44,375,321)/K=1 iw vs qw
186        DoWindow/C invariant_graph
187        ModifyGraph mode=3,marker=8
188        ModifyGraph grid=1
189        ModifyGraph log=1
190        ModifyGraph mirror=2
191        ModifyGraph standoff=0
192        Label left "Intensity (1/cm)"
193        Label bottom "q (1/A)"
194        ModifyGraph rgb($NameofWave(iw))=(0,0,0)
195        ModifyGraph opaque($NameofWave(iw))=1
196        ErrorBars $NameofWave(iw) Y,wave=(sw,sw)
197        Legend
198       
199//      Print TraceNameList("",";",1)
200       
201        //create the extra waves now, and add to plot
202        SetExtrWaves(qw)
203        Wave extr_lqi=extr_lqi
204        Wave extr_lqq=extr_lqq
205        Wave extr_hqi=extr_hqi
206        Wave extr_hqq=extr_hqq
207        AppendtoGraph extr_lqi vs extr_lqq
208        AppendtoGraph extr_hqi vs extr_hqq
209        ModifyGraph lSize(extr_lqi)=2,lSize(extr_hqi)=2
210        ModifyGraph rgb($NameofWave(iw))=(0,0,0),rgb(extr_hqi)=(2,39321,1)
211       
212        //reset the invariant values to zero
213        NVAR meas = root:Packages:NIST:invariant:gInvMeas
214        NVAR lo = root:Packages:NIST:invariant:gInvLowQ
215        NVAR hi = root:Packages:NIST:invariant:gInvHighQ
216        NVAR total = root:Packages:NIST:invariant:gInvTotal
217        meas=0
218        lo=0
219        hi=0
220        total=0
221       
222        return(0)
223End
224
225
226Function LowCheckProc(ctrlName,checked) : CheckBoxControl
227        String ctrlName
228        Variable checked
229
230        Variable val=0
231//      print "checked = ",checked
232        if(cmpstr(ctrlName,"check_0")==0)
233                if(checked)
234                        val=1
235                endif
236        endif
237        CheckBox check_0,value= Val==1
238        CheckBox check_1,value= Val==0
239End
240
241
242Proc Invariant_Panel()
243        SetDataFolder root:             //use absolute paths?
244        PauseUpdate; Silent 1           // building window...
245        NewPanel /W=(510,44,796,529)    /K=2
246        DoWindow/C Invariant_Panel
247        ModifyPanel cbRGB=(65535,43690,0)
248        SetDrawLayer UserBack
249        DrawText 23,196,"Extrapolation"
250        DrawText 158,195,"Power-Law"
251        DrawText 158,211,"Extrapolation"
252        SetDrawEnv fstyle= 1
253        DrawText 58,349,"Units are [A^-3 cm^-1]"
254        SetDrawEnv fstyle= 1
255        DrawText 61,16,"Calculate the Invariant"
256        DrawLine 16,135,264,135
257        DrawLine 16,19,264,19
258       
259        PopupMenu ywave,pos={10,60},size={154,19},title="Data File"
260        PopupMenu ywave,help={"Select the experimental intensity values"}
261        PopupMenu ywave,mode=1,value=root:Packages:NIST:invariant:gDataPopList,proc=Inv_FilePopMenuProc
262       
263        Button loadButton,pos={10,90},size={130,20},proc=Inv_Load_Proc,title="Load and Plot File"
264        Button loadButton,help={"After choosing a file, load it into memory and plot it with this button."}
265       
266        Button Inv_PathButton,pos={10,29},size={80,20},proc=Inv_PickPathButtonProc,title="Pick Path"
267        Button DoneButton,pos={215,453},size={50,20},proc=InvDoneButton,title="Done"
268        Button DoneButton,help={"This button will close the panel and the associated graph"}
269
270        SetVariable setvar_0,pos={27,249},size={80,15},title="# points"
271        SetVariable setvar_0,limits={5,50,0},value= root:Packages:NIST:invariant:gNumLow
272        SetVariable setvar_1,pos={166,249},size={80,15},title="# points"
273        SetVariable setvar_1,limits={5,200,0},value= root:Packages:NIST:invariant:gNumHigh
274        CheckBox check_0,pos={23,202},size={50,14},proc=LowCheckProc,title="Guinier"
275        CheckBox check_0,value= 1
276        CheckBox check_1,pos={23,223},size={68,14},proc=LowCheckProc,title="Power Law"
277        CheckBox check_1,value= 0
278        Button button_0,pos={29,275},size={90,20},proc=InvLowQ,title="Calc Low Q"
279        Button button_1,pos={56,141},size={170,20},proc=InvMeasQ,title="Calculate Measured Q"
280        Button button_2,pos={168,275},size={90,20},proc=InvHighQ,title="Calc High Q"
281//      Button button_3,pos={13,98},size={50,20},proc=Plot_Inv_Data,title="Plot"
282        Button button_4,pos={230,29},size={25,20},proc=Inv_HelpButtonProc,title="?"
283        GroupBox group0,pos={14,165},size={123,144},title="Low Q"
284        GroupBox group0_1,pos={147,165},size={123,144},title="High Q"
285        GroupBox group1,pos={23,318},size={239,124},title="INVARIANT"
286        ValDisplay valdisp0,pos={51,354},size={180,14},title="In measured Q-range "
287        ValDisplay valdisp0,limits={0,0,0},barmisc={0,1000}
288        ValDisplay valdisp0,value= #"root:Packages:NIST:invariant:gInvMeas"
289        ValDisplay valdisp0_1,pos={51,371},size={180,14},title="In low Q extrapolation "
290        ValDisplay valdisp0_1,limits={0,0,0},barmisc={0,1000}
291        ValDisplay valdisp0_1,value= #"root:Packages:NIST:invariant:gInvLowQ"
292        ValDisplay valdisp0_2,pos={51,388},size={180,14},title="In high Q extrapolation "
293        ValDisplay valdisp0_2,limits={0,0,0},barmisc={0,1000}
294        ValDisplay valdisp0_2,value= #"root:Packages:NIST:invariant:gInvHighQ"
295        ValDisplay valdisp0_3,pos={51,411},size={180,14},title="TOTAL "
296        ValDisplay valdisp0_3,limits={0,0,0},barmisc={0,1000}
297        ValDisplay valdisp0_3,value= #"root:Packages:NIST:invariant:gInvTotal"
298       
299        CheckBox check0,pos={10,116},size={101,14},proc=SlitSmearedCheckProc,title="Slit-Smeared Data"
300        CheckBox check0,value= root:Packages:NIST:invariant:gIsSlitSmeared
301        SetVariable setvar0,pos={136,116},size={130,15},title="Slit Height (1/A)"
302        SetVariable setvar0,limits={-inf,inf,0},value= root:Packages:NIST:invariant:gDqv
303       
304        //set up a dependency to calculate the total invariant
305        root:Packages:NIST:invariant:gInvTotal := root:Packages:NIST:invariant:gInvLowQ + root:Packages:NIST:invariant:gInvMeas + root:Packages:NIST:invariant:gInvHighQ
306EndMacro
307
308
309Function InvMeasQ(ctrlName) : ButtonControl
310        String ctrlName
311       
312        //no graph, get out
313        DoWindow/F Invariant_Graph
314        if(V_flag==0)
315                return(0)
316        endif
317       
318        //do the straight calculation of the invariant of the specified data
319        Variable inv,num
320       
321        SVAR QWave = root:Packages:NIST:invariant:QWave
322        Wave qw=$QWave
323        SVAR IWave = root:Packages:NIST:invariant:IWave
324        Wave iw=$IWave
325       
326        NVAR isSlitSmeared=root:Packages:NIST:invariant:gIsSlitSmeared
327        if(isSlitSmeared)
328                inv = Invariant_SlitSmeared(qw,iw)
329        else
330                inv = Invariant(qw,iw)
331        endif
332       
333        num=numpnts(qw)
334        Printf "The invariant over the measured q-range %g to %g is %g A^-3 cm^-1\r\r",qw[0],qw[(num-1)],inv
335       
336        // update the global display on the panel (there is a dependency for the total)
337        NVAR val = root:Packages:NIST:invariant:gInvMeas
338        val = inv
339       
340        return(0)
341End
342
343Function InvLowQ(ctrlName) : ButtonControl
344        String ctrlName
345       
346        //no graph, get out
347        DoWindow/F Invariant_Graph
348        if(V_flag==0)
349                return(0)
350        endif
351       
352        Variable yesGuinier=0,nume,inv
353        // do the extrapolation of the correct type
354        ControlInfo/W=Invariant_Panel check_0           //the Guinier box
355        yesGuinier = V_Value
356//      print "yesGuinier = ",yesGuinier
357        //number of points to use for fit
358        NVAR nbeg=root:Packages:NIST:invariant:gNumLow
359        //define the waves
360        Wave extr_lqi=extr_lqi
361        Wave extr_lqq=extr_lqq
362       
363        SVAR QWave = root:Packages:NIST:invariant:QWave
364        Wave qw=$QWave
365        SVAR IWave = root:Packages:NIST:invariant:IWave
366        Wave iw=$IWave
367        SVAR SWave = root:Packages:NIST:invariant:SWave
368        Wave sw=$SWave
369       
370        Wave/Z W_coef=W_coef
371        Variable/G V_FitMaxIters=300
372//      Variable numi=numpnts(iw)
373       
374        if(yesGuinier)
375                Make/O/D G_coef={1000,-1000}            //input
376                FuncFit Guinier_Fit G_coef iw[0,(nbeg-1)] /X=qw /W=sw /D
377                extr_lqi= Guinier_Fit(G_coef,extr_lqq)
378               
379                Printf "I(q=0) = %g (1/cm)\r",G_coef[0]
380                Printf "Rg = %g (A)\r",sqrt(-3*G_coef[1])
381        else
382                //do a power-law fit instead
383                Make/O/D P_coef={0,1,-1}                        //input
384                //(set background to zero and hold fixed)
385                CurveFit/H="100" Power kwCWave=P_coef  iw[0,(nbeg-1)] /X=qw /W=sw /D
386                extr_lqi=P_coef[0]+P_coef[1]*extr_lqq^P_coef[2]
387                //     
388                Printf "Pre-exponential = %g\r",P_coef[1]
389                Printf "Power law exponent = %g\r",P_coef[2]
390                //     
391        endif
392       
393        //calculate the invariant
394        NVAR isSlitSmeared=root:Packages:NIST:invariant:gIsSlitSmeared
395        if(isSlitSmeared)
396                inv = Invariant_SlitSmeared(extr_lqq,extr_lqi)
397        else
398                inv = Invariant(extr_lqq,extr_lqi)
399        endif
400       
401        nume=numpnts(extr_lqq)
402        Printf "The invariant over the q-range %g to %g is %g A^-3 cm^-1\r\r",extr_lqq[0],extr_lqq[(nume-1)],inv
403       
404        // update the global display on the panel (there is a dependency for the total)
405        NVAR val = root:Packages:NIST:invariant:gInvLowQ
406        val = inv
407       
408        return(0)
409End
410
411Function InvHighQ(ctrlName) : ButtonControl
412        String ctrlName
413       
414        //no graph, get out
415        DoWindow/F Invariant_Graph
416        if(V_flag==0)
417                return(0)
418        endif
419       
420        // do the power-law extrapolation
421       
422        Wave extr_hqi=extr_hqi
423        Wave extr_hqq=extr_hqq
424        SVAR QWave = root:Packages:NIST:invariant:QWave
425        Wave qw=$QWave
426        SVAR IWave = root:Packages:NIST:invariant:IWave
427        Wave iw=$IWave
428        SVAR SWave = root:Packages:NIST:invariant:SWave
429        Wave sw=$SWave
430       
431        Variable/G V_FitMaxIters=300
432        Variable num=numpnts(iw),nume,inv
433        NVAR nend=root:Packages:NIST:invariant:gNumHigh         //number of points for the fit
434
435        Make/O/D P_coef={0,1,-4}                        //input
436        //(set background to zero and hold fixed)
437        CurveFit/H="100" Power kwCWave=P_coef  iw[(num-1-nend),(num-1)] /X=qw /W=sw /D
438        extr_hqi=P_coef[0]+P_coef[1]*extr_hqq^P_coef[2]
439       
440        Printf "Pre-exponential = %g\r",P_coef[1]
441        Printf "Power law exponent = %g\r",P_coef[2]
442       
443        //calculate the invariant
444        NVAR isSlitSmeared=root:Packages:NIST:invariant:gIsSlitSmeared
445        if(isSlitSmeared)
446                inv = Invariant_SlitSmeared(extr_hqq,extr_hqi)
447        else
448                inv = Invariant(extr_hqq,extr_hqi)
449        endif
450
451        nume=numpnts(extr_hqq)
452        Printf "The invariant over the q-range %g to %g is %g A^-3 cm^-1\r\r",extr_hqq[0],extr_hqq[(nume-1)],inv
453       
454        // update the global display on the panel (there is a dependency for the total)
455        NVAR val = root:Packages:NIST:invariant:gInvHighQ
456        val = inv
457       
458        return(0)       
459End
460
461Function UnloadInvariant()
462        if (WinType("Invariant_Panel") == 7)
463                DoWindow/K Invariant_Panel
464        endif
465        if (WinType("Invariant_Graph") != 0)
466                DoWindow/K $"Invariant_Graph"
467        endif
468        if (DatafolderExists("root:Packages:NIST:invariant"))
469                KillDatafolder root:Packages:NIST:invariant
470        endif
471        SetDataFolder root:
472        Killwaves/Z integrand,G_coef,P_coef,extr_hqq,extr_hqi,extr_lqq,extr_lqi
473       
474        SVAR fileVerExt=root:Packages:NIST:SANS_ANA_EXTENSION
475        String fname="Invariant"
476        Execute/P "DELETEINCLUDE \""+fname+fileVerExt+"\""
477        Execute/P "COMPILEPROCEDURES "
478end
479
480Menu "SANS Models"
481        Submenu "Packages"
482                "Unload Invariant", UnloadInvariant()
483        End
484end
485
486Function Inv_HelpButtonProc(ctrlName) : ButtonControl
487        String ctrlName
488
489        DisplayHelpTopic/Z/K=1 "Calculate Scattering Invariant"
490        if(V_flag != 0)
491                DoAlert 0, "The Scattering Invariant Help file can not be found"
492        endif
493End
494
495Function Inv_PickPathButtonProc(ctrlName) : ButtonControl
496        String ctrlName
497
498        A_PickPath()
499        //pop the file menu
500        Inv_FilePopMenuProc("",1,"")
501End
502
503//gets a valid file list (simply not the files with ".SAn" in the name)
504//
505Function Inv_FilePopMenuProc(ctrlName,popNum,popStr) : PopupMenuControl
506        String ctrlName
507        Variable popNum
508        String popStr
509       
510        String tempStr=Inv_filterButtonProc(ctrlName)
511        if(strlen(tempStr)==0)
512                tempStr = "Pick the data path"
513        Endif
514        String/G root:Packages:NIST:invariant:gDataPopList =tempStr
515        ControlUpdate/W=Invariant_Panel ywave
516       
517End
518
519//function called byt the popups to get a file list of data that can be sorted
520// this procedure simply removes the raw data files from the string - there
521//can be lots of other junk present, but this is very fast...
522//
523// could also use the alternate procedure of keeping only file with the proper extension
524//
525Function/S Inv_filterButtonProc(ctrlName)
526        String ctrlName
527
528        String list="",newList="",item=""
529        Variable num,ii
530       
531        //check for the path
532        PathInfo catPathName
533        if(V_Flag==0)
534                DoAlert 0, "Data path does not exist - pick the data path from the button on the invariant panel"
535                Return("")
536        Endif
537       
538        list = IndexedFile(catpathName,-1,"????")
539        num=ItemsInList(list,";")
540        //print "num = ",num
541        for(ii=(num-1);ii>=0;ii-=1)
542                item = StringFromList(ii, list  ,";")
543                //simply remove all that are not raw data files (SA1 SA2 SA3)
544                if( !stringmatch(item,"*.SA1*") && !stringmatch(item,"*.SA2*") && !stringmatch(item,"*.SA3*") )
545                        if( !stringmatch(item,".*") && !stringmatch(item,"*.pxp") && !stringmatch(item,"*.DIV"))                //eliminate mac "hidden" files, pxp, and div files
546                                newlist += item + ";"
547                        endif
548                endif
549        endfor
550        //remove VAX version numbers
551        newList = A_RemoveVersNumsFromList(newList)
552        //sort
553        newList = SortList(newList,";",0)
554
555        return newlist
556End
557
558// Loads the selected file for fitting
559// and graphs the data as needed
560Proc Inv_Load_Proc(ctrlName): ButtonControl
561        String ctrlName
562       
563        //Load the data
564        String tempName="",partialName=""
565        Variable err
566        ControlInfo/W=Invariant_Panel ywave
567        //find the file from the partial filename
568        If( (cmpstr(S_value,"")==0) || (cmpstr(S_value,"none")==0) )
569                //null selection, or "none" from any popup
570                Abort "no file selected in popup menu"
571        else
572                //selection not null
573                partialName = S_value
574                //Print partialName
575        Endif
576        //get a valid file based on this partialName and catPathName
577        tempName = A_FindValidFilename(partialName)
578
579        //prepend path to tempName for read routine
580        PathInfo catPathName
581       
582        tempName = S_path + tempName
583       
584        //load in the data (into the root directory)
585        A_LoadOneDDataWithName(tempName,0)
586        //Print S_fileName
587        //Print tempName
588       
589        String cleanLastFileName = CleanupName(root:Packages:NIST:gLastFileName,0)
590        String dataStr = "root:"+cleanLastFileName+":"
591       
592        // keep global copies of the names rather than reading from the popup
593        tempName=dataStr + cleanLastFileName+"_q"
594        String/G root:Packages:NIST:invariant:QWave=tempName
595        tempName=dataStr + cleanLastFileName+"_i"
596        String/G root:Packages:NIST:invariant:IWave=tempName
597        tempName=dataStr + cleanLastFileName+"_s"
598        String/G root:Packages:NIST:invariant:SWave=tempName
599
600        //Plot, and adjust the scaling to match the axis scaling set by the popups
601        Plot_Inv_Data("")
602
603        //if the slit-smeared box is checked, try to read the slit height
604        // - if can't find it, maybe not really smeared data, so put up the Alert
605        ControlInfo/W=Invariant_Panel check0
606        if(V_Value==1)
607                SlitSmearedCheckProc("",1)
608        endif
609End
610
611Proc InvDoneButton(ctrlName): ButtonControl
612        String ctrlName
613        DoWindow/K Invariant_Graph
614        DoWindow/K Invariant_Panel
615end
616
617//get the slit height if the data is slit-smeared
618//set the globals as needed
619Function SlitSmearedCheckProc(ctrlName,checked) : CheckBoxControl
620        String ctrlName
621        Variable checked
622
623        NVAR isSlitSmeared=root:Packages:NIST:invariant:gIsSlitSmeared
624        SVAR fileStr=root:Packages:NIST:gLastFileName
625       
626        //reset the global to the checkbox state
627        isSlitSmeared = checked         //==0 if the data is not slit smeared
628       
629        if(checked)             //get the smearing info
630                String cleanLastFileName = "root:"+CleanupName(fileStr,0)
631                NVAR dQv=root:Packages:NIST:invariant:gDqv
632                String tempName = cleanLastFileName+"sq"
633                Wave/Z w=$tempName
634                if(WaveExists(w) && w[0] < 0)
635                        dQv = - w[0]
636                        Print "Data is slit-smeared, dqv = ",w[0]
637                else
638                        DoAlert 0,"Can't find the slit height from the data. Enter the value manually if the data is truly slit-smeared, or uncheck the box."
639                endif
640        endif
641       
642        return(0)
643End
Note: See TracBrowser for help on using the repository browser.