Ignore:
Timestamp:
03/10/06 12:09:29 (18 years ago)
Author:
mar637
Message:

enable polarimetry in asap2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Scantable.cpp

    r888 r896  
    5454
    5555#include "Scantable.h"
     56#include "STPolLinear.h"
    5657#include "STAttr.h"
    5758
     
    5960
    6061namespace asap {
     62
     63std::map<std::string, STPol::STPolFactory *> Scantable::factories_;
     64
     65void Scantable::initFactories() {
     66  if ( factories_.empty() ) {
     67    Scantable::factories_["linear"] = &STPolLinear::myFactory;
     68  }
     69}
    6170
    6271Scantable::Scantable(Table::TableType ttype) :
    6372  type_(ttype)
    6473{
     74  initFactories();
    6575  setupMainTable();
    6676  freqTable_ = STFrequencies(*this);
     
    8595  type_(ttype)
    8696{
     97  initFactories();
    8798  Table tab(name, Table::Update);
    8899  Int version;
     
    566577  if ( selector_.empty() )
    567578    throw(AipsError("Trying to flag whole scantable. Aborted."));
     579  TableVector<uChar> tvec(table_, "FLAGTRA");
     580  uChar userflag = 1 << 7;
     581  tvec = userflag;
    568582}
    569583
     
    580594}
    581595
    582 std::vector<float> Scantable::getSpectrum(int whichrow) const
    583 {
     596std::vector<float> Scantable::getSpectrum( int whichrow,
     597                                           const std::string& poltype) const
     598{
     599  std::vector<float> out;
    584600  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  }
    587621  arr.tovector(out);
    588622  return out;
    589623}
    590 
    591624
    592625void asap::Scantable::setSpectrum( const std::vector<float>& spec,
     
    597630  specCol_.get(whichrow, arr);
    598631  if ( spectrum.nelements() != arr.nelements() )
    599     throw AipsError("The specturm has incorrect number of channels.");
     632    throw AipsError("The spectrum has incorrect number of channels.");
    600633  specCol_.put(whichrow, spectrum);
    601634}
     
    616649  return table_;
    617650}
     651
     652std::string Scantable::getPolType() const
     653{
     654  return table_.keywordSet().asString("POLTYPE");
     655}
     656
    618657
    619658std::string Scantable::getPolarizationLabel(bool linear, bool stokes,
     
    655694  oss << setw(15) << "Beams:" << setw(4) << nbeam() << endl
    656695      << 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
    658698      << setw(15) << "Channels:"  << setw(4) << nchan() << endl;
    659699  oss << endl;
     
    839879
    840880
     881Matrix<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
    841894
    842895}//namespace asap
Note: See TracChangeset for help on using the changeset viewer.