Ignore:
Timestamp:
Jan 17, 2017 8:37:19 AM (6 years ago)
Author:
srkline
Message:

adding procedures for:

simple save of a DIV file. no functionality to generate a DIV file yet, since I don't know how this will happen.

Simple dump of the file structure in a data "tree"

Verified that the error bars on the I(q) data are correctly calculated as standard error of the mean. There was never an issue with this, or with SANS calculations.

Started filling in "Correct" routines based on the SANS version. Only stubs present currently.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/VC_HDF5_VSANS_Utils.ipf

    r1002 r1019  
    11#pragma rtGlobals=1             // Use modern global access method. 
     2 
     3// 
     4// ******** 
     5// TODO -- figure out how much of this file is really used, and how much is 
     6//    simply garbage now. I make "fake" data files by starting with a real data file 
     7//    written from NICE, and then I re-write proper values and data arrays to it from  
     8//    simulations in VCALC. So I do not need to define the structure myself. 
     9// 
     10//   JAN 2017 
     11// 
     12// 
     13// 
     14// 
     15// 
    216 
    317// 
     
    200214 
    201215 
    202 // TODO 
    203 // currently, there are no dummy fill values or attributes for the fake DIV file 
    204 // 
    205 Proc Setup_VSANS_DIV_Struct() 
    206  
    207         // lays out the tree and fills with dummy values 
    208         H_Setup_VSANS_DIV_Structure() 
    209          
    210         // writes in the attributes 
    211 //      H_Fill_VSANS_Attributes() 
    212          
    213         // fill in with VCALC simulation bits 
    214 //      H_Fill_VSANS_wSim() 
    215          
    216 End 
    217  
    218 Proc Save_VSANS_DIV_Nexus(fileName) 
    219         String fileName="Test_VSANS_DIV_file" 
    220  
    221         // save as HDF5 (no attributes saved yet) 
    222         Save_VSANS_file("root:VSANS_DIV_file", fileName+".h5") 
    223          
    224 //      // read in a data file using the gateway-- reads from the home path 
    225 //      H_HDF5Gate_Read_Raw(fileName+".h5") 
    226 //       
    227 //      // after reading in a "partial" file using the gateway (to generate the xref) 
    228 //      // Save the xref to disk (for later use) 
    229 //      Save_HDF5___xref("root:"+fileName,"HDF5___xref") 
    230 //       
    231 //      // after you've generated the HDF5___xref, load it in and copy it 
    232 //      // to the necessary folder location. 
    233 //      Copy_HDF5___xref("root:VSANS_DIV_file", "HDF5___xref") 
    234 //       
    235 //      // writes out the contents of a data folder using the gateway 
    236 //      H_HDF5Gate_Write_Raw("root:VSANS_DIV_file", fileName+".h5") 
    237 // 
    238 //      // re-load the data file using the gateway-- reads from the home path 
    239 //      // now with attributes 
    240 //      H_HDF5Gate_Read_Raw(fileName+".h5") 
    241          
    242 End 
    243  
    244 ////////////// fake DIV file tests 
    245 // 
    246 // 
    247 //      Make/O/T/N=1    file_name       = "VSANS_DIV_test.h5" 
    248 // 
    249 // simple generation of a fake div file. for sans, nothing other than the creation date was written to the  
    250 // file header. nothing more is needed (possibly) 
    251 // 
    252 // TODO -- I want to re-visit the propagation of errors in the DIV file. No errors are ever calculated/saved  
    253 //   during the generation of the file, but there's no reason it couldn't. the idea is that the plex 
    254 //   is counted so long that the errors are insignificant compared to the data errors, but that may not 
    255 //   always be the case. A bit of math may prove this. or not. Plus, the situation for VSANS may be different. 
    256 // 
    257 // 
    258 // TODO -- make the number of pixels GLOBAL 
    259 // TODO -- there will be lots of work to do to develop the procedures necessary to actually generate the  
    260 //      9 data sets to become the DIV file contents. More complexity here than for the simple SANS case. 
    261 // 
    262 Proc H_Setup_VSANS_DIV_Structure() 
    263          
    264         NewDataFolder/O/S root:VSANS_DIV_file            
    265  
    266         NewDataFolder/O/S root:VSANS_DIV_file:entry      
    267                 Make/O/T/N=1    title   = "This is a fake DIV file for VSANS" 
    268                 Make/O/T/N=1    start_date      = "2015-02-28T08:15:30-5:00" 
    269                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument           
    270                         Make/O/T/N=1    name    = "NG3_VSANS" 
    271                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_B        
    272                         Make/O/D/N=(150,150)    data    = 1 + (enoise(0.1)) 
    273                         Make/O/D/N=(150,150)    linear_data_error       = 0.01*abs(gnoise(1)) 
    274                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MR               
    275                         Make/O/D/N=(48,128)     data    = 1 + (enoise(0.1)) 
    276                         Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1)) 
    277                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_ML               
    278                         Make/O/D/N=(48,128)     data    = 1 + (enoise(0.1)) 
    279                         Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1)) 
    280                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MT               
    281                         Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1)) 
    282                         Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1)) 
    283                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_MB               
    284                         Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1)) 
    285                         Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1)) 
    286                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FR               
    287                         Make/O/D/N=(48,128)     data    = 1 + (enoise(0.1)) 
    288                         Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1)) 
    289                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FL               
    290                         Make/O/D/N=(48,128)     data    = 1 + (enoise(0.1)) 
    291                         Make/O/D/N=(48,128)     linear_data_error       = 0.01*abs(gnoise(1)) 
    292                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FT               
    293                         Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1)) 
    294                         Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1)) 
    295                 NewDataFolder/O/S root:VSANS_DIV_file:entry:instrument:detector_FB               
    296                         Make/O/D/N=(128,48)     data    = 1 + (enoise(0.1)) 
    297                         Make/O/D/N=(128,48)     linear_data_error       = 0.01*abs(gnoise(1)) 
    298                          
    299         SetDataFolder root: 
    300  
    301 End 
    302  
    303  
    304  
    305  
    306  
    307  
    308  
    309  
    310  
    311  
    312  
    313  
    314  
    315  
    316 // 
    317 // saves a specified folder, with a given filename. 
    318 // saves to the home path 
    319 // 
    320 Proc Save_VSANS_file(dfPath, filename) 
    321         String dfPath   ="root:VSANS_file"              // e.g., "root:FolderA" or ":" 
    322         String filename = "Test_VSANS_file.h5" 
    323          
    324         H_NXSANS_SaveGroupAsHDF5(dfPath, filename) 
    325 End 
    326  
    327  
    328 //       
    329 // this is my procedure to save the folders to HDF5, once I've filled the folder tree 
    330 // 
    331 // this does NOT save attributes, but gets the folder structure correct 
    332 // 
    333 Function H_NXSANS_SaveGroupAsHDF5(dfPath, filename) 
    334         String dfPath   // e.g., "root:FolderA" or ":" 
    335         String filename 
    336  
    337         Variable result = 0     // 0 means no error 
    338          
    339         Variable fileID 
    340         HDF5CreateFile/P=home /O /Z fileID as filename 
    341         if (V_flag != 0) 
    342                 Print "HDF5CreateFile failed" 
    343                 return -1 
    344         endif 
    345  
    346         HDF5SaveGroup /IGOR=0 /O /R /Z $dfPath, fileID, "." 
    347 //      HDF5SaveGroup /O /R /Z $dfPath, fileID, "." 
    348         if (V_flag != 0) 
    349                 Print "HDF5SaveGroup failed" 
    350                 result = -1 
    351         endif 
    352          
    353         HDF5CloseFile fileID 
    354  
    355         return result 
    356 End 
     216 
     217 
     218 
     219 
     220 
     221 
     222 
     223 
     224 
     225 
     226 
     227 
     228 
     229 
     230 
    357231 
    358232// passing null file string presents a dialog 
Note: See TracChangeset for help on using the changeset viewer.