- Timestamp:
- Jun 17, 2019 4:52:45 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Reduction/USANS/WriteUSANSNXcanSAS.ipf
r1172 r1173 10 10 11 11 //************************ 12 // Vers 1.0 0 2019060312 // Vers 1.03 20190617 13 13 // 14 14 //************************ … … 24 24 25 25 Variable fileID 26 String destStr="" 27 destStr = USANSFolder+":"+type 26 String destStr=USANSFolder+":"+type 28 27 String dateStr=date()+" "+time() 29 28 … … 35 34 sPrintf nxcansasBase,"/sasentry%d/",sasentry // HDF5 base path for all 36 35 37 KillDataFolder/Z $base36 NewDataFolder/O/S $(base) 38 37 39 38 // Define common attribute waves 40 Make/ T/N=1 empty = {""}41 Make/ T/N=1 units = {"units"}42 Make/ T/N=1 m = {"m"}43 Make/ T/N=1 mm = {"mm"}44 Make/ T/N=1 cm = {"cm"}45 Make/ T/N=1 angstrom = {"A"}46 Make/ T/N=1 inv_cm = {"1/cm"}47 Make/ T/N=1 inv_angstrom = {"1/A"}39 Make/O/T/N=1 empty = {""} 40 Make/O/T/N=1 units = {"units"} 41 Make/O/T/N=1 m = {"m"} 42 Make/O/T/N=1 mm = {"mm"} 43 Make/O/T/N=1 cm = {"cm"} 44 Make/O/T/N=1 angstrom = {"A"} 45 Make/O/T/N=1 inv_cm = {"1/cm"} 46 Make/O/T/N=1 inv_angstrom = {"1/A"} 48 47 49 48 Variable refNum,integer,realval 50 51 //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error****52 WAVE qvals =$(destStr + ":Qvals")53 WAVE inten=$(destStr + ":DetCts")54 WAVE sig=$(destStr + ":ErrDetCts")55 49 56 50 if(dialog || stringmatch(fullpath, "")) … … 60 54 Endif 61 55 56 if(!fileID) 57 abort "Unable to create file at " + fullpath + "." 58 else 59 //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** 60 WAVE qvals = $(destStr + ":Qvals") 61 WAVE inten = $(destStr + ":DetCts") 62 WAVE sig = $(destStr + ":ErrDetCts") 63 endif 64 62 65 //check each wave 63 66 If(!(WaveExists(qvals))) … … 71 74 Endif 72 75 76 //write out partial set? 77 Duplicate/O qvals,tq,ti,te 78 ti=inten 79 te=sig 80 if( (lo!=hi) && (lo<hi)) 81 redimension/N=(hi-lo+1) tq,ti,te,dumWave //lo to hi, inclusive 82 tq=qvals[p+lo] 83 ti=inten[p+lo] 84 te=sig[p+lo] 85 endif 86 73 87 //Use the evil extra column for the resolution "information". Should probably switch to using slit_length in collimation. 74 88 Duplicate/O qvals,dumWave 75 89 dumWave = dQv 76 90 77 Make/ N= (numpnts(dumWave)) dQw = 091 Make/O/N= (numpnts(dumWave)) dQw = 0 78 92 79 93 // Run Name and title 80 94 NewDataFolder/O/S $(parentBase) 81 Make/T/N=1 $(parentBase + ":title") = {StringByKey("LABEL",note(inten),":",";")} 95 96 // 97 // FIXME: Get useful title - For now, sending empty string 98 // 99 100 Make/T/N=1 $(parentBase + ":title") = {""} //StringByKey("LABEL",note(inten),":",";")} 82 101 CreateStrNxCansas(fileID,nxcansasBase,"","title",$(parentBase + ":title"),empty,empty) 102 103 // 104 // TODO: Any way to programatically get the old filename? 105 // 106 83 107 Make/T/N=1 $(parentBase + ":run") = {""} 84 108 CreateStrNxCansas(fileID,nxcansasBase,"","run",$(parentBase + ":run"),empty,empty) … … 107 131 CreateVarNxCansas(fileID,dataParent,"sasdata","dQl",dumWave,units,inv_angstrom) 108 132 CreateVarNxCansas(fileID,dataParent,"sasdata","dQw",dQw,units,inv_angstrom) 109 CreateVarNxCansas(fileID,dataParent,"sasdata","Qmean",res2,units,inv_angstrom) 110 111 ////////////////////////////////////////////////////////////////////////////////////////////// 133 112 134 // Write the meta data to the file 113 135 WriteUSANSNXcanSASMetaData(fileID,type,parentBase,nxcansasBase,dateStr) … … 116 138 Print "Averaged NXcanSAS File written: ", GetFileNameFromPathNoSemi(fullPath) 117 139 KillWaves/Z dumWave 140 KillDataFolder/Z $base 118 141 119 142 // Close the file … … 134 157 Variable fileID 135 158 String destStr="" 136 destStr = USANSFolder+": Smeared"159 destStr = USANSFolder+":DSM" 137 160 String dateStr=date()+" "+time() 138 161 … … 225 248 CreateVarNxCansas(fileID,dataParent,"sasdata","dQw",res1,units,inv_angstrom) 226 249 CreateVarNxCansas(fileID,dataParent,"sasdata","Qmean",res2,units,inv_angstrom) 227 228 // 229 ////////////////////////////////////////////////////////////////////////////////////////////// 230 231 ////////////////////////////////////////////////////////////////////////////////////////////// 232 // 250 233 251 // Write USANS meta data 234 235 252 WriteUSANSNXcanSASMetaData(fileID,"SMEARED",parentBase,nxcansasBase,dateStr) 236 253 … … 238 255 Print "Averaged NXcanSAS File written: ", GetFileNameFromPathNoSemi(fullPath) 239 256 KillWaves/Z dumWave 257 KillDataFolder/Z $base 240 258 241 259 // Close the file … … 303 321 processNote += empLevStr + " ; "+bkglevStr+"\n" 304 322 323 Make/O/T/N=1 empty = {""} 324 Make/O/T/N=1 units = {"units"} 325 Make/O/T/N=1 m = {"m"} 326 Make/O/T/N=1 mm = {"mm"} 327 Make/O/T/N=1 cm = {"cm"} 328 Make/O/T/N=1 angstrom = {"A"} 329 Make/O/T/N=1 inv_cm = {"1/cm"} 330 Make/O/T/N=1 inv_angstrom = {"1/A"} 331 305 332 // SASinstrument 306 333 String instrParent = nxcansasBase + "sasinstrument/" … … 320 347 Make/O/T/N=5 $(apertureBase + ":attrVals") = {"SASaperture","NXaperture"} 321 348 CreateStrNxCansas(fileID,apertureParent,"","",empty,$(apertureBase + ":attr"),$(apertureBase + ":attrVals")) 322 323 349 // Create SASaperture shape entry 324 350 Make/O/T/N=1 $(apertureBase + ":shape") = {"slit"} … … 336 362 String detectorBase = instrumentBase + ":sasdetector" 337 363 NewDataFolder/O/S $(detectorBase) 338 Make/O/T/N= 5$(detectorBase + ":attr") = {"canSAS_class","NX_class"}339 Make/O/T/N= 5$(detectorBase + ":attrVals") = {"SASdetector","NXdetector"}364 Make/O/T/N=2 $(detectorBase + ":attr") = {"canSAS_class","NX_class"} 365 Make/O/T/N=2 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"} 340 366 CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals")) 341 367 // Create SASdetector name entry 342 368 Make/O/T/N=1 $(detectorBase + ":name") = {"BT5 DETECTOR ARRAY"} 343 369 CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty) 344 370 345 371 // SASsource 346 372 String sourceParent = instrParent + "sassource/" … … 348 374 String sourceBase = instrumentBase + ":sassource" 349 375 NewDataFolder/O/S $(sourceBase) 350 Make/O/T/N= 5$(sourceBase + ":attr") = {"canSAS_class","NX_class"}351 Make/O/T/N= 5$(sourceBase + ":attrVals") = {"SASsource","NXsource"}376 Make/O/T/N=2 $(sourceBase + ":attr") = {"canSAS_class","NX_class"} 377 Make/O/T/N=2 $(sourceBase + ":attrVals") = {"SASsource","NXsource"} 352 378 CreateStrNxCansas(fileID,sourceParent,"","",empty,$(sourceBase + ":attr"),$(sourceBase + ":attrVals")) 353 379 // Create SASsource radiation entry … … 370 396 CreateStrNxCansas(fileID,sampleParent,"","",empty,$(sampleBase + ":attr"),$(sampleBase + ":attrVals")) 371 397 // Create SASsample name entry 398 399 // 400 // FIXME: reinstate sample name once format is correct (same as title) 401 // 402 372 403 Make/O/T/N=1 $(sampleBase + ":name") = {StringByKey("LABEL",note(inten),":",";")} 373 404 CreateStrNxCansas(fileID,sampleParent,"","name",$(sampleBase + ":name"),empty,empty) … … 384 415 String processBase = parentBase + ":sasprocess" 385 416 NewDataFolder/O/S $(processBase) 386 Make/O/T/N= 5$(processBase + ":attr") = {"canSAS_class","NX_class"}387 Make/O/T/N= 5$(processBase + ":attrVals") = {"SASprocess","NXprocess"}417 Make/O/T/N=2 $(processBase + ":attr") = {"canSAS_class","NX_class"} 418 Make/O/T/N=2 $(processBase + ":attrVals") = {"SASprocess","NXprocess"} 388 419 CreateStrNxCansas(fileID,processParent,"","",empty,$(processBase + ":attr"),$(processBase + ":attrVals")) 389 420 // Create SASsample name entry … … 391 422 CreateStrNxCansas(fileID,processParent,"","name",$(processBase + ":name"),empty,empty) 392 423 // Create SASsample thickness entry 393 Make/O/T/N=1 $( sampleBase + ":note") = {processNote}394 Create VarNxCansas(fileID,processParent,"","note",$(processBase + ":note"),units,cm)424 Make/O/T/N=1 $(processBase + ":processnote") = {processNote} 425 CreateStrNxCansas(fileID,processParent,"","note",$(processBase + ":processnote"),empty,empty) 395 426 End
Note: See TracChangeset
for help on using the changeset viewer.