Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMath.cc
r304 r309 55 55 #include <coordinates/Coordinates/CoordinateSystem.h> 56 56 #include <coordinates/Coordinates/CoordinateUtil.h> 57 #include <coordinates/Coordinates/ VelocityAligner.h>57 #include <coordinates/Coordinates/FrequencyAligner.h> 58 58 59 59 #include <lattices/Lattices/LatticeUtilities.h> … … 108 108 109 109 110 SDMemTable* SDMath:: velocityAlignment (const SDMemTable& in, const String& refTime) const111 { 112 113 // Get velocity/frame info from Table110 SDMemTable* SDMath::frequencyAlignment (const SDMemTable& in, const String& refTime) const 111 { 112 113 // Get frame info from Table 114 114 115 115 std::vector<std::string> info = in.getCoordInfo(); 116 116 117 // Parse unit ("" means channels) 118 119 String velUnit(info[0]); 120 if (velUnit.length()==0) { 121 throw(AipsError("You have not set a velocity abcissa unit - use function set_unit")); 122 } else { 123 Unit velUnitU(velUnit); 124 if (velUnitU!=Unit(String("m/s"))) { 125 throw(AipsError("Specified abcissa unit is not consistent with km/s - use function set_unit")); 126 } 117 // Parse frequency system 118 119 String systemStr(info[1]); 120 String baseSystemStr(info[3]); 121 if (baseSystemStr==systemStr) { 122 throw(AipsError("You have not set a frequency frame different from the initial - use function set_freqframe")); 127 123 } 128 129 // Parse doppler 130 131 String dopplerStr(info[2]); 132 String velSystemStr(info[1]); 133 String velBaseSystemStr(info[3]); 134 if (velBaseSystemStr==velSystemStr) { 135 throw(AipsError("You have not set a velocity frame different from the initial - use function set_freqframe")); 136 } 137 138 // Parse frequency system 139 140 MFrequency::Types velSystem; 141 MFrequency::getType(velSystem, velSystemStr); 142 MDoppler::Types doppler; 143 MDoppler::getType(doppler, dopplerStr); 124 // 125 MFrequency::Types freqSystem; 126 MFrequency::getType(freqSystem, systemStr); 144 127 145 128 // Do it 146 129 147 return velocityAlign (in, velSystem, velUnit, doppler, refTime);130 return frequencyAlign (in, freqSystem, refTime); 148 131 } 149 132 … … 152 135 CountedPtr<SDMemTable> SDMath::average(const Block<CountedPtr<SDMemTable> >& in, 153 136 const Vector<Bool>& mask, Bool scanAv, 154 const String& weightStr, Bool align Velocity) const137 const String& weightStr, Bool alignFreq) const 155 138 // 156 139 // Weighted averaging of spectra from one or more Tables. … … 256 239 for (uInt iTab=0; iTab<nTables; iTab++) { 257 240 258 // Should check that the frequency tables don't change if doing VelocityAlignment241 // Should check that the frequency tables don't change if doing FreqAlignment 259 242 260 243 // Attach columns to Table … … 646 629 { 647 630 Bool doVel = False; 631 if (doVel) { 632 for (uInt j=0; j<in.nCoordinates(); ++j) { 633 SpectralCoordinate sC = in.getSpectralCoordinate(j); 634 } 635 } 636 648 637 649 638 // Interpolation method … … 1257 1246 // 'private' functions 1258 1247 1259 SDMemTable* SDMath::velocityAlign (const SDMemTable& in, 1260 MFrequency::Types velSystem, 1261 const String& velUnit, 1262 MDoppler::Types doppler, 1248 1249 SDMemTable* SDMath::frequencyAlign (const SDMemTable& in, 1250 MFrequency::Types freqSystem, 1263 1251 const String& refTime) const 1264 1252 { … … 1301 1289 refEpoch = in.getEpoch(0); 1302 1290 } 1303 cerr << "Aligning at reference Epoch " << formatEpoch(refEpoch) << endl; 1291 cerr << "Aligning at reference Epoch " << formatEpoch(refEpoch) << 1292 " in frame " << MFrequency::showType(freqSystem) << endl; 1304 1293 1305 1294 // Get Reference Position … … 1312 1301 const uInt nFreqIDs = fTab.length(); 1313 1302 1314 // Create VelocityAligner Block. One VA for each possible1303 // Create FrequencyAligner Block. One VA for each possible 1315 1304 // source/freqID combination 1316 1305 1317 PtrBlock< VelocityAligner<Float>* > vA(nFreqIDs*nSrcTab);1318 generate VelocityAligners (vA, in, nChan, nFreqIDs, nSrcTab, firstRow,1319 velSystem, velUnit, doppler,refPos, refEpoch);1306 PtrBlock<FrequencyAligner<Float>* > a(nFreqIDs*nSrcTab); 1307 generateFrequencyAligners (a, in, nChan, nFreqIDs, nSrcTab, firstRow, 1308 freqSystem, refPos, refEpoch); 1320 1309 1321 1310 // New output Table … … 1326 1315 1327 1316 const IPosition polChanAxes(2, asap::PolAxis, asap::ChanAxis); 1328 VelocityAligner<Float>::Method method = VelocityAligner<Float>::LINEAR;1317 FrequencyAligner<Float>::Method method = FrequencyAligner<Float>::LINEAR; 1329 1318 Bool extrapolate=False; 1330 1319 Bool useCachedAbcissa = False; … … 1333 1322 Vector<Float> yOut; 1334 1323 Vector<Bool> maskOut; 1335 uInt ifIdx, vaIdx;1324 uInt ifIdx, faIdx; 1336 1325 // 1337 1326 for (uInt iRow=0; iRow<nRows; ++iRow) { … … 1358 1347 // cerr << "values in = " << values(IPosition(4,0,0,0,0),IPosition(4,0,0,0,9)) << endl; 1359 1348 1360 // For each row, the Velocity abcissa will be the same regardless1349 // For each row, the Frequency abcissa will be the same regardless 1361 1350 // of polarization. For all other axes (IF and BEAM) the abcissa 1362 1351 // will change. So we iterate through the data by pol-chan planes … … 1370 1359 while (!itValuesPlane.pastEnd()) { 1371 1360 1372 // Find the IF index and then the VA PtrBlock index1361 // Find the IF index and then the FA PtrBlock index 1373 1362 1374 1363 const IPosition& pos = itValuesPlane.pos(); 1375 1364 ifIdx = pos(asap::IFAxis); 1376 vaIdx = (srcIdx[iRow]*nFreqIDs) + freqID[ifIdx];1365 faIdx = (srcIdx[iRow]*nFreqIDs) + freqID[ifIdx]; 1377 1366 // 1378 1367 VectorIterator<Float> itValuesVec(itValuesPlane.array(), 1); … … 1382 1371 useCachedAbcissa=False; 1383 1372 while (!itValuesVec.pastEnd()) { 1384 ok = vA[vaIdx]->align (yOut, maskOut, itValuesVec.vector(),1373 ok = a[faIdx]->align (yOut, maskOut, itValuesVec.vector(), 1385 1374 itMaskVec.vector(), epoch, useCachedAbcissa, 1386 1375 method, extrapolate); … … 1411 1400 } 1412 1401 1402 1403 // Write out correct frequency table information for output. 1404 // CLone from input and overwrite 1405 1406 SDFrequencyTable freqTab = in.getSDFreqTable(); 1407 freqTab.setLength(0); 1408 1409 // Note that we don't have anyway to hold frequency table information 1410 // in the SDMemTable which is source dependent. Each FrequencyAligner 1411 // is generated for an freqID/Source combination. Don't know what to 1412 // do about this apart from to pick the aligned SC from the first source 1413 // at the moment. ASAP really needs to handle data description id 1414 // like in aips++ which is a combination of source and freqid. Otherwise 1415 // all else I can do in this function is disallow multiple sources 1416 1417 Bool linear=True; 1418 Vector<String> units(1); 1419 units = String("Hz"); 1420 for (uInt fqID=0; fqID<nFreqIDs; fqID++) { 1421 for (uInt iSrc=0; iSrc<nSrcTab; iSrc++) { 1422 uInt idx = (iSrc*nFreqIDs) + fqID; 1423 1424 // Get Aligned SC in Hz 1425 1426 if (iSrc==0) { 1427 SpectralCoordinate sC = a[idx]->alignedSpectralCoordinate(linear); 1428 sC.setWorldAxisUnits(units); 1429 1430 // Write out frequency table information to SDMemTable 1431 1432 Int idx = freqTab.addFrequency(sC.referencePixel()[0], 1433 sC.referenceValue()[0], 1434 sC.increment()[0]); 1435 } 1436 } 1437 } 1438 pTabOut->putSDFreqTable(freqTab); 1439 1440 // Now we must set the base and extra frames to the 1441 // input frame 1442 1443 std::vector<string> info = pTabOut->getCoordInfo(); 1444 info[1] = MFrequency::showType(freqSystem); // Conversion frame 1445 info[3] = info[1]; // Base frame 1446 pTabOut->setCoordInfo(info); 1447 1413 1448 // Clean up PointerBlock 1414 1449 1415 for (uInt i=0; i<vA.nelements(); i++) delete vA[i]; 1416 // 1417 pTabOut->resetCursor(); 1418 return pTabOut; 1450 for (uInt i=0; i<a.nelements(); i++) delete a[i]; 1451 // 1452 return pTabOut; 1419 1453 } 1420 1454 … … 1780 1814 1781 1815 1782 void SDMath::generateVelocityAligners (PtrBlock<VelocityAligner<Float>* >& vA, 1816 1817 void SDMath::generateFrequencyAligners (PtrBlock<FrequencyAligner<Float>* >& a, 1783 1818 const SDMemTable& in, uInt nChan, 1784 1819 uInt nFreqIDs, uInt nSrcTab, 1785 1820 const Vector<uInt>& firstRow, 1786 MFrequency::Types velSystem, 1787 const String& velUnit, 1788 MDoppler::Types doppler, 1821 MFrequency::Types system, 1789 1822 const MPosition& refPos, 1790 1823 const MEpoch& refEpoch) const … … 1795 1828 MDirection refDir = in.getDirection(firstRow[iSrc]); 1796 1829 uInt idx = (iSrc*nFreqIDs) + fqID; 1797 vA[idx] = new VelocityAligner<Float>(sC, nChan, refEpoch, refDir, refPos, 1798 velUnit, doppler, velSystem); 1830 a[idx] = new FrequencyAligner<Float>(sC, nChan, refEpoch, refDir, refPos, system); 1799 1831 } 1800 1832 } 1801 1833 } 1802 1834 1835 -
trunk/src/SDMath.h
r299 r309 36 36 #include <casa/aips.h> 37 37 #include <casa/Utilities/CountedPtr.h> 38 #include <coordinates/Coordinates/ VelocityAligner.h>38 #include <coordinates/Coordinates/FrequencyAligner.h> 39 39 40 40 #include "SDDefs.h" … … 44 44 class casa::MPosition; 45 45 template<class T> class casa::PtrBlock; 46 //template<class T> class casa::VelocityAligner;47 46 48 47 … … 78 77 casa::Bool scanAverage, 79 78 const casa::String& weightStr, 80 casa::Bool align Velocity=casa::False) const;79 casa::Bool align=casa::False) const; 81 80 82 81 // Statistics. If row<0, all rows are done otherwise, just the … … 106 105 const casa::String& method, casa::Bool doAll) const; 107 106 108 // Velocity Alignment109 SDMemTable* velocityAlignment (const SDMemTable& in, const casa::String& refTime) const;107 // Frequency Alignment 108 SDMemTable* frequencyAlignment (const SDMemTable& in, const casa::String& refTime) const; 110 109 111 110 // Opacity correction … … 194 193 const casa::Vector<casa::String>& srcNames) const; 195 194 196 // Generate velocity aligners 197 void generateVelocityAligners (casa::PtrBlock<casa::VelocityAligner<casa::Float>* >& vA, 198 const SDMemTable& in, casa::uInt nChan, 199 casa::uInt nFreqIDs, casa::uInt nSrcTab, 200 const casa::Vector<casa::uInt>& firstRow, 201 casa::MFrequency::Types velSystem, 202 const casa::String& velUnit, 203 casa::MDoppler::Types doppler, 204 const casa::MPosition& refPos, 205 const casa::MEpoch& refEpoch) const; 206 207 // Align in Velocity 208 SDMemTable* velocityAlign (const SDMemTable& in, 209 casa::MFrequency::Types velSystem, 210 const casa::String& velUnit, 211 casa::MDoppler::Types doppler, 195 // Generate frequency aligners 196 void generateFrequencyAligners (casa::PtrBlock<casa::FrequencyAligner<casa::Float>* >& a, 197 const SDMemTable& in, casa::uInt nChan, 198 casa::uInt nFreqIDs, casa::uInt nSrcTab, 199 const casa::Vector<casa::uInt>& firstRow, 200 casa::MFrequency::Types system, 201 const casa::MPosition& refPos, 202 const casa::MEpoch& refEpoch) const; 203 204 // Align in Frequency 205 SDMemTable* frequencyAlign (const SDMemTable& in, 206 casa::MFrequency::Types system, 212 207 const casa::String& timeRef) const; 213 208
Note:
See TracChangeset
for help on using the changeset viewer.