Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMath.cc
r363 r397 111 111 112 112 113 SDMemTable* SDMath::frequencyAlignment (const SDMemTable& in, const String& refTime, const String& method) const114 { 115 113 SDMemTable* SDMath::frequencyAlignment (const SDMemTable& in, const String& refTime, 114 const String& method, Bool perFreqID) const 115 { 116 116 // Get frame info from Table 117 117 … … 131 131 // Do it 132 132 133 return frequencyAlign (in, freqSystem, refTime, method );133 return frequencyAlign (in, freqSystem, refTime, method, perFreqID); 134 134 } 135 135 … … 1361 1361 SDMemTable* SDMath::frequencyAlign (const SDMemTable& in, 1362 1362 MFrequency::Types freqSystem, 1363 const String& refTime, const String& methodStr) const 1363 const String& refTime, 1364 const String& methodStr, 1365 Bool perFreqID) const 1364 1366 { 1365 1367 // Get Header … … 1381 1383 Vector<Double> times = mjdCol.getColumn(); 1382 1384 1383 // Generate DataDesc table 1385 // Generate DataDesc table 1384 1386 1385 1387 Matrix<uInt> ddIdx; 1386 1388 SDDataDesc dDesc; 1387 generateDataDescTable (ddIdx, dDesc, nIF, in, tabIn, srcCol, fqIDCol );1389 generateDataDescTable (ddIdx, dDesc, nIF, in, tabIn, srcCol, fqIDCol, perFreqID); 1388 1390 1389 1391 // Get reference Epoch to time of first row or given String … … 1404 1406 MPosition refPos = in.getAntennaPosition(); 1405 1407 1406 // Create FrequencyAligner Block. One VA for each possible1407 // source/freqID combination1408 // Create FrequencyAligner Block. One FA for each possible 1409 // source/freqID (perFreqID=True) or source/IF (perFreqID=False) combination 1408 1410 1409 1411 PtrBlock<FrequencyAligner<Float>* > a(dDesc.length()); 1410 generateFrequencyAligners (a, dDesc, in, nChan, freqSystem, refPos, refEpoch); 1411 1412 // Generate and fill output Frequency Tabke 1412 generateFrequencyAligners (a, dDesc, in, nChan, freqSystem, refPos, 1413 refEpoch, perFreqID); 1414 1415 // Generate and fill output Frequency Table. WHen perFreqID=True, there is one output FreqID 1416 // for each entry in the SDDataDesc table. However, in perFreqID=False mode, there may be 1417 // some degeneracy, so we need a little translation map 1413 1418 1414 1419 SDFrequencyTable freqTabOut = in.getSDFreqTable(); … … 1418 1423 Bool linear=True; 1419 1424 // 1425 Vector<uInt> ddFQTrans(dDesc.length(),0); 1420 1426 for (uInt i=0; i<dDesc.length(); i++) { 1421 1427 … … 1427 1433 // Add FreqID 1428 1434 1429 freqTabOut.addFrequency(sC.referencePixel()[0], 1430 sC.referenceValue()[0], 1431 sC.increment()[0]); 1435 uInt idx = freqTabOut.addFrequency(sC.referencePixel()[0], 1436 sC.referenceValue()[0], 1437 sC.increment()[0]); 1438 ddFQTrans(i) = idx; // output FreqID = ddFQTrans(ddIdx) 1432 1439 } 1433 1440 … … 1439 1446 // New output Table 1440 1447 1448 cerr << "Create output table" << endl; 1441 1449 SDMemTable* pTabOut = new SDMemTable(in,True); 1442 1450 pTabOut->putSDFreqTable(freqTabOut); … … 1453 1461 Vector<uInt> freqID(nIF); 1454 1462 uInt ifIdx, faIdx; 1463 Vector<Double> xIn; 1455 1464 // 1456 1465 for (uInt iRow=0; iRow<nRows; ++iRow) { … … 1471 1480 Array<Bool> mask = mArrIn.getMask(); 1472 1481 1473 // cerr << "values in = " << values(IPosition(4,0,0,0,0),IPosition(4,0,0,0,9)) << endl;1474 1475 1482 // For each row, the Frequency abcissa will be the same regardless 1476 1483 // of polarization. For all other axes (IF and BEAM) the abcissa … … 1488 1495 ifIdx = pos(asap::IFAxis); 1489 1496 faIdx = ddIdx(iRow,ifIdx); 1497 1498 // Generate abcissa for perIF. Could cache this in a Matrix 1499 // on a per scan basis. Pretty expensive doing it for every row. 1500 1501 if (!perFreqID) { 1502 xIn.resize(nChan); 1503 uInt fqID = dDesc.secID(ddIdx(iRow,ifIdx)); 1504 SpectralCoordinate sC = in.getSpectralCoordinate(fqID); 1505 Double w; 1506 for (uInt i=0; i<nChan; i++) { 1507 sC.toWorld(w,Double(i)); 1508 xIn[i] = w; 1509 } 1510 } 1490 1511 // 1491 1512 VectorIterator<Float> itValuesVec(itValuesPlane.array(), 1); … … 1497 1518 useCachedAbcissa=False; 1498 1519 while (!itValuesVec.pastEnd()) { 1499 ok = a[faIdx]->align (yOut, maskOut, itValuesVec.vector(), 1500 itMaskVec.vector(), epoch, useCachedAbcissa, 1501 interp, extrapolate); 1520 if (perFreqID) { 1521 ok = a[faIdx]->align (yOut, maskOut, itValuesVec.vector(), 1522 itMaskVec.vector(), epoch, useCachedAbcissa, 1523 interp, extrapolate); 1524 } else { 1525 ok = a[faIdx]->align (yOut, maskOut, xIn, itValuesVec.vector(), 1526 itMaskVec.vector(), epoch, useCachedAbcissa, 1527 interp, extrapolate); 1528 } 1502 1529 // 1503 1530 itValuesVec.vector() = yOut; … … 1517 1544 } 1518 1545 1519 // cerr << "values out = " << values(IPosition(4,0,0,0,0),IPosition(4,0,0,0,9)) << endl;1520 1521 1546 // Create SDContainer and put back 1522 1547 1523 1548 SDContainer sc = in.getSDContainer(iRow); 1524 1549 putDataInSDC(sc, values, mask); 1550 1551 // Set output FreqIDs 1552 1525 1553 for (uInt i=0; i<nIF; i++) { 1526 uInt idx = ddIdx(iRow,i); 1527 freqID(i) = d Desc.freqID(idx);1554 uInt idx = ddIdx(iRow,i); // Index into SDDataDesc table 1555 freqID(i) = ddFQTrans(idx); // FreqID in output FQ table 1528 1556 } 1529 1557 sc.putFreqMap(freqID); … … 1850 1878 const Table& tabIn, 1851 1879 const ROScalarColumn<String>& srcCol, 1852 const ROArrayColumn<uInt>& fqIDCol) const 1880 const ROArrayColumn<uInt>& fqIDCol, 1881 Bool perFreqID) const 1853 1882 { 1854 1883 const uInt nRows = tabIn.nrow(); … … 1862 1891 const MDirection& dir = in.getDirection(iRow); 1863 1892 // 1864 for (uInt iIF=0; iIF<nIF; iIF++) { 1865 uInt idx = dDesc.addEntry(srcName, freqIDs[iIF], dir); 1866 ddIdx(iRow,iIF) = idx; 1893 if (perFreqID) { 1894 1895 // One entry per source/freqID pair 1896 1897 for (uInt iIF=0; iIF<nIF; iIF++) { 1898 ddIdx(iRow,iIF) = dDesc.addEntry(srcName, freqIDs[iIF], dir, 0); 1899 } 1900 } else { 1901 1902 // One entry per source/IF pair. Hang onto the FreqID as well 1903 1904 for (uInt iIF=0; iIF<nIF; iIF++) { 1905 ddIdx(iRow,iIF) = dDesc.addEntry(srcName, iIF, dir, freqIDs[iIF]); 1906 } 1867 1907 } 1868 1908 } 1869 1909 } 1910 1911 1912 1913 1870 1914 1871 1915 MEpoch SDMath::epochFromString (const String& str, MEpoch::Types timeRef) const … … 1895 1939 MFrequency::Types system, 1896 1940 const MPosition& refPos, 1897 const MEpoch& refEpoch) const 1941 const MEpoch& refEpoch, 1942 Bool perFreqID) const 1898 1943 { 1899 1944 for (uInt i=0; i<dDesc.length(); i++) { 1900 uInt freqID = dDesc.freqID(i); 1901 const MDirection& refDir = dDesc.direction(i); 1902 // 1903 SpectralCoordinate sC = in.getSpectralCoordinate(freqID); 1904 a[i] = new FrequencyAligner<Float>(sC, nChan, refEpoch, refDir, refPos, system); 1945 uInt ID = dDesc.ID(i); 1946 uInt secID = dDesc.secID(i); 1947 const MDirection& refDir = dDesc.secDir(i); 1948 // 1949 if (perFreqID) { 1950 1951 // One aligner per source/FreqID pair. 1952 1953 SpectralCoordinate sC = in.getSpectralCoordinate(ID); 1954 a[i] = new FrequencyAligner<Float>(sC, nChan, refEpoch, refDir, refPos, system); 1955 } else { 1956 1957 // One aligner per source/IF pair. But we still need the FreqID to 1958 // get the right SC. Hence the messing about with the secondary ID 1959 1960 SpectralCoordinate sC = in.getSpectralCoordinate(secID); 1961 a[i] = new FrequencyAligner<Float>(sC, nChan, refEpoch, refDir, refPos, system); 1962 } 1905 1963 } 1906 1964 } -
trunk/src/SDMath.h
r354 r397 112 112 // Frequency Alignment 113 113 SDMemTable* frequencyAlignment (const SDMemTable& in, const casa::String& refTime, 114 const casa::String& method ) const;114 const casa::String& method, casa::Bool perFreqID) const; 115 115 116 116 // Opacity correction … … 191 191 casa::MFrequency::Types system, 192 192 const casa::String& timeRef, 193 const casa::String& method ) const;193 const casa::String& method, casa::Bool perIF) const; 194 194 195 195 // Generate frequency aligners … … 199 199 casa::MFrequency::Types system, 200 200 const casa::MPosition& refPos, 201 const casa::MEpoch& refEpoch ) const;201 const casa::MEpoch& refEpoch, casa::Bool perFreqID) const; 202 202 203 203 // Generate data description table (combines source and freqID) … … 208 208 const casa::Table& tabIn, 209 209 const casa::ROScalarColumn<casa::String>& srcCol, 210 const casa::ROArrayColumn<casa::uInt>& fqIDCol) const; 210 const casa::ROArrayColumn<casa::uInt>& fqIDCol, 211 casa::Bool perFreqID) const; 211 212 212 213 // Function to get the current cursor location
Note:
See TracChangeset
for help on using the changeset viewer.