Changeset 866 for trunk/src


Ignore:
Timestamp:
03/06/06 10:47:14 (19 years ago)
Author:
mar637
Message:

Update to setInfo
added setUnit, setDoppler

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STFrequencies.cpp

    r856 r866  
    161161    Unit unitu(unitstr);
    162162    if ( unitu == Unit("Hz") ) {
     163      Vector<String> wau(1); wau = unitu.getName();
     164      spc.setWorldAxisUnits(wau);
    163165    } else {
    164166      spc.setVelocity(unitstr, getDoppler());
     
    279281    const TableRecord& rec = row.get(i);
    280282    oss <<  setw(8)
    281     << "frame" << setw(16) << setprecision(8)
     283    << rec.asString("FRAME") << setw(16) << setprecision(8)
    282284    << rec.asDouble("REFVAL") << setw(10)
    283285    << rec.asDouble("REFPIX") << setw(12)
     
    315317  out.push_back(r.asString("FRAME"));
    316318  out.push_back(r.asString("DOPPLER"));
     319  return out;
    317320}
    318321
     
    320323{
    321324  if ( theinfo.size() != 3 ) throw(AipsError("setInfo needs three parameters"));
    322   String un,rfrm,dpl;
    323   un = theinfo[0];rfrm = theinfo[1];dpl = theinfo[2];
    324   TableRecord& r = table_.rwKeywordSet();
    325   setFrame(rfrm);
    326   MDoppler::Types dtype;
    327   dpl.upcase();
    328   if (!MDoppler::getType(dtype, dpl)) {
    329     throw(AipsError("Doppler type unknown"));
     325  try {
     326    setUnit(theinfo[0]);
     327    setFrame(theinfo[1]);
     328    setDoppler(theinfo[2]);
     329  } catch (AipsError& e) {
     330    throw(e);
     331  }
     332}
     333
     334void asap::STFrequencies::setUnit( const std::string & unit )
     335{
     336  if (unit == "" || unit == "pixel" || unit == "channel" ) {
     337    table_.rwKeywordSet().define("UNIT", "");
    330338  } else {
    331     r.define("DOPPLER",dpl);
    332   }
    333 }
     339    Unit u(unit);
     340    if ( u == Unit("km/s") || u == Unit("Hz") )
     341      table_.rwKeywordSet().define("UNIT", unit);
     342    else {
     343      throw(AipsError("Illegal spectral unit."));
     344    }
     345  }
     346}
     347
    334348void asap::STFrequencies::setFrame( const std::string & frame )
    335349{
     
    338352    Int a,b;const uInt* c;
    339353    const String* valid = MFrequency::allMyTypes(a, b, c);
    340     String pfix = "Please specify a legal frame type. Types are\n";
    341     throw(AipsError(pfix+(*valid)));
     354    Vector<String> ftypes(IPosition(1,a), valid);
     355    ostringstream oss;
     356    oss <<  String("Please specify a legal frequency type. Types are\n");
     357    oss << ftypes;
     358    String msg(oss);
     359    throw(AipsError(msg));
    342360  } else {
    343361    table_.rwKeywordSet().define("FRAME", frame);
     
    345363}
    346364
     365void asap::STFrequencies::setDoppler( const std::string & doppler )
     366{
     367  MDoppler::Types mdt;
     368  if (!MDoppler::getType(mdt, doppler)) {
     369    cout << "DEBUG" << endl;
     370    Int a,b;const uInt* c;
     371    const String* valid = MDoppler::allMyTypes(a, b, c);
     372    Vector<String> ftypes(IPosition(1,a), valid);
     373    ostringstream oss;
     374    oss <<  String("Please specify a legal doppler type. Types are\n");
     375    oss << ftypes;
     376    String msg(oss);
     377    throw(AipsError(msg));
     378  } else {
     379    table_.rwKeywordSet().define("DOPPLER", doppler);
     380  }
     381}
     382
    347383
    348384} // namespace
  • trunk/src/STFrequencies.h

    r856 r866  
    115115   */
    116116  void setFrame(casa::MFrequency::Types frame);
    117 
     117  void setUnit( const std::string & unit );
     118  void setDoppler( const std::string & doppler );
    118119  /**
    119120   * rescale the whole table by a given factor
Note: See TracChangeset for help on using the changeset viewer.