Ignore:
Timestamp:
Jun 14, 2018 12:18:24 PM (4 years ago)
Author:
srkline
Message:

Added functions to check that files in a protocol, including the sample data are all from the same configuration. In SANS, the only flag was a beam center mismatch. In VSANS, a more complete check of the configuration in necessary.

Changed all instances of calls to the read and normalize the monitor count to use the "norm"al monitor, not the value listed in the Control block.

File:
1 edited

Legend:

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

    r1101 r1106  
    355355        Endif 
    356356         
    357         V_MakeProtocolFromPanel( $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtocol) ) 
    358         String/G  root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr = newProtocol 
    359          
     357        Variable err 
     358        err = V_MakeProtocolFromPanel( $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtocol) ) 
     359        if(err) 
     360                DoAlert 0,"BGD and EMP files do not have the same configuration. No protocol saved." 
     361                KillWaves/Z $("root:Packages:NIST:VSANS:Globals:Protocols:" + newProtocol) 
     362        else 
     363                String/G  root:Packages:NIST:VSANS:Globals:Protocols:gProtoStr = newProtocol 
     364        endif 
    360365        //the data folder WAS changed above, this must be reset to root: 
    361366        SetDatafolder root: 
     
    369374// TODO 
    370375// -- update for 12 points 
     376// 
     377// returns error==1 if files (emp, bgd) are not of the same configuration 
    371378// 
    372379Function V_MakeProtocolFromPanel(w) 
     
    526533        //currently unused 
    527534        w[11] = "" 
    528                  
    529         return(0) 
     535 
     536 
     537//      check that w[0](BGD) and w[1](EMP) are from matching configurations 
     538        if(cmpstr(w[0],"none")==0 || cmpstr(w[0],"ask")==0) 
     539                // no file specified for BGD, so no issues 
     540                return(0) 
     541        endif 
     542        if(cmpstr(w[1],"none")==0 || cmpstr(w[1],"ask")==0) 
     543                // no file specified for EMP, so no issues 
     544                return(0) 
     545        endif 
     546        Variable matchOK 
     547        // returns 1 for match , 0 if no match 
     548        matchOK = V_RawFilesMatchConfig(StringFromList(0, w[0], ","),StringFromList(0, w[1], ",")) 
     549         
     550        return(!matchOK) 
    530551End 
    531552 
     
    930951        String temp="root:Packages:NIST:VSANS:Globals:Protocols:tempProtocol" 
    931952        Wave/T w=$temp 
    932         Variable ii=0,num=12 
     953        Variable ii=0,num=12,err 
    933954        do 
    934955                w[ii] = "" 
     
    936957        while(ii<num) 
    937958         
    938         V_MakeProtocolFromPanel(w) 
    939  
     959         
     960        err = V_MakeProtocolFromPanel(w) 
     961        if(err) 
     962                DoAlert 0,"BGD and EMP files do not have the same configuration." 
     963                return(0) 
     964        endif 
     965         
    940966        //the "current" protocol is the "tempProtocol" that was parsed from the panel input 
    941967        //set the global, so that the data writing routine can find the protocol wave (fatal otherwise) 
     
    19071933        //7 = beginning trim points 
    19081934        //8 = end trim points 
    1909         //9 = unused 
     1935        //9 = collimation type for reduced data 
    19101936        //10 = unused 
    19111937        //11 = unused 
     
    19571983        // -- this may not be the most reliable way to pass the file name (for naming of the saved file later) 
    19581984        SVAR file_name = root:file_Name 
    1959         String samFileLoaded = file_name                //keep a copy of the sample file loaded 
     1985        String samFileLoaded = file_name                //keep a copy of the sample file loaded  
    19601986         
    19611987        //always update 
    19621988        V_UpdateDisplayInformation(ActiveType) 
     1989 
     1990 
     1991// TODO -- the logic here is flawed 
     1992// check that the SAM file is of the same configuration as BGD or EMP, if they are used 
     1993// need to be able to handle all of the permutations AND catch the "ask" cases 
     1994         
     1995        Variable filesMatch=1           //assume OK 
     1996         
     1997        if(cmpstr("none",prot[0])==0 || cmpstr("ask",prot[0])==0) 
     1998                // BGD not identified, try EMP. 
     1999                if(cmpstr("none",prot[1])==0 || cmpstr("ask",prot[1])==0) 
     2000                        // EMP not identified either, no mismatch possible 
     2001                else 
     2002                        // compare to EMP 
     2003                        filesMatch = V_RawFilesMatchConfig(samFileLoaded,StringFromList(0,prot[1],",")) 
     2004                endif 
     2005        else 
     2006                // BGD is identified, compare 
     2007                filesMatch = V_RawFilesMatchConfig(samFileLoaded,StringFromList(0,prot[0],",")) 
     2008        endif 
     2009 
     2010        if(filesMatch == 0) 
     2011                Abort "SAM data is not the same configuration as the protocol." 
     2012                SetDataFolder root: 
     2013        endif            
     2014 
    19632015 
    19642016 
Note: See TracChangeset for help on using the changeset viewer.