Changeset 896 for trunk/src/Scantable.cpp
- Timestamp:
- 03/10/06 12:09:29 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Scantable.cpp
r888 r896 54 54 55 55 #include "Scantable.h" 56 #include "STPolLinear.h" 56 57 #include "STAttr.h" 57 58 … … 59 60 60 61 namespace asap { 62 63 std::map<std::string, STPol::STPolFactory *> Scantable::factories_; 64 65 void Scantable::initFactories() { 66 if ( factories_.empty() ) { 67 Scantable::factories_["linear"] = &STPolLinear::myFactory; 68 } 69 } 61 70 62 71 Scantable::Scantable(Table::TableType ttype) : 63 72 type_(ttype) 64 73 { 74 initFactories(); 65 75 setupMainTable(); 66 76 freqTable_ = STFrequencies(*this); … … 85 95 type_(ttype) 86 96 { 97 initFactories(); 87 98 Table tab(name, Table::Update); 88 99 Int version; … … 566 577 if ( selector_.empty() ) 567 578 throw(AipsError("Trying to flag whole scantable. Aborted.")); 579 TableVector<uChar> tvec(table_, "FLAGTRA"); 580 uChar userflag = 1 << 7; 581 tvec = userflag; 568 582 } 569 583 … … 580 594 } 581 595 582 std::vector<float> Scantable::getSpectrum(int whichrow) const 583 { 596 std::vector<float> Scantable::getSpectrum( int whichrow, 597 const std::string& poltype) const 598 { 599 std::vector<float> out; 584 600 Vector<Float> arr; 585 specCol_.get(whichrow, arr); 586 std::vector<float> out; 601 uInt requestedpol = polCol_(whichrow); 602 String basetype = getPolType(); 603 if ( String(poltype) == basetype) { 604 specCol_.get(whichrow, arr); 605 } else { 606 STPol* stpol = 0; 607 stpol =STPol::getPolClass(Scantable::factories_, basetype); 608 try { 609 uInt row = uInt(whichrow); 610 stpol->setSpectra(getPolMatrix(row)); 611 Float frot,fang,ftan; 612 focusTable_.getEntry(frot, fang, ftan, row); 613 stpol->setPhaseCorrections(frot, fang, ftan); 614 arr = stpol->getSpectrum(requestedpol, poltype); 615 delete stpol; 616 } catch (AipsError& e) { 617 delete stpol; 618 throw(e); 619 } 620 } 587 621 arr.tovector(out); 588 622 return out; 589 623 } 590 591 624 592 625 void asap::Scantable::setSpectrum( const std::vector<float>& spec, … … 597 630 specCol_.get(whichrow, arr); 598 631 if ( spectrum.nelements() != arr.nelements() ) 599 throw AipsError("The spect urm has incorrect number of channels.");632 throw AipsError("The spectrum has incorrect number of channels."); 600 633 specCol_.put(whichrow, spectrum); 601 634 } … … 616 649 return table_; 617 650 } 651 652 std::string Scantable::getPolType() const 653 { 654 return table_.keywordSet().asString("POLTYPE"); 655 } 656 618 657 619 658 std::string Scantable::getPolarizationLabel(bool linear, bool stokes, … … 655 694 oss << setw(15) << "Beams:" << setw(4) << nbeam() << endl 656 695 << setw(15) << "IFs:" << setw(4) << nif() << endl 657 << setw(15) << "Polarisations:" << setw(4) << npol() << endl 696 << setw(15) << "Polarisations:" << setw(4) << npol() 697 << "(" << getPolType() << ")" << endl 658 698 << setw(15) << "Channels:" << setw(4) << nchan() << endl; 659 699 oss << endl; … … 839 879 840 880 881 Matrix<Float> asap::Scantable::getPolMatrix( uInt whichrow ) const 882 { 883 ROTableRow row(table_); 884 const TableRecord& rec = row.get(whichrow); 885 Table t = 886 originalTable_( originalTable_.col("SCANNO") == Int(rec.asuInt("SCANNO")) 887 && originalTable_.col("BEAMNO") == Int(rec.asuInt("BEAMNO")) 888 && originalTable_.col("IFNO") == Int(rec.asuInt("IFNO")) 889 && originalTable_.col("CYCLENO") == Int(rec.asuInt("CYCLENO")) ); 890 ROArrayColumn<Float> speccol(t, "SPECTRA"); 891 return speccol.getColumn(); 892 } 893 841 894 842 895 }//namespace asap
Note: See TracChangeset
for help on using the changeset viewer.