Ignore:
Timestamp:
Oct 28, 2014 10:38:51 AM (8 years ago)
Author:
srkline
Message:

Correcting the search in the patch panel for certain cases where multiple run numbers could be returned if they matched the year.

Adding routines and preferences to be able to add together raw data files with different attenuation. Not sure why this was not possible in the past. There must be a good reason for this. This is toggled on/off with a SANS preference checkbox. Default is OFF

Adding to Transmission "guessing" to show buttons to bump the guess to one more or one fewer character, rather than forcing an exit if the match is not correct.

Location:
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/PatchFiles.ipf

    r741 r948  
    196196//              list = ReplaceString(",", list, ";") 
    197197//              newList = list 
     198 
     199// cut this 0ct 2014 -- the ListMatch at the bottom returns bad results when certain conditions are met: 
     200// -- for example OCT14nnn runs will return all of the OCT141nn runs if you try to match run 141 
     201// 
     202//               
     203//              list = ExpandNumRanges(match)           //now simply comma delimited 
     204//              num=ItemsInList(list,",") 
     205//              for(ii=0;ii<num;ii+=1) 
     206//                      item = StringFromList(ii,list,",") 
     207//                      val=str2num(item) 
     208//                      //make a three character string of the run number 
     209//                      if(val<10) 
     210//                              numStr = "00"+num2str(val) 
     211//                      else 
     212//                              if(val<100) 
     213//                                      numStr = "0"+num2str(val) 
     214//                              else 
     215//                                      numStr = num2str(val) 
     216//                              Endif 
     217//                      Endif 
     218//                      runList += ListMatch(newList,"*"+numStr+"*",";") 
     219//                       
     220//              endfor           
    198221                 
     222// oct 2014 -- try this way:     
    199223                list = ExpandNumRanges(match)           //now simply comma delimited 
    200224                num=ItemsInList(list,",") 
     
    202226                        item = StringFromList(ii,list,",") 
    203227                        val=str2num(item) 
    204                         //make a three character string of the run number 
    205                         if(val<10) 
    206                                 numStr = "00"+num2str(val) 
    207                         else 
    208                                 if(val<100) 
    209                                         numStr = "0"+num2str(val) 
    210                                 else 
    211                                         numStr = num2str(val) 
    212                                 Endif 
    213                         Endif 
    214                         runList += ListMatch(newList,"*"+numStr+"*",";") 
     228 
     229                        runList += GetFileNameFromPathNoSemi(FindFileFromRunNumber(val)) + ";" 
    215230                         
    216231                endfor 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Transmission.ipf

    r888 r948  
    18241824        Variable ii,row 
    18251825        Variable transTableExists 
     1826         
     1827        Variable/G root:myGlobals:TransHeaderInfo:gNumMatchChars = numChars 
     1828         
    18261829        Make/O/D/N=0 root:myGlobals:TransHeaderInfo:matchRows 
    18271830        Wave matchRows=root:myGlobals:TransHeaderInfo:matchRows 
    18281831         
    1829         transTableExists = WinType("TransFileTable") 
    1830         if (transTableExists != 0) 
     1832   transTableExists = WinType("TransFileTable") 
     1833   if (transTableExists != 0) 
    18311834                GetSelection table,transFileTable,1      
    18321835                row = V_startRow 
     
    18611864        String/G root:myGlobals:TransHeaderInfo:gResultStr = result 
    18621865         
    1863         DoWindow/F ConfirmGuess         //it really shouldn't exist... 
     1866        DoWindow/F ConfirmGuess         //if being called recursively, the panel is already up 
    18641867        if(V_flag==1) 
    18651868                TitleBox title0,pos={9,5},variable=root:myGlobals:TransHeaderInfo:gResultStr 
     
    18691872                TitleBox title0,pos={15,8},size={560,32} 
    18701873                TitleBox title0,variable= root:myGlobals:TransHeaderInfo:gResultStr 
    1871                 Button button0,pos={9,150},size={190,20},proc=DoAssignTransButtonProc,title="Assign Transmission Files" 
    1872                 Button button2,pos={341,150},size={90,20},proc=DoTryAgainButtonProc,title="Try Again" 
    1873                 ToolsGrid snap=1,visible=1 
     1874                Button button0,pos={240,150},size={190,20},proc=DoAssignTransButtonProc,title="Assign Transmission Files" 
     1875                Button button1,pos={10,150},size={100,20},proc=DoTryAgainMoreButtonProc,title="Try Again (+)" 
     1876                Button button2,pos={120,150},size={100,20},proc=DoTryAgainFewerButtonProc,title="Try Again (-)" 
     1877                Button button3,pos={450,150},size={70,20},proc=SkipTransButtonProc,title="Skip" 
    18741878        endif 
    18751879         
     
    18781882// figure out from the return code what the user did... 
    18791883// 1 = OK, accept guess (assign, and calculate immediately) 
    1880 // 2 = try again 
    1881 // 0 = cancel, don't do anything (not used, simply try again) 
     1884// 2 = try again (+) // NO - not an "exit" code 
     1885// 3 = try again (-)    //NO - not an "exit" code 
     1886// 0 = cancel, don't do anything, drop out of case 
    18821887        NVAR guessOK = root:myGlobals:TransHeaderInfo:GuessOK 
    18831888         
     
    18861891                case 1:          
    18871892                        // accept guess (assign, and calculate immediately) 
     1893                        num=numpnts(matchRows)          //this may have changed 
    18881894                        for(ii=0;ii<num;ii+=1) 
    18891895                                snam[matchRows[ii]] = tnam[row] 
     
    18921898                        endfor                   
    18931899                        break                                            
    1894                 case 2: //try again (with more / fewer characters?)      
    1895                         //              does nothing right now 
     1900                case 2: //try again (with more characters) 
     1901                        // not an exit code, does nothing 
    18961902                        break 
    1897                 case 0: 
     1903                case 3: //try again (with fewer characters) 
     1904                        // not an exit code, can't do anything 
     1905                        break 
     1906                case 0: // cancel 
    18981907                        // do nothing 
    18991908                        break 
     
    19932002// files are wrong, let the user try it again 
    19942003// sets a flag, nothing else 
    1995 Function DoTryAgainButtonProc(ba) : ButtonControl 
     2004Function DoTryAgainMoreButtonProc(ba) : ButtonControl 
    19962005        STRUCT WMButtonAction &ba 
    19972006 
     2007        Variable row,ii,num 
     2008        String tmpStr 
     2009         
     2010        Wave/T sw = root:myGlobals:TransHeaderInfo:S_Labels             //Sample file labels 
     2011        Wave/T tw = root:myGlobals:TransHeaderInfo:T_Labels             //trans file labels 
     2012        Wave/T tnam = root:myGlobals:TransHeaderInfo:T_FileNames        //trans file names 
     2013        Wave/T snam = root:myGlobals:TransHeaderInfo:S_TRANS_FileNames  //Scattering - trans correspondence 
     2014        Wave/T samfile = root:myGlobals:TransHeaderInfo:S_FileNames     //Scattering file name 
     2015         
    19982016        switch( ba.eventCode ) 
    19992017                case 2: // mouse up 
    20002018                        // click code here 
    20012019                        Variable/G root:myGlobals:TransHeaderInfo:GuessOK= 2 
    2002                         DoWindow/K ConfirmGuess 
     2020                        NVAR numChars = root:myGlobals:TransHeaderInfo:gNumMatchChars 
     2021                        SVAR resultStr = root:myGlobals:TransHeaderInfo:gResultStr 
     2022 
     2023                        numChars += 1 
     2024 
     2025                        Make/O/D/N=0 root:myGlobals:TransHeaderInfo:matchRows 
     2026                        Wave matchRows=root:myGlobals:TransHeaderInfo:matchRows 
     2027         
     2028                   //transTableExists = WinType("TransFileTable") 
     2029                //if (transTableExists != 0) 
     2030                        GetSelection table,transFileTable,1      
     2031                        row = V_startRow 
     2032                        GuessTransToScattFiles(numChars,row,matchRows) 
     2033                 
     2034                        num=numpnts(matchRows) 
     2035 
     2036                        resultStr = "" 
     2037                        for(ii=0;ii<num;ii+=1) 
     2038                                sprintf tmpStr,"\\f01\\K(52428,1,1)%s\\K(0,0,0)\\f00* Matches file: \\f01%s\\f00 | \\K(52428,1,1)\\f01%s\\f00\\K(0,0,0)%s\r",(tw[row])[0,numChars-1],samfile[matchRows[ii]],(sw[matchRows[ii]])[0,numchars-1],(sw[matchRows[ii]])[numchars,59] 
     2039                                resultStr += tmpStr 
     2040                        endfor 
     2041         
     2042                        if(cmpstr(resultStr,"")==0) 
     2043                                resultStr = "No match found for "+ (tw[row])[0,numChars-1] 
     2044                        endif            
     2045                         
     2046//                      DoWindow/K ConfirmGuess 
    20032047                        //Print "Try Again" 
    20042048                        break 
     
    20082052End 
    20092053 
    2010 // not used 
    2011 Function DoCancelGuessButtonProc(ba) : ButtonControl 
     2054// files are wrong, let the user try it again 
     2055// sets a flag, nothing else 
     2056Function DoTryAgainFewerButtonProc(ba) : ButtonControl 
     2057        STRUCT WMButtonAction &ba 
     2058 
     2059        Variable row,ii,num 
     2060        String tmpStr 
     2061         
     2062        Wave/T sw = root:myGlobals:TransHeaderInfo:S_Labels             //Sample file labels 
     2063        Wave/T tw = root:myGlobals:TransHeaderInfo:T_Labels             //trans file labels 
     2064        Wave/T tnam = root:myGlobals:TransHeaderInfo:T_FileNames        //trans file names 
     2065        Wave/T snam = root:myGlobals:TransHeaderInfo:S_TRANS_FileNames  //Scattering - trans correspondence 
     2066        Wave/T samfile = root:myGlobals:TransHeaderInfo:S_FileNames     //Scattering file name 
     2067         
     2068        switch( ba.eventCode ) 
     2069                case 2: // mouse up 
     2070                        // click code here 
     2071                        Variable/G root:myGlobals:TransHeaderInfo:GuessOK= 3 
     2072                         
     2073                        NVAR numChars = root:myGlobals:TransHeaderInfo:gNumMatchChars 
     2074                        SVAR resultStr = root:myGlobals:TransHeaderInfo:gResultStr 
     2075 
     2076                        numChars -= 1 
     2077 
     2078                        Make/O/D/N=0 root:myGlobals:TransHeaderInfo:matchRows 
     2079                        Wave matchRows=root:myGlobals:TransHeaderInfo:matchRows 
     2080         
     2081                   //transTableExists = WinType("TransFileTable") 
     2082                //if (transTableExists != 0) 
     2083                        GetSelection table,transFileTable,1      
     2084                        row = V_startRow 
     2085                        GuessTransToScattFiles(numChars,row,matchRows) 
     2086                 
     2087                        num=numpnts(matchRows) 
     2088 
     2089                        resultStr = "" 
     2090                        for(ii=0;ii<num;ii+=1) 
     2091                                sprintf tmpStr,"\\f01\\K(52428,1,1)%s\\K(0,0,0)\\f00* Matches file: \\f01%s\\f00 | \\K(52428,1,1)\\f01%s\\f00\\K(0,0,0)%s\r",(tw[row])[0,numChars-1],samfile[matchRows[ii]],(sw[matchRows[ii]])[0,numchars-1],(sw[matchRows[ii]])[numchars,59] 
     2092                                resultStr += tmpStr 
     2093                        endfor 
     2094         
     2095                        if(cmpstr(resultStr,"")==0) 
     2096                                resultStr = "No match found for "+ (tw[row])[0,numChars-1] 
     2097                        endif            
     2098//                      DoWindow/K ConfirmGuess 
     2099                        //Print "Try Again" 
     2100                        break 
     2101        endswitch 
     2102         
     2103        return 0 
     2104End 
     2105 
     2106 
     2107// cancel, skip this set of trans 
     2108Function SkipTransButtonProc(ba) : ButtonControl 
    20122109        STRUCT WMButtonAction &ba 
    20132110 
  • sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/WorkFileUtils.ipf

    r940 r948  
    6565Function Add_raw_to_work(newType) 
    6666        String newType 
    67                  
     67         
     68        // NEW OCT 2014 
     69        // this corrects for adding raw data files with different attenuation    
     70        // does nothing if the attenuation of RAW and destination are the same 
     71        NVAR doAdjustRAW_Atten = root:Packages:NIST:gDoAdjustRAW_Atten 
     72        if(doAdjustRAW_Atten) 
     73                Adjust_RAW_Attenuation(newType) 
     74        endif 
     75         
    6876        String destPath="" 
    6977         
     
    15431551        return newlist 
    15441552End 
     1553 
     1554// 
     1555// tests if two values are close enough to each other 
     1556// very useful since ICE came to be 
     1557// 
     1558// tol is an absolute value (since input v1 or v2 may be zero, can't reliably 
     1559// use a percentage 
     1560Function CloseEnough(v1,v2,tol) 
     1561        Variable v1, v2, tol 
     1562 
     1563        if(abs(v1-v2) < tol) 
     1564                return(1) 
     1565        else 
     1566                return(0) 
     1567        endif 
     1568End 
     1569 
     1570// 
     1571// 
     1572// match the attenuation of the RAW data to the "type" data 
     1573// so that they can be properly added 
     1574// 
     1575// are the attenuator numbers the same? if so exit 
     1576// 
     1577// if not, find the attenuator number for type 
     1578// - find both attenuation factors 
     1579// 
     1580// rescale the raw data to match the ratio of the two attenuation factors 
     1581// -- adjust the detector count (rw) 
     1582// -- the linear data 
     1583// 
     1584// 
     1585Function Adjust_RAW_Attenuation(type) 
     1586        String type 
     1587         
     1588        WAVE rw=$("root:Packages:NIST:RAW:realsread") 
     1589        WAVE linear_data=$("root:Packages:NIST:RAW:linear_data") 
     1590        WAVE data=$("root:Packages:NIST:RAW:data") 
     1591        WAVE data_err=$("root:Packages:NIST:RAW:linear_data_error") 
     1592        WAVE/T tw = $("root:Packages:NIST:RAW:textRead") 
     1593         
     1594        WAVE dest_reals=$("root:Packages:NIST:"+type+":realsread") 
     1595 
     1596        Variable dest_atten,raw_atten,tol 
     1597        Variable lambda,raw_atten_err,raw_AttenFactor,dest_attenFactor,dest_atten_err 
     1598        String fileStr 
     1599 
     1600        dest_atten = dest_reals[3] 
     1601        raw_atten = rw[3] 
     1602         
     1603        tol = 0.1               // within 0.1 atten units is OK 
     1604        if(abs(dest_atten - raw_atten) < tol ) 
     1605                return(0) 
     1606        endif 
     1607 
     1608        fileStr = tw[3] 
     1609        lambda = rw[26] 
     1610        raw_AttenFactor = AttenuationFactor(fileStr,lambda,raw_atten,raw_atten_err) 
     1611        dest_AttenFactor = AttenuationFactor(fileStr,lambda,dest_atten,dest_atten_err) 
     1612                 
     1613        rw[2] *= dest_AttenFactor/raw_AttenFactor 
     1614        linear_data *= dest_AttenFactor/raw_AttenFactor 
     1615         
     1616        // to keep "data" and linear_data in sync 
     1617        data = linear_data 
     1618         
     1619        return(0) 
     1620End 
Note: See TracChangeset for help on using the changeset viewer.