source: sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_ShowDataTree.ipf @ 1074

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

adding procedures for:

simple save of a DIV file. no functionality to generate a DIV file yet, since I don't know how this will happen.

Simple dump of the file structure in a data "tree"

Verified that the error bars on the I(q) data are correctly calculated as standard error of the mean. There was never an issue with this, or with SANS calculations.

Started filling in "Correct" routines based on the SANS version. Only stubs present currently.

File size: 3.8 KB
RevLine 
[1019]1#pragma TextEncoding = "MacRoman"
2#pragma rtGlobals=3             // Use modern global access method and strict wave access.
3
4
5//
6// This is a copy (wtih slight modifications) of the DataFolderTree_SRK.ipf file
7// which itself is from Igor Exchange (see below)
8//
9// it is modified to look for VSANS files, and ignore the DAS_log folder if possible
10// since it's not part of the file I'm concerned with during reduction.
11//
12//
13
14////////
15// see the help entry for IndexedDir for help on (possibly) how to do this faster
16// -- see the function Function ScanDirectories(pathName, printDirNames)
17//
18
19
20// from IgorExchange On July 17th, 2011 jtigor
21// started from "Recursively List Data Folder Contents"
22// Posted July 15th, 2011 by hrodstein
23
24Proc V_ShowDataFolderTree(dataFolderStr, level, sNBName)
25//      String dataFolderStr="root:"
26        String dataFolderStr="root:Packages:NIST:VSANS:RawVSANS:"
27        Variable level=0
28        String sNBName="DataFolderTree"
29       
30        V_ListDataFolder($dataFolderStr, level, sNBName)
31
32
33end
34
35// ListDataFolder(dfr, level)
36// Recursively lists objects in data folder.
37// Pass data folder path for dfr and 0 for level.
38// Example: ListDataFolder(root:, 0, "NoteBook")
39//Start with sNBName = "" to print to history
40Function V_ListDataFolder(dfr, level, sNBName)
41        DFREF dfr
42        Variable level                  // Pass 0 to start
43        String sNBName
44 
45        String name
46        String sString
47 
48        if (level == 0)
49                name = GetDataFolder(1, dfr)
50                sPrintf sString, "%s (data folder)\r", name
51                V_WriteBrowserInfo(sString, 1, sNBName)
52        endif
53 
54        Variable i
55 
56        String indentStr = "\t"
57        for(i=0; i<level; i+=1)
58                indentStr += "\t"
59        endfor
60 
61        Variable numWaves = CountObjectsDFR(dfr, 1)
62        for(i=0; i<numWaves; i+=1)
63                name = GetIndexedObjNameDFR(dfr, 1, i)
64//              Print "wave type = ",WaveType(dfr:$name,1)              //1=numeric, 2=text
65                if(WaveType(dfr:$name,1) == 1)
66                        WAVE w=dfr:$name
67                        if(numpnts(w) > 0)              //the Igor_Folder_Attributes wave has zero points, catch the error
68//                              sPrintf sString, "%s%s (wave) %g\ttyp=%g\r", indentStr, name, w[0], WaveType(w)
69                                sPrintf sString, "%s%s   \t%g\r", indentStr, name, w[0]
70                        else
71                                sPrintf sString, "%s%s (wave)\r", indentStr, name
72                        endif
73                else
74                        WAVE/T wt=dfr:$name             // text wave is assumed...
75//                      sPrintf sString, "%s%s (wave) \"%s\"\ttyp=text\r", indentStr, name, wt[0]
76                        sPrintf sString, "%s%s   \t\"%s\"\r", indentStr, name, wt[0]
77                endif
78                V_WriteBrowserInfo(sString, 2, sNBName)
79        endfor 
80 
81        Variable numNumericVariables = CountObjectsDFR(dfr, 2) 
82        for(i=0; i<numNumericVariables; i+=1)
83                name = GetIndexedObjNameDFR(dfr, 2, i)
84                sPrintf sString, "%s%s (numeric variable)\r", indentStr, name
85                V_WriteBrowserInfo(sString, 3, sNBName)
86        endfor 
87 
88        Variable numStringVariables = CountObjectsDFR(dfr, 3)   
89        for(i=0; i<numStringVariables; i+=1)
90                name = GetIndexedObjNameDFR(dfr, 3, i)
91                sPrintf sString, "%s%s (string variable)\r", indentStr, name
92                V_WriteBrowserInfo(sString, 4, sNBName)
93        endfor 
94 
95        Variable numDataFolders = CountObjectsDFR(dfr, 4)       
96        for(i=0; i<numDataFolders; i+=1)
97                name = GetIndexedObjNameDFR(dfr, 4, i)
98                if(cmpstr(name,"DAS_logs") != 0)                //ignore DAS_log folder
99                        sPrintf sString, "%s%s (data folder)\r", indentStr, name
100                        V_WriteBrowserInfo(sString, 1, sNBName)
101                        DFREF childDFR = dfr:$(name)
102                        V_ListDataFolder(childDFR, level+1, sNBName)
103                endif
104        endfor 
105 
106//when finished walking tree, save as RTF with dialog   
107        if(level == 0 && strlen(sNBName) != 0)
108                SaveNotebook /I /S=4  $sNBName
109        endif
110End
111 
112Function V_WriteBrowserInfo(sString, vType, sNBName)
113        String sString
114        Variable vType
115        String sNBName
116 
117        if(strlen(sNBName) == 0)
118                print sString
119                return 0
120        endif
121        DoWindow $sNBName
122        if(V_flag != 1)
123                NewNoteBook/F=1 /N=$sNBName /V=1 as sNBName
124        else
125                DoWindow/F $sNBName
126        endif
127        Notebook $sNBName selection={endOfFile, endOfFile}
128        if(vType == 1)//wave
129                Notebook $sNBName fstyle=1
130                Notebook $sNBName text=sString
131                Notebook $sNBName fstyle=-1
132        else
133                Notebook $sNBName text=sString 
134        endif
135 
136End
137
Note: See TracBrowser for help on using the repository browser.