source: sans/Dev/trunk/NCNR_User_Procedures/Common/Packages/PlotManager/PlotManager_v40.ipf @ 1022

Last change on this file since 1022 was 1022, checked in by srkline, 6 years ago

ADDED:

included common NCNR procedures for the PlotManager?, to allow plotting of 1D data sets using a familiar interface

greatly expanded Patch functionality to include input in the multiple sections of the Nexus file, including separate panels to handle patching of waves to the file - needed for non-linear coefficients, dead time, and XY beam centers. All patch operations are expandable as more fields become necessary to patch.

removed bug of group_id being defined in /reduction and in /sample (removed R/W that referenced /reduction)

added panel to "isolate" a single detector panel, allowing the corrections to be applied/removed/recalculated as needed to directly see their effects.

linked new procedures to their appropriate action buttons

Added more data fields (label, intent, etc.) to the VCALC to Nexus data writer to get more realistic values into the fake data files for testing

Added VCALC simulation functions with EMP and BGD in anticipation of testing the CORRECT step

more little bug and documentation fixes which I can't remember, but they are all important...

File size: 10.1 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma version=4.00
3#pragma IgorVersion=6.1
4
5
6//////////////////////////////////////////
7//
8// Plot manager that is largely based on the plot manager in the Reduction package
9//
10// "A_" is crudely prepended to function names to avoid conflicts
11//
12// -- data folders will sitll overlap, but should not be an issue
13//
14// 28SEP07 SRK
15//
16//////////////////////////////////////////
17Proc Show_Plot_Manager()
18        A_Init_OneDLoader()
19        DoWindow/F Plot_Manager
20        if(V_flag==0)
21                A_Plot_Manager()
22        endif
23        A_OneDLoader_GetListButton("")
24End
25
26Window A_Plot_Manager()
27        PauseUpdate; Silent 1           // building window...
28        NewPanel /W=(658,347,1018,737)/N=Plot_Manager/K=2 as "Plot Manager"
29        ModifyPanel cbRGB=(37265,65535,32896)
30        ModifyPanel fixedSize=1
31       
32        Button button0,pos={165,353},size={50,20},proc=A_PlotManager_Done,title="Done"
33        PopupMenu popup0,pos={15,225},size={233,20},title="Data in Memory"
34        PopupMenu popup0,mode=1,value= #"A_OneDDataInMemory()"
35        Button button2,pos={122,259},size={100,20},proc=A_PlotManager_Append,title="Append Data"
36        Button button3,pos={15,259},size={80,20},proc=A_PlotManager_newGraph,title="New Graph"
37        Button button4,pos={15,293},size={220,20},proc=A_PlotManager_Kill,title="Remove Selection From Memory"
38        Button button5,pos={15,323},size={220,20},proc=A_PlotManager_KillAll,title="Remove All Data From Memory"
39        ListBox fileList,pos={13,11},size={206,179}
40        ListBox fileList,listWave=root:Packages:NIST:OneDLoader:fileWave
41        ListBox fileList,selWave=root:Packages:NIST:OneDLoader:selWave,mode= 4
42        Button button6,pos={238,165},size={100,20},proc=A_OneDLoader_LoadButton,title="Load File(s)"
43        Button button6,help={"Loads the selected files into memory and will graph them if that option is checked"}
44        Button button7,pos={238,20},size={100,20},proc=A_OneDLoader_NewFolderButton,title="New Folder"
45        Button button7,help={"Select a new data folder"}
46        Checkbox check0,pos={240,190},title="Plot data on loading?",noproc,value=1
47        GroupBox group0,pos={222,127},size={50,4},title="Shift-click to load"
48        GroupBox group0_1,pos={222,143},size={50,4},title="multiple files"
49        GroupBox group1,pos={7,207},size={350,4}
50        Button button8,pos={238,76},size={100,20},proc=A_OneDLoader_HelpButton,title="Help"
51        Button button9,pos={238,48},size={100,20},proc=A_PlotManager_Refresh,title="Refresh List"
52EndMacro
53
54//open the Help file for the Fit Manager
55Function A_OneDLoader_HelpButton(ba) : ButtonControl
56        STRUCT WMButtonAction &ba
57
58        switch( ba.eventCode )
59                case 2: // mouse up
60                        // click code here
61                        DisplayHelpTopic/K=1/Z "Plot Manager"
62                        if(V_flag !=0)
63                                DoAlert 0,"The Plot Manager Help file could not be found"
64                        endif
65                        break
66        endswitch
67
68        return 0
69End
70
71//uses the same data folder listing as the wrapper
72// if it's right there, it's right here
73Function/S A_OneDDataInMemory()
74        //AJJ Oct 2008
75        //To make this general for both analysis and reduction this code must be a duplicate
76        //W_DataPopupList rather than a call to it as IGOR doesn't like assignment to function
77        //that doesn't exists even if you've done a if(exists... to check first.
78        //Grrr
79        String list = GetAList(4)
80        if (strlen(list) == 0)
81                list = "No data loaded"
82        endif
83        list = SortList(list)
84       
85        return(list)
86end
87
88
89Function A_PlotManager_Done(ctrlName) : ButtonControl
90        String ctrlName
91        DoWindow/K Plot_Manager
92End
93
94Function A_PlotManager_Append(ctrlName) : ButtonControl
95        String ctrlName
96        //appends data set from memory
97       
98        //get the current selection
99        ControlInfo popup0
100        if(strlen(S_Value)==0 || cmpstr(S_Value,"No data loaded")==0)
101                Abort "You must load data from a file into memory before appending the data"
102        Endif
103       
104        A_PM_doAppend(S_Value)
105       
106        DoWindow/F Plot_Manager
107End
108
109//actually does the appending
110//pass it the name of the wave, find the q-i-s waves
111Function A_PM_doAppend(DF)
112        String DF
113        //appends data set from memory
114        String qStr,eStr,istr
115        Variable rr,gg,bb
116       
117        if(cmpstr(WinList("*", ";","WIN:1"),"") == 0 )
118                DoAlert 0,"There are no open graphs. Please use the New Graph button"
119                return(0)
120        endif
121       
122        SetDataFolder $("root:"+DF)
123        //iStr will end in "i"
124        qStr = DF+"_q"
125        eStr = DF+"_s"
126        iStr = DF+"_i"
127       
128        rr = abs(trunc(enoise(65535)))
129        gg = abs(trunc(enoise(65535)))
130        bb = abs(trunc(enoise(65535)))
131       
132        // append to whatever is top-most graph
133        AppendToGraph $iStr vs $qStr
134        ModifyGraph log=1,mode($istr)=3,marker($iStr)=19,msize($iStr)=2,rgb($iStr)=(rr,gg,bb)
135        ErrorBars/T=0 $iStr Y,wave=($eStr,$eStr)
136
137        SetDataFolder root:
138End
139
140Proc A_PlotManager_newGraph(ctrlName) : ButtonControl
141        String ctrlName
142       
143        //get the current selection
144        ControlInfo popup0
145        if(strlen(S_Value)==0 || cmpstr(S_Value,"No data loaded")==0)
146                Abort "You must load data from a file into memory before plotting the data"
147        Endif
148       
149        A_PM_doNewGraph(S_Value)
150        DoWindow/F Plot_Manager
151End
152
153Function A_PM_doNewGraph(DF)
154        String DF
155
156        String qStr,eStr,iStr
157        Variable rr,gg,bb
158       
159        SVAR/Z angst = root:Packages:NIST:gAngstStr
160       
161        SetDataFolder $("root:"+DF)
162        //iStr will end in "i"
163        qStr = DF+"_q"
164        eStr = DF+"_s"
165        iStr = DF+"_i"
166       
167        rr = abs(trunc(enoise(65535)))
168        gg = abs(trunc(enoise(65535)))
169        bb = abs(trunc(enoise(65535)))
170       
171        // always make a new graph
172        Display $iStr vs $qStr
173        ModifyGraph log=1,mode($istr)=3,marker($iStr)=19,msize($iStr)=2,rgb=(rr,gg,bb)
174        ModifyGraph grid=1,mirror=2,standoff=0
175        ErrorBars/T=0 $iStr Y,wave=($eStr,$eStr)
176        ModifyGraph tickUnit=1
177                               
178        Label left "I(q)"
179//      Label bottom "q (A\\S-1\\M)"
180        Label bottom "q ("+angst+"\\S-1\\M)"   
181        Legend
182       
183        SetDataFolder root:
184End
185
186//kill the specified wave (if possible)
187Proc A_PlotManager_Kill(ctrlName) : ButtonControl
188        String ctrlName
189       
190        String savDF=GetDataFolder(1)
191        String DF
192
193        ControlInfo popup0
194        DF=S_Value              //this will end in "i"
195
196        SetDataFolder DF
197        KillVariables/A                 //removes the dependent variables
198        SetDataFolder savDF
199               
200        //now kill the data folder
201        KillDataFolder/Z $DF
202        ControlUpdate popup0            //refresh the popup, very important if last item removed
203End
204
205//kill the specified wave (if possible)
206Proc A_PlotManager_KillAll(ctrlName) : ButtonControl
207        String ctrlName
208       
209        String savDF=GetDataFolder(1)
210        String DF
211
212        String list =  A_OneDDataInMemory()
213        Variable num=ItemsInList(list),ii
214       
215        ii=0
216        do     
217                DF=StringFromList(ii, list  ,";")
218               
219                SetDataFolder DF
220                KillVariables/A                 //removes the dependent variables first
221                SetDataFolder savDF
222       
223                //now kill the data folder
224                KillDataFolder/Z $DF
225                ii+=1
226        while(ii<num)
227        ControlUpdate popup0            //refresh the popup, very important if all items are removed
228End
229
230Proc A_Init_OneDLoader()
231        //create the data folder
232        NewDataFolder/O/S root:Packages:NIST:OneDLoader
233        //create the waves
234        Make/O/T/N=1 fileWave=""
235        Make/O/N=1 selWave=0
236        Variable/G ind=0
237        SetDataFolder root:
238End
239
240
241//prompt for a new path, and get a new listing
242Function A_OneDLoader_NewFolderButton(ctrlName) : ButtonControl
243        String ctrlName
244
245        A_PickPath()
246        A_OneDLoader_GetListButton("")
247        return(0)
248End
249
250//refresh the listing
251Function A_PlotManager_Refresh(ctrlName) : ButtonControl
252        String ctrlName
253
254        A_OneDLoader_GetListButton("")
255        return(0)
256End
257
258//filters to remove only the files that are named like a raw data file, i.e. "*.SAn"
259//does not check to see if they really are RAW files though...(too tedious)
260Function A_OneDLoader_GetListButton(ctrlName) : ButtonControl
261        String ctrlName
262       
263        //make sure that path exists
264        PathInfo catPathName
265        if (V_flag == 0)
266                Abort "Folder path does not exist - use \"New Folder\" button on Main Panel"
267        Endif
268       
269        String newList = A_ReducedDataFileList("")
270        Variable num
271       
272        num=ItemsInList(newlist,";")
273        WAVE/T fileWave=$"root:Packages:NIST:OneDLoader:fileWave"
274        WAVE selWave=$"root:Packages:NIST:OneDLoader:selWave"
275        Redimension/N=(num) fileWave
276        Redimension/N=(num) selWave
277        fileWave = StringFromList(p,newlist,";")
278        Sort filewave,filewave
279End
280
281Function A_OneDLoader_LoadButton(ctrlName) : ButtonControl
282        String ctrlName
283       
284        //loop through the selected files in the list...
285        Wave/T fileWave=$"root:Packages:NIST:OneDLoader:fileWave"
286        Wave sel=$"root:Packages:NIST:OneDLoader:selWave"
287        Variable num=numpnts(sel),ii=0
288        String fname="",pathStr="",fullPath="",newFileName=""
289       
290        PathInfo catPathName                    //this is where the files are
291        pathStr=S_path
292       
293        Variable doGraph,cnt
294
295        ControlInfo check0
296        doGraph=V_Value
297        cnt=0
298        // get the current state
299        do
300                if(sel[ii] == 1)
301                        fname=pathStr + fileWave[ii]
302                        Execute "A_LoadOneDDataWithName(\""+fname+"\","+num2str(doGraph)+")"
303                        cnt += 1        //a file was loaded
304                endif
305                ii+=1
306        while(ii<num)
307
308        ControlUpdate/W=Plot_Manager popup0
309
310        return(0)
311End
312
313
314//function called by the popups to get a file list of data that can be sorted
315// this procedure simply removes the raw data files from the string - there
316//can be lots of other junk present, but this is very fast...
317//
318// could also use the alternate procedure of keeping only file with the proper extension
319//
320// another possibility is to get a listing of the text files, but is unreliable on
321// Windows, where the data file must be .txt (and possibly OSX)
322//
323// TODO: this is a duplicated procedure. See the equivalent in NCNR_Utils and which one to keep?
324Function/S A_ReducedDataFileList(ctrlName)
325        String ctrlName
326
327        String list="",newList="",item=""
328        Variable num,ii
329       
330        //check for the path
331        PathInfo catPathName
332        if(V_Flag==0)
333                DoAlert 0, "Data path does not exist - pick the data path from the button on the main panel"
334                Return("")
335        Endif
336       
337        list = IndexedFile(catpathName,-1,"????")
338       
339        list = RemoveFromList(ListMatch(list,"*.SA1*",";"), list, ";", 0)
340        list = RemoveFromList(ListMatch(list,"*.SA2*",";"), list, ";", 0)
341        list = RemoveFromList(ListMatch(list,"*.SA3*",";"), list, ";", 0)
342        list = RemoveFromList(ListMatch(list,"*.SA4*",";"), list, ";", 0)               // added JAN 2013 for new guide hall
343        list = RemoveFromList(ListMatch(list,"*.SA5*",";"), list, ";", 0)
344        list = RemoveFromList(ListMatch(list,".*",";"), list, ";", 0)
345        list = RemoveFromList(ListMatch(list,"*.pxp",";"), list, ";", 0)
346        list = RemoveFromList(ListMatch(list,"*.DIV",";"), list, ";", 0)
347        list = RemoveFromList(ListMatch(list,"*.GSP",";"), list, ";", 0)
348        list = RemoveFromList(ListMatch(list,"*.MASK",";"), list, ";", 0)
349#if(exists("QUOKKA") == 6)
350        list = RemoveFromList(ListMatch(list,"*.nx.hdf",";"), list, ";", 0)     
351        list = RemoveFromList(ListMatch(list,"*.bin",";"), list, ";", 0)       
352#endif
353       
354
355        //sort
356        newList = SortList(List,";",0)
357
358        return newlist
359End
Note: See TracBrowser for help on using the repository browser.