Ignore:
Timestamp:
Mar 7, 2016 11:55:46 AM (7 years ago)
Author:
srkline
Message:

CHANGES to SANS:
Now allow 4 files to be combined in one step. This required modification of one routine in NIST_XML to allow an extra file name, and significant addition to the NSORT panel to allow an (optional) 4th data file. behaviors are still the same as before with 2, 3, or 4 sets being allowed. The "combine table" also allows up to 4 files to be combined (can be mixed, 2, 3, 4 all allowed).

More addtions to VSANS present as well, not specific changes, but in-progress changes to the beam center handling and ciombining data to 1D.

File:
1 edited

Legend:

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

    r982 r983  
    544544//     wave as passed in, or if it will only write as DP. 
    545545// -- do I need to write separate functions for real, integer, etc.? 
     546// -- the lines to create a missing group have been commented out to avoid filling 
     547//    in missing fields that should have been generated by the data writer. Need to make 
     548//    a separate function that will write and generate if needed, and use this in specific cases 
     549//    only if I really have to force it. 
    546550//       
    547551// -x change the /P=home to the user-defined data path (catPathName)             
     
    578582//              groupName = "/" + NXentry_name + groupName 
    579583                Print "groupName = ",groupName 
     584                HDF5OpenGroup /Z fileID , groupName, groupID 
     585 
     586                if(!groupID) 
     587                // don't create the group if the name isn't right -- throw up an error 
     588                        //HDF5CreateGroup /Z fileID, groupName, groupID 
     589                        err = 1 
     590                        HDF5CloseFile /Z fileID 
     591                        DoAlert 0, "HDF5 group does not exist "+groupName+varname 
     592                        return(err) 
     593                else 
     594                        // get attributes and save them 
     595                        //HDF5ListAttributes /Z fileID, groupName    this is returning null. expect it to return semicolon delimited list of attributes  
     596                        //Wave attributes = S_HDF5ListAttributes 
     597                endif 
     598         
     599                HDF5SaveData /O /Z /IGOR=0 wav, groupID, varName 
     600                if (V_flag != 0) 
     601                        err = 1 
     602                        abort "Cannot save wave to HDF5 dataset " + varName 
     603                endif    
     604                 
     605                 
     606                //attributes - something could be added here as optional parameters and flagged 
     607//              String attributes = "units" 
     608//              Make/O/T/N=1 tmp 
     609//              tmp[0] = "dimensionless" 
     610//              HDF5SaveData /O /Z /IGOR=0 /A=attributes tmp, groupID, varName 
     611//              if (V_flag != 0) 
     612//                      err = 1 
     613//                      abort "Cannot save attributes to HDF5 dataset" 
     614//              endif    
     615        catch 
     616 
     617        endtry 
     618 
     619// it is not necessary to close the group here. HDF5CloseFile will close the group as well       
     620        if(groupID) 
     621                HDF5CloseGroup /Z groupID 
     622        endif 
     623         
     624        if(fileID) 
     625                HDF5CloseFile /Z fileID  
     626        endif 
     627 
     628        setDataFolder $cDF 
     629        return err 
     630end 
     631 
     632//Write Wave 'wav' to hdf5 file 'fname' 
     633//Based on code from ANSTO (N. Hauser. nha 8/1/09) 
     634// 
     635// TODO 
     636// 
     637// -x change the /P=home to the user-defined data path (catPathName)             
     638// 
     639Function V_WriteTextWaveToHDF(fname, groupName, varName, wav) 
     640        String fname, groupName, varName 
     641        Wave/T wav 
     642         
     643        variable err=0, fileID,groupID 
     644        String cDF = getDataFolder(1), temp 
     645        String NXentry_name 
     646         
     647        try      
     648                HDF5OpenFile/P=catPathName /Z fileID  as fname  //open file read-write 
     649                if(!fileID) 
     650                        err = 1 
     651                        abort "HDF5 file does not exist" 
     652                endif 
     653                 
     654                //get the NXentry node name 
     655                HDF5ListGroup /TYPE=1 fileID, "/" 
     656                //remove trailing ; from S_HDF5ListGroup 
     657                 
     658                Print "S_HDF5ListGroup = ",S_HDF5ListGroup 
     659                 
     660                NXentry_name = S_HDF5ListGroup 
     661                NXentry_name = ReplaceString(";",NXentry_name,"") 
     662                if(strsearch(NXentry_name,":",0)!=-1) //more than one entry under the root node 
     663                        err = 1 
     664                        abort "More than one entry under the root node. Ambiguous" 
     665                endif  
     666 
     667                //concatenate NXentry node name and groupName 
     668                // SRK - NOV2015 - dropped this and require the full group name passed in 
     669//              groupName = "/" + NXentry_name + groupName 
     670                Print "groupName = ",groupName 
     671 
    580672                HDF5OpenGroup /Z fileID , groupName, groupID 
    581673 
     
    612704 
    613705        endtry 
    614  
    615 // it is not necessary to close the group here. HDF5CloseFile will close the group as well       
     706         
    616707        if(groupID) 
    617708                HDF5CloseGroup /Z groupID 
     
    626717end 
    627718 
    628 //Write Wave 'wav' to hdf5 file 'fname' 
    629 //Based on code from ANSTO (N. Hauser. nha 8/1/09) 
    630 // 
    631 // TODO 
    632 // 
    633 // -x change the /P=home to the user-defined data path (catPathName)             
    634 // 
    635 Function V_WriteTextWaveToHDF(fname, groupName, varName, wav) 
    636         String fname, groupName, varName 
    637         Wave/T wav 
    638          
    639         variable err=0, fileID,groupID 
    640         String cDF = getDataFolder(1), temp 
    641         String NXentry_name 
    642          
    643         try      
    644                 HDF5OpenFile/P=catPathName /Z fileID  as fname  //open file read-write 
    645                 if(!fileID) 
    646                         err = 1 
    647                         abort "HDF5 file does not exist" 
    648                 endif 
    649                  
    650                 //get the NXentry node name 
    651                 HDF5ListGroup /TYPE=1 fileID, "/" 
    652                 //remove trailing ; from S_HDF5ListGroup 
    653                  
    654                 Print "S_HDF5ListGroup = ",S_HDF5ListGroup 
    655                  
    656                 NXentry_name = S_HDF5ListGroup 
    657                 NXentry_name = ReplaceString(";",NXentry_name,"") 
    658                 if(strsearch(NXentry_name,":",0)!=-1) //more than one entry under the root node 
    659                         err = 1 
    660                         abort "More than one entry under the root node. Ambiguous" 
    661                 endif  
    662  
    663                 //concatenate NXentry node name and groupName 
    664                 // SRK - NOV2015 - dropped this and require the full group name passed in 
    665 //              groupName = "/" + NXentry_name + groupName 
    666                 Print "groupName = ",groupName 
    667  
    668                 HDF5OpenGroup /Z fileID , groupName, groupID 
    669  
    670                 if(!groupID) 
    671                 // don't create the group it the name isn't right -- throw up an error 
    672                         //HDF5CreateGroup /Z fileID, groupName, groupID 
    673                         err = 1 
    674                         HDF5CloseFile /Z fileID 
    675                         DoAlert 0, "HDF5 group does not exist "+groupName+varname 
    676                         return(err) 
    677                 else 
    678                         // get attributes and save them 
    679                         //HDF5ListAttributes /Z fileID, groupName    this is returning null. expect it to return semicolon delimited list of attributes  
    680                         //Wave attributes = S_HDF5ListAttributes 
    681                 endif 
    682          
    683                 HDF5SaveData /O /Z /IGOR=0 wav, groupID, varName 
    684                 if (V_flag != 0) 
    685                         err = 1 
    686                         abort "Cannot save wave to HDF5 dataset " + varName 
    687                 endif    
    688                  
    689                  
    690                 //attributes - something could be added here as optional parameters and flagged 
    691 //              String attributes = "units" 
    692 //              Make/O/T/N=1 tmp 
    693 //              tmp[0] = "dimensionless" 
    694 //              HDF5SaveData /O /Z /IGOR=0 /A=attributes tmp, groupID, varName 
    695 //              if (V_flag != 0) 
    696 //                      err = 1 
    697 //                      abort "Cannot save attributes to HDF5 dataset" 
    698 //              endif    
    699         catch 
    700  
    701         endtry 
    702          
    703         if(groupID) 
    704                 HDF5CloseGroup /Z groupID 
    705         endif 
    706          
    707         if(fileID) 
    708                 HDF5CloseFile /Z fileID  
    709         endif 
    710  
    711         setDataFolder $cDF 
    712         return err 
    713 end 
    714  
    715719////////////////////////////// 
    716720////////////////////////////// 
    717721////////////////////////////// 
    718722 
     723// TODO: 
     724// -- this must be called as needed to force a re-read of the data from disk 
     725//    "as needed" means that when an operation is done that needs to ensure 
     726//     a fresh read from disk, it must take care of the kill. 
     727// -- the ksBaseDFPath needs to be removed. It's currently pointing to RawVSANS, which is 
     728//    really not used as intended anymore. 
     729// 
    719730Function V_KillNamedDataFolder(fname) 
    720731        String fname 
     
    735746//returns the name as a string without the ".fbdfasga" extension 
    736747// 
    737 // returns the input string if a"." can't be found (maybe it wasn't there" 
     748// returns the input string if a "." can't be found (maybe it wasn't there) 
    738749Function/S V_RemoveDotExtension(item) 
    739750        String item 
Note: See TracChangeset for help on using the changeset viewer.