Changeset 847 for trunk/src/STFrequencies.cpp
- Timestamp:
- 02/24/06 10:03:21 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STFrequencies.cpp
r840 r847 33 33 namespace asap { 34 34 35 const casa::String STFrequencies::name_ = "FREQUENCIES";36 37 STFrequencies::STFrequencies( casa::Table::TableType tt) :35 const String STFrequencies::name_ = "FREQUENCIES"; 36 37 STFrequencies::STFrequencies(Table::TableType tt) : 38 38 STSubTable( name_, tt ) 39 39 { … … 53 53 table_.addColumn(ScalarColumnDesc<Double>("INCREMENT")); 54 54 55 table_.rwKeywordSet().define("REFFRAME", String("TOPO")); 55 table_.rwKeywordSet().define("FRAME", String("TOPO")); 56 table_.rwKeywordSet().define("BASEFRAME", String("TOPO")); 56 57 table_.rwKeywordSet().define("EQUINOX",String( "J2000")); 57 58 table_.rwKeywordSet().define("UNIT", String("Hz")); … … 108 109 } 109 110 110 SpectralCoordinate STFrequencies::getSpectralCoordinate( uInt freqID )111 { 112 Table t = table_(table_.col("ID") == Int( freqID) );111 SpectralCoordinate STFrequencies::getSpectralCoordinate( uInt id ) const 112 { 113 Table t = table_(table_.col("ID") == Int(id) ); 113 114 114 115 if (t.nrow() == 0 ) { 115 throw(AipsError("STFrequencies::getSpectralCoordinate - freqID out of range"));116 throw(AipsError("STFrequencies::getSpectralCoordinate - ID out of range")); 116 117 } 117 118 … … 121 122 const TableRecord& rec = row.get(0); 122 123 123 return SpectralCoordinate( getFrame( ), rec.asDouble("REFVAL"),124 return SpectralCoordinate( getFrame(true), rec.asDouble("REFVAL"), 124 125 rec.asDouble("INCREMENT"), 125 126 rec.asDouble("REFPIX")); 126 127 } 127 128 128 void STFrequencies::rescale( casa::Float factor, const std::string& mode ) 129 SpectralCoordinate 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 152 void STFrequencies::rescale( Float factor, const std::string& mode ) 129 153 { 130 154 TableRow row(table_); … … 137 161 const TableRecord& rec = row.get(i); 138 162 139 SpectralCoordinate sc ( getFrame( ), rec.asDouble("REFVAL"),163 SpectralCoordinate sc ( getFrame(true), rec.asDouble("REFVAL"), 140 164 rec.asDouble("INCREMENT"), rec.asDouble("REFPIX") ); 141 165 … … 177 201 178 202 179 casa::MFrequency::Types STFrequencies::getFrame() const203 MFrequency::Types STFrequencies::getFrame(bool base) const 180 204 { 181 205 // get the ref frame 182 String rf; 183 table_.keywordSet().get("REFFRAME", rf); 206 String rf = table_.keywordSet().asString("BASEFRAME"); 184 207 185 208 // Create SpectralCoordinate (units Hz) … … 192 215 193 216 return mft; 217 } 218 219 std::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 225 std::string asap::STFrequencies::getUnitString( ) const 226 { 227 return table_.keywordSet().asString("UNIT"); 228 } 229 230 Unit asap::STFrequencies::getUnit( ) const 231 { 232 return Unit(table_.keywordSet().asString("UNIT")); 233 } 234 235 std::string asap::STFrequencies::getDopplerString( ) const 236 { 237 return table_.keywordSet().asString("DOPPLER"); 238 } 239 240 MDoppler::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; 194 250 } 195 251 … … 226 282 const Record& r = table_.keywordSet(); 227 283 const Record& ro = other.table_.keywordSet(); 228 return ( r.asString(" REFFRAME") == ro.asString("REFFRAME") &&284 return ( r.asString("FRAME") == ro.asString("FRAME") && 229 285 r.asString("EQUINOX") == ro.asString("EQUINOX") && 230 286 r.asString("UNIT") == ro.asString("UNIT") && … … 233 289 } 234 290 291 std::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 300 void 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 } 315 void 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 235 328 } // namespace
Note: See TracChangeset
for help on using the changeset viewer.