source: sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Reduction/VSANS/V_Write_VSANS_NXcanSAS.ipf @ 1189

Last change on this file since 1189 was 1189, checked in by krzywon, 3 years ago

Incorporate suggested changes for cleaner separation of VSANS, USANS, and SANS reduction methods. Plus fixes.

File size: 39.4 KB
Line 
1#pragma TextEncoding = "MacRoman"
2#pragma rtGlobals=3             // Use modern global access method and strict wave access.
3
4
5Function V_WriteNXcanSAS1DData(pathStr,folderStr,saveName)
6        String pathStr,folderStr,saveName
7       
8        // Define local function variables
9        String formatStr=""
10        String destStr="", parentBase, nxcansasBase
11        Variable fileID
12        Variable refnum,dialog=0
13        String/G base = "root:V_NXcanSAS_file"
14       
15        NewDataFolder/O/S $(base)
16       
17        // Check fullpath and dialog
18        fileID = NXcanSAS_OpenOrCreate(dialog,saveName,base)
19        SetDataFolder $(pathStr+folderStr)
20       
21        Variable sasentry = NumVarOrDefault("root:Packages:NIST:gSASEntryNumber", 1)
22        sPrintf parentBase,"%s:sasentry%d",base,sasentry // Igor memory base path for all
23        sPrintf nxcansasBase,"/sasentry%d/",sasentry // HDF5 base path for all
24
25        Wave qw = tmp_q
26        Wave iw = tmp_i
27        Wave sw = tmp_s
28        Wave sigQ = tmp_sq
29        Wave qbar = tmp_qb
30        Wave fs = tmp_fs
31       
32        SVAR gProtoStr = root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr
33        Wave/T proto=$("root:Packages:NIST:VSANS:Globals:Protocols:"+gProtoStr)
34       
35        //make sure the waves exist
36        if(WaveExists(qw) == 0)
37                Abort "q is missing"
38        endif
39        if(WaveExists(iw) == 0)
40                Abort "i is missing"
41        endif
42        if(WaveExists(sw) == 0)
43                Abort "s is missing"
44        endif
45        if(WaveExists(sigQ) == 0)
46                Abort "Resolution information is missing."
47        endif
48        if(WaveExists(proto) == 0)
49                Abort "protocol information is missing."
50        endif
51       
52        ///////////////////////////////////////////////////////////////////////////
53        // Write all data
54       
55        // Define common attribute waves
56        Make/T/O/N=1 empty = {""}
57        Make/T/O/N=1 units = {"units"}
58        Make/T/O/N=1 inv_cm = {"1/cm"}
59        Make/T/O/N=1 inv_angstrom = {"1/A"}
60       
61        // Run Name and title
62        NewDataFolder/O/S $(parentBase)
63        Make/O/T/N=1 $(parentBase + ":title") = {V_getSampleDescription(folderStr)}
64        CreateStrNxCansas(fileID,nxcansasBase,"","title",$(parentBase + ":title"),empty,empty)
65        Make/O/T/N=1 $(parentBase + ":run") = {V_getExperiment_identifier(folderStr)}
66        CreateStrNxCansas(fileID,nxcansasBase,"","run",$(parentBase + ":run"),empty,empty)
67       
68        // SASData
69        String dataParent = nxcansasBase + "sasdata/"
70        // Create SASdata entry
71        String dataBase = parentBase + ":sasdata"
72        NewDataFolder/O/S $(dataBase)
73        Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices", "timestamp"}
74        Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q","NXdata","0",V_getDataEndTime(folderStr)}
75        CreateStrNxCansas(fileID,dataParent,"","",empty,$(dataBase + ":attr"),$(dataBase + ":attrVals"))
76        // Create qx and qy entry
77        NewDataFolder/O/S $(dataBase + ":q")
78        Make/O/T/N=2 $(dataBase + ":q:attr") = {"units","resolutions"}
79        Make/O/T/N=2 $(dataBase + ":q:attrVals") = {"1/angstrom","Qdev"}
80        CreateVarNxCansas(fileID,dataParent,"sasdata","Q",qw,$(dataBase + ":q:attr"),$(dataBase + ":q:attrVals"))
81        // Create i entry
82        NewDataFolder/O/S $(dataBase + ":i")
83        Make/O/T/N=2 $(dataBase + ":i:attr") = {"units","uncertainties"}
84        Make/O/T/N=2 $(dataBase + ":i:attrVals") = {"1/cm","Idev"}
85        CreateVarNxCansas(fileID,dataParent,"sasdata","I",iw,$(dataBase + ":i:attr"),$(dataBase + ":i:attrVals"))
86        // Create idev entry
87        CreateVarNxCansas(fileID,dataParent,"sasdata","Idev",sw,units,inv_cm)
88        // Create qdev entry
89        CreateVarNxCansas(fileID,dataParent,"sasdata","Qdev",sigQ,units,inv_angstrom)
90        CreateVarNxCansas(fileID,dataParent,"sasdata","Qmean",qbar,units,inv_angstrom)
91       
92        // Write all VSANS meta data
93        V_WriteMetaData(fileID,parentBase,nxcansasBase,folderStr,proto)
94               
95        //
96        ///////////////////////////////////////////////////////////////////////////
97       
98        // Close the file
99        if(fileID)
100                HDF5CloseFile /Z fileID
101        endif
102       
103        KillDataFolder/Z $base
104       
105End
106
107//
108//////////////////////////////////////////////////////////////////////////////////////////////////
109
110
111///////// QxQy Export  //////////
112//
113// (see the similar-named SANS routine for additonal steps - like resolution, etc.)
114// NXcanSAS output using the latest standard
115//
116//      July 2019 -- first version
117//
118//
119// TODO:
120// -- resolution is not generated here (and it shouldn't be) since resolution is not known yet.
121// -- The final writer will need to be aware of resolution, and there may be different forms
122//
123Function V_WriteNXcanSAS2DData(folderStr,pathStr,saveName,dialog)
124        String pathStr,folderStr,saveName
125        Variable dialog         //=1 will present dialog for name
126       
127        // Define local function variables
128        String formatStr="",detStr="",detSavePath
129        String destStr="",parentBase,nxcansasBase
130        String type=folderStr
131       
132        Variable fileID
133        String/G base = "root:V_NXcanSAS_file"
134       
135        NewDataFolder/O/S $(base)
136        SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr)
137       
138        // Check fullpath and dialog
139        fileID = NXcanSAS_OpenOrCreate(dialog,pathStr,base)
140               
141        Variable sasentry = NumVarOrDefault("root:Packages:NIST:gSASEntryNumber", 1)
142        sPrintf parentBase,"%s:sasentry%d",base,sasentry // Igor memory base path for all
143        sPrintf nxcansasBase,"/sasentry%d/",sasentry // HDF5 base path for all
144       
145        // declare, or make a fake protocol if needed (if the export type is RAW)
146        SVAR gProtoStr = root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr
147        String rawTag=""
148        if(cmpstr(folderStr,"RAW")==0)
149                Make/O/T/N=(kNumProtocolSteps) proto
150                RawTag = "RAW Data File: "     
151        else
152                Wave/T proto=$("root:Packages:NIST:VSANS:Globals:Protocols:"+gProtoStr)
153        endif
154       
155        SVAR samFiles = $("root:Packages:NIST:VSANS:"+folderStr+":gFileList")
156       
157        ///////////////////////////////////////////////////////////////////////////
158        // Write all data
159       
160        // Define common attribute waves
161        Make/O/T/N=1 empty = {""}
162        Make/O/T/N=1 units = {"units"}
163        Make/O/T/N=1 inv_cm = {"1/cm"}
164        Make/O/T/N=1 inv_angstrom = {"1/A"}
165       
166        // Run Name and title
167        NewDataFolder/O/S $(parentBase)
168       
169        Make/O/T/N=1 $(parentBase + ":title") = {V_getSampleDescription(folderStr)}
170        CreateStrNxCansas(fileID,nxcansasBase,"","title",$(parentBase + ":title"),empty,empty)
171        Make/O/T/N=1 $(parentBase + ":run") = {V_getExperiment_identifier(folderStr)}
172        CreateStrNxCansas(fileID,nxcansasBase,"","run",$(parentBase + ":run"),empty,empty)
173
174        // data values to populate the file header
175        String fileName,fileDate,fileLabel
176        Variable monCt,lambda,offset,dist,trans,thick
177        Variable bCentX,bCentY,a2,a1a2_dist,deltaLam,bstop
178        String a1Str
179        Variable pixX,pixY
180        Variable numTextLines,ii,jj,kk
181        Variable pixSizeX,pixSizeY
182        Variable duration
183
184        numTextLines = 30
185        Make/O/T/N=(numTextLines) labelWave
186       
187        //loop over all of the detector panels
188        NVAR gIgnoreDetB = root:Packages:NIST:VSANS:Globals:gIgnoreDetB
189
190        String detList
191        if(gIgnoreDetB)
192                detList = ksDetectorListNoB
193        else
194                detList = ksDetectorListAll
195        endif
196       
197        for(kk=0;kk<ItemsInList(detList);kk+=1)
198
199                detStr = StringFromList(kk, detList, ";")
200                detSavePath = pathStr + "_" + detStr
201               
202                pixX = V_getDet_pixel_num_x(type,detStr)
203                pixY = V_getDet_pixel_num_y(type,detStr)
204               
205                fileName = saveName
206                fileDate = V_getDataStartTime(type)             // already a string
207                fileLabel = V_getSampleDescription(type)
208               
209                monCt = V_getBeamMonNormData(type)
210                lambda = V_getWavelength(type)
211
212                offset = V_getDet_LateralOffset(type,detStr)
213       
214                dist = V_getDet_ActualDistance(type,detStr)
215                trans = V_getSampleTransmission(type)
216                thick = V_getSampleThickness(type)
217               
218                bCentX = V_getDet_beam_center_x(type,detStr)
219                bCentY = V_getDet_beam_center_y(type,detStr)
220                a1Str = V_getSourceAp_size(type)                //already a string
221                a2 = V_getSampleAp2_size(type)
222                a1a2_dist = V_getSourceAp_distance(type)
223                deltaLam = V_getWavelength_spread(type)
224                // TODO -- decipher which beamstop, if any is actually in place
225                // or -- V_getBeamStopC3_size(type)
226                bstop = V_getBeamStopC2_size(type)
227
228                pixSizeX = V_getDet_x_pixel_size(type,detStr)
229                pixSizeY = V_getDet_y_pixel_size(type,detStr)
230               
231                duration = V_getCount_time(type)
232               
233                WAVE data = V_getDetectorDataW(type,detStr)
234                WAVE data_err = V_getDetectorDataErrW(type,detStr)
235               
236                // TODO - replace hard wired paths with Read functions
237                // hard-wired
238                Wave qx_val = $("root:Packages:NIST:VSANS:"+type+":entry:instrument:detector_"+detStr+":qx_"+detStr)
239                Wave qy_val = $("root:Packages:NIST:VSANS:"+type+":entry:instrument:detector_"+detStr+":qy_"+detStr)
240                Wave qz_val = $("root:Packages:NIST:VSANS:"+type+":entry:instrument:detector_"+detStr+":qz_"+detStr)
241                Wave qTot = $("root:Packages:NIST:VSANS:"+type+":entry:instrument:detector_"+detStr+":qTot_"+detStr)
242               
243        ///// calculation of the resolution function (2D)
244
245        //
246                Variable acc,ssd,lambda0,yg_d,qstar,g,L1,L2,vz_1,sdd
247                // L1 = source to sample distance [cm]
248                L1 = V_getSourceAp_distance(type)
249       
250        // L2 = sample to detector distance [cm]
251                L2 = V_getDet_ActualDistance(type,detStr)               //cm
252
253        //             
254                G = 981.  //!   ACCELERATION OF GRAVITY, CM/SEC^2
255                vz_1 =  3.956E5 //      3.956E5 //!     CONVERT WAVELENGTH TO VELOCITY CM/SEC
256                acc = vz_1
257                SDD = L2                //1317
258                SSD = L1                //1627          //cm
259                lambda0 = lambda                //              15
260                YG_d = -0.5*G*SDD*(SSD+SDD)*(LAMBDA0/acc)^2
261                Print "DISTANCE BEAM FALLS DUE TO GRAVITY (CM) = ",YG_d
262        ////            Print "Gravity q* = ",-2*pi/lambda0*2*yg_d/sdd
263                qstar = -2*pi/lambda0*2*yg_d/sdd
264        //     
265        //
266        //// the gravity center is not the resolution center
267        //// gravity center = beam center
268        //// resolution center = offset y = dy + (2)*yg_d
269        /////************
270        //// do everything to write out the resolution too
271        //      // un-comment these if you want to write out qz_val and qval too, then use the proper save command
272        //      qval = CalcQval(p+1,q+1,rw[16],rw[17],rw[18],rw[26],rw[13]/10)
273                Duplicate/O qTot,phi,r_dist
274                Variable xctr,yctr
275
276
277                xctr = V_getDet_beam_center_x_pix(type,detStr)
278                yctr = V_getDet_beam_center_y_pix(type,detStr)
279                phi = V_FindPhi( pixSizeX*((p+1)-xctr) , pixSizeY*((q+1)-yctr)+(2)*yg_d)                //(dx,dy+yg_d)
280                r_dist = sqrt(  (pixSizeX*((p+1)-xctr))^2 +  (pixSizeY*((q+1)-yctr)+(2)*yg_d)^2 )               //radial distance from ctr to pt
281       
282                //make everything in 1D now
283                Duplicate/O qTot SigmaQX,SigmaQY,fsubS,qval     
284                Redimension/N=(pixX*pixY) SigmaQX,SigmaQY,fsubS,qval,phi,r_dist
285
286                Variable ret1,ret2,ret3,nq
287                String collimationStr = proto[9]
288               
289                nq = pixX*pixY
290                ii=0
291
292// TODO
293// this loop is the slow step. it takes Å 0.7 s for F or M panels, and Å 120 s for the Back panel (6144 pts vs. 1.12e6 pts)
294// find some way to speed this up!
295// MultiThreading will be difficult as it requires all the dependent functions (HDF5 reads, etc.) to be threadsafe as well
296// and there are a lot of them... and I don't know if opening a file multiple times is a threadsafe operation?
297//  -- multiple open attempts seems like a bad idea.
298                //type = work folder
299               
300//              (this doesn't work...and isn't any faster)
301//              Duplicate/O qval dum
302//              dum = V_get2DResolution(qval,phi,r_dist,type,detStr,collimationStr,SigmaQX,SigmaQY,fsubS)
303
304v_tic()
305                Make/O/N=(2,pixX,pixY) qxy_vals
306                Make/O/N=(pixX,pixY) shadow
307                Make/O/N=(2,pixX,pixY) SigmaQ_combined
308                ii=0
309                do
310                        jj = 0
311                        do
312                                nq = ii * pixY + jj
313                                V_get2DResolution(qval[nq],phi[nq],r_dist[nq],folderStr,detStr,collimationStr,ret1,ret2,ret3)
314                                qxy_vals[0][ii][jj] = qx_val[nq]
315                                qxy_vals[1][ii][jj] = qy_val[nq]
316                                SigmaQ_combined[0][ii][jj] = ret1
317                                SigmaQ_combined[1][ii][jj] = ret2
318                                shadow[ii][jj] = ret3
319                                jj+=1
320//                      while(jj<pixX)
321                        while(jj<pixY)
322                        ii+=1
323//              while(ii<pixY)
324                while(ii<pixX)
325v_toc()
326
327        ////*********************       
328                Duplicate/O qx_val,qx_val_s
329                Duplicate/O qy_val,qy_val_s
330                Duplicate/O qz_val,qz_val_s
331                Duplicate/O data,z_val_s
332                Duplicate/O SigmaQx,sigmaQx_s
333                Duplicate/O SigmaQy,sigmaQy_s
334                Duplicate/O fSubS,fSubS_s
335                Duplicate/O data_err,sw_s
336               
337                //so that double precision data is not written out
338                Redimension/S qx_val_s,qy_val_s,qz_val_s,z_val_s,sw_s
339                Redimension/S SigmaQx_s,SigmaQy_s,fSubS_s
340       
341                Redimension/N=(pixX*pixY) qx_val_s,qy_val_s,qz_val_s,z_val_s,sw_s
342               
343                // SASData
344                String dataParent,dataBase
345                sPrintf dataParent,"%ssasdata%d/",nxcansasBase,kk
346                // Create SASdata entry
347                sPrintf dataBase,"%s:sasdata%d",parentBase,kk
348                NewDataFolder/O/S $(dataBase)
349                Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices", "timestamp"}
350                Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q,Q","NXdata","0,1",V_getDataEndTime(folderStr)}
351                CreateStrNxCansas(fileID,dataParent,"","",empty,$(dataBase + ":attr"),$(dataBase + ":attrVals"))
352                // Create i entry
353                NewDataFolder/O/S $(dataBase + ":i")
354                Make/O/T/N=2 $(dataBase + ":i:attr") = {"units","uncertainties"}
355                Make/O/T/N=2 $(dataBase + ":i:attrVals") = {"1/cm","Idev"}
356                CreateVarNxCansas(fileID,dataParent,"sasdata","I",data,$(dataBase + ":i:attr"),$(dataBase + ":i:attrVals"))
357                //
358                // TODO: Reinstate Qdev/resolutions when I can fix the reader issue
359                //
360                // Create qx and qy entry
361                NewDataFolder/O/S $(dataBase + ":q")
362                Make/O/T/N=2 $(dataBase + ":q:attr") = {"units"}//,"resolutions"}
363                Make/O/T/N=2 $(dataBase + ":q:attrVals") = {"1/angstrom"}//,"Qdev"}
364                CreateVarNxCansas(fileID,dataParent,"sasdata","Q",qxy_vals,$(dataBase + ":q:attr"),$(dataBase + ":q:attrVals"))
365                // Create idev entry
366                CreateVarNxCansas(fileID,dataParent,"sasdata","Idev",data_err,units,inv_cm)
367                // Create qdev entry
368                CreateVarNxCansas(fileID,dataParent,"sasdata","Qdev",SigmaQ_combined,units,inv_angstrom)
369                // Create shadwfactor entry
370                CreateVarNxCansas(fileID,dataParent,"sasdata","ShadowFactor",shadow,empty,empty)
371                //
372                ///////////////////////////////////////////////////////////////////////////
373               
374                KillWaves/Z qx_val_s,qy_val_s,z_val_s,qz_val_s,SigmaQx_s,SigmaQy_s,fSubS_s,sw,sw_s
375                Killwaves/Z qval,sigmaQx,SigmaQy,fSubS,phi,r_dist
376       
377        endfor
378       
379        KillWaves/Z labelWave,dum
380       
381        // Write all VSANS meta data
382        V_WriteMetaData(fileID,parentBase,nxcansasBase,folderStr,proto)
383               
384        //
385        ///////////////////////////////////////////////////////////////////////////
386       
387        // Close the file
388        if(fileID)
389                HDF5CloseFile /Z fileID
390        endif
391       
392        KillDataFolder/Z $base
393       
394        return(0)
395End
396
397///////////////////////////////////////////////////////////////////////////
398// - V_WriteMetaData - Method used to write non data elements into NXcanSAS
399// format. This is common between 1D and 2D data sets.
400
401Function V_WriteMetaData(fileID,base,parentBase,folderStr,proto)
402        String base,parentBase,folderStr
403        Variable fileID
404        Wave/T proto
405       
406        // Define common attribute waves
407        Make/T/O/N=1 empty = {""}
408        Make/T/O/N=1 units = {"units"}
409        Make/T/O/N=1 m = {"m"}
410        Make/T/O/N=1 mm = {"mm"}
411        Make/T/O/N=1 cm = {"cm"}
412        Make/T/O/N=1 pixel = {"pixel"}
413        Make/T/O/N=1 angstrom = {"A"}
414       
415        // SASinstrument
416        String instrParent = parentBase + "sasinstrument/"
417        // Create SASinstrument entry
418        String instrumentBase = base + ":sasinstrument"
419        NewDataFolder/O/S $(instrumentBase)
420        Make/O/T/N=5 $(instrumentBase + ":attr") = {"canSAS_class","NX_class"}
421        Make/O/T/N=5 $(instrumentBase + ":attrVals") = {"SASinstrument","NXinstrument"}
422        CreateStrNxCansas(fileID,instrParent,"","",empty,$(instrumentBase + ":attr"),$(instrumentBase + ":attrVals"))
423        // Create SASinstrument name entry
424        Make/O/T/N=1 $(instrumentBase + ":name") = {V_getInstrumentName(folderStr)}
425        CreateStrNxCansas(fileID,instrParent,"","name",$(instrumentBase + ":name"),empty,empty)
426       
427        // SASaperture
428        String apertureParent = instrParent + "sasaperture/"
429        // Create SASaperture entry
430        String apertureBase = instrumentBase + ":sasaperture"
431        NewDataFolder/O/S $(apertureBase)
432        Make/O/T/N=5 $(apertureBase + ":attr") = {"canSAS_class","NX_class"}
433        Make/O/T/N=5 $(apertureBase + ":attrVals") = {"SASaperture","NXaperture"}
434        CreateStrNxCansas(fileID,apertureParent,"","",empty,$(apertureBase + ":attr"),$(apertureBase + ":attrVals"))
435        // Create SASaperture shape entry
436        Make/O/T/N=1 $(apertureBase + ":shape") = {V_getSampleAp_shape(folderStr)}
437        CreateStrNxCansas(fileID,apertureParent,"sasaperture","shape",$(apertureBase + ":shape"),empty,empty)
438        // Create SASaperture x_gap entry
439        Make/O/N=1 $(apertureBase + ":x_gap") = {V_getSampleAp_height(folderStr)}
440        CreateVarNxCansas(fileID,apertureParent,"sasaperture","x_gap",$(apertureBase + ":x_gap"),units,mm)
441        // Create SASaperture y_gap entry
442        Make/O/N=1 $(apertureBase + ":y_gap") = {V_getSampleAp_width(folderStr)}
443        CreateVarNxCansas(fileID,apertureParent,"sasaperture","y_gap",$(apertureBase + ":y_gap"),units,mm)
444       
445        // SAScollimation
446        String collimationParent = instrParent + "sascollimation/"
447        // Create SAScollimation entry
448        String collimationBase = instrumentBase + ":sascollimation"
449        NewDataFolder/O/S $(collimationBase)
450        Make/O/T/N=5 $(collimationBase + ":attr") = {"canSAS_class","NX_class"}
451        Make/O/T/N=5 $(collimationBase + ":attrVals") = {"SAScollimation","NXcollimator"}
452        CreateStrNxCansas(fileID,collimationParent,"","",empty,$(collimationBase + ":attr"),$(collimationBase + ":attrVals"))
453        // Create SAScollimation distance entry
454        Make/O/N=1 $(collimationBase + ":distance") = {V_getSourceAp_distance(folderStr)}
455        CreateVarNxCansas(fileID,collimationParent,"sasaperture","distance",$(collimationBase + ":distance"),units,m)
456       
457        // SASdetector - Front Top
458        String detectorParent = instrParent + "sasdetector1/"
459        // Create SASdetector entry
460        String detectorBase = instrumentBase + ":sasdetector1"
461        NewDataFolder/O/S $(detectorBase)
462        Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"}
463        Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"}
464        CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals"))
465        // Create SASdetector name entry
466        Make/O/T/N=1 $(detectorBase + ":name") = {"FrontTop"}
467        CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty)
468        // Create SASdetector type entry
469        Make/O/T/N=1 $(detectorBase + ":type") = {"He3 gas cylinder"}
470        CreateStrNxCansas(fileID,detectorParent,"","type",$(detectorBase + ":type"),empty,empty)
471        // Create SASdetector distance entry
472        Make/O/N=1 $(detectorBase + ":SDD") = {V_getDet_ActualDistance(folderStr,"FT")}
473        CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,cm)
474        // Create SASdetector beam_center_x entry
475        Make/O/N=1 $(detectorBase + ":beam_center_x") = {V_getDet_beam_center_x_mm(folderStr,"FT")}
476        CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,mm)
477        // Create SASdetector beam_center_y entry
478        Make/O/N=1 $(detectorBase + ":beam_center_y") = {V_getDet_beam_center_y_mm(folderStr,"FT")}
479        CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,mm)
480        // Create SASdetector x_pixel_size entry
481        Make/O/N=1 $(detectorBase + ":x_pixel_size") = {V_getDet_x_pixel_size(folderStr,"FT")}
482        CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm)
483        // Create SASdetector y_pixel_size entry
484        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"FT")}
485        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm)
486       
487        // SASdetector - Front Bottom
488        detectorParent = instrParent + "sasdetector2/"
489        // Create SASdetector entry
490        detectorBase = instrumentBase + ":sasdetector2"
491        NewDataFolder/O/S $(detectorBase)
492        Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"}
493        Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"}
494        CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals"))
495        // Create SASdetector name entry
496        Make/O/T/N=1 $(detectorBase + ":name") = {"FrontBottom"}
497        CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty)
498        // Create SASdetector type entry
499        Make/O/T/N=1 $(detectorBase + ":type") = {"He3 gas cylinder"}
500        CreateStrNxCansas(fileID,detectorParent,"","type",$(detectorBase + ":type"),empty,empty)
501        // Create SASdetector distance entry
502        Make/O/N=1 $(detectorBase + ":SDD") = {V_getDet_ActualDistance(folderStr,"FB")}
503        CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,cm)
504        // Create SASdetector beam_center_x entry
505        Make/O/N=1 $(detectorBase + ":beam_center_x") = {V_getDet_beam_center_x_mm(folderStr,"FB")}
506        CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,mm)
507        // Create SASdetector beam_center_y entry
508        Make/O/N=1 $(detectorBase + ":beam_center_y") = {V_getDet_beam_center_y_mm(folderStr,"FB")}
509        CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,mm)
510        // Create SASdetector x_pixel_size entry
511        Make/O/N=1 $(detectorBase + ":x_pixel_size") = {V_getDet_x_pixel_size(folderStr,"FB")}
512        CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm)
513        // Create SASdetector y_pixel_size entry
514        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"FB")}
515        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm)   
516       
517        // SASdetector - Front Left
518        detectorParent = instrParent + "sasdetector3/"
519        // Create SASdetector entry
520        detectorBase = instrumentBase + ":sasdetector3"
521        NewDataFolder/O/S $(detectorBase)
522        Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"}
523        Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"}
524        CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals"))
525        // Create SASdetector name entry
526        Make/O/T/N=1 $(detectorBase + ":name") = {"FrontLeft"}
527        CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty)
528        // Create SASdetector type entry
529        Make/O/T/N=1 $(detectorBase + ":type") = {"He3 gas cylinder"}
530        CreateStrNxCansas(fileID,detectorParent,"","type",$(detectorBase + ":type"),empty,empty)
531        // Create SASdetector distance entry
532        Make/O/N=1 $(detectorBase + ":SDD") = {V_getDet_ActualDistance(folderStr,"FL")}
533        CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,cm)
534        // Create SASdetector beam_center_x entry
535        Make/O/N=1 $(detectorBase + ":beam_center_x") = {V_getDet_beam_center_x_mm(folderStr,"FL")}
536        CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,mm)
537        // Create SASdetector beam_center_y entry
538        Make/O/N=1 $(detectorBase + ":beam_center_y") = {V_getDet_beam_center_y_mm(folderStr,"FL")}
539        CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,mm)
540        // Create SASdetector x_pixel_size entry
541        Make/O/N=1 $(detectorBase + ":x_pixel_size") = {V_getDet_x_pixel_size(folderStr,"FL")}
542        CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm)
543        // Create SASdetector y_pixel_size entry
544        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"FL")}
545        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm)
546       
547        // SASdetector - Front Right
548        detectorParent = instrParent + "sasdetector4/"
549        // Create SASdetector entry
550        detectorBase = instrumentBase + ":sasdetector4"
551        NewDataFolder/O/S $(detectorBase)
552        Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"}
553        Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"}
554        CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals"))
555        // Create SASdetector name entry
556        Make/O/T/N=1 $(detectorBase + ":name") = {"FrontRight"}
557        CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty)
558        // Create SASdetector type entry
559        Make/O/T/N=1 $(detectorBase + ":type") = {"He3 gas cylinder"}
560        CreateStrNxCansas(fileID,detectorParent,"","type",$(detectorBase + ":type"),empty,empty)
561        // Create SASdetector distance entry
562        Make/O/N=1 $(detectorBase + ":SDD") = {V_getDet_ActualDistance(folderStr,"FR")}
563        CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,cm)
564        // Create SASdetector beam_center_x entry
565        Make/O/N=1 $(detectorBase + ":beam_center_x") = {V_getDet_beam_center_x_mm(folderStr,"FR")}
566        CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,mm)
567        // Create SASdetector beam_center_y entry
568        Make/O/N=1 $(detectorBase + ":beam_center_y") = {V_getDet_beam_center_y_mm(folderStr,"FR")}
569        CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,mm)
570        // Create SASdetector x_pixel_size entry
571        Make/O/N=1 $(detectorBase + ":x_pixel_size") = {V_getDet_x_pixel_size(folderStr,"FR")}
572        CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm)
573        // Create SASdetector y_pixel_size entry
574        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"FR")}
575        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm)
576       
577        // SASdetector - Middle Top
578        detectorParent = instrParent + "sasdetector5/"
579        // Create SASdetector entry
580        detectorBase = instrumentBase + ":sasdetector5"
581        NewDataFolder/O/S $(detectorBase)
582        Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"}
583        Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"}
584        CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals"))
585        // Create SASdetector name entry
586        Make/O/T/N=1 $(detectorBase + ":name") = {"MiddleTop"}
587        CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty)
588        // Create SASdetector type entry
589        Make/O/T/N=1 $(detectorBase + ":type") = {"He3 gas cylinder"}
590        CreateStrNxCansas(fileID,detectorParent,"","type",$(detectorBase + ":type"),empty,empty)
591        // Create SASdetector distance entry
592        Make/O/N=1 $(detectorBase + ":SDD") = {V_getDet_ActualDistance(folderStr,"MT")}
593        CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,cm)
594        // Create SASdetector beam_center_x entry
595        Make/O/N=1 $(detectorBase + ":beam_center_x") = {V_getDet_beam_center_x_mm(folderStr,"MT")}
596        CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,mm)
597        // Create SASdetector beam_center_y entry
598        Make/O/N=1 $(detectorBase + ":beam_center_y") = {V_getDet_beam_center_y_mm(folderStr,"MT")}
599        CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,mm)
600        // Create SASdetector x_pixel_size entry
601        Make/O/N=1 $(detectorBase + ":x_pixel_size") = {V_getDet_x_pixel_size(folderStr,"MT")}
602        CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm)
603        // Create SASdetector y_pixel_size entry
604        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"MT")}
605        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm)
606       
607        // SASdetector - Middle Bottom
608        detectorParent = instrParent + "sasdetector6/"
609        // Create SASdetector entry
610        detectorBase = instrumentBase + ":sasdetector6"
611        NewDataFolder/O/S $(detectorBase)
612        Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"}
613        Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"}
614        CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals"))
615        // Create SASdetector name entry
616        Make/O/T/N=1 $(detectorBase + ":name") = {"MiddleBottom"}
617        CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty)
618        // Create SASdetector type entry
619        Make/O/T/N=1 $(detectorBase + ":type") = {"He3 gas cylinder"}
620        CreateStrNxCansas(fileID,detectorParent,"","type",$(detectorBase + ":type"),empty,empty)
621        // Create SASdetector distance entry
622        Make/O/N=1 $(detectorBase + ":SDD") = {V_getDet_ActualDistance(folderStr,"MB")}
623        CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,cm)
624        // Create SASdetector beam_center_x entry
625        Make/O/N=1 $(detectorBase + ":beam_center_x") = {V_getDet_beam_center_x_mm(folderStr,"MB")}
626        CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,mm)
627        // Create SASdetector beam_center_y entry
628        Make/O/N=1 $(detectorBase + ":beam_center_y") = {V_getDet_beam_center_y_mm(folderStr,"MB")}
629        CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,mm)
630        // Create SASdetector x_pixel_size entry
631        Make/O/N=1 $(detectorBase + ":x_pixel_size") = {V_getDet_x_pixel_size(folderStr,"MB")}
632        CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm)
633        // Create SASdetector y_pixel_size entry
634        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"MB")}
635        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm)
636       
637        // SASdetector - Middle Left
638        detectorParent = instrParent + "sasdetector7/"
639        // Create SASdetector entry
640        detectorBase = instrumentBase + ":sasdetector7"
641        NewDataFolder/O/S $(detectorBase)
642        Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"}
643        Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"}
644        CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals"))
645        // Create SASdetector name entry
646        Make/O/T/N=1 $(detectorBase + ":name") = {"MiddleLeft"}
647        CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty)
648        // Create SASdetector type entry
649        Make/O/T/N=1 $(detectorBase + ":type") = {"He3 gas cylinder"}
650        CreateStrNxCansas(fileID,detectorParent,"","type",$(detectorBase + ":type"),empty,empty)
651        // Create SASdetector distance entry
652        Make/O/N=1 $(detectorBase + ":SDD") = {V_getDet_ActualDistance(folderStr,"ML")}
653        CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,cm)
654        // Create SASdetector beam_center_x entry
655        Make/O/N=1 $(detectorBase + ":beam_center_x") = {V_getDet_beam_center_x_mm(folderStr,"ML")}
656        CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,mm)
657        // Create SASdetector beam_center_y entry
658        Make/O/N=1 $(detectorBase + ":beam_center_y") = {V_getDet_beam_center_y_mm(folderStr,"ML")}
659        CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,mm)
660        // Create SASdetector x_pixel_size entry
661        Make/O/N=1 $(detectorBase + ":x_pixel_size") = {V_getDet_x_pixel_size(folderStr,"ML")}
662        CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm)
663        // Create SASdetector y_pixel_size entry
664        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"ML")}
665        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm)
666       
667        // SASdetector - Middle Right
668        detectorParent = instrParent + "sasdetector8/"
669        // Create SASdetector entry
670        detectorBase = instrumentBase + ":sasdetector8"
671        NewDataFolder/O/S $(detectorBase)
672        Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"}
673        Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"}
674        CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals"))
675        // Create SASdetector name entry
676        Make/O/T/N=1 $(detectorBase + ":name") = {"MiddleRight"}
677        CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty)
678        // Create SASdetector type entry
679        Make/O/T/N=1 $(detectorBase + ":type") = {"He3 gas cylinder"}
680        CreateStrNxCansas(fileID,detectorParent,"","type",$(detectorBase + ":type"),empty,empty)
681        // Create SASdetector distance entry
682        Make/O/N=1 $(detectorBase + ":SDD") = {V_getDet_ActualDistance(folderStr,"MR")}
683        CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,cm)
684        // Create SASdetector beam_center_x entry
685        Make/O/N=1 $(detectorBase + ":beam_center_x") = {V_getDet_beam_center_x_mm(folderStr,"MR")}
686        CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,mm)
687        // Create SASdetector beam_center_y entry
688        Make/O/N=1 $(detectorBase + ":beam_center_y") = {V_getDet_beam_center_y_mm(folderStr,"MR")}
689        CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,mm)
690        // Create SASdetector x_pixel_size entry
691        Make/O/N=1 $(detectorBase + ":x_pixel_size") = {V_getDet_x_pixel_size(folderStr,"MR")}
692        CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm)
693        // Create SASdetector y_pixel_size entry
694        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"MR")}
695        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm)
696       
697        NVAR ignoreBack = root:Packages:NIST:VSANS:Globals:gIgnoreDetB
698        if(ignoreBack == 0)     
699                // SASdetector - Back High Res
700                detectorParent = instrParent + "sasdetector9/"
701                // Create SASdetector entry
702                detectorBase = instrumentBase + ":sasdetector9"
703                NewDataFolder/O/S $(detectorBase)
704                Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"}
705                Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"}
706                CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals"))
707                // Create SASdetector name entry
708                Make/O/T/N=1 $(detectorBase + ":name") = {"HighResolutionBack"}
709                CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty)
710                // Create SASdetector type entry
711                Make/O/T/N=1 $(detectorBase + ":type") = {"He3 gas cylinder"}
712                CreateStrNxCansas(fileID,detectorParent,"","type",$(detectorBase + ":type"),empty,empty)
713                // Create SASdetector distance entry
714                Make/O/N=1 $(detectorBase + ":SDD") = {V_getDet_ActualDistance(folderStr,"B")}
715                CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,cm)
716                // Create SASdetector beam_center_x entry
717                Make/O/N=1 $(detectorBase + ":beam_center_x") = {V_getDet_beam_center_x_mm(folderStr,"B")}
718                CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,mm)
719                // Create SASdetector beam_center_y entry
720                Make/O/N=1 $(detectorBase + ":beam_center_y") = {V_getDet_beam_center_y_mm(folderStr,"B")}
721                CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,mm)
722                // Create SASdetector x_pixel_size entry
723                Make/O/N=1 $(detectorBase + ":x_pixel_size") = {V_getDet_x_pixel_size(folderStr,"B")}
724                CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm)
725                // Create SASdetector y_pixel_size entry
726                Make/O/N=1 $(detectorBase + ":y_pixel_size") = {V_getDet_y_pixel_size(folderStr,"B")}
727                CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm)
728        EndIf
729       
730        // SASsource
731        String sourceParent = instrParent + "sassource/"
732        // Create SASdetector entry
733        String sourceBase = instrumentBase + ":sassource"
734        NewDataFolder/O/S $(sourceBase)
735        Make/O/T/N=5 $(sourceBase + ":attr") = {"canSAS_class","NX_class"}
736        Make/O/T/N=5 $(sourceBase + ":attrVals") = {"SASsource","NXsource"}
737        CreateStrNxCansas(fileID,sourceParent,"","",empty,$(sourceBase + ":attr"),$(sourceBase + ":attrVals"))
738        // Create SASsource radiation entry
739        Make/O/T/N=1 $(sourceBase + ":radiation") = {V_getSourceType(folderStr)}
740        CreateStrNxCansas(fileID,sourceParent,"","radiation",$(sourceBase + ":radiation"),empty,empty)
741        // Create SASsource incident_wavelength entry
742        Make/O/N=1 $(sourceBase + ":incident_wavelength") = {V_getWavelength(folderStr)}
743        CreateVarNxCansas(fileID,sourceParent,"","incident_wavelength",$(sourceBase + ":incident_wavelength"),units,angstrom)
744        // Create SASsource incident_wavelength_spread entry
745        Make/O/N=1 $(sourceBase + ":incident_wavelength_spread") = {V_getWavelength_spread(folderStr)}
746        CreateVarNxCansas(fileID,sourceParent,"","incident_wavelength_spread",$(sourceBase + ":incident_wavelength_spread"),units,angstrom)
747
748        // SASsample
749        String sampleParent = parentBase + "sassample/"
750        // Create SASsample entry
751        String sampleBase = base + ":sassample"
752        NewDataFolder/O/S $(sampleBase)
753        Make/O/T/N=5 $(sampleBase + ":attr") = {"canSAS_class","NX_class"}
754        Make/O/T/N=5 $(sampleBase + ":attrVals") = {"SASsample","NXsample"}
755        CreateStrNxCansas(fileID,sampleParent,"","",empty,$(sampleBase + ":attr"),$(sampleBase + ":attrVals"))
756        // Create SASsample name entry
757        Make/O/T/N=1 $(sampleBase + ":name") = {V_getSampleDescription(folderStr)}
758        CreateStrNxCansas(fileID,sampleParent,"","name",$(sampleBase + ":name"),empty,empty)
759        // Create SASsample thickness entry
760        Make/O/N=1 $(sampleBase + ":thickness") = {V_getSampleThickness(folderStr)}
761        CreateVarNxCansas(fileID,sampleParent,"","thickness",$(sampleBase + ":thickness"),units,mm)
762        // Create SASsample transmission entry
763        Make/O/N=1 $(sampleBase + ":transmission") = {V_getSampleTransmission(folderStr)}
764        CreateVarNxCansas(fileID,sampleParent,"","transmission",$(sampleBase + ":transmission"),empty,empty)
765       
766        // Create SASsample temperature entry
767        If(V_getSampleTemperature(folderStr) != -999999)
768                Make/O/N=1 $(sampleBase + ":temperature") = {V_getSampleTemperature(folderStr)}
769                CreateVarNxCansas(fileID,sampleParent,"","temperature",$(sampleBase + ":temperature"),empty,empty)
770        EndIf
771       
772        //
773        // TODO: Include other sample environment when they are available
774       
775        // SASprocess
776        SVAR samFiles = root:Packages:NIST:VSANS:Globals:Protocols:gSAM
777        String protoStr7,protoStr8
778        if(strlen(proto[7]) == 0)
779                protoStr7 = "(Default) "+ ksBinTrimBegDefault
780        else
781                protoStr7 = proto[7]
782        endif
783        if(strlen(proto[8]) == 0)
784                protoStr8 = "(Default) "+ ksBinTrimEndDefault
785        else
786                protoStr8 = proto[8]
787        endif
788        String processNote0,processNote1,processNote2,processNote3,processNote4
789        String processNote5,processNote6,processNote7,processNote8,processNote9
790        sPrintf processNote0,"SAM: %s",samFiles
791        sPrintf processNote1,"BGD: %s",Proto[0]
792        sPrintf processNote2,"EMP: %s",Proto[1]
793        sPrintf processNote3,"DIV: %s",Proto[2]
794        sPrintf processNote4,"MASK: %s",Proto[3]
795        sPrintf processNote5,"ABS Parameters (3-6): %s",Proto[4]
796        sPrintf processNote6,"Average Choices: %s",Proto[5]
797        sPrintf processNote7,"Beginning Trim Points: %s",ProtoStr7
798        sPrintf processNote8,"End Trim Points: %s",ProtoStr8
799        sPrintf processNote9,"COLLIMATION=%s",proto[9]
800        // Create SASprocess entry
801        String processParent = parentBase + "sasprocess/"
802        String processBase = base + ":sasprocess"
803        NewDataFolder/O/S $(processBase)
804        Make/O/T/N=5 $(processBase + ":attr") = {"canSAS_class","NX_class"}
805        Make/O/T/N=5 $(processBase + ":attrVals") = {"SASprocess","NXprocess"}
806        CreateStrNxCansas(fileID,processParent,"","",empty,$(processBase + ":attr"),$(processBase + ":attrVals"))
807        // Create SASprocess name entry
808        Make/O/T/N=1 $(processBase + ":name") = {samFiles}
809        CreateStrNxCansas(fileID,processParent,"","name",$(processBase + ":name"),empty,empty)
810        // Create SASprocess note entries
811        Make/O/T/N=1 $(processBase + ":note0") = {processNote0}
812        CreateStrNxCansas(fileID,processParent,"","note0",$(processBase + ":note0"),empty,empty)
813        Make/O/T/N=1 $(processBase + ":note1") = {processNote1}
814        CreateStrNxCansas(fileID,processParent,"","note1",$(processBase + ":note1"),empty,empty)
815        Make/O/T/N=1 $(processBase + ":note2") = {processNote2}
816        CreateStrNxCansas(fileID,processParent,"","note2",$(processBase + ":note2"),empty,empty)
817        Make/O/T/N=1 $(processBase + ":note3") = {processNote3}
818        CreateStrNxCansas(fileID,processParent,"","note3",$(processBase + ":note3"),empty,empty)
819        Make/O/T/N=1 $(processBase + ":note4") = {processNote4}
820        CreateStrNxCansas(fileID,processParent,"","note4",$(processBase + ":note4"),empty,empty)
821        Make/O/T/N=1 $(processBase + ":note5") = {processNote5}
822        CreateStrNxCansas(fileID,processParent,"","note5",$(processBase + ":note5"),empty,empty)
823        Make/O/T/N=1 $(processBase + ":note6") = {processNote6}
824        CreateStrNxCansas(fileID,processParent,"","note6",$(processBase + ":note6"),empty,empty)
825        Make/O/T/N=1 $(processBase + ":note7") = {processNote7}
826        CreateStrNxCansas(fileID,processParent,"","note7",$(processBase + ":note7"),empty,empty)
827        Make/O/T/N=1 $(processBase + ":note8") = {processNote8}
828        CreateStrNxCansas(fileID,processParent,"","note8",$(processBase + ":note8"),empty,empty)
829        Make/O/T/N=1 $(processBase + ":note9") = {processNote9}
830        CreateStrNxCansas(fileID,processParent,"","note9",$(processBase + ":note9"),empty,empty)
831       
832End
833       
834//
835///////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.