Changeset 2126 for branches/casa-prerelease/pre-asap/src
- Timestamp:
- 04/08/11 21:06:20 (14 years ago)
- Location:
- branches/casa-prerelease/pre-asap
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/casa-prerelease/pre-asap
-
branches/casa-prerelease/pre-asap/src
- Property svn:mergeinfo changed
/trunk/src merged: 2125
- Property svn:mergeinfo changed
-
branches/casa-prerelease/pre-asap/src/MathUtils.cpp
r1819 r2126 30 30 //#--------------------------------------------------------------------------- 31 31 32 #include <iostream> 32 33 #include <casa/aips.h> 33 34 #include <casa/Arrays/Vector.h> … … 161 162 out.resize(in.nelements()); 162 163 out[0] = in[0];out[out.nelements()-1] = in[in.nelements()-1]; 164 //--s 165 cout << "out[0]=" << out[0] << ";" << endl; 166 //--e 163 167 outmask.resize(mask.nelements()); 164 outmask = False;168 outmask[0] = mask[0]; outmask[outmask.nelements()-1] = mask[mask.nelements()-1]; 165 169 uInt m;Vector<Float>* w; 166 170 for (uInt i=1; i < out.nelements()-1;++i) { … … 169 173 if (weighted[m]) { 170 174 out[i] = (*w)[0]*in[i-1] + (*w)[1]*in[i] + (*w)[2]*in[i+1]; 171 outmask[i] = True;175 //outmask[i] = True; 172 176 } else { // mask it 173 177 out[i] = in[i];//use arbitrary value 174 outmask[i] = False;178 //outmask[i] = False; 175 179 } 180 //--s 181 if (i < 13) { 182 cout << "mask[" << i-1 << "-" << i+1 << "]=[" << mask[i-1] << ", " << mask[i] << ", " << mask[i+1] << "]; "; 183 cout << "m=" << m << "; "; 184 cout << "weights[" << m << "]=" << weights[m] << "; "; 185 cout << "in[" << i-1 << "-" << i+1 << "]=[" << in[i-1] << ", " << in[i] << ", " << in[i+1] << "] --> "; 186 cout << out[i] << ";" << endl; 187 cout << "-------------------------------" << endl; 188 } 189 //--e 190 outmask[i] = mask[i]; 176 191 } 177 192 } -
branches/casa-prerelease/pre-asap/src/RowAccumulator.cpp
r1819 r2126 10 10 // 11 11 // 12 13 #include <iostream> 14 12 15 #include <casa/iomanip.h> 13 14 16 #include <casa/Arrays/MaskArrMath.h> 15 17 #include <casa/Arrays/MaskArrLogi.h> … … 18 20 #include "RowAccumulator.h" 19 21 20 21 22 using namespace casa; 22 23 using namespace asap; 23 24 24 RowAccumulator::RowAccumulator(WeightType wt) : 25 weightType_(wt), 26 initialized_(False) 25 RowAccumulator::RowAccumulator(WeightType wt) : weightType_(wt), initialized_(False) 27 26 { 28 27 reset(); … … 34 33 35 34 36 void RowAccumulator::add( const Vector< Float >& v, 37 const Vector< Bool >& m, 38 const Vector< Float >& tsys, 39 Double interval, 40 Double time ) 41 { 42 if (!initialized_) { 43 Vector<Float> dummy(v.nelements(), 0.0); 44 Vector<Bool> dummymsk(m.nelements(), True); 45 spectrum_.setData(dummy, dummymsk); 46 n_.setData(Vector<uInt>(v.nelements(), 0), dummymsk); 47 weightSum_.setData(Vector<Float>(v.nelements(), 0.0), dummymsk); 48 tsysSum_.resize(tsys.nelements()); tsysSum_=0.0; 49 } 50 // add spectrum related weights, so far it is variance only. 51 Float totalweight = 1.0; 52 53 // only add these if not everything masked 54 if ( !allEQ(m, False) ) { 55 totalweight *= addTsys(tsys); 56 totalweight *= addInterval(interval); 57 addTime(time); 58 } 59 addSpectrum(v, m, totalweight); 60 initialized_ = True; 61 } 62 63 void RowAccumulator::addSpectrum( const Vector< Float >& v, 64 const Vector< Bool >& m, 65 Float weight) 66 { 67 Float totalweight = weight; 68 MaskedArray<Float> data(v,m); 69 if ( weightType_ == asap::W_VAR ) { 70 if (m.nelements() == userMask_.nelements()) { 71 Float fac = 1.0/variance(data(userMask_)); 72 totalweight *= fac; 73 } else { 74 Float fac = 1.0/variance(data); 75 totalweight *= fac; 76 } 77 } 78 data *= totalweight; 79 MaskedArray<Float> wadd(Vector<Float>(m.nelements(),totalweight), m); 80 weightSum_ += wadd; 81 spectrum_ += data; 82 const MaskedArray<uInt> inc(Vector<uInt>(m.nelements(),1), m); 83 n_ += inc; 84 } 85 86 Float RowAccumulator::addTsys( const casa::Vector< casa::Float > & v ) 35 void RowAccumulator::reset(const uInt size, const uInt tsysSize) 36 { 37 Vector<Bool> m(size, True); 38 39 spectrum_.setData(Vector<Float>(size, 0.0), Vector<Bool>(size, True)); 40 spectrumNoMask_.setData(Vector<Float>(size, 0.0), Vector<Bool>(size, True)); 41 42 n_.setData(Vector<uInt>(size, 0), Vector<Bool>(size, True)); 43 nNoMask_.setData(Vector<uInt>(size, 0), Vector<Bool>(size, True)); 44 45 weightSum_.setData(Vector<Float>(size, 0.0), Vector<Bool>(size, True)); 46 weightSumNoMask_.setData(Vector<Float>(size, 0.0), Vector<Bool>(size, True)); 47 48 tsysSum_.resize(tsysSize); tsysSum_=0.0; 49 tsysSumNoMask_.resize(tsysSize); tsysSumNoMask_=0.0; 50 51 intervalSum_ = 0.0; 52 intervalSumNoMask_ = 0.0; 53 54 timeSum_ = 0.0; 55 timeSumNoMask_ = 0.0; 56 } 57 58 void RowAccumulator::initialize(const uInt size, const uInt tsysSize) 59 { 60 reset(size, tsysSize); 61 initialized_ = True; 62 } 63 64 void RowAccumulator::add(const Vector<Float>& v, 65 const Vector<Bool>& m, 66 const Vector<Float>& tsys, 67 const Double interval, 68 const Double time) 69 { 70 uInt size = v.nelements(); 71 //if (size != m.nelements()) raiseError; 72 if (!initialized_) initialize(size, tsys.nelements()); 73 74 addSpectrum(v, m, tsys, interval, time); 75 } 76 77 void RowAccumulator::addSpectrum(const Vector<Float>& v, 78 const Vector<Bool>& m, 79 const Vector<Float>& tsys, 80 const Double interval, 81 const Double time) 82 { 83 doAddSpectrum(v, m, tsys, interval, time, False); 84 doAddSpectrum(v, m, tsys, interval, time, True); // CAS-2776 85 } 86 87 void RowAccumulator::doAddSpectrum(const Vector<Float>& v, 88 const Vector<Bool>& m, 89 const Vector<Float>& tsys, 90 const Double interval, 91 const Double time, 92 const Bool ignoreMask) 93 { 94 Vector<Float> vUse = v.copy(); 95 Vector<Bool> mUse = m.copy(); 96 if (ignoreMask) mUse = !mUse; 97 98 MaskedArray<Float> vadd(vUse, mUse); 99 Float totalWeight = getTotalWeight(vadd, tsys, interval, time, ignoreMask); 100 vadd *= totalWeight; 101 MaskedArray<Float> wadd(Vector<Float>(mUse.nelements(), totalWeight), mUse); 102 MaskedArray<uInt> inc(Vector<uInt>(mUse.nelements(), 1), mUse); 103 104 if (ignoreMask) { 105 spectrumNoMask_ += vadd; 106 weightSumNoMask_ += wadd; 107 nNoMask_ += inc; 108 } else { 109 spectrum_ += vadd; 110 weightSum_ += wadd; 111 n_ += inc; 112 } 113 114 // 115 cout << "***" << endl; 116 Vector<Float> spe = spectrum_.getArray(); 117 Vector<Float> spe0 = spectrumNoMask_.getArray(); 118 Vector<Float> wei = weightSum_.getArray(); 119 Vector<Float> wei0 = weightSumNoMask_.getArray(); 120 Vector<uInt> n = n_.getArray(); 121 Vector<uInt> n0 = nNoMask_.getArray(); 122 cout << "S__" << "[" << spe[0] << "][" << spe[1] << "][" << spe[2] << "][" << spe[3] << "][" << spe[4] << "][" << spe[5] << "][" << spe[6] << "][" << spe[7] << "][" << spe[8] << "][" << spe[9] << "][" << spe[10] << "][" << spe[11] << "][" << spe[12] << "]" << endl; 123 cout << "S0_" << "[" << spe0[0] << "][" << spe0[1] << "][" << spe0[2] << "][" << spe0[3] << "][" << spe0[4] << "][" << spe0[5] << "][" << spe0[6] << "][" << spe0[7] << "][" << spe0[8] << "][" << spe0[9] << "][" << spe0[10] << "][" << spe0[11] << "][" << spe0[12] << "]" << endl; 124 cout << "W__" << "[" << wei[0] << "][" << wei[1] << "][" << wei[2] << "][" << wei[3] << "][" << wei[4] << "][" << wei[5] << "][" << wei[6] << "][" << wei[7] << "][" << wei[8] << "][" << wei[9] << "][" << wei[10] << "][" << wei[11] << "][" << wei[12] << "]" << endl; 125 cout << "W0_" << "[" << wei0[0] << "][" << wei0[1] << "][" << wei0[2] << "][" << wei0[3] << "][" << wei0[4] << "][" << wei0[5] << "][" << wei0[6] << "][" << wei0[7] << "][" << wei0[8] << "][" << wei0[9] << "][" << wei0[10] << "][" << wei0[11] << "][" << wei0[12] << "]" << endl; 126 cout << "N__" << "[" << n[0] << "][" << n[1] << "][" << n[2] << "][" << n[3] << "][" << n[4] << "][" << n[5] << "][" << n[6] << "][" << n[7] << "][" << n[8] << "][" << n[9] << "][" << n[10] << "][" << n[11] << "][" << n[12] << "]" << endl; 127 cout << "N0_" << "[" << n0[0] << "][" << n0[1] << "][" << n0[2] << "][" << n0[3] << "][" << n0[4] << "][" << n0[5] << "][" << n0[6] << "][" << n0[7] << "][" << n0[8] << "][" << n0[9] << "][" << n0[10] << "][" << n0[11] << "][" << n0[12] << "]" << endl; 128 cout << "***" << endl; 129 // 130 } 131 132 Float RowAccumulator::getTotalWeight(const MaskedArray<Float>& data, 133 const Vector<Float>& tsys, 134 const Double interval, 135 const Double time, 136 const Bool ignoreMask) 137 { 138 Float totalWeight = 1.0; 139 140 Vector<Bool> m = data.getMask(); 141 if (!allEQ(m, False)) { // only add these if not everything masked 142 totalWeight *= addTsys(tsys, ignoreMask); 143 totalWeight *= addInterval(interval, ignoreMask); 144 addTime(time, ignoreMask); 145 } 146 147 if (weightType_ == W_VAR) { 148 Float fac = 1.0/variance(data); 149 if (!ignoreMask && (m.nelements() == userMask_.nelements())) 150 fac = 1.0/variance(data(userMask_)); 151 152 totalWeight *= fac; 153 } 154 155 return totalWeight; 156 } 157 158 Float RowAccumulator::addTsys(const Vector<Float>& v, Bool ignoreMask) 87 159 { 88 160 // @fixme this assume tsys is the same for all channels 89 161 90 162 Float w = 1.0; 91 tsysSum_ += v[0]; 92 if ( weightType_ == asap::W_TSYS || weightType_ == asap::W_TINTSYS ) { 163 if (ignoreMask) { 164 tsysSumNoMask_ += v[0]; 165 } else { 166 tsysSum_ += v[0]; 167 } 168 if ( weightType_ == W_TSYS || weightType_ == W_TINTSYS ) { 93 169 w /= (v[0]*v[0]); 94 170 } … … 96 172 } 97 173 98 void asap::RowAccumulator::addTime( casa::Double t ) 99 { 100 timeSum_ += t; 101 } 102 103 Float asap::RowAccumulator::addInterval( casa::Double inter ) 174 void RowAccumulator::addTime(Double t, Bool ignoreMask) 175 { 176 if (ignoreMask) { 177 timeSumNoMask_ += t; 178 } else { 179 timeSum_ += t; 180 } 181 } 182 183 Float RowAccumulator::addInterval(Double inter, Bool ignoreMask) 104 184 { 105 185 Float w = 1.0; 106 intervalSum_ += inter; 107 if ( weightType_ == asap::W_TINT || weightType_ == asap::W_TINTSYS ) { 186 if (ignoreMask) { 187 intervalSumNoMask_ += inter; 188 } else { 189 intervalSum_ += inter; 190 } 191 if (weightType_ == W_TINT || weightType_ == W_TINTSYS) { 108 192 w /= Float(inter); 109 193 } … … 111 195 } 112 196 113 void asap::RowAccumulator::reset( ) 114 { 115 initialized_ = False; 116 intervalSum_ = 0.0; 117 tsysSum_.resize(); 118 timeSum_ = 0.0; 119 } 120 121 casa::Vector< casa::Float > RowAccumulator::getSpectrum( ) const 197 Vector<Float> RowAccumulator::getSpectrum() const 122 198 { 123 199 return (spectrum_/weightSum_).getArray(); 124 200 } 125 201 126 casa::Double asap::RowAccumulator::getTime( ) const 127 { 128 uInt n = max(n_); 129 return timeSum_/Float(n); 130 } 131 132 casa::Double asap::RowAccumulator::getInterval( ) const 202 Double RowAccumulator::getTime() const 203 { 204 return timeSum_/Float(max(n_)); 205 } 206 207 Double RowAccumulator::getInterval() const 133 208 { 134 209 return intervalSum_; 135 210 } 136 211 137 casa::Vector< casa::Bool > RowAccumulator::getMask() const212 Vector<Bool> RowAccumulator::getMask() const 138 213 { 139 214 // Return the "total" mask - False where no points have been accumulated. … … 141 216 } 142 217 143 casa::Vector< casa::Float > asap::RowAccumulator::getTsys() const218 Vector<Float> RowAccumulator::getTsys() const 144 219 { 145 220 // @fixme this assumes tsys.nelements() == 1 … … 147 222 } 148 223 149 void asap::RowAccumulator::setUserMask( const casa::Vector< casa::Bool > & m)224 void RowAccumulator::setUserMask(const Vector<Bool>& m) 150 225 { 151 226 userMask_.resize(); … … 154 229 155 230 // Added by TT check the state of RowAccumulator 156 casa::Bool RowAccumulator::state() const231 Bool RowAccumulator::state() const 157 232 { 158 233 return initialized_; 159 234 } 160 235 236 void RowAccumulator::replaceNaN() 237 { 238 Vector<Float> v = spectrum_.getArray(); 239 Vector<Float> w = weightSum_.getArray(); 240 Vector<Float> vRef = spectrumNoMask_.getArray(); 241 Vector<Float> wRef = weightSumNoMask_.getArray(); 242 243 //------- 244 cout << "SB-"; 245 for (uInt i=0; i<13; ++i) { 246 cout << "[" << v[i] << "]"; 247 } 248 cout << endl; 249 cout << "WB-"; 250 for (uInt i=0; i<13; ++i) { 251 cout << "[" << w[i] << "]"; 252 } 253 cout << endl; 254 //------- 255 256 for (uInt i = 0; i < v.size(); ++i) { 257 if (w[i] == 0.0) { 258 v[i] = vRef[i]; 259 w[i] = wRef[i]; 260 } 261 } 262 263 spectrum_.setData(v, Vector<Bool>(v.nelements(), True)); 264 weightSum_.setData(w, Vector<Bool>(w.nelements(), True)); 265 266 //------- 267 cout << "SA-"; 268 for (uInt i=0; i<13; ++i) { 269 cout << "[" << v[i] << "]"; 270 } 271 cout << endl; 272 cout << "WA-"; 273 for (uInt i=0; i<13; ++i) { 274 cout << "[" << w[i] << "]"; 275 } 276 cout << endl; 277 //------- 278 } -
branches/casa-prerelease/pre-asap/src/RowAccumulator.h
r1819 r2126 13 13 #define ASAPROWACCUMULATOR_H 14 14 15 #include <math.h> 15 16 #include <casa/aips.h> 16 17 #include <casa/Arrays/Vector.h> … … 48 49 const casa::Vector<casa::Bool>& m, 49 50 const casa::Vector<casa::Float>& tsys, 50 c asa::Double interval,51 c asa::Double time);51 const casa::Double interval, 52 const casa::Double time); 52 53 /** 53 54 * Also set a user mask which get combined with the individual masks … … 84 85 * Reset the acummulator to the state at construction. 85 86 */ 86 void reset(); 87 void reset(const casa::uInt size=0, const casa::uInt tsysSize=0); 88 void initialize(const casa::uInt size, const casa::uInt tsysSize); 87 89 /** 88 90 * check the initialization state 89 91 */ 90 92 casa::Bool state() const; 93 /** 94 * replace NaN values with (normal) values at the same channels in the given spetrum. 95 * (CAS-2776; 2011/04/07 by Wataru Kawasaki) 96 */ 97 void replaceNaN(); 91 98 92 99 private: 93 void addSpectrum( const casa::Vector<casa::Float>& v, 94 const casa::Vector<casa::Bool>& m, 95 casa::Float weight); 96 97 casa::Float addTsys(const casa::Vector<casa::Float>& v); 98 casa::Float addInterval(casa::Double inter); 99 void addTime(casa::Double t); 100 void addSpectrum(const casa::Vector<casa::Float>& v, 101 const casa::Vector<casa::Bool>& m, 102 const casa::Vector<casa::Float>& tsys, 103 const casa::Double interval, 104 const casa::Double time); 105 void doAddSpectrum(const casa::Vector<casa::Float>& v, 106 const casa::Vector<casa::Bool>& m, 107 const casa::Vector<casa::Float>& tsys, 108 const casa::Double interval, 109 const casa::Double time, 110 const casa::Bool ignoreMask); 111 casa::Float getTotalWeight(const casa::MaskedArray<casa::Float>& data, 112 const casa::Vector<casa::Float>& tsys, 113 const casa::Double interval, 114 const casa::Double time, 115 const casa::Bool ignoreMask); 116 casa::Float addTsys(const casa::Vector<casa::Float>& v, casa::Bool ignoreMask); 117 casa::Float addInterval(casa::Double inter, casa::Bool ignoreMask); 118 void addTime(casa::Double t, casa::Bool ignoreMask); 100 119 101 120 WeightType weightType_; … … 106 125 casa::MaskedArray<casa::uInt> n_; 107 126 127 //these three are used for normalise() (CAS-2776; 2011/04/07 by WK) 128 casa::MaskedArray<casa::Float> spectrumNoMask_; 129 casa::MaskedArray<casa::Float> weightSumNoMask_; 130 casa::MaskedArray<casa::uInt> nNoMask_; 131 108 132 casa::Vector<casa::Bool> userMask_; 109 133 110 casa::Vector<casa::Float> tsysSum_ ;111 casa::Double timeSum_ ;112 casa::Double intervalSum_ ;134 casa::Vector<casa::Float> tsysSum_, tsysSumNoMask_; 135 casa::Double timeSum_, timeSumNoMask_; 136 casa::Double intervalSum_, intervalSumNoMask_; 113 137 }; 114 138 -
branches/casa-prerelease/pre-asap/src/SConscript
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/casa-prerelease/pre-asap/src/STMath.cpp
r2103 r2126 207 207 ROScalarColumn<Double> tmp(tin, "TIME"); 208 208 Double td;tmp.get(0,td); 209 Table basesubt = tin( tin.col("BEAMNO") == Int(rec.asuInt("BEAMNO"))210 && tin.col("IFNO") == Int(rec.asuInt("IFNO"))211 && tin.col("POLNO") == Int(rec.asuInt("POLNO")) );209 Table basesubt = tin( tin.col("BEAMNO") == Int(rec.asuInt("BEAMNO")) 210 && tin.col("IFNO") == Int(rec.asuInt("IFNO")) 211 && tin.col("POLNO") == Int(rec.asuInt("POLNO")) ); 212 212 Table subt; 213 213 if ( avmode == "SOURCE") { 214 subt = basesubt( basesubt.col("SRCNAME") == rec.asString("SRCNAME") 214 subt = basesubt( basesubt.col("SRCNAME") == rec.asString("SRCNAME")); 215 215 } else if (avmode == "SCAN") { 216 //subt = basesubt( basesubt.col("SCANNO") == Int(rec.asuInt("SCANNO")) ); 217 subt = basesubt( basesubt.col("SCANNO") == Int(rec.asuInt("SCANNO")) 218 && basesubt.col("SRCNAME") == rec.asString("SRCNAME") ); 216 subt = basesubt( basesubt.col("SRCNAME") == rec.asString("SRCNAME") 217 && basesubt.col("SCANNO") == Int(rec.asuInt("SCANNO")) ); 219 218 } else { 220 219 subt = basesubt; … … 266 265 acc.add(spec, !bflag, tsys, inter, time); 267 266 } 267 268 // If there exists a channel at which all the input spectra are masked, 269 // spec has 'nan' values for that channel and it may affect the following 270 // processes. To avoid this, replacing 'nan' values in spec with 271 // weighted-mean of all spectra in the following line. 272 // (done for CAS-2776, 2011/04/07 by Wataru Kawasaki) 273 acc.replaceNaN(); 268 274 } 269 275 const Vector<Bool>& msk = acc.getMask(); … … 278 284 Vector<uChar> flg(msk.shape()); 279 285 convertArray(flg, !msk); 286 for (uInt k = 0; k < flg.nelements(); ++k) { 287 uChar userFlag = 1 << 7; 288 if (msk[k]==True) userFlag = 0 << 7; 289 flg(k) = userFlag; 290 } 291 280 292 flagColOut.put(i, flg); 281 293 specColOut.put(i, acc.getSpectrum()); … … 627 639 // check if vector size is equal to nrow 628 640 Vector<Float> fact( val ) ; 629 if ( fact.nelements() != in->nrow()) {641 if (fact.nelements() != uInt(in->nrow())) { 630 642 throw( AipsError("Vector size must be 1 or be same as number of row.") ) ; 631 643 } … … 688 700 // some checks 689 701 vector<uInt> nchans; 690 for ( uInt i = 0 ; i < in->nrow() ; i++) {691 nchans.push_back( (in->getSpectrum( i )).size() );702 for (Int i = 0 ; i < in->nrow() ; i++) { 703 nchans.push_back((in->getSpectrum(i)).size()); 692 704 } 693 705 //Vector<uInt> mchans( nchans ) ; … … 2248 2260 Table outtab = out->table(); 2249 2261 2250 const uInt ntau = uInt(tau.size());2262 const Int ntau = uInt(tau.size()); 2251 2263 std::vector<float>::const_iterator tauit = tau.begin(); 2252 2264 AlwaysAssert((ntau == 1 || ntau == in->nif() || ntau == in->nif() * in->npol()), … … 2292 2304 { 2293 2305 CountedPtr< Scantable > out = getScantable(in, false); 2294 Table& table = out->table(); 2295 ArrayColumn<Float> specCol(table, "SPECTRA"); 2296 ArrayColumn<uChar> flagCol(table, "FLAGTRA"); 2297 Vector<Float> spec; 2298 Vector<uChar> flag; 2299 for ( uInt i=0; i<table.nrow(); ++i) { 2300 specCol.get(i, spec); 2301 flagCol.get(i, flag); 2302 Vector<Bool> mask(flag.nelements()); 2303 convertArray(mask, flag); 2304 Vector<Float> specout; 2305 Vector<Bool> maskout; 2306 if ( kernel == "hanning" ) { 2307 mathutil::hanning(specout, maskout, spec , !mask); 2308 convertArray(flag, !maskout); 2309 } else if ( kernel == "rmedian" ) { 2310 mathutil::runningMedian(specout, maskout, spec , mask, width); 2311 convertArray(flag, maskout); 2312 } else if ( kernel == "poly" ) { 2313 mathutil::polyfit(specout, maskout, spec, !mask, width, order); 2314 convertArray(flag, !maskout); 2315 } 2316 flagCol.put(i, flag); 2317 specCol.put(i, specout); 2306 Table table = out->table(); 2307 2308 TableIterator iter(table, "IFNO"); 2309 while (!iter.pastEnd()) { 2310 Table tab = iter.table(); 2311 ArrayColumn<Float> specCol(tab, "SPECTRA"); 2312 ArrayColumn<uChar> flagCol(tab, "FLAGTRA"); 2313 Vector<Float> spec; 2314 Vector<uChar> flag; 2315 for (uInt i = 0; i < tab.nrow(); ++i) { 2316 specCol.get(i, spec); 2317 flagCol.get(i, flag); 2318 Vector<Bool> mask(flag.nelements()); 2319 convertArray(mask, flag); 2320 Vector<Float> specout; 2321 Vector<Bool> maskout; 2322 if (kernel == "hanning") { 2323 mathutil::hanning(specout, maskout, spec, !mask); 2324 convertArray(flag, !maskout); 2325 } else if (kernel == "rmedian") { 2326 mathutil::runningMedian(specout, maskout, spec , mask, width); 2327 convertArray(flag, maskout); 2328 } else if (kernel == "poly") { 2329 mathutil::polyfit(specout, maskout, spec, !mask, width, order); 2330 convertArray(flag, !maskout); 2331 } 2332 2333 for (uInt j = 0; j < flag.nelements(); ++j) { 2334 uChar userFlag = 1 << 7; 2335 if (maskout[j]==True) userFlag = 0 << 7; 2336 flag(j) = userFlag; 2337 } 2338 2339 flagCol.put(i, flag); 2340 specCol.put(i, specout); 2341 } 2342 ++iter; 2318 2343 } 2319 2344 return out; … … 2822 2847 if (fstart-1 > 0 ) { 2823 2848 interp = spec[fstart-1]; 2824 if (fend+1 < spec.nelements()) {2849 if (fend+1 < Int(spec.nelements())) { 2825 2850 interp = (interp+spec[fend+1])/2.0; 2826 2851 } -
branches/casa-prerelease/pre-asap/src/python_Scantable.cpp
r2114 r2126 155 155 .def("_getflagtrafast", &ScantableWrapper::getFlagtraFast, 156 156 (boost::python::arg("whichrow")=0) ) 157 //.def("_sspline_baseline", &ScantableWrapper::smoothingSplineBaseline, 158 // (boost::python::arg("thres")=3.0, 159 // boost::python::arg("niter")=1) ) 157 //.def("_sspline_baseline", &ScantableWrapper::smoothingSplineBaseline) 160 158 //.def("_test_cin", &ScantableWrapper::testCin) 161 159 ;
Note:
See TracChangeset
for help on using the changeset viewer.