source: sans/Dev/trunk/NCNR_Igor_Procedures/NCNR_Package_Loader.ipf @ 884

Last change on this file since 884 was 884, checked in by srkline, 10 years ago

Added the binning of QxQy? data to 1D as a menu option under SANSModels->2D utilities. Mostly as a consistency check for the 2D data.

Added a package loader for the Event Mode Processing to the NCNR package loader, so that it behaves like the real spaces modeling and the polarization.

Added routines that split large event files, and then allow the accumulation of the slices from each chunk as it is processed. Eliminates the need to add a large number of split files together during the reduction.

File size: 13.7 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion=6.2
3
4// load/unload courtesy of Jan Ilavsky
5// June 2008
6
7// - SRK Oct 2008
8// rather than deleting the macros, it is preferable to simply hide the appropriate panels.
9// deleting the ipf files will break dependencies, leave panels hanging open without
10// their associated procedures, etc.
11
12// names of everything have been changed so I won't clash with Jan's code
13//
14//
15// - make this an independent module in case of bad compilation...
16
17
18Menu "Macros"
19        StrVarOrDefault("root:Packages:NCNRItemStr1a","Load NCNR Analysis Macros"), NCNR_AnalysisLoader(StrVarOrDefault("root:Packages:NCNRItemStr1a","Load NCNR Analysis Macros"))
20        StrVarOrDefault("root:Packages:NCNRItemStr1b","-"), NCNR_AnalysisLoader(StrVarOrDefault("root:Packages:NCNRItemStr1b","-"))
21
22        StrVarOrDefault("root:Packages:NCNRItemStr2a","Load NCNR SANS Reduction Macros"), NCNR_SANSReductionLoader(StrVarOrDefault("root:Packages:NCNRItemStr2a","Load NCNR SANS Reduction Macros"))
23        StrVarOrDefault("root:Packages:NCNRItemStr2b","-"), NCNR_SANSReductionLoader(StrVarOrDefault("root:Packages:NCNRItemStr2b","-"))
24
25        StrVarOrDefault("root:Packages:NCNRItemStr3a","Load NCNR USANS Reduction Macros"), NCNR_USANSReductionLoader(StrVarOrDefault("root:Packages:NCNRItemStr3a","Load NCNR USANS Reduction Macros"))
26        StrVarOrDefault("root:Packages:NCNRItemStr3b","-"), NCNR_USANSReductionLoader(StrVarOrDefault("root:Packages:NCNRItemStr3b","-"))
27       
28        StrVarOrDefault("root:Packages:NCNRItemStr4a","Load NCNR SANS Live Data"), NCNR_SANSLiveLoader(StrVarOrDefault("root:Packages:NCNRItemStr4a","Load NCNR SANS Live Data"))
29        StrVarOrDefault("root:Packages:NCNRItemStr4b","-"), NCNR_SANSLiveLoader(StrVarOrDefault("root:Packages:NCNRItemStr4b","-"))
30
31        // for testing ONLY
32        "-"
33        "Load Polarization Reduction - Beta",PolarizationLoader()
34
35//      "Load Batch Fitting",Execute/P "INSERTINCLUDE \"Auto_Fit\"";Execute/P "COMPILEPROCEDURES ";Execute/P "InitializeAutoFitPanel()"
36
37        "Load Real Space Modeling - Beta",RealSpaceLoader()
38        "Event Mode Processing - Beta",EventModeLoader()
39        "-"
40
41end
42
43Function NCNR_AnalysisLoader(itemStr)
44        String itemStr
45               
46        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.2)
47                Abort "Your version of Igor is lower than 6.2, these macros need version 6.2 or higher.... "
48        endif
49       
50        NewDataFolder/O root:Packages           //create the folder for string variable
51        String/G root:Packages:NCNRItemStr1a = itemStr
52        String/G root:Packages:NCNRItemStr1b = itemStr
53        SVAR gMenuStr1a = root:Packages:NCNRItemStr1a
54        SVAR gMenuStr1b = root:Packages:NCNRItemStr1b
55       
56        String SANSAna_WinList = "wrapperPanel;Procedure_List;Report;Plot_Manager;A_FitPanel;A_FitWindow;Sum_Model_Panel;"
57        SANSAna_WinList += "NewGlobalFitPanel;SimpGFPanel;Invariant_Panel;invariant_graph;"
58        strswitch(itemStr)      // string switch
59                case "Load NCNR Analysis Macros":       
60                        Execute/P "INSERTINCLUDE \"SA_Includes_v410\""
61                        Execute/P "INSERTINCLUDE \"PlotUtilsMacro_v40\""
62                        Execute/P "INSERTINCLUDE \"GaussUtils_v40\""
63                        Execute/P "INSERTINCLUDE \"WriteModelData_v40\""
64                        Execute/P "INSERTINCLUDE \"USANS_SlitSmearing_v40\""
65                        Execute/P "INSERTINCLUDE \"SANSModelPicker_v40\""
66                        Execute/P "COMPILEPROCEDURES "
67                        Execute/P ("Init_WrapperPanel()")
68                        Execute/P ("ModelPicker_Panel()")
69                        Execute/P ("DoIgorMenu \"Control\" \"Retrieve All Windows\"")
70               
71                        gMenuStr1a = "Hide NCNR Analysis Macros"
72//                      gMenuStr1b = "Unload NCNR Analysis Macros"
73                        gMenuStr1b = "-"
74                        BuildMenu "Macros"
75                       
76                        break                                           
77                case "Unload NCNR Analysis Macros":     
78                // very dangerous - don't really want to implement this because it will surely crash
79                        Execute/P "DELETEINCLUDE \"SA_Includes_v410\""
80                        Execute/P "DELETEINCLUDE \"PlotUtilsMacro_v40\""
81                        Execute/P "DELETEINCLUDE \"GaussUtils_v40\""
82                        Execute/P "DELETEINCLUDE \"WriteModelData_v40\""
83                        Execute/P "DELETEINCLUDE \"USANS_SlitSmearing_v40\""
84                        Execute/P "DELETEINCLUDE \"SANSModelPicker_v40\""
85                        Execute/P "COMPILEPROCEDURES "
86                        DoWindow wrapperPanel
87                        if(V_Flag)
88                                DoWindow/K wrapperPanel
89                        endif
90                        DoWindow Procedure_List
91                        If(V_Flag)
92                                DoWindow/K Procedure_List
93                        endif
94
95                        gMenuStr1a = "Load NCNR Analysis Macros"
96                        gMenuStr1b = "-"
97                       
98                        BuildMenu "Macros"
99                       
100                        break
101                case "Hide NCNR Analysis Macros":       
102                        HideShowWindowsInList(SANSAna_WinList,1)       
103               
104                        gMenuStr1a = "Show NCNR Analysis Macros"
105//                      gMenuStr1b = "Unload NCNR Analysis Macros"
106                        gMenuStr1b = "-"
107                        BuildMenu "Macros"
108                       
109                        break
110                case "Show NCNR Analysis Macros":
111                        HideShowWindowsInList(SANSAna_WinList,0)       
112               
113                        gMenuStr1a = "Hide NCNR Analysis Macros"
114//                      gMenuStr1b = "Unload NCNR Analysis Macros"
115                        gMenuStr1b = "-"
116                        BuildMenu "Macros"
117                       
118                        break
119                default:
120                        Abort "Invalid Menu Selection"
121        endswitch
122
123end
124
125
126// now add for the SANS Reduction
127Function NCNR_SANSReductionLoader(itemStr)
128        String itemStr
129       
130        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.2)
131                Abort "Your version of Igor is lower than 6.2, these macros need version 6.2 or higher.... "
132        endif
133       
134        NewDataFolder/O root:Packages           //create the folder for string variable
135        String/G root:Packages:NCNRItemStr2a = itemStr
136        String/G root:Packages:NCNRItemStr2b = itemStr
137        SVAR gMenuStr2a = root:Packages:NCNRItemStr2a
138        SVAR gMenuStr2b = root:Packages:NCNRItemStr2b
139       
140        String SANSRed_WinList = "Main_Panel;CatVSTable;SANS_Data;Plot_Manager;Average_Panel;Plot_1d;CatWin;Surface_3D;FitPanel;FitWindow;"
141        SANSRed_WinList += "FitRPAPanel;SANS_Histo;drawMaskWin;Multiple_Reduce_Panel;NSORT_Panel;NSORT_Graph;CombineTable;ToCombine;Patch_Panel;"
142        SANSRed_WinList += "ProtocolPanel;Schematic_Layout;Tile_2D;RAW_to_ASCII;Trans_Panel;TransFileTable;ScatterFileTable;Convert_to_Trans;"
143        SANSRed_WinList += "WorkFileMath;Pref_Panel;Subtract_1D_Panel;Plot_Sub1D;SASCALC;MC_SASCALC;Saved_Configurations;TISANE;Sim_1D_Panel;"
144        SANSRed_WinList += "Trial_Configuration;Saved_Configurations;DataArithmeticPanel;DAPlotPanel;"
145        strswitch(itemStr)      // string switch
146                case "Load NCNR SANS Reduction Macros":
147                        Execute/P "INSERTINCLUDE \"Includes_v520\""
148                        Execute/P "COMPILEPROCEDURES "
149                        Execute/P ("Initialize()")
150                        Execute/P ("DoIgorMenu \"Control\" \"Retrieve All Windows\"")
151
152                        gMenuStr2a = "Hide NCNR SANS Reduction Macros"
153//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
154                        gMenuStr2b = "-"
155                        BuildMenu "Macros"
156                       
157                        break                                           
158                case "Unload NCNR SANS Reduction Macros":       
159                // very dangerous - don't really want to implement this because it will surely crash
160                        Execute/P "DELETEINCLUDE \"Includes_v520\""
161                        Execute/P "COMPILEPROCEDURES "
162                        DoWindow Main_Panel
163                        if(V_Flag)
164                                DoWindow/K Main_Panel
165                        endif
166
167                        gMenuStr2a = "Load NCNR SANS Reduction Macros"
168                        gMenuStr2b = "-"
169                       
170                        BuildMenu "Macros"
171                       
172                        break
173                case "Hide NCNR SANS Reduction Macros":
174                        HideShowWindowsInList(SANSRed_WinList,1)
175               
176                        gMenuStr2a = "Show NCNR SANS Reduction Macros"
177//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
178                        gMenuStr2b = "-"
179                        BuildMenu "Macros"
180                       
181                        break
182                case "Show NCNR SANS Reduction Macros":
183                        HideShowWindowsInList(SANSRed_WinList,0)
184               
185                        gMenuStr2a = "Hide NCNR SANS Reduction Macros"
186//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
187                        gMenuStr2b = "-"
188                        BuildMenu "Macros"
189                       
190                        break
191                default:
192                        Abort "Invalid Menu Selection"
193        endswitch
194
195end
196
197// now add for the SANS Reduction
198Function NCNR_USANSReductionLoader(itemStr)
199        String itemStr
200       
201        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.2)
202                Abort "Your version of Igor is lower than 6.2, these macros need version 6.2 or higher.... "
203        endif
204       
205        NewDataFolder/O root:Packages           //create the folder for string variable
206        String/G root:Packages:NCNRItemStr3a = itemStr
207        String/G root:Packages:NCNRItemStr3b = itemStr
208        SVAR gMenuStr3a = root:Packages:NCNRItemStr3a
209        SVAR gMenuStr3b = root:Packages:NCNRItemStr3b
210       
211        String USANS_WinList = "USANS_Panel;COR_Graph;RawDataWin;Desmear_Graph;USANS_Slope;UCALC;"
212       
213        strswitch(itemStr)      // string switch
214                case "Load NCNR USANS Reduction Macros":       
215                        Execute/P "INSERTINCLUDE \"USANS_Includes_v230\""
216                        Execute/P "COMPILEPROCEDURES "
217                        Execute/P ("ShowUSANSPanel()")
218                        Execute/P ("DoIgorMenu \"Control\" \"Retrieve All Windows\"")
219
220                        gMenuStr3a = "Hide NCNR USANS Reduction Macros"
221//                      gMenuStr3b = "Unload NCNR USANS Reduction Macros"
222                        gMenuStr3b = "-"
223                        BuildMenu "Macros"
224                       
225                        break                                           
226                case "Unload NCNR USANS Reduction Macros":     
227                // very dangerous - don't really want to implement this because it will surely crash
228                        Execute/P "DELETEINCLUDE \"USANS_Includes_v230\""
229                        Execute/P "COMPILEPROCEDURES "
230                        DoWindow USANS_Panel
231                        if(V_Flag)
232                                DoWindow/K USANS_Panel
233                        endif
234
235                        gMenuStr3a = "Load NCNR USANS Reduction Macros"
236                        gMenuStr3b = "-"
237                       
238                        BuildMenu "Macros"
239                       
240                        break
241                case "Hide NCNR USANS Reduction Macros":       
242                        HideShowWindowsInList(USANS_WinList,1) 
243               
244                        gMenuStr3a = "Show NCNR USANS Reduction Macros"
245//                      gMenuStr3b = "Unload NCNR USANS Reduction Macros"
246                        gMenuStr3b = "-"
247                        BuildMenu "Macros"
248                       
249                        break
250                case "Show NCNR USANS Reduction Macros":
251                        HideShowWindowsInList(USANS_WinList,0) 
252                       
253                        gMenuStr3a = "Hide NCNR USANS Reduction Macros"
254//                      gMenuStr3b = "Unload NCNR USANS Reduction Macros"
255                        gMenuStr3b = "-"
256                        BuildMenu "Macros"
257                       
258                        break
259                default:
260                        Abort "Invalid Menu Selection"
261        endswitch
262       
263end
264
265// 1 = hide, 0 = show
266Function HideShowWindowsInList(list,hide)
267        String list
268        Variable hide
269       
270        String item
271        Variable ii,num=ItemsinList(list)
272        for(ii=0;ii<num;ii+=1)
273                item = StringFromList(ii, list , ";")
274                DoWindow $item
275                if(V_Flag)
276                        DoWindow/HIDE=(hide) $item
277                endif
278        endfor
279        return(0)
280End
281
282// now add for the SANS Live
283Function NCNR_SANSLiveLoader(itemStr)
284        String itemStr
285       
286        if (str2num(stringByKey("IGORVERS",IgorInfo(0))) < 6.2)
287                Abort "Your version of Igor is lower than 6.2, these macros need version 6.2 or higher.... "
288        endif
289       
290        NewDataFolder/O root:Packages           //create the folder for string variable
291        String/G root:Packages:NCNRItemStr4a = itemStr
292        String/G root:Packages:NCNRItemStr4b = itemStr
293        SVAR gMenuStr4a = root:Packages:NCNRItemStr4a
294        SVAR gMenuStr4b = root:Packages:NCNRItemStr4b
295       
296        String SANSLive_WinList = "RT_Panel;SANS_Data;"
297        //SANSLive_WinList += "FitRPAPanel;SANS_Histo;drawMaskWin;Multiple_Reduce_Panel;NSORT_Panel;NSORT_Graph;CombineTable;ToCombine;Patch_Panel;"
298        //SANSLive_WinList += "ProtocolPanel;Schematic_Layout;Tile_2D;RAW_to_ASCII;Trans_Panel;TransFileTable;ScatterFileTable;Convert_to_Trans;"
299        //SANSLive_WinList += "WorkFileMath;Pref_Panel;Subtract_1D_Panel;Plot_Sub1D;SASCALC;MC_SASCALC;Saved_Configurations;TISANE;"
300        strswitch(itemStr)      // string switch
301                case "Load NCNR SANS Live Data":       
302                        Execute/P "INSERTINCLUDE \"Includes_v520\""
303                        Execute/P "COMPILEPROCEDURES "
304                        Execute/P ("Init_for_RealTime()")
305               
306                        gMenuStr4a = "Hide NCNR SANS Live Data"
307//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
308                        gMenuStr4b = "-"
309                        BuildMenu "Macros"
310                       
311                        break                                           
312                case "Unload NCNR SANS Live Data":     
313                // very dangerous - don't really want to implement this because it will surely crash
314                        Execute/P "DELETEINCLUDE \"Includes_v520\""
315                        Execute/P "COMPILEPROCEDURES "
316                        DoWindow Main_Panel
317                        if(V_Flag)
318                                DoWindow/K Main_Panel
319                        endif
320
321                        gMenuStr4a = "Load NCNR SANS Live Data"
322                        gMenuStr4b = "-"
323                       
324                        BuildMenu "Macros"
325                       
326                        break
327                case "Hide NCNR SANS Live Data":
328                        HideShowWindowsInList(SANSLive_WinList,1)
329               
330                        gMenuStr4a = "Show NCNR SANS Reduction Macros"
331//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
332                        gMenuStr4b = "-"
333                        BuildMenu "Macros"
334                       
335                        break
336                case "Show NCNR SANS Reduction Macros":
337                        HideShowWindowsInList(SANSLive_WinList,0)
338               
339                        gMenuStr4a = "Hide NCNR SANS Reduction Macros"
340//                      gMenuStr2b = "Unload NCNR SANS Reduction Macros"
341                        gMenuStr4b = "-"
342                        BuildMenu "Macros"
343                       
344                        break
345                default:
346                        Abort "Invalid Menu Selection"
347        endswitch
348
349end
350
351Function WhatSymbolsAreDefined()
352
353#if (exists("QUOKKA")==6)
354                print "function QUOKKA defined"
355#else
356                print "function QUOKKA NOT defined"
357#endif
358       
359#if(exists("HFIR")==6)
360                print "function HFIR defined"
361#else
362                print "function HFIR NOT defined"
363#endif
364       
365#if(exists("ILL_D22")==6)
366                print "function ILL_D22 defined"
367#else
368                print "function ILL_D22 NOT defined"
369#endif
370
371
372
373// for a lot of reasons, defined symbols do not work
374// mostly, the procedures are compiled before the symbols are
375// defined (or re-defined)
376// another issues is that they are persistent, and  don't disappear
377// until Igor is quit.
378       
379//      SetIgorOption poundDefine=QUOKKA?
380//      if(V_flag)
381//              print "QUOKKA defined"
382//      else
383//              print "QUOKKA NOT defined"
384//      endif
385//     
386//      SetIgorOption poundDefine=HFIR?
387//      if(V_flag)
388//              print "HFIR defined"
389//      else
390//              print "HFIR NOT defined"
391//      endif
392//     
393//      SetIgorOption poundDefine=ILL_D22?
394//      if(V_flag)
395//              print "ILL_D22 defined"
396//      else
397//              print "ILL_D22 NOT defined"
398//      endif
399
400        return(0)
401End
402
403Proc ClearDefinedSymbols()
404        SetIgorOption poundUnDefine=QUOKKA
405        SetIgorOption poundUnDefine=HFIR
406        SetIgorOption poundUnDefine=ILL_D22
407End
408
409Function PolarizationLoader()
410
411        // be sure that the SANS reduction is loaded and compiles
412        NCNR_SANSReductionLoader("Load NCNR SANS Reduction Macros")
413       
414        // then the polarization
415        Execute/P "INSERTINCLUDE \"Include_Polarization\"";Execute/P "COMPILEPROCEDURES "
416        BuildMenu "Macros"
417
418        return(0)
419End
420
421// loads all of the FFT procedures and the fit functions too
422Function RealSpaceLoader()
423
424        // be sure that the SANS Analysis is loaded and compiles
425        NCNR_AnalysisLoader("Load NCNR Analysis Macros")
426       
427        // then the FFT files
428        Execute/P "INSERTINCLUDE \"FFT_Cubes_Includes\""
429        Execute/P "INSERTINCLUDE \"FFT_Fit_Includes\""
430        Execute/P "COMPILEPROCEDURES "
431        Execute/P "Init_FFT()"
432       
433        BuildMenu "Macros"
434
435        return(0)
436End
437
438Function EventModeLoader()
439
440        // be sure that the SANS reduction is loaded and compiles
441        NCNR_SANSReductionLoader("Load NCNR SANS Reduction Macros")
442       
443        // then bring up the Event Mode panel
444        Execute/P "Show_Event_Panel()"
445//      BuildMenu "Macros"
446
447        return(0)
448End
Note: See TracBrowser for help on using the repository browser.