source: sans/Dev/trunk/NCNR_User_Procedures/USANS/Main_USANS.ipf @ 360

Last change on this file since 360 was 328, checked in by ajj, 15 years ago

Rearranging files

  • Property eol-style set to native
File size: 36.7 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma Version=2.21
3#pragma IgorVersion=6.0
4
5//********************
6// 101101 Vers. 1
7//
8// Main initialization procedures for USANS reduction
9// initializes globals and oflders
10// draws the main panel for user interaction
11// action procedures for the USANS_Panel
12//
13//
14//
15// 09 NOV 04 vers 1.1
16// - updated dOmega and dQv
17// - write out dQv to 6-column data sets for analysis compatibility
18//
19//
20//********************
21
22Menu "USANS"
23        "USANS Reduction Panel",ShowUSANSPanel()
24        "Build USANS Notebook"
25        "Desmear USANS Data",Desmear()
26        "-"
27        "Load USANS Data",U_LoadOneDData()
28        "Convert to 6 Columns",Convert3ColTo6Col()
29        "-"
30        "Feedback or Bug Report",U_OpenTracTicketPage("")
31End
32
33// Bring the USANS_Panel to the front
34// ALWAYS initializes the folders and variables
35// then draws the panel if necessary
36//
37Proc ShowUSANSPanel()
38        //version number
39        Variable/G root:USANS_RED_VERSION=2.21                  //distribution as of Jan 2007
40       
41        Init_MainUSANS()
42        DoWindow/F USANS_Panel
43        if(V_Flag==0)
44                USANS_Panel()
45        Endif
46End
47
48// initializes the folders and globals for use with the USANS_Panel
49// waves for the listboxes must exist before the panel is drawn
50// "dummy" values for the COR_Graph are set here
51// instrumental constants are set here as well
52//
53Proc Init_MainUSANS()
54        NewDataFolder/O root:Globals
55        NewDataFolder/O/S root:Globals:MainPanel
56       
57        Make/O/T/N=1 fileWave,samWave,empWave,curWave //Added curWave Sept 06 A. Jackson
58        fileWave=""
59        samWave=""
60        empWave=""
61        curWave="" //Added Sept 06 A. Jackson
62        //Wave for handling Current Data AJJ Sept 06
63        Make/O/N=1 SAMisCurrent,EMPisCurrent
64        SAMisCurrent = 0
65        EMPisCurrent = 0
66        Make/O/T/N=5 statusWave=""
67        Make/O/B/U/N=1 selFileW
68        Make/O/B/U/N=1 cselFileW
69        //for the graph control bar
70        Variable/G gTransWide = 1
71        Variable/G gTransRock = 1
72        Variable/G gEmpCts = 0.76                       //default values as of 15 DEC 05 J. Barker
73        Variable/G gBkgCts = 0.62                       //default values as of 15 DEC 05 J. Barker
74        Variable/G gThick = 0.1
75        Variable/G gTypeCheck=1
76        //Text filter for data files AJJ Sept 06
77        String/G FilterStr
78        Variable/G gUseCurrentData = 0
79       
80        SetDataFolder root:
81       
82        NewDataFolder/O root:RAW
83        NewDataFolder/O root:SAM
84        NewDataFolder/O root:COR
85        NewDataFolder/O root:EMP
86        NewDataFolder/O root:BKG
87        NewDataFolder/O root:SWAP
88        NewDataFolder/O root:Graph
89       
90        //dummy waves for bkg and emp levels
91        Make/O root:EMP:empLevel,root:BKG:bkgLevel
92        root:EMP:empLevel := root:Globals:MainPanel:gEmpCts             //dependency to connect to SetVariable in panel
93        root:BKG:bkgLevel := root:Globals:MainPanel:gBkgCts
94       
95        //INSTRUMENTAL CONSTANTS
96        Variable/G  root:Globals:MainPanel:gTheta_H = 3.9e-6            //Darwin FWHM   (pre- NOV 2004)
97        Variable/G  root:Globals:MainPanel:gTheta_V = 0.014             //Vertical divergence   (pre- NOV 2004)
98        //Variable/G  root:Globals:MainPanel:gDomega = 2.7e-7           //Solid angle of detector (pre- NOV 2004)
99        Variable/G  root:Globals:MainPanel:gDomega = 7.1e-7             //Solid angle of detector (NOV 2004)
100        Variable/G  root:Globals:MainPanel:gDefaultMCR = 1e6            //factor for normalization
101       
102        //Variable/G  root:Globals:MainPanel:gDQv = 0.037               //divergence, in terms of Q (1/A) (pre- NOV 2004)
103        Variable/G  root:Globals:MainPanel:gDQv = 0.117         //divergence, in terms of Q (1/A)  (NOV 2004)
104
105       
106
107End
108
109//draws the USANS_Panel, the main control panel for the macros
110//
111
112Window USANS_Panel() : Panel
113        PauseUpdate; Silent 1           // building window...
114        NewPanel /W=(600,44,1015,493)/K=1 as "USANS_Panel"
115        SetDrawLayer UserBack
116        SetDrawEnv fstyle= 1
117        DrawText 12,53,"Data Files"
118        SetDrawEnv fstyle= 1
119        DrawText 157,192,"Empty Scans"
120        SetDrawEnv fstyle= 1
121        DrawText 154,54,"Sample Scans"
122        DrawLine 6,337,398,337
123        DrawLine 5,33,393,33
124        SetDrawEnv fstyle= 1
125        DrawText 140,357,"Raw Data Header"
126        SetDrawEnv fstyle= 1
127        DrawText 293,55,"Current Data"
128        ListBox fileLB,pos={5,55},size={110,230},proc=FileListBoxProc
129        ListBox fileLB,listWave=root:Globals:MainPanel:fileWave
130        ListBox fileLB,selWave=root:Globals:MainPanel:selFileW,mode= 4
131        ListBox samLB,pos={149,55},size={110,90},listWave=root:Globals:MainPanel:samWave
132        ListBox samLB,mode= 1,selRow= -1
133        Button ClearSamButton,pos={224,148},size={35,21},proc=ClearButtonProc,title="Clr"
134        Button ClearSamButton,help={"Clears the list of sample scans"}
135        Button ClearEmpButton,pos={227,286},size={35,20},proc=ClearButtonProc,title="Clr"
136        Button ClearEmpButton,help={"Clears the list of empty scans"}
137        Button RefreshButton,pos={9,310},size={104,20},proc=RefreshListButtonProc,title="Refresh"
138        Button RefreshButton,help={"Refreshes the list of raw ICP data files"}
139        Button DelSamButton,pos={186,148},size={35,20},proc=DelSamButtonProc,title="Del"
140        Button DelSamButton,help={"Deletes the selected file(s) from the list of sample scans"}
141        Button DelEmpButton,pos={190,286},size={35,20},proc=DelEmpButtonProc,title="Del"
142        Button DelEmpButton,help={"Deletes the selected file(s) from the list of empty scans"}
143        ListBox empLB,pos={151,194},size={110,90}
144        ListBox empLB,listWave=root:Globals:MainPanel:empWave,mode= 1,selRow= 0
145        Button toSamList,pos={118,55},size={25,90},proc=toSamListButtonProc,title="S->"
146        Button toSamList,help={"Adds the selected file(s) to the list of sample scans"}
147        Button toEmpList,pos={120,195},size={25,90},proc=toEmptyListButtonProc,title="E->"
148        Button toEmpList,help={"Adds the selected file(s) to the list of empty (cell) scans"}
149        ListBox StatusLB,pos={11,358},size={386,77}
150        ListBox StatusLB,listWave=root:Globals:MainPanel:statusWave
151        Button pickPathButton,pos={6,8},size={80,20},proc=PickBT5PathButton,title="DataPath..."
152        Button pickPathButton,help={"Select the data folder where the raw ICP data files are located"}
153        Button PlotSelectedSAMButton,pos={148,148},size={35,20},proc=PlotSelectedSAMButtonProc,title="Plot"
154        Button PlotSelectedSAMButton,help={"Plot the selected sample scattering files in the COR_Graph"}
155        Button PlotSelectedEMPButton,pos={152,286},size={35,20},proc=PlotSelectedEMPButtonProc,title="Plot"
156        Button PlotSelectedEMPButton,help={"Plot the selected empty cell scattering files in the COR_Graph"}
157        Button pickSavePathButton,pos={97,8},size={80,20},proc=PickSaveButtonProc,title="SavePath..."
158        Button pickSavePathButton,help={"Select the data folder where data is to be saved to disk"}
159        Button USANSHelpButton,pos={341,6},size={50,20},proc=USANSHelpButtonProc,title="Help"
160        Button USANSHelpButton,help={"Show the USANS reduction help file"}
161        Button RefreshCurrent,pos={298,310},size={95,20},proc=RefreshCurrentButtonProc,title="Refresh",disable=2
162        Button RefreshCurrent,help={"Updates data files on Charlotte and gets current data file name"}
163        Button AddCurToSAM,pos={264,55},size={25,90},proc=CurtoSamListButtonProc,title="<-S",disable=2
164        Button AddCurToSAM,help={"Adds the current data file to the list of sample scans"}
165        Button AddCurToEMP,pos={265,194},size={25,90},proc=CurtoEmptyListButtonProc,title="<-E",disable=2
166        Button AddCurToEMP,help={"Adds the current data file to the list of empty scans"}
167        ListBox CurFileBox,pos={295,55},size={100,230},proc=FileListBoxProc,disable=1
168        ListBox CurFileBox,listWave=root:Globals:MainPanel:curWave,mode=1
169        SetVariable FilterSetVar,pos={8,289},size={106,18},title="Filter",fSize=12
170        SetVariable FilterSetVar,value= root:Globals:MainPanel:FilterStr
171        CheckBox UseCurrentData,pos={298,290},size={10,10},proc=UseCurrentDataProc,title="Enable Current Data"
172        CheckBox UseCurrentData,value=0
173        Button USANSFeedback,pos={220,6},size={100,20},proc=U_OpenTracTicketPage,title="Feedback"
174       
175EndMacro
176
177
178
179//draws a simple graph of the monitor counts, transmission counts, and detector counts
180// plots the selected raw data file when "plot raw" is selected from the USANS_Panel
181//
182Proc GraphRawData()
183        PauseUpdate; Silent 1           // building window...
184        String fldrSav= GetDataFolder(1)
185        SetDataFolder root:RAW:
186        //String textStr = StringForRawGraph()
187        //textStr=StringByKey("FILE",textStr,":",";")+" MONRATE:"+num2str(mean(MonCts)/NumberByKey("TIMEPT",textStr,":",";"))
188        Display /W=(600,525,1015,850)/L=left1/B=bottom1 /K=1 DetCts vs Angle as "Raw Data"
189        ModifyGraph margin(top)=50
190        //Display /W=(600,525,1015,850) /K=1 DetCts vs Angle as "Raw Data"
191        DoWindow/C RawDataWin
192        //AppendToGraph/L=left1 /B=bottom1 DetCts vs Angle
193        AppendToGraph/L=left2/B=bottom1 TransCts vs Angle
194        AppendToGraph/L=left3/B=bottom1 MonCts vs Angle
195        SetAxis/A/N=2 left1
196        SetAxis/A/N=2 left2
197        SetAxis/A/N=2 left3
198        ModifyGraph mode=4, marker=19
199        ModifyGraph rgb(TransCts)=(1,4,52428),rgb(MonCts)=(1,39321,19939)
200        ModifyGraph msize=1,grid=1,mirror=2,standoff=1,lblPos=50,tickUnit=1,notation=1,freePos={0.1,kwFraction}
201        ModifyGraph nticks(left2)=2
202        ModifyGraph nticks(left3)=2
203        ModifyGraph mirror(bottom1)=0
204        ModifyGraph axisEnab(left1)={0.1,0.5},gridEnab(left1)={0.1,1}
205        ModifyGraph axisEnab(left2)={0.57,0.77},gridEnab(left2)={0.1,1}
206        ModifyGraph axisEnab(left3)={0.8,1},gridEnab={0.1,1}
207        ModifyGraph axisEnab(bottom1)={0.1,1},gridEnab(bottom1)={0.1,1}
208        ErrorBars DetCts Y,wave=(ErrDetCts,ErrDetCts)
209        TextBox/F=0/E=2/A=MB/Y=2/N=text1 "Angle"
210        TextBox/F=0/O=90/E=2/A=LC/X=2/N=text2 "Counts"
211        //TextBox/N=text1/A=RC/X=0.50/Y=-2 textStr
212        //Label bottom1 "Angle (degrees)"
213        Label left1 " "
214        Label left2 " "
215        Label left3 " "
216        TitleForRawGraph()
217        SetDataFolder fldrSav
218End
219
220// plots the selected EMP files onto the COR_Graph
221// Does the following:
222// - loads raw data
223// - normalizes counts to time and 1E6 monitor counts
224// sorts by angle
225// finds zero angle (and peak height)
226// converts to q-values
227// finds T wide
228// updates the graph
229//
230Function PlotSelectedEMPButtonProc(ctrlName) : ButtonControl
231        String ctrlName
232
233        //get selected files from listbox (everything)
234        //use the listBox wave directly
235        Wave/T listW=$"root:Globals:MainPanel:empWave"
236        //Wave for indication of current data set AJJ Sept 2006
237        Wave isCurrent = $"root:Globals:MainPanel:EMPisCurrent"
238        Variable ii,num=numpnts(listW)
239        String fname="",fpath="",curPathStr=""
240        PathInfo bt5PathName
241        fpath = S_Path
242        PathInfo bt5CurPathName
243        curPathStr = S_Path
244               
245        if(cmpstr("",listW[0])==0)
246                return(0)               //null item in 1st position, exit
247        Endif
248       
249        //load, normalize, and append
250        //loop over the number of items in the list
251        for(ii=0;ii<num;ii+=1)
252               
253                //Check to see if file is current data set AJJ Sept 06
254                if (isCurrent[ii] ==  1)
255                        fname = curPathStr + listw[ii]
256                else
257                        fname = fpath + listw[ii]
258                endif
259
260               
261                LoadBT5File(fname,"SWAP")       //overwrite what's in the SWAP folder
262                Convert2Countrate("SWAP")
263                if(ii==0)       //first time, overwrite
264                        NewDataWaves("SWAP","EMP")
265                else            //append to waves in "EMP"
266                        AppendDataWaves("SWAP","EMP")
267                endif
268        endfor
269        //sort after all loaded
270        DoAngleSort("EMP")
271       
272        //find the peak and convert to Q-values
273        Variable zeroAngle = FindZeroAngle("EMP")
274        if(zeroAngle == -9999)
275                DoAlert 0,"Couldn't find a peak - using zero as zero angle"
276                zeroAngle = 0
277        Endif
278        ConvertAngle2Qvals("EMP",zeroAngle)
279       
280        //find the Trans Cts for T_Wide
281        FindTWideCts("EMP")
282       
283        //copy the data to plot to the root:Graph directory, and give clear names
284        if(WaveExists($("root:EMP:Qvals")))
285                Duplicate/O $("root:EMP:Qvals"),$("root:Graph:Qvals_EMP")
286        Endif
287        Duplicate/O $("root:EMP:Angle"),$("root:Graph:Angle_EMP")
288        Duplicate/O $("root:EMP:DetCts"),$("root:Graph:DetCts_EMP")
289        Duplicate/O $("root:EMP:ErrDetCts"),$("root:Graph:ErrDetCts_EMP")
290       
291        //now plot the data (or just bring the graph to the front)
292        DoCORGraph()
293End
294
295// plots the selected SAM files onto the COR_Graph
296// Does the following:
297// - loads raw data
298// - normalizes counts to time and 1E6 monitor counts
299// sorts by angle
300// finds zero angle (and peak height)
301// converts to q-values
302// finds T wide
303// updates the graph
304//
305Function PlotSelectedSAMButtonProc(ctrlName) : ButtonControl
306        String ctrlName
307
308        //get selected files from listbox (everything)
309        //use the listBox wave directly
310        Wave/T listW=$"root:Globals:MainPanel:samWave"
311        //Wave for indication of current data set AJJ Sept 2006
312        Wave isCurrent = $"root:Globals:MainPanel:SAMisCurrent"
313        Variable ii,num=numpnts(listW)
314        String fname="",fpath="",curPathStr=""
315        PathInfo bt5PathName
316        fpath = S_Path
317        PathInfo bt5CurPathName
318        curPathStr = S_Path
319       
320        if(cmpstr("",listW[0])==0)
321                return(0)               //null item in 1st position, exit
322        Endif
323       
324        //load, normalize, and append
325        //loop over the number of items in the list
326        for(ii=0;ii<num;ii+=1)
327                fname = fpath + listw[ii]
328               
329                //Check to see if file is current data set AJJ Sept 06
330                if (isCurrent[ii] ==  1)
331                        fname = curPathStr + listw[ii]
332                else
333                        fname = fpath + listw[ii]
334                endif
335                               
336                LoadBT5File(fname,"SWAP")       //overwrite what's in the SWAP folder
337                Convert2Countrate("SWAP")
338                if(ii==0)       //first time, overwrite
339                        NewDataWaves("SWAP","SAM")
340                else            //append to waves in "SAM"
341                        AppendDataWaves("SWAP","SAM")
342                endif
343        endfor
344        //sort after all loaded
345        DoAngleSort("SAM")
346       
347        //find the peak and convert to Q-values
348        Variable zeroAngle = FindZeroAngle("SAM")
349        if(zeroAngle == -9999)
350                DoAlert 0,"Couldn't find a peak - using zero as zero angle"
351                zeroAngle = 0
352        Endif
353        ConvertAngle2Qvals("SAM",zeroAngle)
354        //find the Trans Cts for T_Wide
355        FindTWideCts("SAM")
356        //
357        //copy the data to plot to the root:Graph directory, and give clear names
358        if(WaveExists($("root:SAM:Qvals")))
359                Duplicate/O $("root:SAM:Qvals"),$("root:Graph:Qvals_SAM")
360        Endif
361        Duplicate/O $("root:SAM:Angle"),$("root:Graph:Angle_SAM")
362        Duplicate/O $("root:SAM:DetCts"),$("root:Graph:DetCts_SAM")
363        Duplicate/O $("root:SAM:ErrDetCts"),$("root:Graph:ErrDetCts_SAM")
364       
365        //now plot the data (or just bring the graph to the front)
366        DoCORGraph()
367End
368
369//sort the data in the "type"folder, based on angle
370//carry along all associated waves
371//
372Function DoAngleSort(type)
373        String type
374       
375        Wave angle = $("root:"+Type+":Angle")
376        Wave detCts = $("root:"+Type+":DetCts")
377        Wave ErrdetCts = $("root:"+Type+":ErrDetCts")
378        Wave MonCts = $("root:"+Type+":MonCts")
379        Wave TransCts = $("root:"+Type+":TransCts")
380       
381        Sort Angle DetCts,ErrDetCts,MonCts,TransCts,Angle
382        return(0)
383End
384
385// converts to countrate per 1E6 monitor counts (default value)
386// by dividing by the counting time (reported in header in seconds per point)
387// and the globally defined monitor count
388//
389// works on data in "type" folder
390//
391// note that trans detector counts are NOT normalized to 1E6 mon cts (not necessary)
392//
393Function Convert2Countrate(type)
394        String type
395       
396        String noteStr = note($("root:"+Type+":DetCts"))
397        Variable ctTime
398        ctTime = NumberByKey("TIMEPT",noteStr,":",";")
399        //normalize by counting time
400        Wave detCts = $("root:"+Type+":DetCts")
401        Wave ErrdetCts = $("root:"+Type+":ErrDetCts")
402        Wave MonCts = $("root:"+Type+":MonCts")
403        Wave TransCts = $("root:"+Type+":TransCts")
404       
405        detCts /= ctTime
406        ErrDetCts /= ctTime
407        MonCts /= ctTime
408        TransCts /= ctTime
409       
410        //normalize to monitor countrate [=] counts/monitor
411        //trans countrate does not need to be normalized
412        NVAR defaultMCR=root:Globals:MainPanel:gDefaultMCR
413        DetCts /= monCts/defaultMCR
414        ErrDetCts /= MonCts/defaultMCR
415       
416        //adjust the note (now on basis of 1 second)
417        ctTime = 1
418        noteStr = ReplaceNumberByKey("TIMEPT",noteStr,ctTime,":",";")
419        Note/K detCts
420        Note detCts,noteStr
421       
422        return(0)
423End
424
425
426// copies data from one folder to another
427//
428// used for the first set, simply obliterate the old waves in the folder
429//
430Function NewDataWaves(fromType,toType)
431        String fromType,toType
432       
433        Duplicate/O $("root:"+fromType+":Angle"),$("root:"+toType+":Angle")
434        Duplicate/O $("root:"+fromType+":DetCts"),$("root:"+toType+":DetCts")
435        Duplicate/O $("root:"+fromType+":ErrDetCts"),$("root:"+toType+":ErrDetCts")
436        Duplicate/O $("root:"+fromType+":MonCts"),$("root:"+toType+":MonCts")
437        Duplicate/O $("root:"+fromType+":TransCts"),$("root:"+toType+":TransCts")
438       
439        //check for qvals wave, move if it's there
440        if(WaveExists($("root:"+fromType+":Qvals")))
441                Duplicate/O $("root:"+fromType+":Qvals"),$("root:"+toType+":Qvals")
442        Endif
443       
444End
445
446//to add additional data to a folder, need to concatenate the data in the waves
447//and need to update the wave note associated with "DetCts" to include the additional file
448//
449Function AppendDataWaves(fromType,toType)
450        String fromType,toType
451       
452        String fromNote="",toNote="",newNote="",fromfile="",toFile=""
453       
454        ConcatenateData( ("root:"+toType+":Angle"),("root:"+fromType+":Angle") ) //appends "from" at the end of "to"
455        ConcatenateData( ("root:"+toType+":DetCts"),("root:"+fromType+":DetCts") )
456        ConcatenateData( ("root:"+toType+":ErrDetCts"),("root:"+fromType+":ErrDetCts") )
457        ConcatenateData( ("root:"+toType+":MonCts"),("root:"+fromType+":MonCts") )
458        ConcatenateData( ("root:"+toType+":TransCts"),("root:"+fromType+":TransCts") )
459       
460
461        //adjust the wavenote, to account for the new dataset
462        fromNote = note($("root:"+fromType+":DetCts"))
463        fromFile = StringByKey("FILE",fromNote,":",";")
464        toNote = note($("root:"+toType+":DetCts"))
465        toFile = StringByKey("FILE",toNote,":",";")
466        toFile += "," + fromfile
467        toNote = ReplaceStringByKey("FILE",toNote,toFile,":",";")
468        Note/K $("root:"+toType+":DetCts")
469        Note $("root:"+toType+":DetCts"),toNote
470       
471        Return(0)
472End
473
474// action procedure to select the raw data path where the bt5 files are located
475//
476Function PickBT5PathButton(PathButton) : ButtonControl
477        String PathButton
478       
479        //Print "DataPathButton Proc"
480        Variable err = PickBT5Path()            //=1 if error
481
482End
483
484//pick the data folder to save the data to - in general must be a local disk, not the ICP database....
485//
486Function PickSaveButtonProc(ctrlName) : ButtonControl
487        String ctrlName
488       
489        NewPath/O/M="SAVE data to the selected folder" savePathName
490        PathInfo/S savePathName
491        String dum = S_path
492        if (V_flag == 0)
493                return(1)
494        else
495                return(0)               //no error
496        endif
497End
498
499// Show the help file, don't necessarily keep it with the experiment (/K=1)
500Function USANSHelpButtonProc(ctrlName) : ButtonControl
501        String ctrlName
502       
503        DisplayHelpTopic/Z/K=1 "USANS Data Reduction"
504        if(V_flag !=0)
505                DoAlert 0,"The USANS Data Reduction Help file could not be found"
506        endif
507        return(0)
508End
509
510//prompts user to choose the local folder that contains the BT5 Data
511//only one folder can be used, and its path is bt5PathName (and is a NAME, not a string)
512//this will overwrite the path selection
513//returns 1 if no path selected as error condition
514Function PickBT5Path()
515       
516        NVAR isChecked = root:Globals:MainPanel:gUseCurrentData
517       
518        //set the global string to the selected pathname
519        NewPath/O/M="pick the BT5 data folder" bt5PathName
520        PathInfo/S bt5PathName
521        String dum = S_path
522        if (V_flag == 0)
523                //Path does not exist
524                return(1)
525        else
526                if (isChecked == 1)
527                        NewPath/O/M="Select Current Data" bt5CurPathName, getCurrentPath(S_Path)
528                        return(0)               //no error
529                Endif
530        endif
531End
532
533//action procedure to load and plot a raw data file
534// loads the data based on selected file and bt5pathname
535// draws a new graph if necessary
536// otherwise just updates the data
537//
538Function PlotRawButtonProc(ctrlName) : ButtonControl
539        String ctrlName
540
541        String fname=""
542       
543        if (cmpstr(ctrlName,"FileLB") == 0)
544                //Print "PlotRaw Button"
545                //take the selection, and simply plot the counts vs. angle - don't save the data anyplace special
546                //get the selected wave
547                Wave/T fileWave=$"root:Globals:MainPanel:fileWave"
548                Wave sel=$"root:Globals:MainPanel:selFileW"
549                Variable ii=0,num=numpnts(sel),err
550
551               
552                PathInfo bt5PathName
553                fname = S_Path
554                do
555                        if(sel[ii] == 1)
556                                fname+=filewave[ii]
557                                break
558                        endif
559                        ii+=1
560                while(ii<num)
561        elseif (cmpstr(ctrlName,"CurFileBox" )== 0)
562                Wave/T fileWave=$"root:Globals:MainPanel:curWave"
563                PathInfo bt5CurPathName
564                fname = S_Path
565                fname+=filewave[0]
566        endif
567        //Print fname
568        err = LoadBT5File(fname,"RAW")
569        if(err)
570                return(err)
571        endif
572        //if the "Raw Data" Graph exists, do nothing - else draw it
573        //DoWindow/F RawDataWin
574        if(WinType("RawDataWin")!=1)
575                Execute "GraphRawData()"
576        else
577                //just update the textbox
578                //String textStr=StringForRawGraph()
579                //TextBox/W=RawDataWin/C/N=text1/A=RC/X=0.50/Y=-2 textStr
580                //TextBox/W=RawDataWin/C/E=2/A=MT/X=0/Y=0/N=text0 textStr
581                TitleForRawGraph()
582        Endif
583        //bring the panel back to the front
584        DoWindow/F USANS_Panel
585End
586
587// action procedure for the raw data listbox
588// responds to selection or (shift)selection events
589// by acting if the "status" button was pressed
590//(note that the status button is obsolete and not drawn on the USANS_Panel, but
591// I kept the nomenclature)
592//
593Function FileListBoxProc(ctrlName,row,col,event)
594        String ctrlName
595        Variable row,col,event
596       
597        if (cmpstr(ctrlName, "fileLB") == 0)
598                //event == 4 is a selection
599                //event == 5 is a selection + shift key
600                if( (event==4) || (event==5) )
601                        StatusButtonProc(ctrlName)              //act as if status button was pressed
602                        PlotRawButtonProc(ctrlName)                                     //automatically plots the raw data
603                Endif
604                return(0)
605        elseif (cmpstr(ctrlName,"CurFileBox") == 0)
606                //print "Selected current data"
607                if  (event == 4)
608                        StatusButtonProc(ctrlName)
609                        PlotRawButtonProc(ctrlName)
610                endif
611                return(0)
612        endif
613        return(1)
614End
615
616// displays the status of the selected file in the raw data file list box
617// - spits the information out to a second listbox
618// - called automatically as an action when there is a selection in the file listbox
619// not used as a button procedure anymore
620//
621Function StatusButtonProc(ctrlName)
622        String ctrlName
623        String fname=""
624
625        if(cmpstr(ctrlName,"fileLB")==0)
626                //Print "Status Button"
627                //display the (first) selected wave
628                Wave/T fileWave=$"root:Globals:MainPanel:fileWave"
629                Wave sel=$"root:Globals:MainPanel:selFileW"
630                Variable ii=0,num=numpnts(sel)
631               
632                PathInfo bt5PathName
633                fname = S_Path
634                do
635                        if(sel[ii] == 1)
636                                fname+=filewave[ii]
637                                break
638                        endif
639                        ii+=1
640                while(ii<num)
641        elseif(cmpstr(ctrlName,"CurFileBox")==0)
642                Wave/T fileWave=$"root:Globals:MainPanel:curWave"
643                PathInfo bt5CurPathName
644                fname = S_Path
645                fname+=filewave[0]
646        endif           
647        //Print fname
648        ReadBT5Header(fname)
649End
650
651// copies the selected files from the raw file list box to the sam file listbox
652//
653// makes sure that any null items are removed from the wave attached to the listbox
654//
655Function toSamListButtonProc(ctrlName) : ButtonControl
656        String ctrlName
657
658        //Print "toSamList button"
659        Wave/T fileWave=$"root:Globals:MainPanel:fileWave"
660        Wave/T samWave=$"root:Globals:MainPanel:samWave"
661        Wave sel=$"root:Globals:MainPanel:selFileW"
662        //Wave to indicate Current status
663        Wave isCurrent = $"root:Globals:MainPanel:SAMisCurrent"
664
665       
666        Variable num=numpnts(sel),ii=0
667        variable lastPt=numpnts(samWave)
668        do
669                if(sel[ii] == 1)
670                        InsertPoints lastPt,1, samWave
671                        samWave[lastPt]=filewave[ii]
672                        InsertPoints lastPt, 1, isCurrent
673                        isCurrent[lastPt] = 0
674                        lastPt +=1
675                endif
676                ii+=1
677        while(ii<num)
678       
679        //clean out any (null) elements
680        num=numpnts(samwave)
681        for(ii=0;ii<num;ii+=1)
682                if(cmpstr(samWave[ii],"") ==0)
683                        DeletePoints ii,1,samWave
684                        DeletePoints ii,1,isCurrent
685                        num -= 1
686                Endif
687        Endfor
688       
689        return(0)
690End
691
692// copies the selected files from the raw file list box to the sam file listbox
693//
694// makes sure that any null items are removed from the wave attached to the listbox
695//
696Function toEmptyListButtonProc(ctrlName) : ButtonControl
697        String ctrlName
698
699        //Print "toEmptyList button"
700        Wave/T fileWave=$"root:Globals:MainPanel:fileWave"
701        Wave/T empWave=$"root:Globals:MainPanel:empWave"
702        Wave sel=$"root:Globals:MainPanel:selFileW"
703        //Wave to indicate Current status
704        Wave isCurrent = $"root:Globals:MainPanel:EMPisCurrent"
705
706
707       
708        Variable num=numpnts(sel),ii=0
709        variable lastPt=numpnts(empWave)
710        do
711                if(sel[ii] == 1)
712                        InsertPoints lastPt,1, empWave
713                        empWave[lastPt]=filewave[ii]
714                        InsertPoints lastPt, 1, isCurrent
715                        isCurrent[lastPt] = 0
716                        lastPt +=1
717                endif
718                ii+=1
719        while(ii<num)
720       
721        //clean out any (null) elements
722        num=numpnts(empwave)
723        for(ii=0;ii<num;ii+=1)
724                if(cmpstr(empWave[ii],"") ==0)
725                        DeletePoints ii,1,empWave
726                        DeletePoints ii,1,isCurrent
727                        num -= 1
728                Endif
729        Endfor
730       
731        return(0)
732End
733
734//deletes the selected file from the sam list
735// multiple selections are not allowed
736// the cor_graph is not updated
737//
738Function DelSamButtonProc(ctrlName) : ButtonControl
739        String ctrlName
740       
741        ControlInfo SamLB
742        Variable selRow=V_Value
743        Wave lw=$(S_DataFolder + S_Value)
744        DeletePoints selRow,1,lw       
745        //Clear out current flag AJJ Sept O6
746        Wave isCurrent = $"root:Globals:MainPanel:SAMisCurrent"
747        DeletePoints selRow, 1, isCurrent       
748End
749
750//deletes the selected file from the emp list
751// multiple selections are not allowed
752// the cor_graph is not updated
753//
754Function DelEmpButtonProc(ctrlName) : ButtonControl
755        String ctrlName
756       
757        ControlInfo EmpLB
758        Variable selRow=V_Value
759        Wave lw=$(S_DataFolder + S_Value)
760        DeletePoints selRow,1,lw
761        //Clear out current flag AJJ Sept O6
762        Wave isCurrent = $"root:Globals:MainPanel:EMPisCurrent"
763        DeletePoints selRow, 1, isCurrent       
764End
765
766//refreshes the file list presented in the raw data file listbox
767//bt5PathName is hard-wired in, will prompt if none exists
768// reads directly from disk
769//
770// EXCLUDES all files that do not match "*.bt5*" (not case sensitive)
771//
772// sorts the list to alphabetical order
773//
774Function RefreshListButtonProc(ctrlName) : ButtonControl
775        String ctrlName
776       
777        SVAR FilterStr = root:Globals:MainPanel:FilterStr
778        String filter
779       
780        //check for path and force user to pick a path
781        do
782                PathInfo bt5PathName
783                if(V_Flag)
784                        break
785                Endif
786                PickBT5Path()
787        while(V_Flag==0)
788       
789        //Get the filter and determine the match string required AJJ Sept06
790        if (stringmatch(FilterStr,"!"))
791                filter = FilterStr+"*.bt5*"
792        else
793                filter = "*.bt5*"
794        endif
795       
796        //get all the files, then trim the list
797        String list=IndexedFile(bt5PathName,-1,"????")
798        String newList="",item=""
799        Variable num=ItemsInList(list,";"),ii
800        for(ii=0;ii<num;ii+=1)
801                item = StringFromList(ii, list  ,";")
802               
803                if( stringmatch(item,filter) )          //ONLY keep files that match the filter + *.bt5 AJJ Sept 06
804                        newlist += item + ";"
805                endif
806                //print "ii=",ii
807        endfor
808        newList = SortList(newList,";",0)       //get them in order
809        num=ItemsInList(newlist,";")
810        Wave/T fileWave = $" root:Globals:MainPanel:fileWave"
811        Wave selFileW = $"root:Globals:MainPanel:selFileW"
812        Redimension/N=(num) fileWave
813        Redimension/N=(num) selFileW
814        fileWave=""
815        selFileW = 0
816        fileWave = StringFromList(p,newlist,";")        //  ! quick and easy assignment of the list
817        Sort filewave,filewave
818       
819End
820
821//clears either the sample or empty scan Lists...
822//Also clears the data folders and the COR_Graph
823//
824// very useful to make sure that the data is really what you think it is on the cor_graph
825//
826Function ClearButtonProc(ctrlName) : ButtonControl
827        String ctrlName
828       
829        SetDataFolder root:Globals:MainPanel
830        strswitch(ctrlName)
831                case "ClearSamButton":
832                        Make/O/T/N=1 samWave
833                        samWave=""
834                        //Clear out current flags AJJ Sept O6
835                        Make/O/N=1 SAMisCurrent,EMPisCurrent
836                        SAMisCurrent = 0
837                        EMPisCurrent = 0
838                        //clear the graph, then the data folders as well
839                        CleanOutGraph("SAM")
840                        CleanOutFolder("SAM")
841                        CleanOutGraph("COR")
842                        CleanOutFolder("COR")
843                        break
844                case "ClearEmpButton":
845                        Make/O/T/N=1 empWave
846                        empWave=""
847                        //Clear out current flags AJJ Sept O6
848                        Make/O/N=1 SAMisCurrent,EMPisCurrent
849                        SAMisCurrent = 0
850                        EMPisCurrent = 0
851                        //clear the graph, then the data folders as well
852                        CleanOutGraph("EMP")
853                        CleanOutFolder("EMP")
854                        CleanOutGraph("COR")
855                        CleanOutFolder("COR")
856                        break
857        endswitch
858        DoWindow/F USANS_Panel          //focus back to MainPanel
859        SetDataFolder root:
860End
861
862//reads header information, to display on main panel only
863// called from the action procedure of the raw data listbox
864//
865// puts the pertinent information in the "statusWave" that is associated
866//with the status listbox (which will automatically update)
867//
868Function ReadBT5Header(fname)
869        String fname
870       
871        Variable err=0,refNum
872        Wave/T statusWave=$"root:Globals:MainPanel:statusWave"
873       
874        Open/R refNum as fname          //READ-ONLY.......if fname is "", a dialog will be presented
875        if(refnum==0)
876                return(1)               //user cancelled
877        endif
878        //read in the ASCII data line-by-line
879        Variable numLinesLoaded = 0,firstchar
880        Variable v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,ii,valuesRead
881        String buffer ="",s1,s2,s3,s4,s5,s6,s7,s8,s9,s10
882       
883        //parse the first line
884        FReadLine refnum,buffer
885        sscanf buffer, "%s%s%s%s%s%s%g%g%s%g%s",s1,s2,s3,s4,s5,s6,v1,v2,s7,v3,s8
886        statusWave[0] = "FILE: "+s1
887        statusWave[1] = "DATE: "+s2+" "+s3+" "+s4+" "+s5
888       
889        //v1 is the time per point (sec)
890        //v2  is the monitor prefactor. Let's multiply the time by the prefactor. AJJ 5 March 07
891        statusWave[2] = "TIME/PT: "+num2istr(v1*v2)+" sec"
892       
893        //skip the next line
894        FReadLine refnum,buffer
895        //the next line is the title, use it all
896        FReadLine refnum,buffer
897        statusWave[3] = "TITLE: "+ buffer
898       
899        //skip the next 3 lines
900        For(ii=0;ii<3;ii+=1)
901                FReadLine refnum,buffer
902        EndFor
903       
904        //parse the angular range from the next line
905        FReadLine refnum,buffer
906        sscanf buffer,"%g%g%g%g",v1,v2,v3,v4
907        statusWave[4] = "RANGE: "+num2str(v2)+" to "+num2str(v4)+" step "+num2str(v3)
908       
909        Close refNum            // Close the file, read-only, so don't need to move to EOF first
910        return err                      // Zero signifies no error.     
911End
912
913// given a string that is the wavenote of the just-loaded raw data file
914// pick out the file and time list items (and values)
915//and return a string that is to be used for the textbox in the graph of raw data
916//
917Function TitleForRawGraph()
918
919        WAVE detCts=$"root:RAW:detCts"
920        WAVE monCts = $"root:RAW:monCts"
921        String str=note(detCts)
922       
923        String retStr="\\JC"
924        retStr += StringByKey("FILE",str,":",";")+"\r"
925        retStr += "Count Time: "+StringByKey("TIMEPT",str,":",";")
926        retStr += " \tMonitor Rate: "+num2str(mean(monCts)/NumberByKey("TIMEPT",str,":",";"))+"\r"
927        retStr += "\\s(DetCts) DetCts \\s(TransCts) TransCts \\s(MonCts) MonCts"
928       
929        TextBox/W=RawDataWin/C/E=2/A=MT/X=5/Y=0/N=text0 retStr
930End
931
932
933//concatenates datasets (full names are passed in as a string)
934//tacks w2 onto the end of w1 (so keep w1)
935//
936// copied from a wavemetrics procedure (concatenatewaves?)
937Function ConcatenateData(w1, w2)
938        String w1, w2
939       
940        Variable numPoints1, numPoints2
941
942        if (Exists(w1) == 0)
943                Duplicate $w2, $w1
944        else
945                String wInfo=WaveInfo($w2, 0)
946                numPoints1 = numpnts($w1)
947                numPoints2 = numpnts($w2)
948                Redimension/N=(numPoints1 + numPoints2) $w1
949                Wave/D ww1=$w1
950                Wave/D ww2=$w2
951                ww1[numPoints1, ] = ww2[p-numPoints1]
952        endif
953End
954
955//takes the given inputs, subtracts EMP and BKG from the SAM data
956//the user must supply the correct sample thickness, BKGLevel, and EMPLevel for extrapolation
957Function DoCorrectData()
958       
959        //constants
960//      NVAR  thetaH = root:Globals:MainPanel:gTheta_H                  //Darwin FWHM
961//      NVAR  thetaV = root:Globals:MainPanel:gTheta_V                  //Vertical divergence
962        NVAR dOmega =  root:Globals:MainPanel:gDomega                   //Solid angle of detector
963        NVAR defaultMCR = root:Globals:MainPanel:gDefaultMCR
964        //waves
965        Wave iqSAM = $"root:SAM:DetCts"
966        Wave errSAM = $"root:SAM:ErrDetCts"
967        Wave qvalSAM = $"root:SAM:Qvals"
968        Wave iqEMP = $"root:EMP:DetCts"
969        Wave errEMP = $"root:EMP:ErrDetCts"
970        Wave qvalEMP = $"root:EMP:Qvals"
971        //BKG,EMP levels,trans,thick
972        NVAR bkgLevel = root:Globals:MainPanel:gBkgCts
973        NVAR empLevel = root:Globals:MainPanel:gEmpCts
974        NVAR Trock = root:Globals:MainPanel:gTransRock
975        NVAR Twide = root:Globals:MainPanel:gTransWide
976        NVAR thick = root:Globals:MainPanel:gThick
977        //New waves in COR folder, same length as SAM data
978        Duplicate/O iqSAM,$"root:COR:DetCts"
979        Duplicate/O errSAM,$"root:COR:ErrDetCts"
980        Duplicate/O qvalSAM,$"root:COR:Qvals"
981        Wave iqCOR = $"root:COR:DetCts"
982        Wave qvalCOR = $"root:COR:Qvals"
983        Wave errCOR = $"root:COR:ErrDetCts"
984       
985        //correction done here
986        //q-values of EMP must be interpolated to match SAM data
987        //use the extrapolated value of EMP beyind its measured range
988        Variable num=numpnts(iqSAM),ii,scale,tempI,temperr,maxq,wq
989        maxq = qvalEMP[(numpnts(qvalEMP)-1)]            //maximum measure q-value for the empty
990       
991        for(ii=0;ii<num;ii+=1)
992                wq = qvalSAM[ii]        //q-point of the sample
993                if(wq<maxq)
994                        tempI = interp(wq,qvalEMP,iqEMP)
995                        temperr = interp(wq,qvalEMP,errEMP)
996                else
997                        tempI = empLevel
998                        //temperr = sqrt(empLevel)
999                        temperr = 0             //JGB 5/31/01
1000                endif
1001                iqCOR[ii] = iqSAM[ii] - Trock*tempI - (1-Trock)*bkglevel
1002                errCOR[ii] = sqrt(errSAM[ii]^2 + Trock^2*temperr^2)             //Trock^2; JGB 5/31/01
1003        endfor
1004       
1005        String str=note(iqEMP)
1006        Variable pkHtEMP=NumberByKey("PEAKVAL", str,":",";")
1007        //absolute scaling factor
1008        scale = 1/(Twide*thick*dOmega*pkHtEMP)
1009        iqCOR *= scale
1010        errCOR *= scale
1011       
1012        //copy to Graph directory to plot
1013        Duplicate/O $("root:COR:Qvals"),$("root:Graph:Qvals_COR")
1014        Duplicate/O $("root:COR:DetCts"),$("root:Graph:DetCts_COR")
1015        Duplicate/O $("root:COR:ErrDetCts"),$("root:Graph:ErrDetCts_COR")
1016       
1017        //now plot the data (or just bring the graph to the front)
1018        DoCORGraph()
1019        return(0)
1020End
1021
1022//cleans out the specified data folder (type)
1023// and clears out the same-named data from the Graph folder
1024// kills what is not in use
1025//
1026Function CleanOutFolder(type)
1027        String type
1028       
1029        SetDataFolder $("root:"+type)
1030        Killwaves/Z DetCts,Qvals,ErrDetCts,Angle,MonCts,TransCts
1031       
1032        SetDataFolder root:Graph
1033        KillWaves/Z $("DetCts_"+type),$("ErrDetCts_"+type),$("Qvals_"+type)
1034       
1035        SetDataFolder root:
1036End
1037
1038// removes the selected datatype from the COR_Graph
1039//                     
1040Function CleanOutGraph(type)
1041        String type
1042       
1043        DoWindow/F COR_Graph
1044        if(V_flag)
1045                RemoveFromGraph/W=COR_Graph/Z $("DetCts_"+type)
1046        endif
1047End
1048
1049//Edits by AJJ, September 2006
1050//Add functions to get data from Current Folder
1051
1052Function RefreshCurrentButtonProc(ctrlName) : ButtonControl
1053        String ctrlName
1054       
1055        //Prod the web update page
1056        //This is a horrible kludge that doesn't really work as the
1057        //webscript does not update the current run as of Sept 26 2006
1058        //Will get Nick M to look into it
1059        BrowseURL/Z "http://www-i.ncnr.nist.gov/icpdata/recent.php?action=1&instr=bt5"
1060       
1061        Print "Waiting 20s for update..."
1062        Sleep/S 20
1063        Print "Waited 20s, new file should be there."
1064       
1065        //check for path and force user to pick a path
1066        //assume that if bt5PathName has been assigned, so has bt5CurPathName
1067        do
1068                PathInfo bt5PathName
1069                if(V_Flag)
1070                        break
1071                Endif
1072                PickBT5Path()
1073        while(V_Flag==0)
1074       
1075        PathInfo bt5CurPathName
1076        if(V_flag==0)
1077                NewPath/O/M="Select Current Data" bt5CurPathName, getCurrentPath(S_Path)
1078        endif
1079               
1080        //get all the files, then trim the list
1081        String list=IndexedFile(bt5CurPathName,-1,"????")
1082        String newList="",item=""
1083        Variable num=ItemsInList(list,";"),ii
1084        for(ii=0;ii<num;ii+=1)
1085                item = StringFromList(ii, list  ,";")
1086                if( stringmatch(item,"*.bt5*") )                //ONLY keep files with ".bt5" in the name (NOT case-sensitive)
1087                        newlist += item + ";"
1088                endif
1089                //print "ii=",ii
1090        endfor
1091        newList = SortList(newList,";",0)       //get them in order
1092        num=ItemsInList(newlist,";")
1093        Wave/T curWave = $" root:Globals:MainPanel:curWave"
1094        Redimension/N=(num) curWave
1095        curWave=""
1096        curWave = StringFromList(p,newlist,";") //  ! quick and easy assignment of the list
1097        Sort curwave,curwave
1098       
1099End
1100
1101//Reduced version of toSamListButtonProc for putting current data into Sample data
1102Function CurtoSamListButtonProc(ctrlName) : ButtonControl
1103        String ctrlName
1104
1105        Wave/T curWave=$"root:Globals:MainPanel:curWave"
1106        Wave/T samWave=$"root:Globals:MainPanel:samWave"
1107        Wave isCurrent = $"root:Globals:MainPanel:SAMisCurrent"
1108       
1109        Variable num, ii = 0
1110        variable lastPt=numpnts(samWave)
1111       
1112        InsertPoints lastPt,1, samWave
1113        samWave[lastPt]=curwave[ii]
1114        InsertPoints lastPt, 1, isCurrent
1115        isCurrent[lastPt] = 1
1116       
1117        //clean out any (null) elements
1118        num = numpnts(samwave)
1119        for(ii=0;ii<num;ii+=1)
1120                if(cmpstr(samWave[ii],"") ==0)
1121                        DeletePoints ii,1,samWave
1122                        DeletePoints ii,1,isCurrent
1123                        num -= 1
1124                Endif
1125        Endfor
1126       
1127        return(0)
1128End
1129
1130//Reduced version of toEmptyListButtonProc for putting current data into Empty data
1131Function CurtoEmptyListButtonProc(ctrlName) : ButtonControl
1132        String ctrlName
1133
1134        Wave/T curWave=$"root:Globals:MainPanel:curWave"
1135        Wave/T empWave=$"root:Globals:MainPanel:empWave"
1136        Wave isCurrent = $"root:Globals:MainPanel:EMPisCurrent"
1137               
1138        Variable num, ii=0
1139        variable lastPt=numpnts(empWave)
1140
1141        InsertPoints lastPt,1, empWave
1142        empWave[lastPt]=curwave[ii]
1143        InsertPoints lastPt, 1, isCurrent
1144        isCurrent[lastPt] = 1
1145
1146       
1147        //clean out any (null) elements
1148        num=numpnts(empwave)
1149        for(ii=0;ii<num;ii+=1)
1150                if(cmpstr(empWave[ii],"") ==0)
1151                        DeletePoints ii,1,empWave
1152                        DeletePoints ii,1,isCurrent
1153                        num -= 1
1154                Endif
1155        Endfor
1156       
1157       
1158        return(0)
1159End
1160
1161Function UseCurrentDataProc(ctrlName,checked) : CheckBoxControl
1162        String ctrlName
1163        Variable checked
1164       
1165        NVAR isChecked = root:Globals:MainPanel:gUseCurrentData
1166       
1167        if (checked == 1)
1168                DoAlert 1, "Enabling Current Data requires access to the NCNR Network.\rDo you wish to continue?"
1169                if(V_flag == 1)
1170                        ModifyControl/Z CurFileBox, disable=0
1171                        ModifyControl/Z AddCurToSAM, disable=0
1172                        ModifyControl/Z AddCurToEMP, disable=0
1173                        ModifyControl/Z RefreshCurrent,disable=0
1174                        isChecked = 1
1175                endif
1176        else
1177                ModifyControl/Z CurFileBox, disable=1
1178                ModifyControl/Z AddCurToSAM, disable=2
1179                ModifyControl/Z AddCurToEMP, disable=2
1180                ModifyControl/Z RefreshCurrent,disable=2       
1181                isChecked = 0
1182        endif
1183
1184End
1185
1186//Function to get path for Current file
1187Function/S getCurrentPath(inPath)
1188        String inPath
1189       
1190        Variable pos=0,mpos = 0
1191        Variable i = 0,j = 0
1192        // The saga continues...
1193        // Originally used ParseFilePath - not in Igor 4
1194        // Switched to strsearch, but useful searching from end of string not in Igor 4
1195        // Now have ugly loops going through the string, but should work.
1196
1197        for( i = 0;i<4; i+=1)   
1198                do
1199                        pos = strsearch(inPath,":",j)
1200                        if (pos != -1)
1201                                mpos = pos
1202                        endif
1203                        j = pos+1
1204                while (pos !=-1)
1205               
1206                inPath = inPath[0,mpos -1]
1207                pos = 0
1208                mpos = 0
1209                j = 0
1210        endfor
1211       
1212        inPath = inPath + ":current:"
1213
1214        return inPath
1215       
1216End
1217
1218//
1219Function U_OpenTracTicketPage(ctrlName)
1220        String ctrlName
1221        DoAlert 1,"Your web browser will open to a page where you can submit your bug report or feature request. OK?"
1222        if(V_flag==1)
1223                BrowseURL "http://danse.chem.utk.edu/trac/newticket"
1224        endif
1225End
1226
1227
Note: See TracBrowser for help on using the repository browser.