Debian Codegraph @

bindings/idl/recursivesearch.pro

raw
1 functiorecursivesearch, filepath
2 ;new_dlm_file = '/home/scratch/lns/kauppila/temp/IDLNeXus-API/NeXusIDL-API.dlm'
3 ;DLM_REGISTER, new_dlm_file
4
5 ; S = nxopen("data/nx.hdf","NXACC_READ",fileid)
6 ; S = nxopen("data/dmc01.h5","NXACC_READ",fileid)
7 ; S = nxopen("data/dmc01.hdf","NXACC_READ",fileid)
8 ; S = nxopen("data/dmc01.xml","NXACC_READ",fileid)
9 ; S = nxopen("data/dmc02.h5","NXACC_READ",fileid)
10 ; S = nxopen("data/dmc02.hdf","NXACC_READ",fileid)
11 ; S = nxopen("data/dmc02.xml","NXACC_READ",fileid)
12 ; S = nxopen("data/NXtest.nxs","NXACC_READ",fileid)
13 ; S = nxopen("data/NXtest.hdf","NXACC_READ",fileid)
14 ; S = nxopen("NXtest.nxs","NXACC_READ",fileid)
15 ; S = nxopen("C:\temp\dlm\dlm\NXtest.nxs","NXACC_READ",fileid)
16 ; S = nxopen("C:\temp\dlm\dlm\data\dmc01.h5","NXACC_READ",fileid)
17
18 if(N_PARAMS() EQ 1) then begin
19 S = nxopen(filepath,"NXACC_READ",fileid)
20
21 paths = strarr(20)
22
23 endif else begin
24 print, 'Reading default file NXtest.h5'
25 ;S = nxopen("NXtest.h5","NXACC_READ",fileid)
26 S = nxopen("data/dmc02.h5","NXACC_READ",fileid)
27
28 endelse
29
30 print, 'nxopen status: ',S
31 print, ''
32
33 common cblock, testpaths
34 common cblock2, numberofsignals
35
36 numberofsignals = 0
37 testpaths = strarr(20)
38
39 opendir, fileid, paths
40
41 ; Read global attributes
42
43 S = nxgetattrinfo(fileid, numberofattr)
44 ; print, 'nxgetattrinfo status:',S
45 print, 'number of global attributes: ', numberofattr
46
47 S= nxinitattrdir (fileid)
48 ; print, 'nxinitattrdir', S
49 ; print, ''
50
51 for j = 1, numberofattr, 1 do begin
52 S = nxgetnextattr(fileid, attrname, lenght,attr_type)
53 print, 'global attribute name: ', attrname
54 print, 'global attrubute lenght: ', lenght
55 print, 'global attribute type: ', attr_type
56
57 S = nxgetattr(fileid, attrname, value, lenght,attr_type)
58 ;print, 'global attribute name: ', attrname
59 ;print, 'global attrubute lenght: ', lenght
60 ;print, 'global attribute type: ', attr_type
61 print, 'global attribute value: ', value
62 print, ''
63
64 endfor
65
66 S = nxclose(fileid)
67 ; print, 'nxclose status: ', S
68
69 print, 'signal 1 found in paths: '
70
71 print, testpaths[0]
72 print, testpaths[1]
73
74 RETURN, testpaths
75 end
76
77 pro opendir, fileid, paths
78
79 common cblock
80 common cblock2
81
82 S = nxgetgroupinfo(fileid, item_number, group_name, group_class)
83 ;print, 'nxgetgroupinfo status', S
84 print, 'current group name: ', group_name
85 ;print, 'current group class: ', group_class
86 print, 'number of items in group', item_number
87 print, ''
88
89 for j = 1, item_number, 1 do begin
90
91 S = nxgetnextentry(fileid, name, class, data_type)
92 print, 'nxgetnextentry status: ', S
93 if(S EQ 1) then begin
94 print, 'nxgetnextentry name: ', name
95 ;print, 'nxgetnextentry class: ', class
96 ;print, 'nxgetnextentry data_type', data_type
97 print, ''
98 if (strcmp(class, 'SDS')) then begin
99
100 print, 'opening data: ', name
101 S = nxopendata(fileid, name)
102 ;print, 'nxopendata status:', S
103 ;print, ''
104 if(S EQ 1) then begin
105
106 result = opendata(fileid)
107
108 if(result EQ 1) then begin
109 print, 'SIGNAL 1 FOUND'
110 testpaths[numberofsignals] = '/' + group_name + '/'+ name
111 print, 'SIGNAL 1 FOUND in : ', testpaths[1]
112 numberofsignals = numberofsignals + 1
113 endif
114
115 endif
116
117
118 S = nxclosedata(fileid)
119 ;print, 'nxclosedata status', S
120 ;print, ''
121
122 endif else begin
123
124 S = nxopengroup(fileid, name, class)
125 ;print, 'nxopengroup status', S
126 ;print, ''
127 if(S EQ 1) then begin
128 opendir, fileid, paths
129 endif
130
131 S = nxclosegroup(fileid)
132 ;print, 'nxclosegroup status', S
133 ;print, ''
134
135 endelse
136 endif
137 endfor
138
139 end
140
141 function opendata, fileid
142
143 S = nxgetdata(fileid, data)
144 ;print, 'nxgetdata status: ', S
145 ;print, 'data :'
146 ;print, data
147 ;print, ''
148 S = nxgetattrinfo(fileid, numberofattr)
149 ;print, 'nxgetattrinfo status:',S
150 print, 'number of attributes: ', numberofattr
151
152 ;S= nxinitattrdir (fileid)
153 ;print, 'nxinitattrdir', S
154 ;print, ''
155
156 for j = 1, numberofattr, 1 do begin
157 S = nxgetnextattr(fileid, attrname, lenght,attr_type)
158 if(S EQ 1) then begin
159 ;print, 'attribute name: ', attrname
160 ;print, 'attrubute lenght: ', lenght
161 ;print, 'attribute type: ', attr_type
162
163 S = nxgetattr(fileid, attrname, value, lenght,attr_type)
164 ;print, 'attribute name: ', attrname
165 ;print, 'attrubute lenght: ', lenght
166 ;print, 'attribute type: ', attr_type
167 print, 'attribute value: ', value
168 print, ''
169 if((strcmp(attrname, 'signal')) AND (strcmp(string(value), '1'))) then begin
170 RETURN, 1
171 endif
172 endif
173 endfor
174 RETURN, 0
175 end