Changeset 1179


Ignore:
Timestamp:
Jul 17, 2019 9:56:29 AM (3 years ago)
Author:
krzywon
Message:

VSANS 1D NXcanSAS writer created with appropriate data locations, but fake meta data.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Reduction/VSANS/V_Write_VSANS_NXcanSAS.ipf

    r1175 r1179  
    55 
    66// TODO: 
    7 // -- this is a temporary solution before a real writer is created 
     7// -- This is a placeholder for the final NXcanSAS writer for VSANS data. 
    88// -- resolution is not generated here (and it shouldn't be) since resolution is not known yet. 
    9 // -- but a real writer will need to be aware of resolution, and there may be different forms 
    10 // 
    11 // this will bypass save dialogs 
    12 // -- AND WILL OVERWITE DATA WITH THE SAME NAME 
    13 // 
    14 Function V_Write1DData(pathStr,folderStr,saveName) 
     9// -- The final writer will need to be aware of resolution, and there may be different forms 
     10// 
     11Function V_WriteNXcanSAS1DData(pathStr,folderStr,saveName) 
    1512        String pathStr,folderStr,saveName 
    1613         
    17         String formatStr="",fullpath="" 
     14        // Define local function variables 
     15        String formatStr="" 
     16        String destStr="", parentBase, nxcansasBase 
     17        Variable fileID 
    1818        Variable refnum,dialog=1 
    19  
     19        String/G base = "root:V_NXcanSAS_file" 
     20         
    2021        SetDataFolder $(pathStr+folderStr) 
    21  
    22         Wave qw = tmp_q 
    23         Wave iw = tmp_i 
    24         Wave sw = tmp_s 
    25         Wave sigQ = tmp_sq 
    26         Wave qbar = tmp_qb 
    27         Wave fs = tmp_fs 
     22         
     23        Make/T textw = {"","","","","","","","",""} 
     24        Make rw = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 
     25         
     26        // Check fullpath and dialog 
     27        if(stringmatch(saveName, "")) 
     28                fileID = NxCansas_DoSaveFileDialog() 
     29        else 
     30                fileID = NxCansas_CreateFile(saveName) 
     31        Endif 
     32        if(!fileID) 
     33                abort "Unable to create file at " + saveName + "." 
     34        else 
     35                Variable sasentry = NumVarOrDefault("root:Packages:NIST:gSASEntryNumber", 1) 
     36                sPrintf parentBase,"%s:sasentry%d",base,sasentry // Igor memory base path for all 
     37                sPrintf nxcansasBase,"/sasentry%d/",sasentry // HDF5 base path for all 
     38 
     39                Wave qw = tmp_q 
     40                Wave iw = tmp_i 
     41                Wave sw = tmp_s 
     42                Wave sigQ = tmp_sq 
     43                Wave qbar = tmp_qb 
     44                Wave fs = tmp_fs 
     45        EndIf 
    2846         
    2947        String dataSetFolderParent,basestr 
    30          
    31         // ParseFilePath to get path without folder name 
    32 //      dataSetFolderParent = ParseFilePath(1,folderStr,":",1,0) 
    33         // ParseFilePath to get basestr 
    34 //      basestr = ParseFilePath(0,folderStr,":",1,0) 
    3548         
    3649        SVAR gProtoStr = root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr 
     
    5770        endif 
    5871         
    59 //      Duplicate/O qw qbar,sigQ,fs 
    60 //      if(dimsize(resW,1) > 4) 
    61 //              //it's USANS put -dQv back in the last 3 columns 
    62 //              NVAR/Z dQv = USANS_dQv 
    63 //              if(NVAR_Exists(dQv) == 0) 
    64 //                      SetDataFolder root: 
    65 //                      Abort "It's USANS data, and I don't know what the slit height is." 
    66 //              endif 
    67 //              sigQ = -dQv 
    68 //              qbar = -dQv 
    69 //              fs = -dQv 
    70 //      else 
    71 //              //it's SANS 
    72 //              sigQ = resw[p][0] 
    73 //              qbar = resw[p][1] 
    74 //              fs = resw[p][2] 
    75 //      endif 
    76 //       
    77  
    78 // TODO -- not sure if I need to implement this. Update to VSANS specs if I do. 
    79 //      //strings can be too long to print-- must trim to 255 chars 
    80 //      Variable ii,num=8 
    81 //      Make/O/T/N=(num) tempShortProto 
    82 //      for(ii=0;ii<num;ii+=1) 
    83 //              tempShortProto[ii] = (proto[ii])[0,240] 
    84 //      endfor 
    85  
    86 // if the "default" trimming is used, the proto[] values will be null 
    87 // fill them in with the default values 
    88         String protoStr7,protoStr8 
    89         if(strlen(proto[7]) == 0) 
    90                 protoStr7 = "(Default) "+ ksBinTrimBegDefault 
    91         else 
    92                 protoStr7 = proto[7] 
    93         endif 
    94         if(strlen(proto[8]) == 0) 
    95                 protoStr8 = "(Default) "+ ksBinTrimEndDefault 
    96         else 
    97                 protoStr8 = proto[8] 
    98         endif    
    99  
    100         PathInfo catPathName 
    101         fullPath = S_Path + saveName 
    102  
    103         Open refnum as fullpath 
    104  
    105         fprintf refnum,"Combined data written from folder %s on %s\r\n",folderStr,(date()+" "+time()) 
    106  
    107         //insert protocol information here 
    108         //-1 list of sample files 
    109         //0 - bkg 
    110         //1 - emp 
    111         //2 - div 
    112         //3 - mask 
    113         //4 - abs params c2-c5 
    114         //5 - average params 
    115         //6 - DRK (unused in VSANS) 
    116         //7 - beginning trim points 
    117         //8 - end trim points 
    118         fprintf refnum, "SAM: %s\r\n",samFiles 
    119         fprintf refnum, "BGD: %s\r\n",proto[0] 
    120         fprintf refnum, "EMP: %s\r\n",Proto[1] 
    121         fprintf refnum, "DIV: %s\r\n",Proto[2] 
    122         fprintf refnum, "MASK: %s\r\n",Proto[3] 
    123         fprintf refnum, "ABS Parameters (3-6): %s\r\n",Proto[4] 
    124         fprintf refnum, "Average Choices: %s\r\n",Proto[5] 
    125         fprintf refnum, "Beginning Trim Points: %s\r\n",ProtoStr7 
    126         fprintf refnum, "End Trim Points: %s\r\n",ProtoStr8 
    127         fprintf refnum, "COLLIMATION=%s\r\n",proto[9] 
    128  
    129 // TODO 
    130 // x- make this work for 6-columns (or??) 
    131         formatStr = "%15.4g %15.4g %15.4g %15.4g %15.4g %15.4g\r\n"      
    132         fprintf refnum, "The 6 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm) | sigmaQ | meanQ | ShadowFactor|\r\n"         
    133         wfprintf refnum,formatStr,qw,iw,sw,sigQ,qbar,fs 
    134  
    135         // three column vresion 
    136 //      formatStr = "%15.4g %15.4g %15.4g\r\n"   
    137 //      fprintf refnum, "The 3 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm)\r\n"  
    138 // 
    139 //      wfprintf refnum,formatStr,qw,iw,sw 
    140  
    141  
    142         Close refnum 
    143          
    144 //      KillWaves/Z sigQ,qbar,fs 
    145         Print "Data written to: ",fullpath 
    146          
    147         SetDataFolder root: 
    148         return(0) 
     72        /////////////////////////////////////////////////////////////////////////// 
     73        // Write all data 
     74         
     75        // Define common attribute waves 
     76        Make/T/O/N=1 empty = {""} 
     77        Make/T/O/N=1 units = {"units"} 
     78        Make/T/O/N=1 inv_cm = {"1/cm"} 
     79        Make/T/O/N=1 inv_angstrom = {"1/A"} 
     80         
     81        // Run Name and title 
     82        NewDataFolder/O/S $(parentBase) 
     83         
     84         
     85        // 
     86        // FIXME: Replace textw and rw with actual data locations 
     87        // 
     88         
     89        Make/O/T/N=1 $(parentBase + ":title") = {textw[6]} 
     90        CreateStrNxCansas(fileID,nxcansasBase,"","title",$(parentBase + ":title"),empty,empty) 
     91        Make/O/T/N=1 $(parentBase + ":run") = {textw[0]} 
     92        CreateStrNxCansas(fileID,nxcansasBase,"","run",$(parentBase + ":run"),empty,empty) 
     93         
     94        // SASData 
     95        String dataParent = nxcansasBase + "sasdata/" 
     96        // Create SASdata entry 
     97        String dataBase = parentBase + ":sasdata" 
     98        NewDataFolder/O/S $(dataBase) 
     99        Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices", "timestamp"} 
     100        Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q","NXdata","0",textw[1]} 
     101        CreateStrNxCansas(fileID,dataParent,"","",empty,$(dataBase + ":attr"),$(dataBase + ":attrVals")) 
     102        // Create q entry 
     103        NewDataFolder/O/S $(dataBase + ":q") 
     104        Make/T/N=2 $(dataBase + ":q:attr") = {"units","resolutions"} 
     105        Make/T/N=2 $(dataBase + ":q:attrVals") = {"1/angstrom","Qdev"} 
     106        CreateVarNxCansas(fileID,dataParent,"sasdata","Q",qw,$(dataBase + ":q:attr"),$(dataBase + ":q:attrVals")) 
     107        // Create i entry 
     108        NewDataFolder/O/S $(dataBase + ":i") 
     109        Make/O/T/N=2 $(dataBase + ":i:attr") = {"units","uncertainties"} 
     110        Make/O/T/N=2 $(dataBase + ":i:attrVals") = {"1/cm","Idev"} 
     111        CreateVarNxCansas(fileID,dataParent,"sasdata","I",iw,$(dataBase + ":i:attr"),$(dataBase + ":i:attrVals")) 
     112        // Create idev entry 
     113        CreateVarNxCansas(fileID,dataParent,"sasdata","Idev",sw,units,inv_cm) 
     114        // Create qdev entry 
     115        CreateVarNxCansas(fileID,dataParent,"sasdata","Qdev",sigQ,units,inv_angstrom) 
     116        CreateVarNxCansas(fileID,dataParent,"sasdata","Qmean",qbar,units,inv_angstrom) 
     117         
     118        // Write all VSANS meta data 
     119        V_WriteMetaData(fileID,parentBase,nxcansasBase,proto,textw,rw) 
     120         
    149121End 
    150122 
    151  
    152  
    153 // TODO: 
    154 // -- this is a temporary solution before a real writer is created 
    155 // -- resolution is not generated here (and it shouldn't be) since resolution is not known yet. 
    156 // -- but a real writer will need to be aware of resolution, and there may be different forms 
    157 // 
    158 // This saves the data in Igor Text format, an ASCII format, but NOT standard SANS columns 
    159 // No concatenation is done. This is meant to be used for input to TRIM, or for general troubleshooting 
    160 // 
    161 // 
    162 // this will bypass save dialogs 
    163 // -- AND WILL OVERWRITE DATA WITH THE SAME NAME 
    164 // 
    165 Function V_Write1DData_ITX(pathStr,folderStr,saveName,binType) 
    166         String pathStr,folderStr,saveName 
    167         Variable binType 
    168          
    169         String formatStr="",fullpath="" 
    170         Variable refnum,dialog=1 
    171  
    172         SetDataFolder $(pathStr+folderStr) 
    173  
    174  
    175         //TODO 
    176         //-- make sure the waves exist 
    177          
    178 //      if(WaveExists(qw) == 0) 
    179 //              Abort "q is missing" 
    180 //      endif 
    181 //      if(WaveExists(iw) == 0) 
    182 //              Abort "i is missing" 
    183 //      endif 
    184 //      if(WaveExists(sw) == 0) 
    185 //              Abort "s is missing" 
    186 //      endif 
    187 //      if(WaveExists(resw) == 0) 
    188 //              Abort "Resolution information is missing." 
    189 //      endif 
    190          
    191 //      Duplicate/O qw qbar,sigQ,fs 
    192 //      if(dimsize(resW,1) > 4) 
    193 //              //it's USANS put -dQv back in the last 3 columns 
    194 //              NVAR/Z dQv = USANS_dQv 
    195 //              if(NVAR_Exists(dQv) == 0) 
    196 //                      SetDataFolder root: 
    197 //                      Abort "It's USANS data, and I don't know what the slit height is." 
    198 //              endif 
    199 //              sigQ = -dQv 
    200 //              qbar = -dQv 
    201 //              fs = -dQv 
    202 //      else 
    203 //              //it's SANS 
    204 //              sigQ = resw[p][0] 
    205 //              qbar = resw[p][1] 
    206 //              fs = resw[p][2] 
    207 //      endif 
    208 //       
    209  
    210  
    211  
    212         // TODO: 
    213         // -- currently I'm using the Save comand and the /B flag 
    214         //    to save the data as Igor Text format, since otherwise the command string would be 
    215         //    too long. Need to come up with an Igor-demo friendly save here 
    216         // 
    217         // -- see V_ExportProtocol() for a quick example of how to generate the .ITX format 
    218         // 
    219         // -- need a reader/plotter capable of handling this data. The regular data loader won't handle 
    220         //    all the different number of columns present, or the ITX format. See V_DataPlotting and duplicate these routines 
    221         //    Most of these routines take "winNameStr" as an argument, so I may be able to use them 
    222         // 
    223         // -- do I want to add the /O flag to force an overwrite if there is a name conflict? 
    224  
    225         PathInfo catPathName 
    226         fullPath = S_Path + saveName + ".itx" 
    227  
    228 //      Open refnum as fullpath 
    229 //      fprintf refnum,"Individual data sets written from folder %s on %s\r\n",folderStr,(date()+" "+time()) 
    230  
    231         String waveStr="" 
    232         // can be a multiple number of columns 
    233                  
    234         switch(binType) 
    235                 case 1:         // 9 sets = 27 waves! 
    236                         waveStr = "qBin_qxqy_B;iBin_qxqy_B;eBin_qxqy_B;" 
    237                         waveStr += "qBin_qxqy_ML;iBin_qxqy_ML;eBin_qxqy_ML;" 
    238                         waveStr += "qBin_qxqy_MR;iBin_qxqy_MR;eBin_qxqy_MR;" 
    239                         waveStr += "qBin_qxqy_MT;iBin_qxqy_MT;eBin_qxqy_MT;" 
    240                         waveStr += "qBin_qxqy_MB;iBin_qxqy_MB;eBin_qxqy_MB;" 
    241                         waveStr += "qBin_qxqy_FL;iBin_qxqy_FL;eBin_qxqy_FL;" 
    242                         waveStr += "qBin_qxqy_FR;iBin_qxqy_FR;eBin_qxqy_FR;" 
    243                         waveStr += "qBin_qxqy_FT;iBin_qxqy_FT;eBin_qxqy_FT;" 
    244                         waveStr += "qBin_qxqy_FB;iBin_qxqy_FB;eBin_qxqy_FB;" 
    245                          
    246                          
    247                         Save/T/M="\r\n"/B waveStr as fullPath 
    248  
    249                                                  
    250 //                      formatStr = "%15.4g %15.4g %15.4g\r\n" 
    251 //                       
    252 //                      fprintf refnum, "The 3 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm)\r\n"  
    253 //       
    254 //                      wfprintf refnum,formatStr,qw,iw,sw 
    255                         break 
    256                 case 2:         // 5 sets 
    257  
    258                         waveStr = "qBin_qxqy_B;iBin_qxqy_B;eBin_qxqy_B;" 
    259                         waveStr += "qBin_qxqy_MLR;iBin_qxqy_MLR;eBin_qxqy_MLR;qBin_qxqy_MTB;iBin_qxqy_MTB;eBin_qxqy_MTB;" 
    260                         waveStr += "qBin_qxqy_FLR;iBin_qxqy_FLR;eBin_qxqy_FLR;qBin_qxqy_FTB;iBin_qxqy_FTB;eBin_qxqy_FTB;" 
    261  
    262                         Save/T/M="\r\n"/B waveStr as fullPath 
    263                          
    264 //                      formatStr = "%15.4g %15.4g %15.4g\r\n" 
    265 //                       
    266 //                      fprintf refnum, "The 3 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm)\r\n"  
    267 //       
    268 //                      wfprintf refnum,formatStr,qw,iw,sw 
    269                         break 
    270                 case 3:         // 3 sets 
    271 //                      WAVE q1 = qBin_qxqy_B 
    272 //                      WAVE i1 = iBin_qxqy_B 
    273 //                      WAVE s1 = eBin_qxqy_B 
    274 //                      WAVE q2 = qBin_qxqy_MLRTB 
    275 //                      WAVE i2 = iBin_qxqy_MLRTB 
    276 //                      WAVE s2 = eBin_qxqy_MLRTB 
    277 //                      WAVE q3 = qBin_qxqy_FLRTB 
    278 //                      WAVE i3 = iBin_qxqy_FLRTB 
    279 //                      WAVE s3 = eBin_qxqy_FLRTB 
    280 // 
    281 //                               
    282 //                      Save/T/M="\r\n" q1,i1,s1,q2,i2,s2,q3,i3,s3 as fullPath 
    283                          
    284                         waveStr = "qBin_qxqy_B;iBin_qxqy_B;eBin_qxqy_B;" 
    285                         waveStr += "qBin_qxqy_MLRTB;iBin_qxqy_MLRTB;eBin_qxqy_MLRTB;qBin_qxqy_FLRTB;iBin_qxqy_FLRTB;eBin_qxqy_FLRTB;" 
    286  
    287                         Save/T/M="\r\n"/B waveStr as fullPath                    
    288                          
    289                          
    290 //                      formatStr = "%15.4g %15.4g %15.4g\r\n" 
    291 //                       
    292 //                      fprintf refnum, "The 3 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm)\r\n"  
    293 //       
    294 //                      wfprintf refnum,formatStr,qw,iw,sw 
    295                         break 
    296                 case 4:         // 9 sets 
    297                         waveStr = "qBin_qxqy_B;iBin_qxqy_B;eBin_qxqy_B;" 
    298                         waveStr += "qBin_qxqy_ML;iBin_qxqy_ML;eBin_qxqy_ML;" 
    299                         waveStr += "qBin_qxqy_MR;iBin_qxqy_MR;eBin_qxqy_MR;" 
    300                         waveStr += "qBin_qxqy_MT;iBin_qxqy_MT;eBin_qxqy_MT;" 
    301                         waveStr += "qBin_qxqy_MB;iBin_qxqy_MB;eBin_qxqy_MB;" 
    302                         waveStr += "qBin_qxqy_FL;iBin_qxqy_FL;eBin_qxqy_FL;" 
    303                         waveStr += "qBin_qxqy_FR;iBin_qxqy_FR;eBin_qxqy_FR;" 
    304                         waveStr += "qBin_qxqy_FT;iBin_qxqy_FT;eBin_qxqy_FT;" 
    305                         waveStr += "qBin_qxqy_FB;iBin_qxqy_FB;eBin_qxqy_FB;" 
    306                          
    307                          
    308                         Save/T/M="\r\n"/B waveStr as fullPath 
    309  
    310 //                      formatStr = "%15.4g %15.4g %15.4g\r\n" 
    311 //                       
    312 //                      fprintf refnum, "The 3 columns are | Q (1/A) | I(Q) (1/cm) | std. dev. I(Q) (1/cm)\r\n"  
    313 //       
    314 //                      wfprintf refnum,formatStr,qw,iw,sw 
    315                         break 
    316                                          
    317                 default: 
    318                 // do nothing, just close 
    319  
    320         endswitch 
    321  
    322 //      Close refnum 
    323  
    324 // TODO 
    325 // -- clean up any waves on exit?        Only if I generate extra waves 
    326 //      KillWaves/Z sigQ,qbar,fs 
    327          
    328         SetDataFolder root: 
    329         return(0) 
    330 End 
    331  
    332 // awkward, but can't call STRUCT from Proc 
    333 Proc Vm_Write1DData_ITX() 
    334         Vf_FakeSaveIQITXClick()  
    335 End 
    336  
    337 Function Vf_FakeSaveIQITXClick() 
    338         STRUCT WMButtonAction ba 
    339         ba.eventCode=2 
    340         V_SaveIQ_ButtonProc(ba) 
    341 end 
     123// 
     124////////////////////////////////////////////////////////////////////////////////////////////////// 
    342125 
    343126 
     
    351134// 
    352135// 
    353 Function V_QxQy_Export(type,fullpath,newFileName,dialog) 
     136Function V_WriteNXcanSAS2DData(type,fullpath,newFileName,dialog) 
    354137        String type,fullpath,newFileName 
    355138        Variable dialog         //=1 will present dialog for name 
     
    622405End 
    623406 
    624  
     407/////////////////////////////////////////////////////////////////////////// 
     408// - V_WriteMetaData - Method used to write non data elements into NXcanSAS 
     409// format. This is common between 1D and 2D data sets. 
     410 
     411// 
     412// FIXME: Remove textw and rw once locations of information are known 
     413// 
     414 
     415Function V_WriteMetaData(fileID,base,parentBase,proto,textw,rw) 
     416        String base,parentBase 
     417        Variable fileID 
     418        Wave/T proto,textw 
     419        Wave rw 
     420         
     421        // Define common attribute waves 
     422        Make/T/O/N=1 empty = {""} 
     423        Make/T/O/N=1 units = {"units"} 
     424        Make/T/O/N=1 m = {"m"} 
     425        Make/T/O/N=1 mm = {"mm"} 
     426        Make/T/O/N=1 cm = {"cm"} 
     427        Make/T/O/N=1 pixel = {"pixel"} 
     428        Make/T/O/N=1 angstrom = {"A"} 
     429         
     430        // SASinstrument 
     431        String instrParent = parentBase + "sasinstrument/" 
     432        // Create SASinstrument entry 
     433        String instrumentBase = base + ":sasinstrument" 
     434        NewDataFolder/O/S $(instrumentBase) 
     435        Make/O/T/N=5 $(instrumentBase + ":attr") = {"canSAS_class","NX_class"} 
     436        Make/O/T/N=5 $(instrumentBase + ":attrVals") = {"SASinstrument","NXinstrument"} 
     437        CreateStrNxCansas(fileID,instrParent,"","",empty,$(instrumentBase + ":attr"),$(instrumentBase + ":attrVals")) 
     438         
     439        // SASaperture 
     440        String apertureParent = instrParent + "sasaperture/" 
     441        // Create SASaperture entry 
     442        String apertureBase = instrumentBase + ":sasaperture" 
     443        NewDataFolder/O/S $(apertureBase) 
     444        Make/O/T/N=5 $(apertureBase + ":attr") = {"canSAS_class","NX_class"} 
     445        Make/O/T/N=5 $(apertureBase + ":attrVals") = {"SASaperture","NXaperture"} 
     446        CreateStrNxCansas(fileID,apertureParent,"","",empty,$(apertureBase + ":attr"),$(apertureBase + ":attrVals")) 
     447         
     448        // Create SASaperture shape entry 
     449        Make/O/T/N=1 $(apertureBase + ":shape") = {"pinhole"}  
     450        CreateStrNxCansas(fileID,apertureParent,"sasaperture","shape",$(apertureBase + ":shape"),empty,empty) 
     451        // Create SASaperture x_gap entry 
     452        Make/O/N=1 $(apertureBase + ":x_gap") = {rw[24]} 
     453        CreateVarNxCansas(fileID,apertureParent,"sasaperture","x_gap",$(apertureBase + ":x_gap"),units,mm) 
     454        // Create SASaperture y_gap entry 
     455        Make/O/N=1 $(apertureBase + ":y_gap") = {rw[24]} 
     456        CreateVarNxCansas(fileID,apertureParent,"sasaperture","y_gap",$(apertureBase + ":y_gap"),units,mm) 
     457         
     458        // SAScollimation 
     459        String collimationParent = instrParent + "sascollimation/" 
     460        // Create SAScollimation entry 
     461        String collimationBase = instrumentBase + ":sascollimation" 
     462        NewDataFolder/O/S $(collimationBase) 
     463        Make/O/T/N=5 $(collimationBase + ":attr") = {"canSAS_class","NX_class"} 
     464        Make/O/T/N=5 $(collimationBase + ":attrVals") = {"SAScollimation","NXcollimator"} 
     465        CreateStrNxCansas(fileID,collimationParent,"","",empty,$(collimationBase + ":attr"),$(collimationBase + ":attrVals")) 
     466        // Create SAScollimation distance entry 
     467        Make/O/N=1 $(collimationBase + ":distance") = {rw[25]} 
     468        CreateVarNxCansas(fileID,collimationParent,"sasaperture","distance",$(collimationBase + ":distance"),units,m) 
     469         
     470        // SASdetector 
     471        String detectorParent = instrParent + "sasdetector/" 
     472        // Create SASdetector entry 
     473        String detectorBase = instrumentBase + ":sasdetector" 
     474        NewDataFolder/O/S $(detectorBase) 
     475        Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"} 
     476        Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"} 
     477        CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals")) 
     478        // Create SASdetector name entry 
     479        Make/O/T/N=1 $(detectorBase + ":name") = {textw[9]} 
     480        CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty) 
     481        // Create SASdetector distance entry 
     482        Make/O/N=1 $(detectorBase + ":SDD") = {rw[18]} 
     483        CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,m) 
     484        // Create SASdetector beam_center_x entry 
     485        Make/O/N=1 $(detectorBase + ":beam_center_x") = {rw[16]} 
     486        CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,pixel) 
     487        // Create SASdetector beam_center_y entry 
     488        Make/O/N=1 $(detectorBase + ":beam_center_y") = {rw[17]} 
     489        CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,pixel) 
     490        // Create SASdetector x_pixel_size entry 
     491        Make/O/N=1 $(detectorBase + ":x_pixel_size") = {rw[10]} 
     492        CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm) 
     493        // Create SASdetector y_pixel_size entry 
     494        Make/O/N=1 $(detectorBase + ":y_pixel_size") = {rw[13]} 
     495        CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm) 
     496         
     497        // SASsource 
     498        String sourceParent = instrParent + "sassource/" 
     499        // Create SASdetector entry 
     500        String sourceBase = instrumentBase + ":sassource" 
     501        NewDataFolder/O/S $(sourceBase) 
     502        Make/O/T/N=5 $(sourceBase + ":attr") = {"canSAS_class","NX_class"} 
     503        Make/O/T/N=5 $(sourceBase + ":attrVals") = {"SASsource","NXsource"} 
     504        CreateStrNxCansas(fileID,sourceParent,"","",empty,$(sourceBase + ":attr"),$(sourceBase + ":attrVals")) 
     505        // Create SASsource radiation entry 
     506        Make/O/T/N=1 $(sourceBase + ":radiation") = {"Reactor Neutron Source"} 
     507        CreateStrNxCansas(fileID,sourceParent,"","radiation",$(sourceBase + ":radiation"),empty,empty) 
     508        // Create SASsource incident_wavelength entry 
     509        Make/O/N=1 $(sourceBase + ":incident_wavelength") = {rw[26]} 
     510        CreateVarNxCansas(fileID,sourceParent,"","incident_wavelength",$(sourceBase + ":incident_wavelength"),units,angstrom) 
     511        // Create SASsource incident_wavelength_spread entry 
     512        Make/O/N=1 $(sourceBase + ":incident_wavelength_spread") = {rw[27]} 
     513        CreateVarNxCansas(fileID,sourceParent,"","incident_wavelength_spread",$(sourceBase + ":incident_wavelength_spread"),units,angstrom) 
     514         
     515        // SASprocess 
     516        SVAR samFiles = root:Packages:NIST:VSANS:Globals:Protocols:gSAM 
     517        String protoStr7,protoStr8 
     518        if(strlen(proto[7]) == 0) 
     519                protoStr7 = "(Default) "+ ksBinTrimBegDefault 
     520        else 
     521                protoStr7 = proto[7] 
     522        endif 
     523        if(strlen(proto[8]) == 0) 
     524                protoStr8 = "(Default) "+ ksBinTrimEndDefault 
     525        else 
     526                protoStr8 = proto[8] 
     527        endif 
     528        String processNote = "" 
     529        sPrintf processNote,"SAM: %s\r\n",samFiles 
     530        sPrintf processNote,"%sBGD: %s\r\n",processNote,proto[0] 
     531        sPrintf processNote,"%sEMP: %s\r\n",processNote,Proto[1] 
     532        sPrintf processNote,"%sDIV: %s\r\n",processNote,Proto[2] 
     533        sPrintf processNote,"%sMASK: %s\r\n",processNote,Proto[3] 
     534        sPrintf processNote,"%sABS Parameters (3-6): %s\r\n",processNote,Proto[4] 
     535        sPrintf processNote,"%sAverage Choices: %s\r\n",processNote,Proto[5] 
     536        sPrintf processNote,"%sBeginning Trim Points: %s\r\n",processNote,ProtoStr7 
     537        sPrintf processNote,"%sEnd Trim Points: %s\r\n",processNote,ProtoStr8 
     538        sPrintf processNote,"%sCOLLIMATION=%s\r\n",processNote,proto[9] 
     539        String processParent = parentBase + "sasprocess/" 
     540        // Create SASprocess entry 
     541        String processBase = base + ":sasprocess" 
     542        NewDataFolder/O/S $(processBase) 
     543        Make/O/T/N=5 $(processBase + ":attr") = {"canSAS_class","NX_class"} 
     544        Make/O/T/N=5 $(processBase + ":attrVals") = {"SASprocess","NXprocess"} 
     545        CreateStrNxCansas(fileID,processParent,"","",empty,$(processBase + ":attr"),$(processBase + ":attrVals")) 
     546        // Create SASprocess name entry 
     547        Make/O/T/N=1 $(processBase + ":name") = {samFiles} 
     548        CreateStrNxCansas(fileID,processParent,"","name",$(processBase + ":name"),empty,empty) 
     549        // Create SASprocess note entry 
     550        Make/O/T/N=1 $(processBase + ":note") = {processNote} 
     551        CreateStrNxCansas(fileID,processParent,"","note",$(processBase + ":note"),empty,empty) 
     552         
     553        // SASsample 
     554        String sampleParent = parentBase + "sassample/" 
     555        // Create SASsample entry 
     556        String sampleBase = base + ":sassample" 
     557        NewDataFolder/O/S $(sampleBase) 
     558        Make/O/T/N=5 $(sampleBase + ":attr") = {"canSAS_class","NX_class"} 
     559        Make/O/T/N=5 $(sampleBase + ":attrVals") = {"SASsample","NXsample"} 
     560        CreateStrNxCansas(fileID,sampleParent,"","",empty,$(sampleBase + ":attr"),$(sampleBase + ":attrVals")) 
     561        // Create SASsample name entry 
     562        Make/O/T/N=1 $(sampleBase + ":name") = {textw[6]} 
     563        CreateStrNxCansas(fileID,sampleParent,"","name",$(sampleBase + ":name"),empty,empty) 
     564        // Create SASsample thickness entry 
     565        Make/O/N=1 $(sampleBase + ":thickness") = {rw[5]} 
     566        CreateVarNxCansas(fileID,sampleParent,"","thickness",$(sampleBase + ":thickness"),units,cm) 
     567        // Create SASsample transmission entry 
     568        Make/O/N=1 $(sampleBase + ":transmission") = {rw[4]} 
     569        CreateVarNxCansas(fileID,sampleParent,"","transmission",$(sampleBase + ":transmission"),empty,empty) 
     570End 
     571         
     572// 
     573/////////////////////////////////////////////////////////////////////////// 
Note: See TracChangeset for help on using the changeset viewer.