- Timestamp:
- 06/29/09 13:52:18 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STMath.cpp
r1571 r1579 1962 1962 CountedPtr< Scantable > 1963 1963 asap::STMath::lagFlag( const CountedPtr< Scantable > & in, 1964 double frequency, double width ) 1964 double start, double end, 1965 const std::string& mode) 1965 1966 { 1966 1967 CountedPtr< Scantable > out = getScantable(in, false); … … 1980 1981 Vector<Float> spec = specCol(i); 1981 1982 Vector<uChar> flag = flagCol(i); 1982 Int lag0 = Int(spec.nelements()*abs(inc)/(frequency+width)+0.5);1983 Int lag1 = Int(spec.nelements()*abs(inc)/(frequency-width)+0.5);1983 int fstart = -1; 1984 int fend = -1; 1984 1985 for (int k=0; k < flag.nelements(); ++k ) { 1985 1986 if (flag[k] > 0) { 1986 spec[k] = 0.0; 1987 fstart = k; 1988 while (flag[k] > 0 && k < flag.nelements()) { 1989 fend = k; 1990 k++; 1991 } 1987 1992 } 1993 Float interp = 0.0; 1994 if (fstart-1 > 0 ) { 1995 interp = spec[fstart-1]; 1996 if (fend+1 < spec.nelements()) { 1997 interp = (interp+spec[fend+1])/2.0; 1998 } 1999 } else { 2000 interp = spec[fend+1]; 2001 } 2002 if (fstart > -1 && fend > -1) { 2003 for (int j=fstart;j<=fend;++j) { 2004 spec[j] = interp; 2005 } 2006 } 2007 fstart =-1; 2008 fend = -1; 1988 2009 } 1989 2010 Vector<Complex> lags; 1990 2011 ffts.fft0(lags, spec); 1991 Int start = max(0, lag0); 1992 Int end = min(Int(lags.nelements()-1), lag1); 1993 if (start == end) { 1994 lags[start] = Complex(0.0); 2012 Int lag0(start+0.5); 2013 Int lag1(end+0.5); 2014 if (mode == "frequency") { 2015 lag0 = Int(spec.nelements()*abs(inc)/(start)+0.5); 2016 lag1 = Int(spec.nelements()*abs(inc)/(end)+0.5); 2017 } 2018 Int lstart = max(0, lag0); 2019 Int lend = min(Int(lags.nelements()-1), lag1); 2020 if (lstart == lend) { 2021 lags[lstart] = Complex(0.0); 1995 2022 } else { 1996 for (int j=start; j <=end ;++j) { 2023 if (lstart > lend) { 2024 Int tmp = lend; 2025 lend = lstart; 2026 lstart = tmp; 2027 } 2028 for (int j=lstart; j <=lend ;++j) { 1997 2029 lags[j] = Complex(0.0); 1998 2030 }
Note:
See TracChangeset
for help on using the changeset viewer.