Changeset 1066


Ignore:
Timestamp:
Sep 28, 2017 11:23:01 AM (5 years ago)
Author:
krzywon
Message:

Bug fixes and clean up of 1D and 2D NXcanSAS writers. NXcollimator, not NXcollimation. Include time stamp in data file. Get detector name from data values. Change angstrom to A. Remove unused data folders and variable definitions.

File:
1 edited

Legend:

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

    r1065 r1066  
    1111 
    1212 
    13 // 
    14 // TODO: Handle all values 
    15 // 
    16  
    17  
    18 /////////////////////////////////////////////////////////////////////////// 
    19 // Main method to be called - WriteNxCansas 
    20 // Creates an HDF5 file and populates it with real values in Igor memory 
    21 // If dialog and fullpath are left blank (0 and "", resp.), a test will be run 
     13/////////////////////////////////////////////////////////////////////////// 
     14// - WriteNxCanSAS1D - Method for writing 1D NXcanSAS data 
     15// Creates an HDF5 file, with reduced 1D data and stores all meta data 
     16// If dialog and fullpath are left blank (0 and ""), fake data will be used 
    2217 
    2318Function WriteNxCanSAS1D(type,fullpath,dialog) 
     
    5146                Print "Unable to create file at " + fullpath + "." 
    5247        else 
    53                 WAVE intw,rw,qvals,inten,sig,qbar,sigmaq,fsubs 
    54                 WAVE/T textw 
    5548                if(stringmatch(type,"")) 
    5649                        // Test values for each data set 
    5750                        Make/N=9 intw = {0,180.0,23,6254,16547,6178,22,2,0} 
    58                         Make/N=5 rw = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 
     51                        Make/N=50 rw = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 
    5952                        Make/T/N=2 textw= {"","","","","","","","","","",""} 
    6053                        Make/N=10 qvals = {1,1,1,1,1,1,1,1,1,1} // qvals, inten, siq, qbar, sigmaq must be same length 
     
    9487        Make/T/N=1 cm = {"cm"} 
    9588        Make/T/N=1 pixel = {"pixel"} 
    96         Make/T/N=1 angstrom = {"angstrom"} 
     89        Make/T/N=1 angstrom = {"A"} 
    9790        Make/T/N=1 inv_cm = {"1/cm"} 
    98         Make/T/N=1 inv_angstrom = {"1/angstrom"} 
     91        Make/T/N=1 inv_angstrom = {"1/A"} 
    9992         
    10093        // Run Name and title 
     
    110103        String dataBase = base + ":entry1:sasdata" 
    111104        NewDataFolder/O/S $(dataBase) 
    112         Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices"} 
    113         Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q","NXdata","0"} 
     105        Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices", "timestamp"} 
     106        Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q","NXdata","0,1",textw[1]} 
    114107        CreateStrNxCansas(fileID,dataParent,"","",empty,$(dataBase + ":attr"),$(dataBase + ":attrVals")) 
    115108        // Create q entry 
     
    124117        CreateVarNxCansas(fileID,dataParent,"sasdata","I",inten,$(dataBase + ":i:attr"),$(dataBase + ":i:attrVals")) 
    125118        // Create idev entry 
    126         NewDataFolder/O/S $(dataBase + ":idev") 
    127         CreateVarNxCansas(fileID,dataParent,"sasdata","Idev",sig,units,$(dataBase + ":idev:attrVals")) 
     119        CreateVarNxCansas(fileID,dataParent,"sasdata","Idev",sig,units,inv_cm) 
    128120        // Create qdev entry 
    129         NewDataFolder/O/S $(dataBase + ":qdev") 
    130121        CreateVarNxCansas(fileID,dataParent,"sasdata","Qdev",sigmaq,units,inv_angstrom) 
    131122        CreateVarNxCansas(fileID,dataParent,"sasdata","Qmean",qbar,units,inv_angstrom) 
     
    164155        NewDataFolder/O/S $(collimationBase) 
    165156        Make/O/T/N=5 $(collimationBase + ":attr") = {"canSAS_class","NX_class"} 
    166         Make/O/T/N=5 $(collimationBase + ":attrVals") = {"SAScollimation","NXcollimation"} 
     157        Make/O/T/N=5 $(collimationBase + ":attrVals") = {"SAScollimation","NXcollimator"} 
    167158        CreateStrNxCansas(fileID,collimationParent,"","",empty,$(collimationBase + ":attr"),$(collimationBase + ":attrVals")) 
    168159        // Create SAScollimation length entry 
     
    182173        CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals")) 
    183174        // Create SASdetector name entry 
    184         Make/O/T/N=1 $(detectorBase + ":name") = {"ORNL"} // TODO: Get real value 
     175        Make/O/T/N=1 $(detectorBase + ":name") = {textw[9]} 
    185176        CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty) 
    186177        // Create SASdetector distance entry 
     
    251242/////////////////////////////////////////////////////////////////////////// 
    252243 
     244 
     245/////////////////////////////////////////////////////////////////////////// 
     246// - WriteNxCanSAS2D - Method for writing 2D NXcanSAS data 
     247// Creates an HDF5 file, generates reduced 2D data and stores all meta data 
     248// If dialog and fullpath are left blank (0 and ""), fake data will be used 
     249 
    253250Function WriteNxCanSAS2D(type,fullpath,dialog) 
    254251        // Define input variables 
     
    282279                Print "Unable to create file at " + fullpath + "." 
    283280        else 
    284                 WAVE intw,rw,qvals,inten,sig,qbar,sigmaq,fsubs 
    285                 WAVE/T textw 
    286281                if(stringmatch(type,"")) 
     282                         
     283                        // TODO: Change the simulated data variables to match those for 2D data 
     284                         
    287285                        // Test values for each data set 
    288286                        Make/N=9 intw = {0,180.0,23,6254,16547,6178,22,2,0} 
     
    358356        //              Print "Gravity q* = ",-2*pi/lambda0*2*yg_d/sdd 
    359357        qstar = -2*pi/lambda0*2*yg_d/sdd 
    360          
    361358 
    362359        // the gravity center is not the resolution center 
     
    376373        Duplicate/O qval SigmaQX,SigmaQY,fsubS 
    377374 
    378  
    379375        //Two parameters DDET and APOFF are instrument dependent.  Determine 
    380376        //these from the instrument name in the header. 
     
    409405        Make/T/N=1 cm = {"cm"} 
    410406        Make/T/N=1 pixel = {"pixel"} 
    411         Make/T/N=1 angstrom = {"angstrom"} 
     407        Make/T/N=1 angstrom = {"A"} 
    412408        Make/T/N=1 inv_cm = {"1/cm"} 
    413         Make/T/N=1 inv_angstrom = {"1/angstrom"} 
     409        Make/T/N=1 inv_angstrom = {"1/A"} 
    414410         
    415411        // Run Name and title 
     
    420416        CreateStrNxCansas(fileID,parentBase,"","run",$(base + ":entry1:run"),empty,empty) 
    421417         
    422         // TODO: Change the steps to save 2D data instead of 1D 
    423          
    424418        // SASData 
    425419        String dataParent = parentBase + "sasdata/" 
     
    427421        String dataBase = base + ":entry1:sasdata" 
    428422        NewDataFolder/O/S $(dataBase) 
    429         Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices"} 
    430         Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Qx,Qy","NXdata","0,1"} 
     423        Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices", "timestamp"} 
     424        Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Qx,Qy","NXdata","0,1",textw[1]} 
    431425        CreateStrNxCansas(fileID,dataParent,"","",empty,$(dataBase + ":attr"),$(dataBase + ":attrVals")) 
    432426        // Create i entry 
     
    436430        CreateVarNxCansas(fileID,dataParent,"sasdata","I",data,$(dataBase + ":i:attr"),$(dataBase + ":i:attrVals")) 
    437431        // Create qx and qy entry 
    438         // data,qx_val,qy_val,z_val,qval,qz_val,phi,r_dist  
    439432        NewDataFolder/O/S $(dataBase + ":qx") 
    440433        Make/T/N=2 $(dataBase + ":qx:attr") = {"units","resolutions"} 
     
    446439        CreateVarNxCansas(fileID,dataParent,"sasdata","Qy",qy_val,$(dataBase + ":qy:attr"),$(dataBase + ":qy:attrVals")) 
    447440        // Create idev entry 
    448         NewDataFolder/O/S $(dataBase + ":idev") 
    449         CreateVarNxCansas(fileID,dataParent,"sasdata","Idev",data_err,units,$(dataBase + ":idev:attrVals")) 
     441        CreateVarNxCansas(fileID,dataParent,"sasdata","Idev",data_err,units,inv_cm) 
    450442        // Create qdev entry 
    451         NewDataFolder/O/S $(dataBase + ":qxdev") 
    452443        CreateVarNxCansas(fileID,dataParent,"sasdata","Qxdev",SigmaQX,units,inv_angstrom) 
    453444        CreateVarNxCansas(fileID,dataParent,"sasdata","Qydev",SigmaQY,units,inv_angstrom) 
     445        // Create shadwfactor entry 
     446         
     447        // TODO: Reinstate ShadowFactor 
     448         
     449        // CreateVarNxCansas(fileID,dataParent,"sasdata","ShadowFactor",fsubs,empty,empty) 
    454450         
    455451        // SASinstrument 
     
    486482        NewDataFolder/O/S $(collimationBase) 
    487483        Make/O/T/N=5 $(collimationBase + ":attr") = {"canSAS_class","NX_class"} 
    488         Make/O/T/N=5 $(collimationBase + ":attrVals") = {"SAScollimation","NXcollimation"} 
     484        Make/O/T/N=5 $(collimationBase + ":attrVals") = {"SAScollimation","NXcollimator"} 
    489485        CreateStrNxCansas(fileID,collimationParent,"","",empty,$(collimationBase + ":attr"),$(collimationBase + ":attrVals")) 
    490486        // Create SAScollimation length entry 
     
    504500        CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals")) 
    505501        // Create SASdetector name entry 
    506         Make/O/T/N=1 $(detectorBase + ":name") = {"ORNL"} // TODO: Get real value 
     502        Make/O/T/N=1 $(detectorBase + ":name") = {textw[9]} 
    507503        CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty) 
    508504        // Create SASdetector distance entry 
Note: See TracChangeset for help on using the changeset viewer.