Changeset 1192
- Timestamp:
- 08/28/06 16:33:58 (18 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/__init__.py
r1190 r1192 409 409 set_restfreqs - set a list of rest frequencies 410 410 flag - flag selected channels in the data 411 lag_flag - flag specified frequency in the data 411 412 save - save the scantable to disk as either 'ASAP', 412 413 'SDFITS' or 'ASCII' -
trunk/python/scantable.py
r1190 r1192 639 639 else: raise 640 640 self._add_history("flag", varlist) 641 642 def lag_flag(self, frequency, unit="GHz", width=0, insitu=None): 643 """ 644 Flag the data in 'lag' space by providing a frequency to remove. 645 Flagged data in the scantable gets set to 0.0 before the fft. 646 No taper is applied. 647 Parameters: 648 frequency: the frequency to remove 649 unit: the frequency unit ()default "GHz") 650 width: the number of 'lag' channels to extent the frequency 651 by, i.e. the interval 652 [bandwidth/frequency-width, bandwidth/frequency+width] 653 """ 654 if insitu is None: insitu = rcParams['insitu'] 655 self._math._setinsitu(insitu) 656 varlist = vars() 657 base = { "GHz": 100000000., "MHz": 1000000., "kHz": 1000., "Hz": 1. } 658 if not base.has_key(unit): 659 raise ValueError("%s is not a valid unit." % unit) 660 try: 661 s = scantable(self._math._lag_flag(self, frequency*base[unit], width)) 662 except RuntimeError, msg: 663 if rcParams['verbose']: 664 print msg 665 return 666 else: raise 667 s._add_history("lag_flag", varlist) 668 print_log() 669 if insitu: 670 self._assign(s) 671 else: 672 return s 641 673 642 674 -
trunk/src/STMath.cpp
r1145 r1192 31 31 #include <tables/Tables/TableIter.h> 32 32 #include <tables/Tables/TableCopy.h> 33 #include <scimath/Mathematics/FFTServer.h> 33 34 34 35 #include <lattices/Lattices/LatticeUtilities.h> … … 1377 1378 return out; 1378 1379 } 1380 1381 CountedPtr< Scantable > 1382 asap::STMath::lagFlag( const CountedPtr< Scantable > & in, 1383 double frequency, int width ) 1384 { 1385 CountedPtr< Scantable > out = getScantable(in, false); 1386 Table& tout = out->table(); 1387 TableIterator iter(tout, "FREQ_ID"); 1388 FFTServer<Float,Complex> ffts; 1389 while ( !iter.pastEnd() ) { 1390 Table tab = iter.table(); 1391 Double rp,rv,inc; 1392 ROTableRow row(tab); 1393 const TableRecord& rec = row.get(0); 1394 uInt freqid = rec.asuInt("FREQ_ID"); 1395 out->frequencies().getEntry(rp, rv, inc, freqid); 1396 ArrayColumn<Float> specCol(tab, "SPECTRA"); 1397 ArrayColumn<uChar> flagCol(tab, "FLAGTRA"); 1398 for (int i=0; i<int(tab.nrow()); ++i) { 1399 Vector<Float> spec = specCol(i); 1400 Vector<uChar> flag = flagCol(i); 1401 Int lag = Int(spec.nelements()*abs(inc)/frequency); 1402 for (int k=0; k < flag.nelements(); ++k ) { 1403 if (flag[k] > 0) { 1404 spec[k] = 0.0; 1405 } 1406 } 1407 Vector<Complex> lags; 1408 ffts.fft(lags, spec); 1409 Int start = max(0, lag-width); 1410 Int end = min(Int(lags.nelements()-1), lag+width); 1411 if (start == end) { 1412 lags[start] = Complex(0.0); 1413 } else { 1414 for (int j=start; j <=end ;++j) { 1415 lags[j] = Complex(0.0); 1416 } 1417 } 1418 ffts.fft(spec, lags); 1419 specCol.put(i, spec); 1420 } 1421 ++iter; 1422 } 1423 return out; 1424 } -
trunk/src/STMath.h
r1145 r1192 184 184 const std::string& srctype = "on"); 185 185 186 /** 187 * "hard" flag the data, this flags everything selected in setSelection() 188 * @param frequency the frequency to remove 189 * @param width the number of lags to flag left to the side of the frequency 190 */ 191 casa::CountedPtr<Scantable> 192 lagFlag( const casa::CountedPtr<Scantable>& in, double frequency, 193 int width); 194 186 195 private: 187 196 casa::CountedPtr<Scantable> applyToPol( const casa::CountedPtr<Scantable>& in, -
trunk/src/STMathWrapper.h
r1145 r1192 156 156 { return ScantableWrapper(STMath::mxExtract(in.getCP(),scantype)); } 157 157 158 ScantableWrapper lagFlag( const ScantableWrapper& in, 159 double frequency, int width ) 160 { return ScantableWrapper(STMath::lagFlag(in.getCP(), frequency, width)); } 161 158 162 }; 159 163 -
trunk/src/python_STMath.cpp
r1145 r1192 67 67 .def("_freq_align", &STMathWrapper::frequencyAlign) 68 68 .def("_mx_extract", &STMathWrapper::mxExtract) 69 .def("_lag_flag", &STMathWrapper::lagFlag) 69 70 ; 70 71 };
Note:
See TracChangeset
for help on using the changeset viewer.