Ignore:
Timestamp:
Sep 28, 2017 4:27:39 PM (5 years ago)
Author:
krzywon
Message:

NXcanSAS writer code cleanup.

File:
1 edited

Legend:

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

    r1067 r1068  
    66 
    77//************************ 
    8 // Vers 0.75 20170717 
     8// Vers 1.14 20170928 
    99// 
    1010//************************ 
     
    3131         
    3232        // Define local waves 
    33         Wave/T vals,attr,attrVals,textw 
    34         Wave intw,rw,qvals,inten,sig,qbar,sigmaq,fsubs 
     33        Wave/T vals,attr,attrVals 
    3534         
    3635        // Define folder for data heirarchy 
     
    4645                Print "Unable to create file at " + fullpath + "." 
    4746        else 
    48                 if(stringmatch(type,"")) 
    49                         // Test values for each data set 
    50                         Make/N=9 intw = {0,180.0,23,6254,16547,6178,22,2,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} 
    52                         Make/T/N=2 textw= {"","","","","","","","","","",""} 
    53                         Make/N=10 qvals = {1,1,1,1,1,1,1,1,1,1} // qvals, inten, siq, qbar, sigmaq must be same length 
    54                         Make/N=10 inten = {0,0,0,0,0,0,0,0,0,0} // qvals, inten, siq, qbar, sigmaq must be same length 
    55                         Make/N=10 sig = {0,0,0,0,0,0,0,0,0,0} // qvals, inten, siq, qbar, sigmaq must be same length 
    56                         Make/N=10 qbar = {0,0,0,0,0,0,0,0,0,0} // qvals, inten, siq, qbar, sigmaq must be same length 
    57                         Make/N=10 sigmaq = {0,0,0,0,0,0,0,0,0,0} // qvals, inten, siq, qbar, sigmaq must be same length 
    58                         Make/N=10 fsubs = {0,0,0,0,0,0,0,0,0,0} // qvals, inten, siq, qbar, sigmaq must be same length 
    59                 else 
    60                         destStr = "root:Packages:NIST:"+type 
    61          
    62                         Variable refNum 
    63                         Variable step=1 
    64          
    65                         //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** 
    66                         WAVE intw = $(destStr + ":integersRead") 
    67                         WAVE rw = $(destStr + ":realsRead") 
    68                         WAVE/T textw=$(destStr + ":textRead") 
    69                         WAVE qvals =$(destStr + ":qval") 
    70                         WAVE inten=$(destStr + ":aveint") 
    71                         WAVE sig=$(destStr + ":sigave") 
    72                         WAVE qbar = $(destStr + ":QBar") 
    73                         WAVE sigmaq = $(destStr + ":SigmaQ") 
    74                         WAVE fsubs = $(destStr + ":fSubS") 
    75                 endif 
    76         endif 
    77  
    78          
     47                destStr = "root:Packages:NIST:"+type 
     48                //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** 
     49                WAVE intw = $(destStr + ":integersRead") 
     50                WAVE rw = $(destStr + ":realsRead") 
     51                WAVE/T textw=$(destStr + ":textRead") 
     52                WAVE qvals =$(destStr + ":qval") 
     53                WAVE inten=$(destStr + ":aveint") 
     54                WAVE sig=$(destStr + ":sigave") 
     55                WAVE qbar = $(destStr + ":QBar") 
     56                WAVE sigmaq = $(destStr + ":SigmaQ") 
     57                WAVE fsubs = $(destStr + ":fSubS") 
     58        endif 
     59 
    7960        /////////////////////////////////////////////////////////////////////////// 
    8061        // Write all data 
     
    8364        Make/T/N=1 empty = {""} 
    8465        Make/T/N=1 units = {"units"} 
    85         Make/T/N=1 m = {"m"} 
    86         Make/T/N=1 mm = {"mm"} 
    87         Make/T/N=1 cm = {"cm"} 
    88         Make/T/N=1 pixel = {"pixel"} 
    89         Make/T/N=1 angstrom = {"A"} 
    9066        Make/T/N=1 inv_cm = {"1/cm"} 
    9167        Make/T/N=1 inv_angstrom = {"1/A"} 
     
    133109        endif 
    134110         
    135         // KillDataFolder/Z $base 
    136          
    137111End 
    138112 
     
    154128        // Define local function variables 
    155129        Variable fileID 
    156         Variable step=1,refnum 
    157130        String destStr="",typeStr="" 
    158131        String parentBase = "/sasentry/" // HDF5 base path for all  
     
    162135         
    163136        // Define local waves 
    164         Wave/T vals,attr,attrVals,textw 
    165         Wave intw,rw,qvals,inten,sig,qbar,sigmaq,fsubs 
     137        Wave/T vals,attr,attrVals 
    166138         
    167139        // Define folder for data heirarchy 
     
    177149                Print "Unable to create file at " + fullpath + "." 
    178150        else 
    179                 if(stringmatch(type,"")) 
    180                          
    181                         // TODO: Change the simulated data variables to match those for 2D data 
    182                          
    183                         // Test values for each data set 
    184                         Make/N=9 intw = {0,180.0,23,6254,16547,6178,22,2,0} 
    185                         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} 
    186                         Make/T/N=2 textw= {"","","","","","","","","","",""} 
    187                         Make/N=10 qvals = {1,1,1,1,1,1,1,1,1,1} // qvals, inten, siq, qbar, sigmaq must be same length 
    188                         Make/N=10 inten = {0,0,0,0,0,0,0,0,0,0} // qvals, inten, siq, qbar, sigmaq must be same length 
    189                         Make/N=10 sig = {0,0,0,0,0,0,0,0,0,0} // qvals, inten, siq, qbar, sigmaq must be same length 
    190                         Make/N=10 qbar = {0,0,0,0,0,0,0,0,0,0} // qvals, inten, siq, qbar, sigmaq must be same length 
    191                         Make/N=10 sigmaq = {0,0,0,0,0,0,0,0,0,0} // qvals, inten, siq, qbar, sigmaq must be same length 
    192                         Make/N=10 fsubs = {0,0,0,0,0,0,0,0,0,0} // qvals, inten, siq, qbar, sigmaq must be same length 
     151                destStr = "root:Packages:NIST:"+type 
     152 
     153                //must select the linear_data to export 
     154                NVAR isLog = $(destStr+":gIsLogScale") 
     155                if(isLog==1) 
     156                        typeStr = ":linear_data" 
    193157                else 
    194                         destStr = "root:Packages:NIST:"+type 
    195          
    196                         //must select the linear_data to export 
    197                         NVAR isLog = $(destStr+":gIsLogScale") 
    198                         if(isLog==1) 
    199                                 typeStr = ":linear_data" 
    200                         else 
    201                                 typeStr = ":data" 
    202                         endif 
    203          
     158                        typeStr = ":data" 
     159                endif 
    204160                        NVAR pixelsX = root:myGlobals:gNPixelsX 
    205                         NVAR pixelsY = root:myGlobals:gNPixelsY 
    206          
    207                         Wave data=$(destStr+typeStr) 
    208                         Wave data_err=$(destStr+":linear_data_error") 
    209                         WAVE intw=$(destStr + ":integersRead") 
    210                         WAVE rw=$(destStr + ":realsRead") 
    211                         WAVE/T textw=$(destStr + ":textRead") 
    212                          
    213                 endif 
     161                NVAR pixelsY = root:myGlobals:gNPixelsY 
     162                Wave data=$(destStr+typeStr) 
     163                Wave data_err=$(destStr+":linear_data_error") 
     164                WAVE intw=$(destStr + ":integersRead") 
     165                WAVE rw=$(destStr + ":realsRead") 
     166                WAVE/T textw=$(destStr + ":textRead") 
    214167        endif 
    215168         
     
    251204        lambda0 = lambda                //              15 
    252205        YG_d = -0.5*G*SDD*(SSD+SDD)*(LAMBDA0/acc)^2 
    253         Print "DISTANCE BEAM FALLS DUE TO GRAVITY (CM) = ",YG_d 
    254         //              Print "Gravity q* = ",-2*pi/lambda0*2*yg_d/sdd 
    255206        qstar = -2*pi/lambda0*2*yg_d/sdd 
    256207 
     
    299250        Make/T/N=1 empty = {""} 
    300251        Make/T/N=1 units = {"units"} 
    301         Make/T/N=1 m = {"m"} 
    302         Make/T/N=1 mm = {"mm"} 
    303         Make/T/N=1 cm = {"cm"} 
    304         Make/T/N=1 pixel = {"pixel"} 
    305         Make/T/N=1 angstrom = {"A"} 
    306252        Make/T/N=1 inv_cm = {"1/cm"} 
    307253        Make/T/N=1 inv_angstrom = {"1/A"} 
     
    354300        endif 
    355301         
    356         // KillDataFolder/Z $base 
    357          
    358302End 
    359303 
     
    379323        Make/T/N=1 pixel = {"pixel"} 
    380324        Make/T/N=1 angstrom = {"A"} 
    381         Make/T/N=1 inv_cm = {"1/cm"} 
    382         Make/T/N=1 inv_angstrom = {"1/A"} 
    383325         
    384326        // SASinstrument 
     
    512454        String fullpath 
    513455        Variable fileID 
    514         print fullPath 
    515456        fullpath = ReplaceString(":\\", fullpath, ":") 
    516         print fullPath 
    517457        fullpath = ReplaceString("\\", fullpath, ":") 
    518         print fullPath 
    519458        HDF5CreateFile /Z fileID as fullpath 
    520459        NXCansas_InitializeFile(fileID) 
Note: See TracChangeset for help on using the changeset viewer.