Ignore:
Timestamp:
02/24/06 10:03:21 (18 years ago)
Author:
mar637
Message:

numerous changes before move to new svn repository sourcecode.atnf.csiro.au

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STFrequencies.cpp

    r840 r847  
    3333namespace asap {
    3434
    35 const casa::String STFrequencies::name_ = "FREQUENCIES";
    36 
    37 STFrequencies::STFrequencies(casa::Table::TableType tt) :
     35const String STFrequencies::name_ = "FREQUENCIES";
     36
     37STFrequencies::STFrequencies(Table::TableType tt) :
    3838  STSubTable( name_, tt )
    3939{
     
    5353  table_.addColumn(ScalarColumnDesc<Double>("INCREMENT"));
    5454
    55   table_.rwKeywordSet().define("REFFRAME", String("TOPO"));
     55  table_.rwKeywordSet().define("FRAME", String("TOPO"));
     56  table_.rwKeywordSet().define("BASEFRAME", String("TOPO"));
    5657  table_.rwKeywordSet().define("EQUINOX",String( "J2000"));
    5758  table_.rwKeywordSet().define("UNIT", String("Hz"));
     
    108109}
    109110
    110 SpectralCoordinate STFrequencies::getSpectralCoordinate( uInt freqID )
    111 {
    112   Table t = table_(table_.col("ID") == Int(freqID) );
     111SpectralCoordinate STFrequencies::getSpectralCoordinate( uInt id ) const
     112{
     113  Table t = table_(table_.col("ID") == Int(id) );
    113114
    114115  if (t.nrow() == 0 ) {
    115     throw(AipsError("STFrequencies::getSpectralCoordinate - freqID out of range"));
     116    throw(AipsError("STFrequencies::getSpectralCoordinate - ID out of range"));
    116117  }
    117118
     
    121122  const TableRecord& rec = row.get(0);
    122123
    123   return SpectralCoordinate( getFrame(), rec.asDouble("REFVAL"),
     124  return SpectralCoordinate( getFrame(true), rec.asDouble("REFVAL"),
    124125                             rec.asDouble("INCREMENT"),
    125126                             rec.asDouble("REFPIX"));
    126127}
    127128
    128 void STFrequencies::rescale( casa::Float factor, const std::string& mode )
     129SpectralCoordinate
     130  asap::STFrequencies::getSpectralCoordinate( const MDirection& md,
     131                                              const MPosition& mp,
     132                                              const MEpoch& me,
     133                                              Double restfreq, uInt id ) const
     134{
     135  SpectralCoordinate spc = getSpectralCoordinate(id);
     136  spc.setRestFrequency(restfreq, True);
     137  if ( !spc.setReferenceConversion(getFrame(), me, mp, md) ) {
     138    throw(AipsError("Couldn't convert frequency frame."));
     139  }
     140  String unitstr = getUnitString();
     141  if ( !unitstr.empty() ) {
     142    Unit unitu(unitstr);
     143    if ( unitu == Unit("Hz") ) {
     144    } else {
     145      spc.setVelocity(unitstr, getDoppler());
     146    }
     147  }
     148  return spc;
     149}
     150
     151
     152void STFrequencies::rescale( Float factor, const std::string& mode )
    129153{
    130154  TableRow row(table_);
     
    137161    const TableRecord& rec = row.get(i);
    138162
    139     SpectralCoordinate sc ( getFrame(), rec.asDouble("REFVAL"),
     163    SpectralCoordinate sc ( getFrame(true), rec.asDouble("REFVAL"),
    140164                            rec.asDouble("INCREMENT"), rec.asDouble("REFPIX") );
    141165
     
    177201
    178202
    179 casa::MFrequency::Types STFrequencies::getFrame( ) const
     203MFrequency::Types STFrequencies::getFrame(bool base) const
    180204{
    181205  // get the ref frame
    182   String rf;
    183   table_.keywordSet().get("REFFRAME", rf);
     206  String rf = table_.keywordSet().asString("BASEFRAME");
    184207
    185208  // Create SpectralCoordinate (units Hz)
     
    192215
    193216  return mft;
     217}
     218
     219std::string asap::STFrequencies::getFrameString( bool base ) const
     220{
     221  if ( base ) return table_.keywordSet().asString("BASEFRAME");
     222  else return table_.keywordSet().asString("FRAME");
     223}
     224
     225std::string asap::STFrequencies::getUnitString( ) const
     226{
     227  return table_.keywordSet().asString("UNIT");
     228}
     229
     230Unit asap::STFrequencies::getUnit( ) const
     231{
     232  return Unit(table_.keywordSet().asString("UNIT"));
     233}
     234
     235std::string asap::STFrequencies::getDopplerString( ) const
     236{
     237  return table_.keywordSet().asString("DOPPLER");
     238}
     239
     240MDoppler::Types asap::STFrequencies::getDoppler( ) const
     241{
     242  String dpl = table_.keywordSet().asString("DOPPLER");
     243
     244  // Create SpectralCoordinate (units Hz)
     245  MDoppler::Types mdt;
     246  if (!MDoppler::getType(mdt, dpl)) {
     247    throw(AipsError("Doppler type unknown"));
     248  }
     249  return mdt;
    194250}
    195251
     
    226282  const Record& r = table_.keywordSet();
    227283  const Record& ro = other.table_.keywordSet();
    228   return ( r.asString("REFFRAME") == ro.asString("REFFRAME") &&
     284  return ( r.asString("FRAME") == ro.asString("FRAME") &&
    229285           r.asString("EQUINOX") == ro.asString("EQUINOX") &&
    230286           r.asString("UNIT") == ro.asString("UNIT") &&
     
    233289}
    234290
     291std::vector< std::string > asap::STFrequencies::getInfo( ) const
     292{
     293  const Record& r = table_.keywordSet();
     294  std::vector<std::string> out;
     295  out.push_back(r.asString("UNIT"));
     296  out.push_back(r.asString("FRAME"));
     297  out.push_back(r.asString("DOPPLER"));
     298}
     299
     300void asap::STFrequencies::setInfo( const std::vector< std::string >& theinfo )
     301{
     302  if ( theinfo.size() != 3 ) throw(AipsError("setInfo needs three parameters"));
     303  String un,rfrm,dpl;
     304  un = theinfo[0];rfrm = theinfo[1];dpl = theinfo[2];
     305  TableRecord& r = table_.rwKeywordSet();
     306  setFrame(rfrm);
     307  MDoppler::Types dtype;
     308  dpl.upcase();
     309  if (!MDoppler::getType(dtype, dpl)) {
     310    throw(AipsError("Doppler type unknown"));
     311  } else {
     312    r.define("DOPPLER",dpl);
     313  }
     314}
     315void asap::STFrequencies::setFrame( const std::string & frame )
     316{
     317  MFrequency::Types mdr;
     318  if (!MFrequency::getType(mdr, frame)) {
     319    Int a,b;const uInt* c;
     320    const String* valid = MFrequency::allMyTypes(a, b, c);
     321    String pfix = "Please specify a legal frame type. Types are\n";
     322    throw(AipsError(pfix+(*valid)));
     323  } else {
     324    table_.rwKeywordSet().define("FRAME", frame);
     325  }
     326}
     327
    235328} // namespace
Note: See TracChangeset for help on using the changeset viewer.