Changeset 948 for sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS
- Timestamp:
- Oct 28, 2014 10:38:51 AM (8 years ago)
- 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 196 196 // list = ReplaceString(",", list, ";") 197 197 // 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 198 221 222 // oct 2014 -- try this way: 199 223 list = ExpandNumRanges(match) //now simply comma delimited 200 224 num=ItemsInList(list,",") … … 202 226 item = StringFromList(ii,list,",") 203 227 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)) + ";" 215 230 216 231 endfor -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/Transmission.ipf
r888 r948 1824 1824 Variable ii,row 1825 1825 Variable transTableExists 1826 1827 Variable/G root:myGlobals:TransHeaderInfo:gNumMatchChars = numChars 1828 1826 1829 Make/O/D/N=0 root:myGlobals:TransHeaderInfo:matchRows 1827 1830 Wave matchRows=root:myGlobals:TransHeaderInfo:matchRows 1828 1831 1829 1830 1832 transTableExists = WinType("TransFileTable") 1833 if (transTableExists != 0) 1831 1834 GetSelection table,transFileTable,1 1832 1835 row = V_startRow … … 1861 1864 String/G root:myGlobals:TransHeaderInfo:gResultStr = result 1862 1865 1863 DoWindow/F ConfirmGuess //i t really shouldn't exist...1866 DoWindow/F ConfirmGuess //if being called recursively, the panel is already up 1864 1867 if(V_flag==1) 1865 1868 TitleBox title0,pos={9,5},variable=root:myGlobals:TransHeaderInfo:gResultStr … … 1869 1872 TitleBox title0,pos={15,8},size={560,32} 1870 1873 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" 1874 1878 endif 1875 1879 … … 1878 1882 // figure out from the return code what the user did... 1879 1883 // 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 1882 1887 NVAR guessOK = root:myGlobals:TransHeaderInfo:GuessOK 1883 1888 … … 1886 1891 case 1: 1887 1892 // accept guess (assign, and calculate immediately) 1893 num=numpnts(matchRows) //this may have changed 1888 1894 for(ii=0;ii<num;ii+=1) 1889 1895 snam[matchRows[ii]] = tnam[row] … … 1892 1898 endfor 1893 1899 break 1894 case 2: //try again (with more / fewer characters?)1895 // does nothing right now1900 case 2: //try again (with more characters) 1901 // not an exit code, does nothing 1896 1902 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 1898 1907 // do nothing 1899 1908 break … … 1993 2002 // files are wrong, let the user try it again 1994 2003 // sets a flag, nothing else 1995 Function DoTryAgain ButtonProc(ba) : ButtonControl2004 Function DoTryAgainMoreButtonProc(ba) : ButtonControl 1996 2005 STRUCT WMButtonAction &ba 1997 2006 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 1998 2016 switch( ba.eventCode ) 1999 2017 case 2: // mouse up 2000 2018 // click code here 2001 2019 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 2003 2047 //Print "Try Again" 2004 2048 break … … 2008 2052 End 2009 2053 2010 // not used 2011 Function DoCancelGuessButtonProc(ba) : ButtonControl 2054 // files are wrong, let the user try it again 2055 // sets a flag, nothing else 2056 Function 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 2104 End 2105 2106 2107 // cancel, skip this set of trans 2108 Function SkipTransButtonProc(ba) : ButtonControl 2012 2109 STRUCT WMButtonAction &ba 2013 2110 -
sans/Dev/trunk/NCNR_User_Procedures/Reduction/SANS/WorkFileUtils.ipf
r940 r948 65 65 Function Add_raw_to_work(newType) 66 66 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 68 76 String destPath="" 69 77 … … 1543 1551 return newlist 1544 1552 End 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 1560 Function 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 1568 End 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 // 1585 Function 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) 1620 End
Note: See TracChangeset
for help on using the changeset viewer.