Changeset 1189


Ignore:
Timestamp:
Aug 7, 2019 11:27:26 AM (3 years ago)
Author:
krzywon
Message:

Incorporate suggested changes for cleaner separation of VSANS, USANS, and SANS reduction methods. Plus fixes.

Location:
sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Analysis/SA_includes_v410.ipf

    r941 r1189  
    2929#include "DataSetHandling"                                      //added Nov 2009 AJJ 
    3030#include "Smear_2D"                                             //for 2D resolution smearing, May 2010 
     31 
     32// AUG 2019 
     33#include "NIST_NXcanSAS_v709" 
     34 
    3135 
    3236Menu "SANS Models" 
  • sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Common/NIST_NXcanSAS_v709.ipf

    r1187 r1189  
    99// 
    1010//************************ 
    11  
    12  
    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 
    17  
    18 Function WriteNxCanSAS1D(type,fullpath,dialog) 
    19         // Define input variables 
    20         String type // data location, in memory, relative to root:Packages:NIST: 
    21         String fullpath // file path and name where data will be saved 
    22         Variable dialog // if 1, prompt user for file path, otherwise, use fullpath 
    23          
    24         // Define local function variables 
    25         Variable fileID 
    26         String destStr="", parentBase, nxcansasBase 
    27         String/G base = "root:NXcanSAS_file" 
    28          
    29         // Define local waves 
    30         Wave/T vals,attr,attrVals 
    31          
    32         // Define folder for data heirarchy 
    33         NewDataFolder/O/S root:NXcanSAS_file 
    34          
    35         // Check fullpath and dialog 
    36         print "fullpath: ",fullpath 
    37         fileID = NXcanSAS_OpenOrCreate(dialog,fullpath,base) 
    38          
    39         Variable sasentry = NumVarOrDefault("root:Packages:NIST:gSASEntryNumber", 1) 
    40         sPrintf parentBase,"%s:sasentry%d",base,sasentry // Igor memory base path for all 
    41         sPrintf nxcansasBase,"/sasentry%d/",sasentry // HDF5 base path for all 
    42  
    43         destStr = "root:Packages:NIST:"+type 
    44         //*****these waves MUST EXIST, or IGOR Pro will crash, with a type 2 error**** 
    45         WAVE intw = $(destStr + ":integersRead") 
    46         WAVE rw = $(destStr + ":realsRead") 
    47         WAVE/T textw=$(destStr + ":textRead") 
    48         WAVE qvals =$(destStr + ":qval") 
    49         WAVE inten=$(destStr + ":aveint") 
    50         WAVE sig=$(destStr + ":sigave") 
    51         WAVE qbar = $(destStr + ":QBar") 
    52         WAVE sigmaq = $(destStr + ":SigmaQ") 
    53         WAVE fsubs = $(destStr + ":fSubS") 
    54  
    55         /////////////////////////////////////////////////////////////////////////// 
    56         // Write all data 
    57          
    58         // Define common attribute waves 
    59         Make/T/O/N=1 empty = {""} 
    60         Make/T/O/N=1 units = {"units"} 
    61         Make/T/O/N=1 inv_cm = {"1/cm"} 
    62         Make/T/O/N=1 inv_angstrom = {"1/A"} 
    63          
    64         // Run Name and title 
    65         NewDataFolder/O/S $(parentBase) 
    66         Make/O/T/N=1 $(parentBase + ":title") = {textw[6]} 
    67         CreateStrNxCansas(fileID,nxcansasBase,"","title",$(parentBase + ":title"),empty,empty) 
    68         Make/O/T/N=1 $(parentBase + ":run") = {textw[0]} 
    69         CreateStrNxCansas(fileID,nxcansasBase,"","run",$(parentBase + ":run"),empty,empty) 
    70          
    71         // SASData 
    72         String dataParent = nxcansasBase + "sasdata/" 
    73         // Create SASdata entry 
    74         String dataBase = parentBase + ":sasdata" 
    75         NewDataFolder/O/S $(dataBase) 
    76         Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices", "timestamp"} 
    77         Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q","NXdata","0",textw[1]} 
    78         CreateStrNxCansas(fileID,dataParent,"","",empty,$(dataBase + ":attr"),$(dataBase + ":attrVals")) 
    79         // Create q entry 
    80         NewDataFolder/O/S $(dataBase + ":q") 
    81         Make/T/N=2 $(dataBase + ":q:attr") = {"units","resolutions"} 
    82         Make/T/N=2 $(dataBase + ":q:attrVals") = {"1/angstrom","Qdev"} 
    83         CreateVarNxCansas(fileID,dataParent,"sasdata","Q",qvals,$(dataBase + ":q:attr"),$(dataBase + ":q:attrVals")) 
    84         // Create i entry 
    85         NewDataFolder/O/S $(dataBase + ":i") 
    86         Make/O/T/N=2 $(dataBase + ":i:attr") = {"units","uncertainties"} 
    87         Make/O/T/N=2 $(dataBase + ":i:attrVals") = {"1/cm","Idev"} 
    88         CreateVarNxCansas(fileID,dataParent,"sasdata","I",inten,$(dataBase + ":i:attr"),$(dataBase + ":i:attrVals")) 
    89         // Create idev entry 
    90         CreateVarNxCansas(fileID,dataParent,"sasdata","Idev",sig,units,inv_cm) 
    91         // Create qdev entry 
    92         CreateVarNxCansas(fileID,dataParent,"sasdata","Qdev",sigmaq,units,inv_angstrom) 
    93         CreateVarNxCansas(fileID,dataParent,"sasdata","Qmean",qbar,units,inv_angstrom) 
    94          
    95         // Write all meta data 
    96         WriteMetaData(fileID,parentBase,nxcansasBase,rw,textw) 
    97          
    98         // 
    99         /////////////////////////////////////////////////////////////////////////// 
    100          
    101         // Close the file 
    102         if(fileID) 
    103                 HDF5CloseFile /Z fileID 
    104         endif 
    105          
    106         KillDataFolder/Z $base 
    107          
    108 End 
    109  
    110 // 
    111 /////////////////////////////////////////////////////////////////////////// 
    112  
    113  
    114 /////////////////////////////////////////////////////////////////////////// 
    115 // - WriteNxCanSAS2D - Method for writing 2D NXcanSAS data 
    116 // Creates an HDF5 file, generates reduced 2D data and stores all meta data 
    117 // If dialog and fullpath are left blank (0 and ""), fake data will be used 
    118  
    119 Function WriteNxCanSAS2D(type,fullpath,dialog) 
    120         // Define input variables 
    121         String type // data location, in memory, relative to root:Packages:NIST: 
    122         String fullpath // file path and name where data will be saved 
    123         Variable dialog // if 1, prompt user for file path, otherwise, use fullpath 
    124          
    125         // Define local function variables 
    126         Variable fileID 
    127         String destStr="",typeStr="", parentBase, nxcansasBase 
    128         String/G base = "root:NXcanSAS_file" 
    129          
    130         // Define local waves 
    131         Wave/T vals,attr,attrVals 
    132          
    133         // Define folder for data heirarchy 
    134         NewDataFolder/O/S root:NXcanSAS_file 
    135          
    136         // Check fullpath and dialog 
    137         fileID = NXcanSAS_OpenOrCreate(dialog,fullpath,base) 
    138  
    139         Variable sasentry = NumVarOrDefault("root:Packages:NIST:gSASEntryNumber", 1) 
    140         sPrintf parentBase,"%s:sasentry%d",base,sasentry // Igor memory base path for all 
    141         sPrintf nxcansasBase,"/sasentry%d/",sasentry // HDF5 base path for all 
    142          
    143         destStr = "root:Packages:NIST:"+type 
    144  
    145         //must select the linear_data to export 
    146         NVAR isLog = $(destStr+":gIsLogScale") 
    147         if(isLog==1) 
    148                 typeStr = ":linear_data" 
    149         else 
    150                 typeStr = ":data" 
    151         endif 
    152         NVAR pixelsX = root:myGlobals:gNPixelsX 
    153         NVAR pixelsY = root:myGlobals:gNPixelsY 
    154         Wave data=$(destStr+typeStr) 
    155         Wave data_err=$(destStr+":linear_data_error") 
    156         WAVE intw=$(destStr + ":integersRead") 
    157         WAVE rw=$(destStr + ":realsRead") 
    158         WAVE/T textw=$(destStr + ":textRead") 
    159          
    160         /////////////////////////////////////////////////////////////////////////// 
    161         // Compute Qx, Qy data from pixel space 
    162          
    163         Duplicate/O data,qx_val,qy_val,z_val,qval,qz_val,phi,r_dist 
    164          
    165         Variable xctr,yctr,sdd,lambda,pixSize 
    166         xctr = rw[16] 
    167         yctr = rw[17] 
    168         sdd = rw[18] 
    169         lambda = rw[26] 
    170         pixSize = rw[13]/10             //convert mm to cm (x and y are the same size pixels) 
    171          
    172         qx_val = CalcQx(p+1,q+1,rw[16],rw[17],rw[18],rw[26],rw[13]/10)          //+1 converts to detector coordinate system 
    173         qy_val = CalcQy(p+1,q+1,rw[16],rw[17],rw[18],rw[26],rw[13]/10) 
    174          
    175         Redimension/N=(pixelsX*pixelsY) qx_val,qy_val,z_val 
    176  
    177         Variable L2 = rw[18] 
    178         Variable BS = rw[21] 
    179         Variable S1 = rw[23] 
    180         Variable S2 = rw[24] 
    181         Variable L1 = rw[25] 
    182         Variable lambdaWidth = rw[27]    
    183         Variable usingLenses = rw[28]           //new 2007 
    184  
    185         Variable vz_1 = 3.956e5         //velocity [cm/s] of 1 A neutron 
    186         Variable g = 981.0                              //gravity acceleration [cm/s^2] 
    187         Variable m_h    = 252.8                 // m/h [=] s/cm^2 
    188  
    189         Variable acc,ssd,lambda0,yg_d,qstar 
    190                  
    191         G = 981.  //!   ACCELERATION OF GRAVITY, CM/SEC^2 
    192         acc = vz_1              //      3.956E5 //!     CONVERT WAVELENGTH TO VELOCITY CM/SEC 
    193         SDD = L2        *100    //1317 
    194         SSD = L1        *100    //1627          //cm 
    195         lambda0 = lambda                //              15 
    196         YG_d = -0.5*G*SDD*(SSD+SDD)*(LAMBDA0/acc)^2 
    197         qstar = -2*pi/lambda0*2*yg_d/sdd 
    198  
    199         // the gravity center is not the resolution center 
    200         // gravity center = beam center 
    201         // resolution center = offset y = dy + (2)*yg_d 
    202         ///************ 
    203         // do everything to write out the resolution too 
    204         // un-comment these if you want to write out qz_val and qval too, then use the proper save command 
    205         qval = CalcQval(p+1,q+1,rw[16],rw[17],rw[18],rw[26],rw[13]/10) 
    206         qz_val = CalcQz(p+1,q+1,rw[16],rw[17],rw[18],rw[26],rw[13]/10) 
    207         //      phi = FindPhi( pixSize*((p+1)-xctr) , pixSize*((q+1)-yctr))             //(dx,dy) 
    208         //      r_dist = sqrt(  (pixSize*((p+1)-xctr))^2 +  (pixSize*((q+1)-yctr))^2 )          //radial distance from ctr to pt 
    209         phi = FindPhi( pixSize*((p+1)-xctr) , pixSize*((q+1)-yctr)+(2)*yg_d)            //(dx,dy+yg_d) 
    210         r_dist = sqrt(  (pixSize*((p+1)-xctr))^2 +  (pixSize*((q+1)-yctr)+(2)*yg_d)^2 )         //radial distance from ctr to pt 
    211         Redimension/N=(pixelsX*pixelsY) qz_val,qval,phi,r_dist 
    212         Make/O/N=(2,pixelsX,pixelsY) qxy_vals 
    213         //everything in 1D now 
    214         Duplicate/O qval SigmaQX,SigmaQY 
    215         Make/O/N=(pixelsX,pixelsY) shadow 
    216         Make/O/N=(2,pixelsX,pixelsY) SigmaQ_combined 
    217  
    218         //Two parameters DDET and APOFF are instrument dependent.  Determine 
    219         //these from the instrument name in the header. 
    220         //From conversation with JB on 01.06.99 these are the current good values 
    221         Variable DDet 
    222         NVAR apOff = root:myGlobals:apOff               //in cm 
    223         DDet = rw[10]/10                        // header value (X) is in mm, want cm here 
    224  
    225         Variable ret1,ret2,ret3,jj 
    226         Variable nq = 0 
    227         Variable ii = 0 
    228          
    229         do 
    230                 jj = 0 
    231                 do 
    232                         nq = ii * pixelsX + jj 
    233                         get2DResolution(qval[nq],phi[nq],lambda,lambdaWidth,DDet,apOff,S1,S2,L1,L2,BS,pixSize,usingLenses,r_dist[nq],ret1,ret2,ret3) 
    234                         qxy_vals[0][ii][jj] = qx_val[nq] 
    235                         qxy_vals[1][ii][jj] = qy_val[nq] 
    236                         SigmaQ_combined[0][ii][jj] = ret1        
    237                         SigmaQ_combined[1][ii][jj] = ret2 
    238                         shadow[ii][jj] = ret3    
    239                         jj+=1 
    240                 while(jj<pixelsX) 
    241                 ii+=1 
    242         while(ii<pixelsY) 
    243         // 
    244         /////////////////////////////////////////////////////////////////////////// 
    245  
    246          
    247         /////////////////////////////////////////////////////////////////////////// 
    248         // Write all data 
    249          
    250         // Define common attribute waves 
    251         Make/O/T/N=1 empty = {""} 
    252         Make/O/T/N=1 units = {"units"} 
    253         Make/O/T/N=1 inv_cm = {"1/cm"} 
    254         Make/O/T/N=1 inv_angstrom = {"1/A"} 
    255          
    256         // Run Name and title 
    257         NewDataFolder/O/S $(parentBase) 
    258         Make/O/T/N=1 $(parentBase + ":title") = {textw[6]} 
    259         CreateStrNxCansas(fileID,nxcansasBase,"","title",$(parentBase + ":title"),empty,empty) 
    260         Make/O/T/N=1 $(parentBase + ":run") = {textw[0]} 
    261         CreateStrNxCansas(fileID,nxcansasBase,"","run",$(parentBase + ":run"),empty,empty) 
    262          
    263         // SASData 
    264         String dataParent = nxcansasBase + "sasdata/" 
    265         // Create SASdata entry 
    266         String dataBase = parentBase + ":sasdata" 
    267         NewDataFolder/O/S $(dataBase) 
    268         Make/O/T/N=5 $(dataBase + ":attr") = {"canSAS_class","signal","I_axes","NX_class","Q_indices", "timestamp"} 
    269         Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q,Q","NXdata","0,1",textw[1]} 
    270         CreateStrNxCansas(fileID,dataParent,"","",empty,$(dataBase + ":attr"),$(dataBase + ":attrVals")) 
    271         // Create i entry 
    272         NewDataFolder/O/S $(dataBase + ":i") 
    273         Make/O/T/N=2 $(dataBase + ":i:attr") = {"units","uncertainties"} 
    274         Make/O/T/N=2 $(dataBase + ":i:attrVals") = {"1/cm","Idev"} 
    275         CreateVarNxCansas(fileID,dataParent,"sasdata","I",data,$(dataBase + ":i:attr"),$(dataBase + ":i:attrVals")) 
    276  
    277         // 
    278         // TODO: Reinstate Qdev/resolutions when I can fix the reader issue 
    279         // 
    280          
    281  
    282         // Create qx and qy entry 
    283         NewDataFolder/O/S $(dataBase + ":q") 
    284         Make/O/T/N=2 $(dataBase + ":q:attr") = {"units"}//,"resolutions"} 
    285         Make/O/T/N=2 $(dataBase + ":q:attrVals") = {"1/angstrom"}//,"Qdev"} 
    286         CreateVarNxCansas(fileID,dataParent,"sasdata","Q",qxy_vals,$(dataBase + ":q:attr"),$(dataBase + ":q:attrVals")) 
    287          
    288         // Create idev entry 
    289         CreateVarNxCansas(fileID,dataParent,"sasdata","Idev",data_err,units,inv_cm) 
    290         // Create qdev entry 
    291         CreateVarNxCansas(fileID,dataParent,"sasdata","Qdev",SigmaQ_combined,units,inv_angstrom) 
    292         // Create shadwfactor entry 
    293         CreateVarNxCansas(fileID,dataParent,"sasdata","ShadowFactor",shadow,empty,empty) 
    294          
    295         // Write all meta data 
    296         WriteMetaData(fileID,parentBase,nxcansasBase,rw,textw) 
    297          
    298         // Close the file 
    299         if(fileID) 
    300                 HDF5CloseFile /Z fileID 
    301         endif 
    302          
    303         KillDataFolder/Z $base 
    304          
    305 End 
    306  
    307 // 
    308 /////////////////////////////////////////////////////////////////////////// 
    309  
    310 /////////////////////////////////////////////////////////////////////////// 
    311 // - WriteMetaData - Method used to write non data elements into NXcanSAS 
    312 // format. This is common between 1D and 2D data sets. 
    313  
    314 Function WriteMetaData(fileID,base,parentBase,rw,textw) 
    315         String base,parentBase 
    316         Variable fileID 
    317         Wave rw 
    318         Wave/T textw 
    319          
    320         // Define common attribute waves 
    321         Make/T/O/N=1 empty = {""} 
    322         Make/T/O/N=1 units = {"units"} 
    323         Make/T/O/N=1 m = {"m"} 
    324         Make/T/O/N=1 mm = {"mm"} 
    325         Make/T/O/N=1 cm = {"cm"} 
    326         Make/T/O/N=1 pixel = {"pixel"} 
    327         Make/T/O/N=1 angstrom = {"A"} 
    328          
    329         // SASinstrument 
    330         String instrParent = parentBase + "sasinstrument/" 
    331         // Create SASinstrument entry 
    332         String instrumentBase = base + ":sasinstrument" 
    333         NewDataFolder/O/S $(instrumentBase) 
    334         Make/O/T/N=5 $(instrumentBase + ":attr") = {"canSAS_class","NX_class"} 
    335         Make/O/T/N=5 $(instrumentBase + ":attrVals") = {"SASinstrument","NXinstrument"} 
    336         CreateStrNxCansas(fileID,instrParent,"","",empty,$(instrumentBase + ":attr"),$(instrumentBase + ":attrVals")) 
    337          
    338         // SASaperture 
    339         String apertureParent = instrParent + "sasaperture/" 
    340         // Create SASaperture entry 
    341         String apertureBase = instrumentBase + ":sasaperture" 
    342         NewDataFolder/O/S $(apertureBase) 
    343         Make/O/T/N=5 $(apertureBase + ":attr") = {"canSAS_class","NX_class"} 
    344         Make/O/T/N=5 $(apertureBase + ":attrVals") = {"SASaperture","NXaperture"} 
    345         CreateStrNxCansas(fileID,apertureParent,"","",empty,$(apertureBase + ":attr"),$(apertureBase + ":attrVals")) 
    346          
    347         // 
    348         // TODO: Where do I get rectangular dimensions from? 
    349         // 
    350          
    351         // Create SASaperture shape entry 
    352         Make/O/T/N=1 $(apertureBase + ":shape") = {"pinhole"}  
    353         CreateStrNxCansas(fileID,apertureParent,"sasaperture","shape",$(apertureBase + ":shape"),empty,empty) 
    354         // Create SASaperture x_gap entry 
    355         Make/O/N=1 $(apertureBase + ":x_gap") = {rw[24]} 
    356         CreateVarNxCansas(fileID,apertureParent,"sasaperture","x_gap",$(apertureBase + ":x_gap"),units,mm) 
    357         // Create SASaperture y_gap entry 
    358         Make/O/N=1 $(apertureBase + ":y_gap") = {rw[24]} 
    359         CreateVarNxCansas(fileID,apertureParent,"sasaperture","y_gap",$(apertureBase + ":y_gap"),units,mm) 
    360          
    361         // SAScollimation 
    362         String collimationParent = instrParent + "sascollimation/" 
    363         // Create SAScollimation entry 
    364         String collimationBase = instrumentBase + ":sascollimation" 
    365         NewDataFolder/O/S $(collimationBase) 
    366         Make/O/T/N=5 $(collimationBase + ":attr") = {"canSAS_class","NX_class"} 
    367         Make/O/T/N=5 $(collimationBase + ":attrVals") = {"SAScollimation","NXcollimator"} 
    368         CreateStrNxCansas(fileID,collimationParent,"","",empty,$(collimationBase + ":attr"),$(collimationBase + ":attrVals")) 
    369         // Create SAScollimation distance entry 
    370         Make/O/N=1 $(collimationBase + ":distance") = {rw[25]} 
    371         CreateVarNxCansas(fileID,collimationParent,"sasaperture","distance",$(collimationBase + ":distance"),units,m) 
    372          
    373         // SASdetector 
    374         String detectorParent = instrParent + "sasdetector/" 
    375         // Create SASdetector entry 
    376         String detectorBase = instrumentBase + ":sasdetector" 
    377         NewDataFolder/O/S $(detectorBase) 
    378         Make/O/T/N=5 $(detectorBase + ":attr") = {"canSAS_class","NX_class"} 
    379         Make/O/T/N=5 $(detectorBase + ":attrVals") = {"SASdetector","NXdetector"} 
    380         CreateStrNxCansas(fileID,detectorParent,"","",empty,$(detectorBase + ":attr"),$(detectorBase + ":attrVals")) 
    381         // Create SASdetector name entry 
    382         Make/O/T/N=1 $(detectorBase + ":name") = {textw[9]} 
    383         CreateStrNxCansas(fileID,detectorParent,"","name",$(detectorBase + ":name"),empty,empty) 
    384         // Create SASdetector distance entry 
    385         Make/O/N=1 $(detectorBase + ":SDD") = {rw[18]} 
    386         CreateVarNxCansas(fileID,detectorParent,"","SDD",$(detectorBase + ":SDD"),units,m) 
    387         // Create SASdetector beam_center_x entry 
    388         Make/O/N=1 $(detectorBase + ":beam_center_x") = {rw[16]} 
    389         CreateVarNxCansas(fileID,detectorParent,"","beam_center_x",$(detectorBase + ":beam_center_x"),units,pixel) 
    390         // Create SASdetector beam_center_y entry 
    391         Make/O/N=1 $(detectorBase + ":beam_center_y") = {rw[17]} 
    392         CreateVarNxCansas(fileID,detectorParent,"","beam_center_y",$(detectorBase + ":beam_center_y"),units,pixel) 
    393         // Create SASdetector x_pixel_size entry 
    394         Make/O/N=1 $(detectorBase + ":x_pixel_size") = {rw[10]} 
    395         CreateVarNxCansas(fileID,detectorParent,"","x_pixel_size",$(detectorBase + ":x_pixel_size"),units,mm) 
    396         // Create SASdetector y_pixel_size entry 
    397         Make/O/N=1 $(detectorBase + ":y_pixel_size") = {rw[13]} 
    398         CreateVarNxCansas(fileID,detectorParent,"","y_pixel_size",$(detectorBase + ":y_pixel_size"),units,mm) 
    399          
    400         // SASsource 
    401         String sourceParent = instrParent + "sassource/" 
    402         // Create SASdetector entry 
    403         String sourceBase = instrumentBase + ":sassource" 
    404         NewDataFolder/O/S $(sourceBase) 
    405         Make/O/T/N=5 $(sourceBase + ":attr") = {"canSAS_class","NX_class"} 
    406         Make/O/T/N=5 $(sourceBase + ":attrVals") = {"SASsource","NXsource"} 
    407         CreateStrNxCansas(fileID,sourceParent,"","",empty,$(sourceBase + ":attr"),$(sourceBase + ":attrVals")) 
    408         // Create SASsource radiation entry 
    409         Make/O/T/N=1 $(sourceBase + ":radiation") = {"Reactor Neutron Source"} 
    410         CreateStrNxCansas(fileID,sourceParent,"","radiation",$(sourceBase + ":radiation"),empty,empty) 
    411         // Create SASsource incident_wavelength entry 
    412         Make/O/N=1 $(sourceBase + ":incident_wavelength") = {rw[26]} 
    413         CreateVarNxCansas(fileID,sourceParent,"","incident_wavelength",$(sourceBase + ":incident_wavelength"),units,angstrom) 
    414         // Create SASsource incident_wavelength_spread entry 
    415         Make/O/N=1 $(sourceBase + ":incident_wavelength_spread") = {rw[27]} 
    416         CreateVarNxCansas(fileID,sourceParent,"","incident_wavelength_spread",$(sourceBase + ":incident_wavelength_spread"),units,angstrom) 
    417          
    418         // SASsample 
    419         String sampleParent = parentBase + "sassample/" 
    420         // Create SASsample entry 
    421         String sampleBase = base + ":sassample" 
    422         NewDataFolder/O/S $(sampleBase) 
    423         Make/O/T/N=5 $(sampleBase + ":attr") = {"canSAS_class","NX_class"} 
    424         Make/O/T/N=5 $(sampleBase + ":attrVals") = {"SASsample","NXsample"} 
    425         CreateStrNxCansas(fileID,sampleParent,"","",empty,$(sampleBase + ":attr"),$(sampleBase + ":attrVals")) 
    426         // Create SASsample name entry 
    427         Make/O/T/N=1 $(sampleBase + ":name") = {textw[6]} 
    428         CreateStrNxCansas(fileID,sampleParent,"","name",$(sampleBase + ":name"),empty,empty) 
    429         // Create SASsample thickness entry 
    430         Make/O/N=1 $(sampleBase + ":thickness") = {rw[5]} 
    431         CreateVarNxCansas(fileID,sampleParent,"","thickness",$(sampleBase + ":thickness"),units,cm) 
    432         // Create SASsample transmission entry 
    433         Make/O/N=1 $(sampleBase + ":transmission") = {rw[4]} 
    434         CreateVarNxCansas(fileID,sampleParent,"","transmission",$(sampleBase + ":transmission"),empty,empty) 
    435 End 
    436          
    437 // 
    438 /////////////////////////////////////////////////////////////////////////// 
    43911 
    44012 
     
    47749        String fullpath,base 
    47850        Variable fileID 
    479         Make/T/O/N=1 $("root:file_name") = fullpath 
     51        Make/T/O/N=1 $("root:NXfile_name") = fullpath 
    48052        fullpath = ReplaceString(":\\", fullpath, ":") 
    48153        fullpath = ReplaceString("\\", fullpath, ":") 
    482         HDF5CreateFile /Z fileID as fullpath 
     54        HDF5CreateFile /O/Z fileID as fullpath 
    48355        NXCansas_InitializeFile(fileID, base) 
    48456        return fileID 
     
    49163        Variable fileID 
    49264        fileName = ParseFilePath(3,fullpath,":",0,0) 
    493         Make/T/O/N=1 $("root:file_name") = fileName 
     65        Make/T/O/N=1 $("root:NXfile_name") = fileName 
    49466        fullpath = ReplaceString(":\\", fullpath, ":") 
    49567        fullpath = ReplaceString("\\", fullpath, ":") 
     
    52294        sPrintf nxParent,"/sasentry%d/",sasentry 
    52395        NewDataFolder/O/S $(location) 
    524         Make/T/N=1 $(location + ":vals") = {""} 
    525         Make/T/N=3 $(location + ":attr") = {"NX_class", "canSAS_class", "version"} 
    526         Make/T/N=3 $(location + ":attrVals") = {"NXentry", "SASentry", "1.0"} 
     96        Make/O/T/N=1 $(location + ":vals") = {""} 
     97        Make/O/T/N=3 $(location + ":attr") = {"NX_class", "canSAS_class", "version"} 
     98        Make/O/T/N=3 $(location + ":attrVals") = {"NXentry", "SASentry", "1.0"} 
    52799        CreateStrNxCansas(fileID,nxParent,"","",$(location + ":vals"),$(location + ":attr"),$(location + ":attrVals")) 
    528         Make/T/N=1 $(location + ":entryAttr") = {""} 
    529         Make/T/N=1 $(location + ":entryAttrVals") = {""} 
     100        Make/O/T/N=1 $(location + ":entryAttr") = {""} 
     101        Make/O/T/N=1 $(location + ":entryAttrVals") = {""} 
    530102        CreateStrNxCansas(fileID,nxParent,"","definition",{"NXcanSAS"},$(location + ":entryAttr"),$(location + ":entryAttrVals")) 
    531103End 
     
    573145                String name_i = names[i] 
    574146                String vals_i = vals[i] 
    575                 Make/T/N=1 vals_i_wave 
     147                Make/O/T/N=1 vals_i_wave 
    576148                vals_i_wave[0] = vals_i 
    577149                if(!stringmatch(name_i,"")) 
  • sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Common/Packages/PlotManager/PlotUtilsMacro_v40.ipf

    r1170 r1189  
    14421442        /// items for everyone 
    14431443        val = NumVarOrDefault("root:Packages:NIST:gASCII_Write", 1 ) 
    1444         if (val == 1) 
    1445                 WritePref("PrefCtrl_0",1) 
    1446         endif 
    14471444        Variable/G root:Packages:NIST:gASCII_Write = val 
     1445 
    14481446        val = NumVarOrDefault("root:Packages:NIST:gXML_Write", 0 ) 
    1449         if (val == 1) 
    1450                 WritePref("PrefCtrl_0a",1) 
    1451         endif 
    14521447        Variable/G root:Packages:NIST:gXML_Write = val 
     1448 
    14531449        val = NumVarOrDefault("root:Packages:NIST:gNXcanSAS_Write", 0 ) 
    1454         if (val == 1) 
    1455                 WritePref("PrefCtrl_0b",1) 
    1456         endif 
    14571450        Variable/G root:Packages:NIST:gNXcanSAS_Write = val 
    14581451         
     1452//      if (root:Packages:NIST:gASCII_Write == 1) 
     1453//              WritePref("PrefCtrl_0",1) 
     1454//      endif 
     1455//      if (root:Packages:NIST:gXML_Write == 1) 
     1456//              WritePref("PrefCtrl_0a",1) 
     1457//      endif    
     1458//      if (root:Packages:NIST:gNXcanSAS_Write == 1) 
     1459//              WritePref("PrefCtrl_0b",1) 
     1460//      endif 
    14591461end 
    14601462 
  • sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Reduction/SANS/NCNR_Includes_v520.ipf

    r1167 r1189  
    9898//#include "MC_Script_Panels" 
    9999 
    100 // JRK JUN 2019 -- import NXcanSAS writer 
     100// JRK JUN 2019 -- import NXcanSAS read and write utilities 
    101101#include "NIST_NXcanSAS_v709" 
     102#include "Write_SANS_NXcanSAS" 
     103 
    102104 
    103105// a simple list of items to add to the Beta menu 
  • sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Reduction/USANS/NCNR_USANS_Includes_v230.ipf

    r1172 r1189  
    5151#Include "WriteModelData_v40" 
    5252#include "PlotManager_v40" 
     53 
     54#include "NIST_NXcanSAS_v709" 
  • sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Reduction/USANS/USANS_Includes.ipf

    r693 r1189  
    55 
    66///point to the current version, so I can recognize old experiments 
    7 #include "USANS_Includes_v230" 
     7#include "NCNR_USANS_Includes_v230" 
    88 
    99 
  • sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Reduction/VSANS/V_Protocol_Reduction.ipf

    r1185 r1189  
    33513351//                                      prot[9] = collimationStr 
    33523352                                        if (useNXcanSASOutput == 1) 
    3353                                                 V_WriteNXcanSAS1DData("root:Packages:NIST:VSANS:",activeType,newFileName+".h5") 
     3353                                                exten = "h5" 
     3354                                                V_WriteNXcanSAS1DData("root:Packages:NIST:VSANS:",activeType,fullPath+".h5")    // pass the full path here 
    33543355                                        else 
    33553356                                                V_Write1DData("root:Packages:NIST:VSANS:",activeType,newFileName+"."+exten)             //don't pass the full path, just the name 
     
    33773378                                break 
    33783379                        case "QxQy_NXcanSAS": 
    3379                                 fullPath = S_Path + newFileName+".h5" 
     3380                                fullPath = S_Path + newFileName+".2D.h5" 
    33803381                                V_WriteNXcanSAS2DData(activeType,fullPath,newFileName,dialog) 
    33813382                                break 
  • sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Reduction/VSANS/V_VSANS_Preferences.ipf

    r1175 r1189  
    4444        // GENERAL tab 
    4545        /// General items for everyone 
    46         val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gXML_Write", 0 ) 
    47         Variable/G root:Packages:NIST:VSANS:Globals:gXML_Write = val 
    48         val = NumVarOrDefault("root:Packages:NIST:VSANS:Globals:gNXcanSAS_Write", 0 ) 
    49         Variable/G root:Packages:NIST:VSANS:Globals:gNXcanSAS_Write = val 
     46        val = NumVarOrDefault("root:Packages:NIST:gASCII_Write", 1 ) 
     47        Variable/G root:Packages:NIST:gASCII_Write = val 
     48        val = NumVarOrDefault("root:Packages:NIST:gXML_Write", 0 ) 
     49        Variable/G root:Packages:NIST:gXML_Write = val 
     50        val = NumVarOrDefault("root:Packages:NIST:gNXcanSAS_Write", 0 ) 
     51        Variable/G root:Packages:NIST:gNXcanSAS_Write = val 
    5052         
    5153        // VSANS tab 
     
    274276        CheckBox PrefCtrl_0b,value= root:Packages:NIST:gNXcanSAS_Write 
    275277 
     278        CheckBox PrefCtrl_0,disable=1 
     279        CheckBox PrefCtrl_0a,disable=1 
     280        CheckBox PrefCtrl_0b,disable=1 
     281                         
    276282//on tab(1) - VSANS - initially visible 
    277283        CheckBox PrefCtrl_1a,pos={21,100},size={171,14},proc=V_LogScalePrefCheck,title="Use Log scaling for 2D data display" 
  • sans/Dev/branches/nxcansas_writer/NCNR_User_Procedures/Reduction/VSANS/V_Write_VSANS_NXcanSAS.ipf

    r1187 r1189  
    1010        String destStr="", parentBase, nxcansasBase 
    1111        Variable fileID 
    12         Variable refnum,dialog=1 
     12        Variable refnum,dialog=0 
    1313        String/G base = "root:V_NXcanSAS_file" 
    1414         
     
    7474        Make/O/T/N=5 $(dataBase + ":attrVals") = {"SASdata","I","Q","NXdata","0",V_getDataEndTime(folderStr)} 
    7575        CreateStrNxCansas(fileID,dataParent,"","",empty,$(dataBase + ":attr"),$(dataBase + ":attrVals")) 
    76         // 
    77         // TODO: Reinstate Qdev/resolutions when I can fix the reader issue 
    78         // 
    7976        // Create qx and qy entry 
    8077        NewDataFolder/O/S $(dataBase + ":q") 
    81         Make/O/T/N=2 $(dataBase + ":q:attr") = {"units"}//,"resolutions"} 
    82         Make/O/T/N=2 $(dataBase + ":q:attrVals") = {"1/angstrom"}//,"Qdev"} 
     78        Make/O/T/N=2 $(dataBase + ":q:attr") = {"units","resolutions"} 
     79        Make/O/T/N=2 $(dataBase + ":q:attrVals") = {"1/angstrom","Qdev"} 
    8380        CreateVarNxCansas(fileID,dataParent,"sasdata","Q",qw,$(dataBase + ":q:attr"),$(dataBase + ":q:attrVals")) 
    8481        // Create i entry 
     
    137134         
    138135        NewDataFolder/O/S $(base) 
    139         SetDataFolder $(pathStr+folderStr) 
     136        SetDataFolder $("root:Packages:NIST:VSANS:"+folderStr) 
    140137         
    141138        // Check fullpath and dialog 
    142         fileID = NXcanSAS_OpenOrCreate(dialog,saveName,base) 
     139        fileID = NXcanSAS_OpenOrCreate(dialog,pathStr,base) 
    143140                 
    144141        Variable sasentry = NumVarOrDefault("root:Packages:NIST:gSASEntryNumber", 1) 
     
    309306                Make/O/N=(pixX,pixY) shadow 
    310307                Make/O/N=(2,pixX,pixY) SigmaQ_combined 
     308                ii=0 
    311309                do 
    312310                        jj = 0 
    313311                        do 
    314                                 nq = ii * pixX + jj 
     312                                nq = ii * pixY + jj 
    315313                                V_get2DResolution(qval[nq],phi[nq],r_dist[nq],folderStr,detStr,collimationStr,ret1,ret2,ret3) 
    316314                                qxy_vals[0][ii][jj] = qx_val[nq] 
     
    320318                                shadow[ii][jj] = ret3 
    321319                                jj+=1 
    322                         while(jj<pixX) 
     320//                      while(jj<pixX) 
     321                        while(jj<pixY) 
    323322                        ii+=1 
    324                 while(ii<pixY) 
     323//              while(ii<pixY) 
     324                while(ii<pixX) 
    325325v_toc() 
    326326 
     
    353353                NewDataFolder/O/S $(dataBase + ":i") 
    354354                Make/O/T/N=2 $(dataBase + ":i:attr") = {"units","uncertainties"} 
    355                  
    356355                Make/O/T/N=2 $(dataBase + ":i:attrVals") = {"1/cm","Idev"} 
    357356                CreateVarNxCansas(fileID,dataParent,"sasdata","I",data,$(dataBase + ":i:attr"),$(dataBase + ":i:attrVals")) 
Note: See TracChangeset for help on using the changeset viewer.