1 | #pragma rtGlobals=1 // Use modern global access method. |
---|
2 | #pragma Version=2.20 |
---|
3 | #pragma IgorVersion=6.1 |
---|
4 | |
---|
5 | #include <HDF5 Browser> |
---|
6 | |
---|
7 | ////////////////////////////////////////////////////////////////////////////////// |
---|
8 | // |
---|
9 | // Write out an NXcanSAS compliant file using all known USANS information |
---|
10 | |
---|
11 | //************************ |
---|
12 | // Vers 1.00 20190603 |
---|
13 | // |
---|
14 | //************************ |
---|
15 | |
---|
16 | // |
---|
17 | Function WriteUSANSNXcanSAS(type,fullpath,lo,hi,dialog) |
---|
18 | |
---|
19 | String type,fullpath |
---|
20 | Variable lo,hi,dialog //=1 will present dialog for name |
---|
21 | |
---|
22 | SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder |
---|
23 | NVAR dQv = root:Packages:NIST:USANS:Globals:MainPanel:gDQv |
---|
24 | |
---|
25 | Variable fileID |
---|
26 | String destStr="" |
---|
27 | destStr = USANSFolder+":"+type |
---|
28 | String dateStr=date()+" "+time() |
---|
29 | |
---|
30 | String parentBase = "/sasentry/" // HDF5 base path for all |
---|
31 | String/G base = "root:NXcanSAS_USANS_file" |
---|
32 | |
---|
33 | KillDataFolder/Z $base |
---|
34 | |
---|
35 | // Define common attribute waves |
---|
36 | Make/T/N=1 empty = {""} |
---|
37 | Make/T/N=1 units = {"units"} |
---|
38 | Make/T/N=1 m = {"m"} |
---|
39 | Make/T/N=1 mm = {"mm"} |
---|
40 | Make/T/N=1 cm = {"cm"} |
---|
41 | Make/T/N=1 angstrom = {"A"} |
---|
42 | Make/T/N=1 inv_cm = {"1/cm"} |
---|
43 | Make/T/N=1 inv_angstrom = {"1/A"} |
---|
44 | |
---|
45 | Variable refNum,integer,realval |
---|
46 | |
---|
47 | //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** |
---|
48 | WAVE qvals =$(destStr + ":Qvals") |
---|
49 | WAVE inten=$(destStr + ":DetCts") |
---|
50 | WAVE sig=$(destStr + ":ErrDetCts") |
---|
51 | |
---|
52 | if(dialog || stringmatch(fullpath, "")) |
---|
53 | fileID = NxCansas_DoSaveFileDialog() |
---|
54 | else |
---|
55 | fileID = NxCansas_CreateFile(fullpath) |
---|
56 | Endif |
---|
57 | |
---|
58 | //check each wave |
---|
59 | If(!(WaveExists(qvals))) |
---|
60 | Abort "qvals DNExist in WriteUSANSWaves()" |
---|
61 | Endif |
---|
62 | If(!(WaveExists(inten))) |
---|
63 | Abort "inten DNExist in WriteUSANSWaves()" |
---|
64 | Endif |
---|
65 | If(!(WaveExists(sig))) |
---|
66 | Abort "sig DNExist in WriteUSANSWaves()" |
---|
67 | Endif |
---|
68 | |
---|
69 | //Use the evil extra column for the resolution "information". Should probably switch to using slit_length in collimation. |
---|
70 | Duplicate/O qvals,dumWave |
---|
71 | dumWave = dQv |
---|
72 | |
---|
73 | Make/N= (numpnts(dumWave)) dQw = 0 |
---|
74 | |
---|
75 | // Run Name and title |
---|
76 | NewDataFolder/O/S $(base + ":entry1") |
---|
77 | Make/T/N=1 $(base + ":entry1:title") = {StringByKey("LABEL",note(inten),":",";")} |
---|
78 | CreateStrNxCansas(fileID,parentBase,"","title",$(base + ":entry1:title"),empty,empty) |
---|
79 | Make/T/N=1 $(base + ":entry1:run") = {""} |
---|
80 | CreateStrNxCansas(fileID,parentBase,"","run",$(base + ":entry1:run"),empty,empty) |
---|
81 | |
---|
82 | // SASData |
---|
83 | String dataParent = parentBase + "sasdata/" |
---|
84 | // Create SASdata entry |
---|
85 | String dataBase = base + ":entry1:sasdata" |
---|
86 | NewDataFolder/O/S $(dataBase) |
---|
87 | Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices", "timestamp"} |
---|
88 | Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q","NXdata","0",dateStr} |
---|
89 | CreateStrNxCansas(fileID,dataParent,"","",empty,$(dataBase + ":attr"),$(dataBase + ":attrVals")) |
---|
90 | // Create q entry |
---|
91 | NewDataFolder/O/S $(dataBase + ":q") |
---|
92 | Make/T/N=2 $(dataBase + ":q:attr") = {"units","resolutions"} |
---|
93 | Make/T/N=2 $(dataBase + ":q:attrVals") = {"1/angstrom","dQl,dQw"} |
---|
94 | CreateVarNxCansas(fileID,dataParent,"sasdata","Q",tq,$(dataBase + ":q:attr"),$(dataBase + ":q:attrVals")) |
---|
95 | // Create i entry |
---|
96 | NewDataFolder/O/S $(dataBase + ":i") |
---|
97 | Make/T/N=2 $(dataBase + ":i:attr") = {"units","uncertainties"} |
---|
98 | Make/T/N=2 $(dataBase + ":i:attrVals") = {"1/cm","Idev"} |
---|
99 | CreateVarNxCansas(fileID,dataParent,"sasdata","I",ti,$(dataBase + ":i:attr"),$(dataBase + ":i:attrVals")) |
---|
100 | // Create idev entry |
---|
101 | CreateVarNxCansas(fileID,dataParent,"sasdata","Idev",te,units,inv_cm) |
---|
102 | // Create qdev entry |
---|
103 | CreateVarNxCansas(fileID,dataParent,"sasdata","dQl",dumWave,units,inv_angstrom) |
---|
104 | CreateVarNxCansas(fileID,dataParent,"sasdata","dQw",dQw,units,inv_angstrom) |
---|
105 | CreateVarNxCansas(fileID,dataParent,"sasdata","Qmean",res2,units,inv_angstrom) |
---|
106 | |
---|
107 | // |
---|
108 | ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
109 | |
---|
110 | ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
111 | // |
---|
112 | // Write USANS meta data |
---|
113 | |
---|
114 | |
---|
115 | //tailor the output given the type of data written out... |
---|
116 | WAVE inten_EMP=$(USANSFolder+":EMP:DetCts") |
---|
117 | String samStr="",empStr="",samLabelStr="",paramStr="",empLevStr="",bkgLevStr="" |
---|
118 | String pkStr="", processNote="" |
---|
119 | NVAR TransWide = $(USANSFolder+":Globals:MainPanel:gTransWide") |
---|
120 | NVAR TransRock = $(USANSFolder+":Globals:MainPanel:gTransRock") |
---|
121 | NVAR empCts = $(USANSFolder+":Globals:MainPanel:gEmpCts") |
---|
122 | NVAR bkgCts = $(USANSFolder+":Globals:MainPanel:gBkgCts") |
---|
123 | NVAR thick = $(USANSFolder+":Globals:MainPanel:gThick") |
---|
124 | |
---|
125 | strswitch(type) |
---|
126 | case "SAM": |
---|
127 | samStr = type +" FILES: "+StringByKey("FILE",note(inten),":",";") |
---|
128 | empStr = "Uncorrected SAM data" |
---|
129 | empLevStr = "Uncorrected SAM data" |
---|
130 | bkgLevStr = "Uncorrected SAM data" |
---|
131 | paramStr = "Uncorrected SAM data" |
---|
132 | pkStr += "SAM PEAK ANGLE: "+num2str(QpkFromNote("SAM")) |
---|
133 | break |
---|
134 | case "EMP": |
---|
135 | samStr = type +" FILES: "+StringByKey("FILE",note(inten),":",";") |
---|
136 | empStr = "Uncorrected EMP data" |
---|
137 | empLevStr = "Uncorrected EMP data" |
---|
138 | bkgLevStr = "Uncorrected EMP data" |
---|
139 | paramStr = "Uncorrected EMP data" |
---|
140 | pkStr += "EMP PEAK ANGLE: "+num2str(QpkFromNote("EMP")) |
---|
141 | break |
---|
142 | default: //"COR" is the default |
---|
143 | samStr = type +" FILES: "+StringByKey("FILE",note(inten),":",";") |
---|
144 | empStr = "EMP FILES: "+StringByKey("FILE",note(inten_EMP),":",";") |
---|
145 | empLevStr = "EMP LEVEL: " + num2str(empCts) |
---|
146 | bkgLevStr = "BKG LEVEL: " + num2str(bkgCts) |
---|
147 | paramStr = "Ds = "+num2str(thick)+" cm ; " |
---|
148 | paramStr += "Twide = "+num2Str(TransWide)+" ; " |
---|
149 | paramStr += "Trock = "+num2str(TransRock) |
---|
150 | pkStr += "SAM PEAK ANGLE: "+num2str(QpkFromNote("SAM")) |
---|
151 | pkStr += " ; EMP PEAK ANGLE: "+num2str(QpkFromNote("EMP")) |
---|
152 | endswitch |
---|
153 | |
---|
154 | processNote = samStr+"\n"+dateStr+"\n"+samLabelStr+"\n"+empStr+"\n"+paramStr+"\n"+pkStr+"\n" |
---|
155 | processNote += empLevStr + " ; "+bkglevStr+"\n" |
---|
156 | |
---|
157 | // SASinstrument |
---|
158 | String instrParent = parentBase + "sasinstrument/" |
---|
159 | // Create SASinstrument entry |
---|
160 | String instrumentBase = base + ":entry1:sasinstrument" |
---|
161 | NewDataFolder/O/S $(instrumentBase) |
---|
162 | Make/O/T/N=5 $(instrumentBase + ":attr") = {"canSAS_class","NX_class"} |
---|
163 | Make/O/T/N=5 $(instrumentBase + ":attrVals") = {"SASinstrument","NXinstrument"} |
---|
164 | CreateStrNxCansas(fileID,instrParent,"","",empty,$(instrumentBase + ":attr"),$(instrumentBase + ":attrVals")) |
---|
165 | |
---|
166 | // SASaperture |
---|
167 | String apertureParent = instrParent + "sasaperture/" |
---|
168 | // Create SASaperture entry |
---|
169 | String apertureBase = instrumentBase + ":sasaperture" |
---|
170 | NewDataFolder/O/S $(apertureBase) |
---|
171 | Make/O/T/N=5 $(apertureBase + ":attr") = {"canSAS_class","NX_class"} |
---|
172 | Make/O/T/N=5 $(apertureBase + ":attrVals") = {"SASaperture","NXaperture"} |
---|
173 | CreateStrNxCansas(fileID,apertureParent,"","",empty,$(apertureBase + ":attr"),$(apertureBase + ":attrVals")) |
---|
174 | |
---|
175 | // Create SASaperture shape entry |
---|
176 | Make/O/T/N=1 $(apertureBase + ":shape") = {"slit"} |
---|
177 | CreateStrNxCansas(fileID,apertureParent,"sasaperture","shape",$(apertureBase + ":shape"),empty,empty) |
---|
178 | // Create SASaperture x_gap entry |
---|
179 | Make/O/N=1 $(apertureBase + ":x_gap") = {0.1} |
---|
180 | CreateVarNxCansas(fileID,apertureParent,"sasaperture","x_gap",$(apertureBase + ":x_gap"),units,cm) |
---|
181 | // Create SASaperture y_gap entry |
---|
182 | Make/O/N=1 $(apertureBase + ":y_gap") = {5.0} |
---|
183 | CreateVarNxCansas(fileID,apertureParent,"sasaperture","y_gap",$(apertureBase + ":y_gap"),units,cm) |
---|
184 | |
---|
185 | // SASdetector |
---|
186 | String detectorParent = instrParent + "sasdetector/" |
---|
187 | // Create SASdetector entry |
---|
188 | String detectorBase = instrumentBase + ":sasdetector" |
---|
189 | NewDataFolder/O/S $(detectorBase) |
---|
190 | Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"} |
---|
191 | Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"} |
---|
192 | CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals")) |
---|
193 | // Create SASdetector name entry |
---|
194 | Make/O/T/N=1 $(detectorBase + ":name") = {"BT5 DETECTOR ARRAY"} |
---|
195 | CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty) |
---|
196 | |
---|
197 | // SASsource |
---|
198 | String sourceParent = instrParent + "sassource/" |
---|
199 | // Create SASdetector entry |
---|
200 | String sourceBase = instrumentBase + ":sassource" |
---|
201 | NewDataFolder/O/S $(sourceBase) |
---|
202 | Make/O/T/N=5 $(sourceBase + ":attr") = {"canSAS_class","NX_class"} |
---|
203 | Make/O/T/N=5 $(sourceBase + ":attrVals") = {"SASsource","NXsource"} |
---|
204 | CreateStrNxCansas(fileID,sourceParent,"","",empty,$(sourceBase + ":attr"),$(sourceBase + ":attrVals")) |
---|
205 | // Create SASsource radiation entry |
---|
206 | Make/O/T/N=1 $(sourceBase + ":radiation") = {"Reactor Neutron Source"} |
---|
207 | CreateStrNxCansas(fileID,sourceParent,"","radiation",$(sourceBase + ":radiation"),empty,empty) |
---|
208 | // Create SASsource incident_wavelength entry |
---|
209 | Make/O/N=1 $(sourceBase + ":incident_wavelength") = {2.38} |
---|
210 | CreateVarNxCansas(fileID,sourceParent,"","incident_wavelength",$(sourceBase + ":incident_wavelength"),units,angstrom) |
---|
211 | // Create SASsource incident_wavelength_spread entry |
---|
212 | Make/O/N=1 $(sourceBase + ":incident_wavelength_spread") = {0.06} |
---|
213 | CreateVarNxCansas(fileID,sourceParent,"","incident_wavelength_spread",$(sourceBase + ":incident_wavelength_spread"),units,angstrom) |
---|
214 | |
---|
215 | // SASsample |
---|
216 | String sampleParent = parentBase + "sassample/" |
---|
217 | // Create SASsample entry |
---|
218 | String sampleBase = base + ":entry1:sassample" |
---|
219 | NewDataFolder/O/S $(sampleBase) |
---|
220 | Make/O/T/N=5 $(sampleBase + ":attr") = {"canSAS_class","NX_class"} |
---|
221 | Make/O/T/N=5 $(sampleBase + ":attrVals") = {"SASsample","NXsample"} |
---|
222 | CreateStrNxCansas(fileID,sampleParent,"","",empty,$(sampleBase + ":attr"),$(sampleBase + ":attrVals")) |
---|
223 | // Create SASsample name entry |
---|
224 | Make/O/T/N=1 $(sampleBase + ":name") = {StringByKey("LABEL",note(inten),":",";")} |
---|
225 | CreateStrNxCansas(fileID,sampleParent,"","name",$(sampleBase + ":name"),empty,empty) |
---|
226 | // Create SASsample thickness entry |
---|
227 | Make/O/N=1 $(sampleBase + ":thickness") = {thick} |
---|
228 | CreateVarNxCansas(fileID,sampleParent,"","thickness",$(sampleBase + ":thickness"),units,cm) |
---|
229 | // Create SASsample transmission entry |
---|
230 | Make/O/N=1 $(sampleBase + ":transmission") = {TransWide} |
---|
231 | CreateVarNxCansas(fileID,sampleParent,"","transmission",$(sampleBase + ":transmission"),empty,empty) |
---|
232 | |
---|
233 | // SASProcess |
---|
234 | String processParent = parentBase + "sasprocess/" |
---|
235 | // Create SASsample entry |
---|
236 | String processBase = base + ":entry1:sasprocess" |
---|
237 | NewDataFolder/O/S $(processBase) |
---|
238 | Make/O/T/N=5 $(processBase + ":attr") = {"canSAS_class","NX_class"} |
---|
239 | Make/O/T/N=5 $(processBase + ":attrVals") = {"SASprocess","NXprocess"} |
---|
240 | CreateStrNxCansas(fileID,processParent,"","",empty,$(processBase + ":attr"),$(processBase + ":attrVals")) |
---|
241 | // Create SASsample name entry |
---|
242 | Make/O/T/N=1 $(processBase + ":name") = {"NIST IGOR"} |
---|
243 | CreateStrNxCansas(fileID,processParent,"","name",$(processBase + ":name"),empty,empty) |
---|
244 | // Create SASsample thickness entry |
---|
245 | Make/O/T/N=1 $(sampleBase + ":note") = {processNote} |
---|
246 | CreateVarNxCansas(fileID,processParent,"","note",$(processBase + ":note"),units,cm) |
---|
247 | |
---|
248 | //write confirmation of write operation to history area |
---|
249 | Print "Averaged XML File written: ", GetFileNameFromPathNoSemi(fullPath) |
---|
250 | KillWaves/Z dumWave |
---|
251 | |
---|
252 | // Close the file |
---|
253 | if(fileID) |
---|
254 | HDF5CloseFile /Z fileID |
---|
255 | endif |
---|
256 | |
---|
257 | End |
---|
258 | |
---|
259 | |
---|
260 | Function WriteNXcanSASUSANSDesmeared(fullpath,lo,hi,dialog) |
---|
261 | |
---|
262 | String fullpath |
---|
263 | Variable lo,hi,dialog //=1 will present dialog for name |
---|
264 | |
---|
265 | SVAR USANSFolder = root:Packages:NIST:USANS:Globals:gUSANSFolder |
---|
266 | NVAR dQv = root:Packages:NIST:USANS:Globals:MainPanel:gDQv |
---|
267 | |
---|
268 | Variable fileID |
---|
269 | String destStr="" |
---|
270 | destStr = USANSFolder+":Smeared" |
---|
271 | String dateStr=date()+" "+time() |
---|
272 | |
---|
273 | String parentBase = "/sasentry/" // HDF5 base path for all |
---|
274 | String/G base = "root:NXcanSAS_USANS_file" |
---|
275 | |
---|
276 | KillDataFolder/Z $base |
---|
277 | |
---|
278 | // Define common attribute waves |
---|
279 | Make/T/N=1 empty = {""} |
---|
280 | Make/T/N=1 units = {"units"} |
---|
281 | Make/T/N=1 m = {"m"} |
---|
282 | Make/T/N=1 mm = {"mm"} |
---|
283 | Make/T/N=1 cm = {"cm"} |
---|
284 | Make/T/N=1 angstrom = {"A"} |
---|
285 | Make/T/N=1 inv_cm = {"1/cm"} |
---|
286 | Make/T/N=1 inv_angstrom = {"1/A"} |
---|
287 | |
---|
288 | Variable refNum,integer,realval |
---|
289 | |
---|
290 | //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** |
---|
291 | WAVE qvals =$(destStr + "Q_dsm") |
---|
292 | WAVE inten=$(destStr + "I_dsm") |
---|
293 | WAVE sig=$(destStr + "S_dsm") |
---|
294 | |
---|
295 | if(dialog || stringmatch(fullpath, "")) |
---|
296 | fileID = NxCansas_DoSaveFileDialog() |
---|
297 | else |
---|
298 | fileID = NxCansas_CreateFile(fullpath) |
---|
299 | Endif |
---|
300 | |
---|
301 | //check each wave |
---|
302 | If(!(WaveExists(qvals))) |
---|
303 | Abort "qvals DNExist in WriteUSANSWaves()" |
---|
304 | Endif |
---|
305 | If(!(WaveExists(inten))) |
---|
306 | Abort "inten DNExist in WriteUSANSWaves()" |
---|
307 | Endif |
---|
308 | If(!(WaveExists(sig))) |
---|
309 | Abort "sig DNExist in WriteUSANSWaves()" |
---|
310 | Endif |
---|
311 | |
---|
312 | //Use the evil extra column for the resolution "information". Should probably switch to using slit_length in collimation. |
---|
313 | //write out partial set? |
---|
314 | Duplicate/O qvals,tq,ti,te |
---|
315 | ti=inten |
---|
316 | te=sig |
---|
317 | if( (lo!=hi) && (lo<hi)) |
---|
318 | redimension/N=(hi-lo+1) tq,ti,te,res1,res2,res3 //lo to hi, inclusive |
---|
319 | tq=qvals[p+lo] |
---|
320 | ti=inten[p+lo] |
---|
321 | te=sig[p+lo] |
---|
322 | endif |
---|
323 | |
---|
324 | Make/N= (numpnts(dumWave)) dQw = 0 |
---|
325 | |
---|
326 | // Run Name and title |
---|
327 | NewDataFolder/O/S $(base + ":entry1") |
---|
328 | Make/T/N=1 $(base + ":entry1:title") = {StringByKey("LABEL",note(inten),":",";")} |
---|
329 | CreateStrNxCansas(fileID,parentBase,"","title",$(base + ":entry1:title"),empty,empty) |
---|
330 | Make/T/N=1 $(base + ":entry1:run") = {""} |
---|
331 | CreateStrNxCansas(fileID,parentBase,"","run",$(base + ":entry1:run"),empty,empty) |
---|
332 | |
---|
333 | // SASData |
---|
334 | String dataParent = parentBase + "sasdata/" |
---|
335 | // Create SASdata entry |
---|
336 | String dataBase = base + ":entry1:sasdata" |
---|
337 | NewDataFolder/O/S $(dataBase) |
---|
338 | Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices", "timestamp"} |
---|
339 | Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q","NXdata","0",dateStr} |
---|
340 | CreateStrNxCansas(fileID,dataParent,"","",empty,$(dataBase + ":attr"),$(dataBase + ":attrVals")) |
---|
341 | // Create q entry |
---|
342 | NewDataFolder/O/S $(dataBase + ":q") |
---|
343 | Make/T/N=2 $(dataBase + ":q:attr") = {"units","resolutions"} |
---|
344 | Make/T/N=2 $(dataBase + ":q:attrVals") = {"1/angstrom","dQ"} |
---|
345 | CreateVarNxCansas(fileID,dataParent,"sasdata","Q",tq,$(dataBase + ":q:attr"),$(dataBase + ":q:attrVals")) |
---|
346 | // Create i entry |
---|
347 | NewDataFolder/O/S $(dataBase + ":i") |
---|
348 | Make/T/N=2 $(dataBase + ":i:attr") = {"units","uncertainties"} |
---|
349 | Make/T/N=2 $(dataBase + ":i:attrVals") = {"1/cm","Idev"} |
---|
350 | CreateVarNxCansas(fileID,dataParent,"sasdata","I",ti,$(dataBase + ":i:attr"),$(dataBase + ":i:attrVals")) |
---|
351 | // Create idev entry |
---|
352 | CreateVarNxCansas(fileID,dataParent,"sasdata","Idev",te,units,inv_cm) |
---|
353 | // Create qdev entry |
---|
354 | CreateVarNxCansas(fileID,dataParent,"sasdata","dQl",dumWave,units,inv_angstrom) |
---|
355 | CreateVarNxCansas(fileID,dataParent,"sasdata","dQw",res1,units,inv_angstrom) |
---|
356 | CreateVarNxCansas(fileID,dataParent,"sasdata","Qmean",res2,units,inv_angstrom) |
---|
357 | |
---|
358 | // |
---|
359 | ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
360 | |
---|
361 | ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
362 | // |
---|
363 | // Write USANS meta data |
---|
364 | |
---|
365 | |
---|
366 | //tailor the output given the type of data written out... |
---|
367 | WAVE inten_EMP=$(USANSFolder+":EMP:DetCts") |
---|
368 | String samStr="",empStr="",samLabelStr="",paramStr="",empLevStr="",bkgLevStr="" |
---|
369 | String pkStr="", processNote="" |
---|
370 | NVAR TransWide = $(USANSFolder+":Globals:MainPanel:gTransWide") |
---|
371 | NVAR TransRock = $(USANSFolder+":Globals:MainPanel:gTransRock") |
---|
372 | NVAR empCts = $(USANSFolder+":Globals:MainPanel:gEmpCts") |
---|
373 | NVAR bkgCts = $(USANSFolder+":Globals:MainPanel:gBkgCts") |
---|
374 | NVAR thick = $(USANSFolder+":Globals:MainPanel:gThick") |
---|
375 | |
---|
376 | samStr = "SMEARED FILES: "+StringByKey("FILE",note(inten),":",";") |
---|
377 | empStr = "EMP FILES: "+StringByKey("FILE",note(inten_EMP),":",";") |
---|
378 | empLevStr = "EMP LEVEL: " + num2str(empCts) |
---|
379 | bkgLevStr = "BKG LEVEL: " + num2str(bkgCts) |
---|
380 | paramStr = "Ds = "+num2str(thick)+" cm ; " |
---|
381 | paramStr += "Twide = "+num2Str(TransWide)+" ; " |
---|
382 | paramStr += "Trock = "+num2str(TransRock) |
---|
383 | pkStr += "SAM PEAK ANGLE: "+num2str(QpkFromNote("SAM")) |
---|
384 | pkStr += " ; EMP PEAK ANGLE: "+num2str(QpkFromNote("EMP")) |
---|
385 | |
---|
386 | processNote = samStr+"\n"+dateStr+"\n"+samLabelStr+"\n"+empStr+"\n"+paramStr+"\n"+pkStr+"\n" |
---|
387 | processNote += empLevStr + " ; "+bkglevStr+"\n" |
---|
388 | |
---|
389 | // SASinstrument |
---|
390 | String instrParent = parentBase + "sasinstrument/" |
---|
391 | // Create SASinstrument entry |
---|
392 | String instrumentBase = base + ":entry1:sasinstrument" |
---|
393 | NewDataFolder/O/S $(instrumentBase) |
---|
394 | Make/O/T/N=5 $(instrumentBase + ":attr") = {"canSAS_class","NX_class"} |
---|
395 | Make/O/T/N=5 $(instrumentBase + ":attrVals") = {"SASinstrument","NXinstrument"} |
---|
396 | CreateStrNxCansas(fileID,instrParent,"","",empty,$(instrumentBase + ":attr"),$(instrumentBase + ":attrVals")) |
---|
397 | |
---|
398 | // SASaperture |
---|
399 | String apertureParent = instrParent + "sasaperture/" |
---|
400 | // Create SASaperture entry |
---|
401 | String apertureBase = instrumentBase + ":sasaperture" |
---|
402 | NewDataFolder/O/S $(apertureBase) |
---|
403 | Make/O/T/N=5 $(apertureBase + ":attr") = {"canSAS_class","NX_class"} |
---|
404 | Make/O/T/N=5 $(apertureBase + ":attrVals") = {"SASaperture","NXaperture"} |
---|
405 | CreateStrNxCansas(fileID,apertureParent,"","",empty,$(apertureBase + ":attr"),$(apertureBase + ":attrVals")) |
---|
406 | |
---|
407 | // Create SASaperture shape entry |
---|
408 | Make/O/T/N=1 $(apertureBase + ":shape") = {"slit"} |
---|
409 | CreateStrNxCansas(fileID,apertureParent,"sasaperture","shape",$(apertureBase + ":shape"),empty,empty) |
---|
410 | // Create SASaperture x_gap entry |
---|
411 | Make/O/N=1 $(apertureBase + ":x_gap") = {0.1} |
---|
412 | CreateVarNxCansas(fileID,apertureParent,"sasaperture","x_gap",$(apertureBase + ":x_gap"),units,cm) |
---|
413 | // Create SASaperture y_gap entry |
---|
414 | Make/O/N=1 $(apertureBase + ":y_gap") = {5.0} |
---|
415 | CreateVarNxCansas(fileID,apertureParent,"sasaperture","y_gap",$(apertureBase + ":y_gap"),units,cm) |
---|
416 | |
---|
417 | // SASdetector |
---|
418 | String detectorParent = instrParent + "sasdetector/" |
---|
419 | // Create SASdetector entry |
---|
420 | String detectorBase = instrumentBase + ":sasdetector" |
---|
421 | NewDataFolder/O/S $(detectorBase) |
---|
422 | Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"} |
---|
423 | Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"} |
---|
424 | CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals")) |
---|
425 | // Create SASdetector name entry |
---|
426 | Make/O/T/N=1 $(detectorBase + ":name") = {"BT5 DETECTOR ARRAY"} |
---|
427 | CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty) |
---|
428 | |
---|
429 | // SASsource |
---|
430 | String sourceParent = instrParent + "sassource/" |
---|
431 | // Create SASdetector entry |
---|
432 | String sourceBase = instrumentBase + ":sassource" |
---|
433 | NewDataFolder/O/S $(sourceBase) |
---|
434 | Make/O/T/N=5 $(sourceBase + ":attr") = {"canSAS_class","NX_class"} |
---|
435 | Make/O/T/N=5 $(sourceBase + ":attrVals") = {"SASsource","NXsource"} |
---|
436 | CreateStrNxCansas(fileID,sourceParent,"","",empty,$(sourceBase + ":attr"),$(sourceBase + ":attrVals")) |
---|
437 | // Create SASsource radiation entry |
---|
438 | Make/O/T/N=1 $(sourceBase + ":radiation") = {"Reactor Neutron Source"} |
---|
439 | CreateStrNxCansas(fileID,sourceParent,"","radiation",$(sourceBase + ":radiation"),empty,empty) |
---|
440 | // Create SASsource incident_wavelength entry |
---|
441 | Make/O/N=1 $(sourceBase + ":incident_wavelength") = {2.38} |
---|
442 | CreateVarNxCansas(fileID,sourceParent,"","incident_wavelength",$(sourceBase + ":incident_wavelength"),units,angstrom) |
---|
443 | // Create SASsource incident_wavelength_spread entry |
---|
444 | Make/O/N=1 $(sourceBase + ":incident_wavelength_spread") = {0.06} |
---|
445 | CreateVarNxCansas(fileID,sourceParent,"","incident_wavelength_spread",$(sourceBase + ":incident_wavelength_spread"),units,angstrom) |
---|
446 | |
---|
447 | // SASsample |
---|
448 | String sampleParent = parentBase + "sassample/" |
---|
449 | // Create SASsample entry |
---|
450 | String sampleBase = base + ":entry1:sassample" |
---|
451 | NewDataFolder/O/S $(sampleBase) |
---|
452 | Make/O/T/N=5 $(sampleBase + ":attr") = {"canSAS_class","NX_class"} |
---|
453 | Make/O/T/N=5 $(sampleBase + ":attrVals") = {"SASsample","NXsample"} |
---|
454 | CreateStrNxCansas(fileID,sampleParent,"","",empty,$(sampleBase + ":attr"),$(sampleBase + ":attrVals")) |
---|
455 | // Create SASsample name entry |
---|
456 | Make/O/T/N=1 $(sampleBase + ":name") = {StringByKey("LABEL",note(inten),":",";")} |
---|
457 | CreateStrNxCansas(fileID,sampleParent,"","name",$(sampleBase + ":name"),empty,empty) |
---|
458 | // Create SASsample thickness entry |
---|
459 | Make/O/N=1 $(sampleBase + ":thickness") = {thick} |
---|
460 | CreateVarNxCansas(fileID,sampleParent,"","thickness",$(sampleBase + ":thickness"),units,cm) |
---|
461 | // Create SASsample transmission entry |
---|
462 | Make/O/N=1 $(sampleBase + ":transmission") = {TransWide} |
---|
463 | CreateVarNxCansas(fileID,sampleParent,"","transmission",$(sampleBase + ":transmission"),empty,empty) |
---|
464 | |
---|
465 | // SASProcess |
---|
466 | String processParent = parentBase + "sasprocess/" |
---|
467 | // Create SASsample entry |
---|
468 | String processBase = base + ":entry1:sasprocess" |
---|
469 | NewDataFolder/O/S $(processBase) |
---|
470 | Make/O/T/N=5 $(processBase + ":attr") = {"canSAS_class","NX_class"} |
---|
471 | Make/O/T/N=5 $(processBase + ":attrVals") = {"SASprocess","NXprocess"} |
---|
472 | CreateStrNxCansas(fileID,processParent,"","",empty,$(processBase + ":attr"),$(processBase + ":attrVals")) |
---|
473 | // Create SASsample name entry |
---|
474 | Make/O/T/N=1 $(processBase + ":name") = {"NIST IGOR"} |
---|
475 | CreateStrNxCansas(fileID,processParent,"","name",$(processBase + ":name"),empty,empty) |
---|
476 | // Create SASsample thickness entry |
---|
477 | Make/O/T/N=1 $(sampleBase + ":note") = {processNote} |
---|
478 | CreateVarNxCansas(fileID,processParent,"","note",$(processBase + ":note"),units,cm) |
---|
479 | |
---|
480 | //write confirmation of write operation to history area |
---|
481 | Print "Averaged XML File written: ", GetFileNameFromPathNoSemi(fullPath) |
---|
482 | KillWaves/Z dumWave |
---|
483 | |
---|
484 | // Close the file |
---|
485 | if(fileID) |
---|
486 | HDF5CloseFile /Z fileID |
---|
487 | endif |
---|
488 | |
---|
489 | End |
---|