- Timestamp:
- 07/04/06 11:22:42 (18 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STMath.cpp
r1033 r1066 21 21 #include <casa/Arrays/ArrayLogical.h> 22 22 #include <casa/Arrays/ArrayMath.h> 23 #include <casa/Arrays/Slice.h> 24 #include <casa/Arrays/Slicer.h> 23 25 #include <casa/Containers/RecordField.h> 24 26 #include <tables/Tables/TableRow.h> … … 66 68 { 67 69 if ( avmode == "SCAN" && in.size() != 1 ) 68 throw(AipsError("Can't perform 'SCAN' averaging on multiple tables")); 70 throw(AipsError("Can't perform 'SCAN' averaging on multiple tables.\n" 71 "Use merge first.")); 69 72 WeightType wtype = stringToWeight(weight); 70 73 … … 186 189 } 187 190 191 188 192 CountedPtr< Scantable > STMath::getScantable(const CountedPtr< Scantable >& in, 189 193 bool droprows) … … 248 252 } 249 253 250 CountedPtr< Scantable > STMath:: quotient( const CountedPtr< Scantable >& in,251 const std::string & mode,252 bool preserve )254 CountedPtr< Scantable > STMath::autoQuotient( const CountedPtr< Scantable >& in, 255 const std::string & mode, 256 bool preserve ) 253 257 { 254 258 /// @todo make other modes available … … 320 324 return out; 321 325 } 326 327 328 CountedPtr< Scantable > STMath::quotient( const CountedPtr< Scantable > & on, 329 const CountedPtr< Scantable > & off, 330 bool preserve ) 331 { 332 bool insitu = insitu_; 333 setInsitu(false); 334 CountedPtr< Scantable > out = getScantable(on, false); 335 setInsitu(insitu); 336 Table& tout = out->table(); 337 const Table& toff = off->table(); 338 TableIterator sit(tout, "SCANNO"); 339 TableIterator s2it(toff, "SCANNO"); 340 while ( !sit.pastEnd() ) { 341 Table ton = sit.table(); 342 TableRow row(ton); 343 Table t = s2it.table(); 344 ArrayColumn<Float> outspecCol(ton, "SPECTRA"); 345 ROArrayColumn<Float> outtsysCol(ton, "TSYS"); 346 ArrayColumn<uChar> outflagCol(ton, "FLAGTRA"); 347 for (uInt i=0; i < ton.nrow(); ++i) { 348 const TableRecord& rec = row.get(i); 349 Table offsel = t( t.col("BEAMNO") == Int(rec.asuInt("BEAMNO")) 350 && t.col("IFNO") == Int(rec.asuInt("IFNO")) 351 && t.col("POLNO") == Int(rec.asuInt("POLNO")) ); 352 TableRow offrow(offsel); 353 const TableRecord& offrec = offrow.get(0);//should be ncycles - take first 354 RORecordFieldPtr< Array<Float> > specoff(offrec, "SPECTRA"); 355 RORecordFieldPtr< Array<Float> > tsysoff(offrec, "TSYS"); 356 RORecordFieldPtr< Array<uChar> > flagoff(offrec, "FLAGTRA"); 357 Float tsysoffscalar = (*tsysoff)(IPosition(1,0)); 358 Vector<Float> specon, tsyson; 359 outtsysCol.get(i, tsyson); 360 outspecCol.get(i, specon); 361 Vector<uChar> flagon; 362 outflagCol.get(i, flagon); 363 MaskedArray<Float> mon = maskedArray(specon, flagon); 364 MaskedArray<Float> moff = maskedArray(*specoff, *flagoff); 365 MaskedArray<Float> quot = (tsysoffscalar * mon / moff); 366 if (preserve) { 367 quot -= tsysoffscalar; 368 } else { 369 quot -= tsyson[0]; 370 } 371 outspecCol.put(i, quot.getArray()); 372 outflagCol.put(i, flagsFromMA(quot)); 373 } 374 ++sit; 375 ++s2it; 376 // take the first off for each on scan which doesn't have a 377 // matching off scan 378 // non <= noff: matching pairs, non > noff matching pairs then first off 379 if ( s2it.pastEnd() ) s2it.reset(); 380 } 381 return out; 382 } 383 322 384 323 385 CountedPtr< Scantable > STMath::freqSwitch( const CountedPtr< Scantable >& in ) … … 1196 1258 return out; 1197 1259 } 1260 -
trunk/src/STMath.h
r995 r1066 58 58 const std::string& weight = "NONE", 59 59 const std::string& avmode = "SCAN"); 60 60 61 casa::CountedPtr< Scantable > 61 62 averagePolarisations( const casa::CountedPtr< Scantable > & in, … … 67 68 const std::string& mode, bool tsys=false ); 68 69 69 casa::CountedPtr<Scantable> quotient( const casa::CountedPtr<Scantable>& in, 70 const std::string& mode = "NEAREST", 70 casa::CountedPtr<Scantable> autoQuotient(const casa::CountedPtr<Scantable>& in, 71 const std::string& mode = "NEAREST", 72 bool preserve = true); 73 74 casa::CountedPtr<Scantable> quotient( const casa::CountedPtr<Scantable>& on, 75 const casa::CountedPtr<Scantable>& off, 71 76 bool preserve = true ); 72 77 -
trunk/src/STMathWrapper.h
r996 r1066 57 57 { return ScantableWrapper(STMath::unaryOperate(in.getCP(), val, mode, tsys)); } 58 58 59 ScantableWrapper quotient( const ScantableWrapper& in, 60 const std::string& mode = "NEAREST", 59 ScantableWrapper autoQuotient( const ScantableWrapper& in, 60 const std::string& mode = "NEAREST", 61 bool preserve = true ) 62 { return ScantableWrapper(STMath::autoQuotient(in.getCP(), mode, preserve)); } 63 64 ScantableWrapper quotient( const ScantableWrapper& on, 65 const ScantableWrapper& off, 61 66 bool preserve = true ) 62 { return ScantableWrapper(STMath::quotient(in.getCP(), mode, preserve)); } 67 { return ScantableWrapper( STMath::quotient( on.getCP(), off.getCP(), 68 preserve ) ); } 63 69 64 70 ScantableWrapper -
trunk/src/python_STMath.cpp
r993 r1066 47 47 .def("_averagepol", &STMathWrapper::averagePolarisations) 48 48 .def("_unaryop", &STMathWrapper::unaryOperate) 49 .def("_auto_quotient", &STMathWrapper::autoQuotient) 49 50 .def("_quotient", &STMathWrapper::quotient) 50 51 .def("_stats", &STMathWrapper::statistic)
Note:
See TracChangeset
for help on using the changeset viewer.