Ignore:
Timestamp:
May 31, 2019 2:08:01 PM (3 years ago)
Author:
krzywon
Message:

Updates to NXcanSAS writer to comply with latest standard.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/WriteHDF5.ipf

    r1069 r1155  
    8080        NewDataFolder/O/S $(dataBase) 
    8181        Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices", "timestamp"} 
    82         Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q","NXdata","0,1",textw[1]} 
     82        Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q","NXdata","0",textw[1]} 
    8383        CreateStrNxCansas(fileID,dataParent,"","",empty,$(dataBase + ":attr"),$(dataBase + ":attrVals")) 
    8484        // Create q entry 
     
    219219        r_dist = sqrt(  (pixSize*((p+1)-xctr))^2 +  (pixSize*((q+1)-yctr)+(2)*yg_d)^2 )         //radial distance from ctr to pt 
    220220        Redimension/N=(pixelsX*pixelsY) qz_val,qval,phi,r_dist 
     221        Make/O/N=(2,pixelsX,pixelsY) qxy_vals 
    221222        //everything in 1D now 
    222         Duplicate/O qval SigmaQX,SigmaQY,fsubS 
     223        Duplicate/O qval SigmaQX,SigmaQY 
     224        Make/O/N=(pixelsX,pixelsY) shadow 
     225        Make/O/N=(2,pixelsX,pixelsY) SigmaQ_combined 
    223226 
    224227        //Two parameters DDET and APOFF are instrument dependent.  Determine 
     
    229232        DDet = rw[10]/10                        // header value (X) is in mm, want cm here 
    230233 
    231         Variable ret1,ret2,ret3,nq 
    232         nq = pixelsX*pixelsY 
     234        Variable ret1,ret2,ret3,jj 
     235        Variable nq = 0 
    233236        Variable ii = 0 
    234237         
    235238        do 
    236                 get2DResolution(qval[ii],phi[ii],lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,pixSize,usingLenses,r_dist[ii],ret1,ret2,ret3) 
    237                 SigmaQX[ii] = ret1       
    238                 SigmaQY[ii] = ret2       
    239                 fsubs[ii] = ret3         
     239                jj = 0 
     240                do 
     241                        nq = ii * pixelsX + jj 
     242                        get2DResolution(qval[nq],phi[nq],lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,pixSize,usingLenses,r_dist[nq],ret1,ret2,ret3) 
     243                        qxy_vals[0][ii][jj] = qx_val[nq] 
     244                        qxy_vals[1][ii][jj] = qy_val[nq] 
     245                        SigmaQ_combined[0][ii][jj] = ret1        
     246                        SigmaQ_combined[1][ii][jj] = ret2 
     247                        shadow[ii][jj] = ret3    
     248                        jj+=1 
     249                while(jj<pixelsX) 
    240250                ii+=1 
    241         while(ii<nq) 
     251        while(ii<pixelsY) 
    242252        // 
    243253        /////////////////////////////////////////////////////////////////////////// 
     
    266276        NewDataFolder/O/S $(dataBase) 
    267277        Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices", "timestamp"} 
    268         Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Qx,Qy","NXdata","0,1",textw[1]} 
     278        Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q,Q","NXdata","0,1",textw[1]} 
    269279        CreateStrNxCansas(fileID,dataParent,"","",empty,$(dataBase + ":attr"),$(dataBase + ":attrVals")) 
    270280        // Create i entry 
     
    273283        Make/T/N=2 $(dataBase + ":i:attrVals") = {"1/cm","Idev"} 
    274284        CreateVarNxCansas(fileID,dataParent,"sasdata","I",data,$(dataBase + ":i:attr"),$(dataBase + ":i:attrVals")) 
     285 
     286        // 
     287        // TODO: Reinstate Qdev/resolutions when I can fix the reader issue 
     288        // 
     289 
    275290        // Create qx and qy entry 
    276         NewDataFolder/O/S $(dataBase + ":qx") 
    277         Make/T/N=2 $(dataBase + ":qx:attr") = {"units","resolutions"} 
    278         Make/T/N=2 $(dataBase + ":qx:attrVals") = {"1/angstrom","Qxdev"} 
    279         CreateVarNxCansas(fileID,dataParent,"sasdata","Qx",qx_val,$(dataBase + ":qx:attr"),$(dataBase + ":qx:attrVals")) 
    280         NewDataFolder/O/S $(dataBase + ":qy") 
    281         Make/T/N=2 $(dataBase + ":qy:attr") = {"units","resolutions"} 
    282         Make/T/N=2 $(dataBase + ":qy:attrVals") = {"1/angstrom","Qydev"} 
    283         CreateVarNxCansas(fileID,dataParent,"sasdata","Qy",qy_val,$(dataBase + ":qy:attr"),$(dataBase + ":qy:attrVals")) 
     291        NewDataFolder/O/S $(dataBase + ":q") 
     292        Make/T/N=2 $(dataBase + ":q:attr") = {"units"}//,"resolutions"} 
     293        Make/T/N=2 $(dataBase + ":q:attrVals") = {"1/angstrom"}//,"Qdev"} 
     294        CreateVarNxCansas(fileID,dataParent,"sasdata","Q",qxy_vals,$(dataBase + ":q:attr"),$(dataBase + ":q:attrVals")) 
     295         
    284296        // Create idev entry 
    285297        CreateVarNxCansas(fileID,dataParent,"sasdata","Idev",data_err,units,inv_cm) 
    286298        // Create qdev entry 
    287         CreateVarNxCansas(fileID,dataParent,"sasdata","Qxdev",SigmaQX,units,inv_angstrom) 
    288         CreateVarNxCansas(fileID,dataParent,"sasdata","Qydev",SigmaQY,units,inv_angstrom) 
     299        CreateVarNxCansas(fileID,dataParent,"sasdata","Qdev",SigmaQ_combined,units,inv_angstrom) 
    289300        // Create shadwfactor entry 
    290          
    291         // TODO: Reinstate ShadowFactor 
    292         // CreateVarNxCansas(fileID,dataParent,"sasdata","ShadowFactor",fsubs,empty,empty) 
     301        CreateVarNxCansas(fileID,dataParent,"sasdata","ShadowFactor",shadow,empty,empty) 
    293302         
    294303        // Write all meta data 
     
    341350        Make/O/T/N=5 $(apertureBase + ":attrVals") = {"SASaperture","NXaperture"} 
    342351        CreateStrNxCansas(fileID,apertureParent,"","",empty,$(apertureBase + ":attr"),$(apertureBase + ":attrVals")) 
     352         
     353        // 
     354        // TODO: Where do I get rectangular dimensions from? 
     355        // 
     356         
    343357        // Create SASaperture shape entry 
    344         Make/O/T/N=1 $(apertureBase + ":shape") = {"pinhole"} // TODO: Where do I get rectangular dimensions from? 
     358        Make/O/T/N=1 $(apertureBase + ":shape") = {"pinhole"}  
    345359        CreateStrNxCansas(fileID,apertureParent,"sasaperture","shape",$(apertureBase + ":shape"),empty,empty) 
    346360        // Create SASaperture x_gap entry 
    347         Make/O/N=1 $(apertureBase + ":x_gap") = {rw[24]} // TODO: Where do I get rectangular dimensions from? 
    348         CreateVarNxCansas(fileID,apertureParent,"sasaperture","x_gap",$(apertureBase + ":x_gap"),units,cm) 
     361        Make/O/N=1 $(apertureBase + ":x_gap") = {rw[24]} 
     362        CreateVarNxCansas(fileID,apertureParent,"sasaperture","x_gap",$(apertureBase + ":x_gap"),units,mm) 
    349363        // Create SASaperture y_gap entry 
    350         Make/O/N=1 $(apertureBase + ":y_gap") = {rw[24]} // TODO: Where do I get rectangular dimensions from? 
    351         CreateVarNxCansas(fileID,apertureParent,"sasaperture","y_gap",$(apertureBase + ":y_gap"),units,cm) 
     364        Make/O/N=1 $(apertureBase + ":y_gap") = {rw[24]} 
     365        CreateVarNxCansas(fileID,apertureParent,"sasaperture","y_gap",$(apertureBase + ":y_gap"),units,mm) 
    352366         
    353367        // SAScollimation 
Note: See TracChangeset for help on using the changeset viewer.