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.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS
Files:
8 edited

Legend:

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

    r1055 r1106  
    291291        //get relative monitor counts (should all be 10^8, since normalized in add step) 
    292292        // get transmission and trans error for SAM, EMP 
    293         // TODO -- verify that the  call to V_getMonitorCount() is really rescaled to 10^8, and saved is the "true" count 
    294  
    295         tmonsam = V_getMonitorCount("SAM")              //monitor count in SAM 
     293        // TODO -- verify that the  call to V_getBeamMonNormData() is really rescaled to 10^8, and saved is the "true" count 
     294 
     295        tmonsam = V_getBeamMonNormData("SAM")           //monitor count in SAM 
    296296        tsam = V_getSampleTransmission("SAM")           //SAM transmission 
    297297        sam_trans_err = V_getSampleTransError("SAM") 
    298298         
    299         tmonemp = V_getMonitorCount("EMP")              //monitor count in EMP 
     299        tmonemp = V_getBeamMonNormData("EMP")           //monitor count in EMP 
    300300        temp = V_getSampleTransmission("EMP")                   //trans emp 
    301301        emp_trans_err = V_getSampleTransError("EMP") 
    302302         
    303         tmonbgd = V_getMonitorCount("BGD")              //monitor count in BGD 
     303        tmonbgd = V_getBeamMonNormData("BGD")           //monitor count in BGD 
    304304 
    305305 
     
    437437        //get relative monitor counts (should all be 10^8, since normalized in add step) 
    438438        // get transmission and trans error for SAM, EMP 
    439         // TODO -- verify that the  call to V_getMonitorCount() is really rescaled to 10^8, and saved is the "true" count 
    440  
    441         tmonsam = V_getMonitorCount("SAM")              //monitor count in SAM 
     439        // TODO -- verify that the  call to V_getBeamMonNormData() is really rescaled to 10^8, and saved is the "true" count 
     440 
     441        tmonsam = V_getBeamMonNormData("SAM")           //monitor count in SAM 
    442442        tsam = V_getSampleTransmission("SAM")           //SAM transmission 
    443443        sam_trans_err = V_getSampleTransError("SAM") 
    444444         
    445         tmonbgd = V_getMonitorCount("BGD")              //monitor count in BGD 
     445        tmonbgd = V_getBeamMonNormData("BGD")           //monitor count in BGD 
    446446 
    447447 
     
    548548        //get relative monitor counts (should all be 10^8, since normalized in add step) 
    549549        // get transmission and trans error for SAM, EMP 
    550         // TODO -- verify that the  call to V_getMonitorCount() is really rescaled to 10^8, and saved is the "true" count 
    551  
    552         tmonsam = V_getMonitorCount("SAM")              //monitor count in SAM 
     550        // TODO -- verify that the  call to V_getBeamMonNormData() is really rescaled to 10^8, and saved is the "true" count 
     551 
     552        tmonsam = V_getBeamMonNormData("SAM")           //monitor count in SAM 
    553553        tsam = V_getSampleTransmission("SAM")           //SAM transmission 
    554554        sam_trans_err = V_getSampleTransError("SAM") 
    555555         
    556         tmonemp = V_getMonitorCount("EMP")              //monitor count in EMP 
     556        tmonemp = V_getBeamMonNormData("EMP")           //monitor count in EMP 
    557557        temp = V_getSampleTransmission("EMP")                   //trans emp 
    558558        emp_trans_err = V_getSampleTransError("EMP") 
     
    707707        //get relative monitor counts (should all be 10^8, since normalized in add step) 
    708708        // get transmission and trans error for SAM, EMP 
    709         // TODO -- verify that the  call to V_getMonitorCount() is really rescaled to 10^8, and saved is the "true" count 
    710          
    711         tmonsam = V_getMonitorCount("SAM")              //monitor count in SAM 
     709        // TODO -- verify that the  call to V_getBeamMonNormData() is really rescaled to 10^8, and saved is the "true" count 
     710         
     711        tmonsam = V_getBeamMonNormData("SAM")           //monitor count in SAM 
    712712        tsam = V_getSampleTransmission("SAM")           //SAM transmission 
    713713        sam_trans_err = V_getSampleTransError("SAM") 
    714714         
    715         tmonemp = V_getMonitorCount("EMP")              //monitor count in EMP 
     715        tmonemp = V_getBeamMonNormData("EMP")           //monitor count in EMP 
    716716        temp = V_getSampleTransmission("EMP")                   //trans emp 
    717717        emp_trans_err = V_getSampleTransError("EMP") 
    718718         
    719         tmonbgd = V_getMonitorCount("BGD")              //monitor count in BGD 
     719        tmonbgd = V_getBeamMonNormData("BGD")           //monitor count in BGD 
    720720 
    721721        // for proper scaling, get the time and actual monitor counts 
     
    870870        //get relative monitor counts (should all be 10^8, since normalized in add step) 
    871871        // get transmission and trans error for SAM, EMP 
    872         // TODO -- verify that the  call to V_getMonitorCount() is really rescaled to 10^8, and saved is the "true" count 
    873          
    874         tmonsam = V_getMonitorCount("SAM")              //monitor count in SAM 
     872        // TODO -- verify that the  call to V_getBeamMonNormData() is really rescaled to 10^8, and saved is the "true" count 
     873         
     874        tmonsam = V_getBeamMonNormData("SAM")           //monitor count in SAM 
    875875        tsam = V_getSampleTransmission("SAM")           //SAM transmission 
    876876        sam_trans_err = V_getSampleTransError("SAM") 
    877877         
    878         tmonbgd = V_getMonitorCount("BGD")              //monitor count in BGD 
     878        tmonbgd = V_getBeamMonNormData("BGD")           //monitor count in BGD 
    879879 
    880880        // for proper scaling, get the time and actual monitor counts 
     
    10011001        //get relative monitor counts (should all be 10^8, since normalized in add step) 
    10021002        // get transmission and trans error for SAM, EMP 
    1003         // TODO -- verify that the  call to V_getMonitorCount() is really rescaled to 10^8, and saved is the "true" count 
    1004          
    1005         tmonsam = V_getMonitorCount("SAM")              //monitor count in SAM 
     1003        // TODO -- verify that the  call to V_getBeamMonNormData() is really rescaled to 10^8, and saved is the "true" count 
     1004         
     1005        tmonsam = V_getBeamMonNormData("SAM")           //monitor count in SAM 
    10061006        tsam = V_getSampleTransmission("SAM")           //SAM transmission 
    10071007        sam_trans_err = V_getSampleTransError("SAM") 
    10081008         
    1009         tmonemp = V_getMonitorCount("EMP")              //monitor count in EMP 
     1009        tmonemp = V_getBeamMonNormData("EMP")           //monitor count in EMP 
    10101010        temp = V_getSampleTransmission("EMP")                   //trans emp 
    10111011        emp_trans_err = V_getSampleTransError("EMP") 
     
    11321132        //get relative monitor counts (should all be 10^8, since normalized in add step) 
    11331133        // get transmission and trans error for SAM, EMP 
    1134         // TODO -- verify that the  call to V_getMonitorCount() is really rescaled to 10^8, and saved is the "true" count 
    1135          
    1136         tmonsam = V_getMonitorCount("SAM")              //monitor count in SAM 
     1134        // TODO -- verify that the  call to V_getBeamMonNormData() is really rescaled to 10^8, and saved is the "true" count 
     1135         
     1136        tmonsam = V_getBeamMonNormData("SAM")           //monitor count in SAM 
    11371137        tsam = V_getSampleTransmission("SAM")           //SAM transmission 
    11381138        sam_trans_err = V_getSampleTransError("SAM") 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_FileCatalog.ipf

    r1105 r1106  
    651651        // Monitor Count Rate 
    652652        InsertPoints lastPoint,1,GMCR 
    653         GMCR[lastPoint]  = V_getMonitorCount(fname)/ctime               //total monitor count / total count time 
     653        GMCR[lastPoint]  = V_getBeamMonNormData(fname)/ctime            //total monitor count / total count time 
    654654 
    655655 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Read.ipf

    r1101 r1106  
    402402//monitor count 
    403403// TODO - verify that this is the correct monitor 
    404 Function V_getMonitorCount(fname) 
     404Function V_getControlMonitorCount(fname) 
    405405        String fname 
    406406         
     
    409409end 
    410410 
    411 Function V_getMonitor_preset(fname) 
     411Function V_getControlMonitor_preset(fname) 
    412412        String fname 
    413413         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_HDF5_Write.ipf

    r1100 r1106  
    828828//monitor count 
    829829// integer value 
    830 Function V_writeMonitorCount(fname,val) 
     830Function V_writeControlMonitorCount(fname,val) 
    831831        String fname 
    832832        Variable val 
     
    854854 
    855855//integer value 
    856 Function V_writeMonitor_preset(fname,val) 
     856Function V_writeControlMonitor_preset(fname,val) 
    857857        String fname 
    858858        Variable val 
     
    879879end 
    880880 
    881 Function V_writePreset(fname,str) 
     881Function V_writeControlPreset(fname,str) 
    882882        String fname,str 
    883883         
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_PatchFiles.ipf

    r1102 r1106  
    296296         
    297297        listWave[2][1] = "monitor_counts" 
    298         listWave[2][2] = num2str(V_getMonitorCount(fname)) 
     298//      listWave[2][2] = num2str(V_getControlMonitorCount(fname)) 
     299        listWave[2][2] = num2str(V_getBeamMonNormData(fname)) 
    299300         
    300301        return(0) 
     
    10751076        if ((selWave[2][0] & 2^4) != 0)         //"monitor_counts" 
    10761077                val = str2num(listWave[2][2]) 
    1077                 err = V_writeMonitorCount(fname,val) 
     1078//              err = V_writeControlMonitorCount(fname,val) 
     1079                err = V_writeBeamMonNormData(fname,val) 
    10781080        endif    
    10791081         
  • 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 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_Testing_Data_Procs.ipf

    r1095 r1106  
    136136                // 
    137137                // divide the monitor count by 1e8 to get a number small enough to write in the field. 
    138         V_writeMonitorCount(fileName,VCALC_getImon()/1e8) 
     138        V_writeBeamMonNormData(fileName,VCALC_getImon()/1e8) 
    139139 
    140140        // total detector count (sum of everything) 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/VSANS/V_WorkFolderUtils.ipf

    r1101 r1106  
    736736                Variable monCount,savedMonCount 
    737737                defmon=1e8                      //default monitor counts 
    738                 monCount = V_getMonitorCount(fname)                     // TODO -- this is read in since VCALC fakes this on output 
    739 //              monCount = V_getBeamMonNormData(fname)          // TODO -- I think this is the *real* one to read 
     738//              monCount = V_getControlMonitorCount(fname)                      // TODO -- this is read in since VCALC fakes this on output 
     739                monCount = V_getBeamMonNormData(fname)          // TODO -- I think this is the *real* one to read 
    740740                savedMonCount   = monCount 
    741741                scale = defMon/monCount         // scale factor to MULTIPLY data by to rescale to defmon 
Note: See TracChangeset for help on using the changeset viewer.