- Timestamp:
- 12/14/06 11:21:48 (18 years ago)
- Location:
- branches/Release2.1.2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Release2.1.2/python/scantable.py
r1295 r1310 1413 1413 return s 1414 1414 1415 def scale(self, factor, tsys=True, insitu=None ,):1415 def scale(self, factor, tsys=True, insitu=None): 1416 1416 """ 1417 1417 Return a scan where all spectra are scaled by the give 'factor' … … 1519 1519 s = None 1520 1520 if isinstance(other, scantable): 1521 print "scantable + scantable NYI" 1522 return 1521 s = scantable(self._math._binaryop(self, other, "ADD")) 1523 1522 elif isinstance(other, float): 1524 1523 s = scantable(self._math._unaryop(self, other, "ADD", False)) … … 1536 1535 s = None 1537 1536 if isinstance(other, scantable): 1538 print "scantable - scantable NYI" 1539 return 1537 s = scantable(self._math._binaryop(self, other, "SUB")) 1540 1538 elif isinstance(other, float): 1541 1539 s = scantable(self._math._unaryop(self, other, "SUB", False)) … … 1553 1551 s = None 1554 1552 if isinstance(other, scantable): 1555 print "scantable * scantable NYI" 1556 return 1553 s = scantable(self._math._binaryop(self, other, "MUL")) 1557 1554 elif isinstance(other, float): 1558 1555 s = scantable(self._math._unaryop(self, other, "MUL", False)) … … 1571 1568 s = None 1572 1569 if isinstance(other, scantable): 1573 print "scantable / scantable NYI" 1574 return 1570 s = scantable(self._math._binaryop(self, other, "DIV")) 1575 1571 elif isinstance(other, float): 1576 1572 if other == 0.0: -
branches/Release2.1.2/src/STMath.cpp
r1259 r1310 281 281 bool tsys ) 282 282 { 283 // modes are "ADD" and "MUL"284 283 CountedPtr< Scantable > out = getScantable(in, false); 285 284 Table& tab = out->table(); … … 291 290 specCol.get(i, spec); 292 291 tsysCol.get(i, ts); 293 if (mode == "MUL") { 292 if (mode == "MUL" || mode == "DIV") { 293 if (mode == "DIV") val = 1.0/val; 294 294 spec *= val; 295 295 specCol.put(i, spec); … … 298 298 tsysCol.put(i, ts); 299 299 } 300 } else if ( mode == "ADD" ) { 300 } else if ( mode == "ADD" || mode == "SUB") { 301 if (mode == "SUB") val *= -1.0; 301 302 spec += val; 302 303 specCol.put(i, spec); … … 309 310 return out; 310 311 } 312 313 CountedPtr<Scantable> STMath::binaryOperate(const CountedPtr<Scantable>& left, 314 const CountedPtr<Scantable>& right, 315 const std::string& mode) 316 { 317 bool insitu = insitu_; 318 if ( ! left->conformant(*right) ) { 319 throw(AipsError("'left' and 'right' scantables are not conformant.")); 320 } 321 setInsitu(false); 322 CountedPtr< Scantable > out = getScantable(left, false); 323 setInsitu(insitu); 324 Table& tout = out->table(); 325 Block<String> coln(5); 326 coln[0] = "SCANNO"; coln[1] = "CYCLENO"; coln[2] = "BEAMNO"; 327 coln[3] = "IFNO"; coln[4] = "POLNO"; 328 Table tmpl = tout.sort(coln); 329 Table tmpr = right->table().sort(coln); 330 ArrayColumn<Float> lspecCol(tmpl,"SPECTRA"); 331 ROArrayColumn<Float> rspecCol(tmpr,"SPECTRA"); 332 ArrayColumn<uChar> lflagCol(tmpl,"FLAGTRA"); 333 ROArrayColumn<uChar> rflagCol(tmpr,"FLAGTRA"); 334 335 for (uInt i=0; i<tout.nrow(); ++i) { 336 Vector<Float> lspecvec, rspecvec; 337 Vector<uChar> lflagvec, rflagvec; 338 lspecvec = lspecCol(i); rspecvec = rspecCol(i); 339 lflagvec = lflagCol(i); rflagvec = rflagCol(i); 340 MaskedArray<Float> mleft = maskedArray(lspecvec, lflagvec); 341 MaskedArray<Float> mright = maskedArray(rspecvec, rflagvec); 342 if (mode == "ADD") { 343 mleft += mright; 344 } else if ( mode == "SUB") { 345 mleft -= mright; 346 } else if ( mode == "MUL") { 347 mleft *= mright; 348 } else if ( mode == "DIV") { 349 mleft /= mright; 350 } else { 351 throw(AipsError("Illegal binary operator")); 352 } 353 lspecCol.put(i, mleft.getArray()); 354 } 355 return out; 356 } 357 358 311 359 312 360 MaskedArray<Float> STMath::maskedArray( const Vector<Float>& s, -
branches/Release2.1.2/src/STMath.h
r1295 r1310 119 119 const std::string& mode, bool tsys=false ); 120 120 121 casa::CountedPtr<Scantable> 122 binaryOperate( const casa::CountedPtr<Scantable>& left, 123 const casa::CountedPtr<Scantable>& right, 124 const std::string& mode); 125 121 126 casa::CountedPtr<Scantable> autoQuotient(const casa::CountedPtr<Scantable>& in, 122 127 const std::string& mode = "NEAREST", -
branches/Release2.1.2/src/STMathWrapper.h
r1200 r1310 72 72 const std::string& mode, bool tsys=false ) 73 73 { return ScantableWrapper(STMath::unaryOperate(in.getCP(), val, mode, tsys)); } 74 75 ScantableWrapper binaryOperate( const ScantableWrapper& left, 76 const ScantableWrapper& right, 77 const std::string& mode) 78 { return ScantableWrapper( STMath::binaryOperate( left.getCP(), right.getCP(), 79 mode ) ); } 80 74 81 75 82 ScantableWrapper autoQuotient( const ScantableWrapper& in, -
branches/Release2.1.2/src/python_STMath.cpp
r1192 r1310 49 49 .def("_averagebeams", &STMathWrapper::averageBeams) 50 50 .def("_unaryop", &STMathWrapper::unaryOperate) 51 .def("_binaryop", &STMathWrapper::binaryOperate) 51 52 .def("_auto_quotient", &STMathWrapper::autoQuotient) 52 53 .def("_quotient", &STMathWrapper::quotient)
Note:
See TracChangeset
for help on using the changeset viewer.