Changeset 397


Ignore:
Timestamp:
02/09/05 13:06:53 (19 years ago)
Author:
kil064
Message:

add support in frequency alignment for a perIF (caters to
manual doppler tracking) or perFreqID mode (caters to no
doppler tracking)

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMath.cc

    r363 r397  
    111111
    112112
    113 SDMemTable* SDMath::frequencyAlignment (const SDMemTable& in, const String& refTime, const String& method) const
    114 {
    115 
     113SDMemTable* SDMath::frequencyAlignment (const SDMemTable& in, const String& refTime,
     114                                         const String& method, Bool perFreqID) const
     115{
    116116// Get frame info from Table
    117117
     
    131131// Do it
    132132
    133    return frequencyAlign (in, freqSystem, refTime, method);
     133   return frequencyAlign (in, freqSystem, refTime, method, perFreqID);
    134134}
    135135
     
    13611361SDMemTable* SDMath::frequencyAlign (const SDMemTable& in,
    13621362                                   MFrequency::Types freqSystem,
    1363                                    const String& refTime, const String& methodStr) const
     1363                                   const String& refTime,
     1364                                   const String& methodStr,
     1365                                   Bool perFreqID) const
    13641366{
    13651367// Get Header
     
    13811383   Vector<Double> times = mjdCol.getColumn();
    13821384
    1383 // Generate DataDesc table
     1385// Generate DataDesc table 
    13841386 
    13851387   Matrix<uInt> ddIdx;
    13861388   SDDataDesc dDesc;
    1387    generateDataDescTable (ddIdx, dDesc, nIF, in, tabIn, srcCol, fqIDCol);
     1389   generateDataDescTable (ddIdx, dDesc, nIF, in, tabIn, srcCol, fqIDCol, perFreqID);
    13881390
    13891391// Get reference Epoch to time of first row or given String
     
    14041406   MPosition refPos = in.getAntennaPosition();
    14051407
    1406 // Create FrequencyAligner Block. One VA for each possible
    1407 // source/freqID combination
     1408// Create FrequencyAligner Block. One FA for each possible
     1409// source/freqID (perFreqID=True) or source/IF (perFreqID=False) combination
    14081410
    14091411   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
    14131418
    14141419   SDFrequencyTable freqTabOut = in.getSDFreqTable();
     
    14181423   Bool linear=True;
    14191424//
     1425   Vector<uInt> ddFQTrans(dDesc.length(),0);
    14201426   for (uInt i=0; i<dDesc.length(); i++) {
    14211427
     
    14271433// Add FreqID
    14281434
    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)
    14321439   }
    14331440
     
    14391446// New output Table
    14401447
     1448   cerr << "Create output table" << endl;
    14411449   SDMemTable* pTabOut = new SDMemTable(in,True);
    14421450   pTabOut->putSDFreqTable(freqTabOut);
     
    14531461   Vector<uInt> freqID(nIF);
    14541462   uInt ifIdx, faIdx;
     1463   Vector<Double> xIn;
    14551464//
    14561465   for (uInt iRow=0; iRow<nRows; ++iRow) {
     
    14711480     Array<Bool> mask = mArrIn.getMask();
    14721481
    1473 // cerr << "values in = " << values(IPosition(4,0,0,0,0),IPosition(4,0,0,0,9)) << endl;
    1474 
    14751482// For each row, the Frequency abcissa will be the same regardless
    14761483// of polarization.  For all other axes (IF and BEAM) the abcissa
     
    14881495        ifIdx = pos(asap::IFAxis);
    14891496        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        }
    14901511//
    14911512        VectorIterator<Float> itValuesVec(itValuesPlane.array(), 1);
     
    14971518        useCachedAbcissa=False;
    14981519        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           }
    15021529//
    15031530           itValuesVec.vector() = yOut;
     
    15171544     }
    15181545
    1519 // cerr << "values out = " << values(IPosition(4,0,0,0,0),IPosition(4,0,0,0,9)) << endl;
    1520 
    15211546// Create SDContainer and put back
    15221547
    15231548    SDContainer sc = in.getSDContainer(iRow);
    15241549    putDataInSDC(sc, values, mask);
     1550
     1551// Set output FreqIDs
     1552
    15251553    for (uInt i=0; i<nIF; i++) {
    1526        uInt idx = ddIdx(iRow,i);
    1527        freqID(i) = dDesc.freqID(idx);
     1554       uInt idx = ddIdx(iRow,i);               // Index into SDDataDesc table
     1555       freqID(i) = ddFQTrans(idx);             // FreqID in output FQ table
    15281556    }
    15291557    sc.putFreqMap(freqID);
     
    18501878                                    const Table& tabIn,
    18511879                                    const ROScalarColumn<String>& srcCol,
    1852                                     const ROArrayColumn<uInt>& fqIDCol) const
     1880                                    const ROArrayColumn<uInt>& fqIDCol,
     1881                                    Bool perFreqID) const
    18531882{
    18541883   const uInt nRows = tabIn.nrow();
     
    18621891      const MDirection& dir = in.getDirection(iRow);
    18631892//
    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         }
    18671907      }
    18681908   }
    18691909}
     1910
     1911
     1912
     1913
    18701914
    18711915MEpoch SDMath::epochFromString (const String& str, MEpoch::Types timeRef) const
     
    18951939                                        MFrequency::Types system,
    18961940                                        const MPosition& refPos,
    1897                                         const MEpoch& refEpoch) const
     1941                                        const MEpoch& refEpoch,
     1942                                        Bool perFreqID) const
    18981943{
    18991944   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      }
    19051963   }
    19061964}
  • trunk/src/SDMath.h

    r354 r397  
    112112// Frequency Alignment
    113113   SDMemTable* frequencyAlignment (const SDMemTable& in, const casa::String& refTime,
    114                                    const casa::String& method) const;
     114                                   const casa::String& method, casa::Bool perFreqID) const;
    115115
    116116// Opacity correction
     
    191191                              casa::MFrequency::Types system,
    192192                              const casa::String& timeRef,
    193                               const casa::String& method) const;
     193                              const casa::String& method, casa::Bool perIF) const;
    194194
    195195// Generate frequency aligners
     
    199199                                   casa::MFrequency::Types system,
    200200                                   const casa::MPosition& refPos,
    201                                    const casa::MEpoch& refEpoch) const;
     201                                   const casa::MEpoch& refEpoch, casa::Bool perFreqID) const;
    202202
    203203// Generate data description table (combines source and freqID)
     
    208208                               const casa::Table& tabIn,
    209209                               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;
    211212
    212213// Function to get the current cursor location
Note: See TracChangeset for help on using the changeset viewer.