- Timestamp:
- 06/29/09 13:52:18 (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r1576 r1579 708 708 self._add_history("flag", varlist) 709 709 710 def lag_flag(self, frequency, width=0.0, unit="GHz", insitu=None):710 def lag_flag(self, start, end, unit="GHz", insitu=None): 711 711 """ 712 712 Flag the data in 'lag' space by providing a frequency to remove. … … 714 714 No taper is applied. 715 715 Parameters: 716 frequency: the frequency (really a period within the bandwidth)717 718 width: the width of the frequency to remove, to remove a719 range of frequencies around the centre.720 unit: the frequency unit (default "GHz")716 start: the start frequency (really a period within the 717 bandwidth) or period to remove 718 end: the end frequency or period to remove 719 unit: the frequency unit (default "GHz") or "" for 720 explicit lag channels 721 721 Notes: 722 It is recommended to flag edges of the band or strong 722 It is recommended to flag edges of the band or strong 723 723 signals beforehand. 724 724 """ … … 726 726 self._math._setinsitu(insitu) 727 727 varlist = vars() 728 base = { "GHz": 1000000000., "MHz": 1000000., "kHz": 1000., "Hz": 1. 729 if not base.has_key(unit):728 base = { "GHz": 1000000000., "MHz": 1000000., "kHz": 1000., "Hz": 1.} 729 if not (unit == "" or base.has_key(unit)): 730 730 raise ValueError("%s is not a valid unit." % unit) 731 731 try: 732 s = scantable(self._math._lag_flag(self, frequency*base[unit], 733 width*base[unit])) 732 if unit == "": 733 s = scantable(self._math._lag_flag(self, start, end, "lags")) 734 else: 735 s = scantable(self._math._lag_flag(self, start*base[unit], 736 end*base[unit], "frequency")) 734 737 except RuntimeError, msg: 735 738 if rcParams['verbose']: -
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.