Changeset 865 for trunk/src


Ignore:
Timestamp:
03/06/06 10:39:18 (19 years ago)
Author:
mar637
Message:

added getAbcissa and several inline get functions. Full support of Table::Plain now (Ger modifications incasa::Table)

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Scantable.cpp

    r860 r865  
    8585  type_(ttype)
    8686{
    87   Table tab(name);
     87  Table tab(name, Table::Update);
    8888  Int version;
    8989  tab.keywordSet().get("VERSION", version);
     
    104104  // with or without data
    105105  String newname = String(generateName());
     106  type_ = other.table_.tableType();
    106107  if ( other.table_.tableType() == Table::Memory ) {
    107108      if ( clear ) {
    108         cout << "copy ctor memory clear" << endl;
    109109        table_ = TableCopy::makeEmptyMemoryTable(newname,
    110110                                                 other.table_, True);
     
    112112        table_ = other.table_.copyToMemoryTable(newname);
    113113  } else {
    114     if ( clear ) {
    115       cout << "copy ctor clear" << endl;
    116       other.table_.deepCopy(newname, Table::New);
    117       cout << "reading table" << endl;
    118       table_ = Table(newname, Table::Scratch);
    119       cout << "removing rows" << endl;
    120       table_.removeRow(table_.rowNumbers());
    121 
    122     } else {
    123       cout << "copy ctor no clear" << endl;
    124       other.table_.deepCopy(newname, Table::Scratch);
    125       table_ = Table(newname, Table::Scratch);
    126     }
    127   }
    128   //table_.rwKeywordSet().renameTables(newname, table_.tableName());
    129   //cout << table_.keywordSet().asTable("TCAL").tableName() << endl;
     114      other.table_.deepCopy(newname, Table::New, False, Table::AipsrcEndian,
     115                            Bool(clear));
     116      table_ = Table(newname, Table::Update);
     117      copySubtables(other);
     118      table_.markForDelete();
     119  }
     120
    130121  attachSubtables();
    131122  originalTable_ = table_;
    132123  attach();
     124}
     125
     126void Scantable::copySubtables(const Scantable& other) {
     127  Table t = table_.rwKeywordSet().asTable("FREQUENCIES");
     128  TableCopy::copyRows(t, other.freqTable_.table());
     129  t = table_.rwKeywordSet().asTable("FOCUS");
     130  TableCopy::copyRows(t, other.focusTable_.table());
     131  t = table_.rwKeywordSet().asTable("WEATHER");
     132  TableCopy::copyRows(t, other.weatherTable_.table());
     133  t = table_.rwKeywordSet().asTable("TCAL");
     134  TableCopy::copyRows(t, other.tcalTable_.table());
     135  t = table_.rwKeywordSet().asTable("MOLECULES");
     136  TableCopy::copyRows(t, other.moleculeTable_.table());
     137  t = table_.rwKeywordSet().asTable("HISTORY");
     138  TableCopy::copyRows(t, other.historyTable_.table());
    133139}
    134140
     
    235241  specCol_.attach(table_, "SPECTRA");
    236242  flagsCol_.attach(table_, "FLAGTRA");
    237   tsCol_.attach(table_, "TSYS");
     243  tsysCol_.attach(table_, "TSYS");
    238244  cycleCol_.attach(table_,"CYCLENO");
    239245  scanCol_.attach(table_, "SCANNO");
     
    390396  Path path(inname);
    391397  inname = path.expandedName();
    392   //cout << table_.tableName() << endl;
    393   //cout << freqTable_.table().tableName() << endl;
    394398  table_.deepCopy(inname, Table::New);
    395   //Table t = Table(inname, Table::Update);
    396   //cout << t.keywordSet().asTable("FREQUENCIES").tableName() << endl;
    397399}
    398400
     
    551553  }
    552554  pushLog(String(oss));
     555}
     556
     557void Scantable::flag()
     558{
     559  if ( selector_.empty() )
     560    throw(AipsError("Trying to flag whole scantable. Aborted."));
    553561}
    554562
     
    726734}
    727735
     736std::vector< double > asap::Scantable::getAbcissa( int whichrow ) const
     737{
     738  if ( whichrow > table_.nrow() ) throw(AipsError("Illegal ro number"));
     739  std::vector<double> stlout;
     740  int nchan = specCol_(whichrow).nelements();
     741  cout << nchan << endl;
     742  String us = freqTable_.getUnitString();
     743  if ( us == "" || us == "pixel" || us == "channel" ) {
     744    for (int i=0; i<nchan; ++i) {
     745      stlout.push_back(double(i));
     746    }
     747    return stlout;
     748  }
     749
     750  const MPosition& mp = getAntennaPosition();
     751  const MDirection& md = dirCol_(whichrow);
     752  const MEpoch& me = timeCol_(whichrow);
     753  Double rf = moleculeTable_.getRestFrequency(mmolidCol_(whichrow));
     754  SpectralCoordinate spc =
     755    freqTable_.getSpectralCoordinate(md, mp, me, rf, mfreqidCol_(whichrow));
     756  Vector<Double> pixel(nchan);
     757  Vector<Double> world;
     758  indgen(pixel);
     759  if ( Unit(us) == Unit("Hz") ) {
     760    for ( int i=0; i < nchan; ++i) {
     761      Double world;
     762      spc.toWorld(world, pixel[i]);
     763      stlout.push_back(double(world));
     764    }
     765  } else if ( Unit(us) == Unit("km/s") ) {
     766    Vector<Double> world;
     767    spc.pixelToVelocity(world, pixel);
     768    world.tovector(stlout);
     769  }
     770  return stlout;
     771}
     772
    728773std::string Scantable::getAbcissaLabel( int whichrow ) const
    729774{
     
    774819}
    775820
     821
     822
    776823}//namespace asap
  • trunk/src/Scantable.h

    r860 r865  
    227227  int getIF(int whichrow) const;
    228228  int getPol(int whichrow) const;
     229  int getCycle(int whichrow) const { return cycleCol_(whichrow); }
     230  int getScan(int whichrow) const { return scanCol_(whichrow); }
    229231
    230232  double getInterval(int whichrow) const
    231233    { return integrCol_(whichrow); }
    232234
    233   float getTsys(int whichrow) const;
     235  float getTsys(int whichrow) const
     236    { return casa::Vector<casa::Float>(tsysCol_(whichrow))(0); }
    234237  float getElevation(int whichrow) const
    235238    { return elCol_(whichrow); }
    236239  float getAzimuth(int whichrow) const
    237240    { return azCol_(whichrow); }
    238   float getParangle(int whichrow) const
     241  float getParAngle(int whichrow) const
    239242    { return paraCol_(whichrow); }
     243
     244  std::string getSourceName(int whichrow) const
     245    { return srcnCol_(whichrow); }
    240246
    241247  std::vector<bool> getMask(int whichrow) const;
     
    277283  void setCoordInfo(std::vector<string> theinfo)
    278284    { return freqTable_.setInfo(theinfo); };
     285
     286
     287  std::vector<double> getAbcissa(int whichrow) const;
    279288
    280289  std::string getAbcissaLabel(int whichrow) const;
     
    329338
    330339  void attachSubtables();
     340  void copySubtables(const Scantable& other);
     341
    331342  /**
    332343   * Convert an "old" asap1 style row index into a new index
     
    365376  casa::ScalarColumn<casa::uInt> scanCol_, beamCol_, ifCol_, polCol_, cycleCol_;
    366377  casa::ScalarColumn<casa::Int> rbeamCol_;
    367   casa::ArrayColumn<casa::Float> specCol_, tsCol_;
     378  casa::ArrayColumn<casa::Float> specCol_, tsysCol_;
    368379  casa::ArrayColumn<casa::uChar> flagsCol_;
    369380
Note: See TracChangeset for help on using the changeset viewer.