Changeset 987 for trunk/src


Ignore:
Timestamp:
04/05/06 14:30:35 (19 years ago)
Author:
mar637
Message:

added direction reference conversions as in Ticket #13

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Scantable.cpp

    r973 r987  
    219219  // the TableMeasDesc gives the column a type
    220220  TableMeasDesc<MDirection> mdirCol(tmvdMDir, mdirRef);
     221  // a uder set table type e.g. GALCTIC, B1950 ...
     222  td.rwKeywordSet().define("DIRECTIONREF", String("J2000"));
    221223  // writing create the measure column
    222224  mdirCol.write(td);
     
    352354  MVAngle mvLon(t[0]);
    353355  String sLon = mvLon.string(MVAngle::TIME,prec);
     356  uInt tp = md.getRef().getType();
     357  if (tp == MDirection::GALACTIC ||
     358      tp == MDirection::SUPERGAL ) {
     359    sLon = mvLon(0.0).string(MVAngle::ANGLE_CLEAN,prec);
     360  }
    354361  MVAngle mvLat(t[1]);
    355362  String sLat = mvLat.string(MVAngle::ANGLE+MVAngle::DIG2,prec);
     
    550557  for (uInt i=0; i<nrow(); ++i) {
    551558    MEpoch me = timeCol(i);
    552     MDirection md = dirCol_(i);
    553     dirCol_.get(i,md);
     559    MDirection md = getDirection(i);
    554560    oss  << " Time: " << formatTime(me,False) << " Direction: " << formatDirection(md)
    555561         << endl << "     => ";
     
    717723  // main table
    718724  String dirtype = "Position ("
    719                   + MDirection::showType(dirCol_.getMeasRef().getType())
     725                  + getDirectionRefString()
    720726                  + ")";
    721727  oss << setw(5) << "Scan" << setw(15) << "Source"
     
    750756      Table bsubt = biter.table();
    751757      ROTableRow brow(bsubt);
    752       MDirection::ROScalarColumn bdirCol(bsubt,"DIRECTION");
    753758      const TableRecord& brec = brow.get(0);
     759      uInt row0 = bsubt.rowNumbers()[0];
    754760      oss << setw(5) << "" <<  setw(4) << std::right << brec.asuInt("BEAMNO")<< std::left;
    755       oss  << setw(4) << ""  << formatDirection(bdirCol(0)) << endl;
     761      oss  << setw(4) << ""  << formatDirection(getDirection(row0)) << endl;
    756762      TableIterator iiter(bsubt, "IFNO");
    757763      while (!iiter.pastEnd()) {
     
    801807
    802808  const MPosition& mp = getAntennaPosition();
    803   const MDirection& md = dirCol_(whichrow);
     809  const MDirection& md = getDirection(whichrow);
    804810  const MEpoch& me = timeCol_(whichrow);
    805811  Double rf = moleculeTable_.getRestFrequency(mmolidCol_(whichrow));
     
    822828  return stlout;
    823829}
     830void asap::Scantable::setDirectionRefString( const std::string & refstr )
     831{
     832  MDirection::Types mdt;
     833  if (refstr != "" && !MDirection::getType(mdt, refstr)) {
     834    throw(AipsError("Illegal Direction frame."));
     835  }
     836  if ( refstr == "" ) {
     837    String defaultstr = MDirection::showType(dirCol_.getMeasRef().getType());
     838    table_.rwKeywordSet().define("DIRECTIONREF", defaultstr);
     839  } else {
     840    table_.rwKeywordSet().define("DIRECTIONREF", String(refstr));
     841  }
     842}
     843
     844std::string asap::Scantable::getDirectionRefString( ) const
     845{
     846  return table_.keywordSet().asString("DIRECTIONREF");
     847}
     848
     849MDirection Scantable::getDirection(int whichrow ) const
     850{
     851  String usertype = table_.keywordSet().asString("DIRECTIONREF");
     852  String type = MDirection::showType(dirCol_.getMeasRef().getType());
     853  if ( usertype != type ) {
     854    MDirection::Types mdt;
     855    if (!MDirection::getType(mdt, usertype)) {
     856      throw(AipsError("Illegal Direction frame."));
     857    }
     858    return dirCol_.convert(uInt(whichrow), mdt);
     859  } else {
     860    return dirCol_(uInt(whichrow));
     861  }
     862}
    824863
    825864std::string Scantable::getAbcissaLabel( int whichrow ) const
     
    827866  if ( whichrow > table_.nrow() ) throw(AipsError("Illegal ro number"));
    828867  const MPosition& mp = getAntennaPosition();
    829   const MDirection& md = dirCol_(whichrow);
     868  const MDirection& md = getDirection(whichrow);
    830869  const MEpoch& me = timeCol_(whichrow);
    831870  const Double& rf = mmolidCol_(whichrow);
     
    902941}
    903942
    904 } //namespace asap
     943
     944}
     945 //namespace asap
  • trunk/src/Scantable.h

    r972 r987  
    143143  int nscan() const;
    144144
    145   //casa::MDirection::Types getDirectionReference() const;
    146145  casa::MEpoch::Types getTimeReference() const;
    147146
     
    151150   */
    152151  casa::MPosition getAntennaPosition() const;
     152
     153  casa::MDirection getDirection( int whichrow ) const;
     154
     155  void setDirectionRefString(const std::string& refstr="");
     156
     157  std::string getDirectionRefString() const;
    153158
    154159  /**
     
    300305  void setRestFrequencies(double rf, const std::string& = "Hz");
    301306  void setRestFrequencies(const std::string& name);
     307
     308  void convertDirection(const std::string& newframe);
    302309
    303310  STFrequencies& frequencies() { return freqTable_; }
  • trunk/src/ScantableWrapper.h

    r972 r987  
    131131  int nrow() const {return table_->nrow();}
    132132  int ncycle(int scanno) const {return table_->ncycle(scanno);}
    133   ///@todo int nstokes() {return table_->nStokes();}
    134133
    135134  void makePersistent(const std::string& fname)
     
    153152    return table_->getCoordInfo();
    154153  }
     154
     155  void setDirection(const std::string& refstr="")
     156    { table_->setDirectionRefString(refstr); }
    155157
    156158  casa::CountedPtr<Scantable> getCP() const {return table_;}
  • trunk/src/python_Scantable.cpp

    r972 r987  
    9999    .def("_setcoordinfo", &ScantableWrapper::setCoordInfo)
    100100    .def("_getcoordinfo", &ScantableWrapper::getCoordInfo)
     101    .def("set_dirframe", &ScantableWrapper::setDirection,
     102         (boost::python::arg("refstr")="") )
    101103    .def("_gethistory", &ScantableWrapper::getHistory)
    102104    .def("_addhistory", &ScantableWrapper::addHistory)
Note: See TracChangeset for help on using the changeset viewer.