Ignore:
Timestamp:
Jun 8, 2017 1:27:07 PM (5 years ago)
Author:
srkline
Message:

Significant changes to the base READ of individual data fields from data files. Now, if the field requested is from a WORK file, and it does not exist, an error condition is returned (or a null wave). Calling procedures are responsible for handling errors. This prevents a string of open file dialogs if fields are missing from a file if they were never in the file to begin with (like sensor logs, polarization hardware, etc.)

New get/write calls were added for the updated temperature sensor fields.

group_ID is now only in the sample block, not the duplicated in the reduction block, and is correctly a number not a string.

File:
1 edited

Legend:

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

    r1042 r1044  
    2222 
    2323// the list of WORK Folders 
    24 Strconstant ksWorkFolderList = "RAW;SAM;EMP;BGD;COR;DIV;ABS;MSK;CAL;STO;SUB;DRK;ADJ;VCALC;RawVSANS;" 
     24// RawVSANS does not behave as a WORK folder, but it is local. so add it in explicitly to the list if needed 
     25// VCALC behaves *almost* as a WORK folder, but it is local. so add it in explicitly to the list if needed 
     26//Strconstant ksWorkFolderList = "RAW;SAM;EMP;BGD;COR;DIV;ABS;MSK;CAL;STO;SUB;DRK;ADJ;VCALC;RawVSANS;" 
    2527Strconstant ksWorkFolderListShort = "RAW;SAM;EMP;BGD;COR;DIV;ABS;MSK;CAL;STO;SUB;DRK;ADJ;" 
    2628 
     
    416418//      endif 
    417419         
    418         // if base_name is from my list of WORK folders, then base_name = "" 
     420        // if base_name is from my list of WORK folders + RawVSANS;, then base_name = "" 
    419421        // use a stringSwitch? WhichListItem? 
    420         Variable isFolder = WhichListItem(base_name,ksWorkFolderList) 
     422        Variable isFolder = WhichListItem(base_name,ksWorkFolderListShort+"RawVSANS;") 
    421423        if(isFolder != -1) 
    422424                base_name = "" 
     
    516518 
    517519// read a single real value  
    518 // - fname passed in is the full path to the file on disk 
     520// - fname passed in is the full path to the file on disk --OR-- a WORK folder 
    519521// - path is the path to the value in the HDF tree 
    520522// 
     523/// -- if data requested from a WORK or VCALC folder: 
    521524// check to see if the value exists (It will be a wave) 
     525// -- if it does, return the value from the local WORK folder 
     526//              if it does not exist, return DUMMY value 
     527// 
     528//// -- if data requested from a file: 
     529// check to see if the value exists locally in RawVSANS (It will be a wave) 
    522530// -- if it does, return the value from the local folder 
    523531// -- if not, read the file in, then return the value 
    524532// 
    525 // TODO: 
    526 // currently, the work folders have the following path - so passing in "RAW" as fname 
    527 // will take some re-configuring.  
    528 //  root:Packages:NIST:VSANS:RAW:entry:instrument:detector_FL:distance 
    529 // -- be sure this read from work folders is not broken in the future, and is passed to ALL of the 
    530 //    top-level R/W routines. (Write is necessary ONLY for SIM data files. Patch is direct to disk.) 
     533// 
    531534Function V_getRealValueFromHDF5(fname,path) 
    532535        String fname,path 
     
    534537        String folderStr="" 
    535538        Variable valExists=0 
     539        Variable errorValue = -999999 
    536540         
    537541        folderStr = V_RemoveDotExtension(V_GetFileNameFromPathNoSemi(fname)) 
    538542 
    539 // check for a work folder first (note that "entry" is now NOT doubled) 
    540         if(Exists("root:Packages:NIST:VSANS:"+folderStr+":"+path)) 
    541                 Wave/Z w = $("root:Packages:NIST:VSANS:"+folderStr+":"+path) 
    542                 return(w[0]) 
    543         endif 
    544          
     543// (1) if requesting data from a WORK folder, get it, or report error 
     544        Variable isWORKFolder = WhichListItem(fname,ksWorkFolderListShort+"VCALC;") 
     545        if(isWORKFolder != -1)          //requesting value from a WORK folder (not RawVSANS) 
     546        // check for a work folder first (note that "entry" is now NOT doubled) 
     547                if(Exists("root:Packages:NIST:VSANS:"+folderStr+":"+path)) 
     548                        Wave/Z w = $("root:Packages:NIST:VSANS:"+folderStr+":"+path) 
     549                        return(w[0]) 
     550                else 
     551                        return(errorValue) 
     552                endif 
     553        endif 
     554 
     555 
     556        // (2) requesting from a file. 
     557        // look locally in RawVSANS if possible, or if not, load in the data from disk 
     558        // - if thee both fail, report an error 
    545559        if(Exists(ksBaseDFPath+folderStr+":"+path)) 
    546560                valExists=1 
     
    560574                return(w[0]) 
    561575        else 
    562                 return(-999999) 
     576                return(errorValue) 
    563577        endif    
    564578End 
     
    574588// -- if not, read the file in, then return the value 
    575589// 
     590// if the wave is null, then that is returned, and the calling function is responsible 
     591// 
    576592Function/WAVE V_getRealWaveFromHDF5(fname,path) 
    577593        String fname,path 
     
    582598        folderStr = V_RemoveDotExtension(V_GetFileNameFromPathNoSemi(fname)) 
    583599 
    584 // check for a work folder first (note that "entry" is NOT doubled) 
    585         if(Exists("root:Packages:NIST:VSANS:"+folderStr+":"+path)) 
    586                 Wave wOut = $("root:Packages:NIST:VSANS:"+folderStr+":"+path) 
    587                 return wOut 
    588         endif 
    589                  
     600// (1) if requesting data from a WORK folder, get it 
     601// no need to check for any existence, null return is OK 
     602        Variable isWORKFolder = WhichListItem(fname,ksWorkFolderListShort+"VCALC;") 
     603        if(isWORKFolder != -1)          //requesting value from a WORK folder (not RawVSANS) 
     604//      // check for a work folder first (note that "entry" is now NOT doubled) 
     605//              if(Exists("root:Packages:NIST:VSANS:"+folderStr+":"+path)) 
     606                        Wave/Z wOut = $("root:Packages:NIST:VSANS:"+folderStr+":"+path) 
     607                        return wOut 
     608        endif 
     609 
     610//// check for a work folder first (note that "entry" is NOT doubled) 
     611//      if(Exists("root:Packages:NIST:VSANS:"+folderStr+":"+path)) 
     612//              Wave wOut = $("root:Packages:NIST:VSANS:"+folderStr+":"+path) 
     613//              return wOut 
     614//      endif 
     615         
     616// (2) requesting from a file 
    590617        if(Exists(ksBaseDFPath+folderStr+":"+path)) 
    591618                valExists=1 
     
    616643// -- if not, read the file in, then return the value 
    617644// 
     645// if the wave is null, then that is returned, and the calling function is responsible 
     646// 
    618647Function/WAVE V_getTextWaveFromHDF5(fname,path) 
    619648        String fname,path 
     
    624653        folderStr = V_RemoveDotExtension(V_GetFileNameFromPathNoSemi(fname)) 
    625654 
    626 // check for a work folder first (note that "entry" is NOT doubled) 
    627         if(Exists("root:Packages:NIST:VSANS:"+folderStr+":"+path)) 
    628                 Wave/T wOut = $("root:Packages:NIST:VSANS:"+folderStr+":"+path) 
    629                 return wOut 
    630         endif 
    631          
     655// (1) if requesting data from a WORK folder, get it 
     656// no need to check for any existence, null return is OK 
     657        Variable isWORKFolder = WhichListItem(fname,ksWorkFolderListShort+"VCALC;") 
     658        if(isWORKFolder != -1)          //requesting value from a WORK folder (not RawVSANS) 
     659//      // check for a work folder first (note that "entry" is now NOT doubled) 
     660//              if(Exists("root:Packages:NIST:VSANS:"+folderStr+":"+path)) 
     661                        Wave/Z/T wOut = $("root:Packages:NIST:VSANS:"+folderStr+":"+path) 
     662                        return wOut 
     663        endif 
     664         
     665//// check for a work folder first (note that "entry" is NOT doubled) 
     666//      if(Exists("root:Packages:NIST:VSANS:"+folderStr+":"+path)) 
     667//              Wave/T wOut = $("root:Packages:NIST:VSANS:"+folderStr+":"+path) 
     668//              return wOut 
     669//      endif 
     670 
     671// (2) requesting from a file    
    632672        if(Exists(ksBaseDFPath+folderStr+":"+path)) 
    633673                valExists=1 
     
    674714 
    675715// read a single string 
    676 // - fname passed in is the full path to the file on disk 
     716// - fname passed in is the full path to the file on disk --OR-- a WORK folder 
    677717// - path is the path to the value in the HDF tree 
    678718// - num is the number of characters in the VAX string 
     719// 
     720/// -- if data requested from a WORK or VCALC folder: 
    679721// check to see if the value exists (It will be a wave) 
     722// -- if it does, return the value from the local WORK folder 
     723//              if it does not exist, return DUMMY value 
     724// 
     725//// -- if data requested from a file: 
     726// check to see if the value exists locally in RawVSANS (It will be a wave) 
    680727// -- if it does, return the value from the local folder 
    681728// -- if not, read the file in, then return the value 
     
    691738        String folderStr="" 
    692739        Variable valExists=0 
     740        String errorString = "The specified wave does not exist: " + path 
    693741         
    694742        folderStr = V_RemoveDotExtension(V_GetFileNameFromPathNoSemi(fname)) 
    695743 
    696 // check for a work folder first (note that "entry" is NOT doubled) 
    697         if(Exists("root:Packages:NIST:VSANS:"+folderStr+":"+path)) 
    698                 Wave/Z/T tw = $("root:Packages:NIST:VSANS:"+folderStr+":"+path) 
    699                 return(tw[0]) 
    700         endif 
    701          
     744// (1) if requesting data from a WORK folder, get it, or report error 
     745        Variable isWORKFolder = WhichListItem(fname,ksWorkFolderListShort+"VCALC;") 
     746        if(isWORKFolder != -1)          //requesting value from a WORK folder (not RawVSANS) 
     747        // check for a work folder first (note that "entry" is now NOT doubled) 
     748                if(Exists("root:Packages:NIST:VSANS:"+folderStr+":"+path)) 
     749                        Wave/Z/T tw = $("root:Packages:NIST:VSANS:"+folderStr+":"+path) 
     750                        return(tw[0]) 
     751                else 
     752                        return(errorSTring) 
     753                endif 
     754        endif 
     755 
     756// (2) requesting from a file. 
     757// look locally in RawVSANS if possible, or if not, load in the data from disk 
     758// - if thee both fail, report an error  
    702759        if(Exists(ksBaseDFPath+folderStr+":"+path)) 
    703760                valExists=1 
     
    722779                return(tw[0]) 
    723780        else 
    724                 return("The specified wave does not exist: " + path) 
     781                return(errorString) 
    725782        endif 
    726783End 
Note: See TracChangeset for help on using the changeset viewer.