Changeset 1475


Ignore:
Timestamp:
01/16/09 15:03:06 (16 years ago)
Author:
Max Voronkov
Message:

fixed frequency alignment problem (#142). Different FREQ_IDs are now gridded together. \
Different IFs are left intact therefore causing no problem for the Tid case. Tested on Tid and Mopra data successfully.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STMath.cpp

    r1439 r1475  
    17461746
    17471747  InterpolateArray1D<Double,Float>::InterpolationMethod interp = stringToIMethod(method);
     1748  /*
     1749  // Comment from MV.
     1750  // the following code has been commented out because different FREQ_IDs have to be aligned together even
     1751  // if the frame doesn't change. So far, lack of this check didn't cause any problems.
    17481752  // test if user frame is different to base frame
    17491753  if ( in->frequencies().getFrameString(true)
     
    17521756                    " (use set_freqframe) or it is aligned already."));
    17531757  }
     1758  */
    17541759  MFrequency::Types system = in->frequencies().getFrame();
    17551760  MVTime mvt(refEpoch.getValue());
     
    17771782
    17781783    ROArrayColumn<Float> sCol(t, "SPECTRA");
    1779     MDirection direction = dirCol(0);
    1780     uInt nchan = sCol(0).nelements();
     1784    const MDirection direction = dirCol(0);
     1785    const uInt nchan = sCol(0).nelements();
     1786
     1787    // skip operations if there is nothing to align
     1788    if (fiter.pastEnd()) {
     1789        continue;
     1790    }
     1791
     1792    Table ftab = fiter.table();
     1793    // align all frequency ids with respect to the first encountered id
     1794    ScalarColumn<uInt> freqidCol(ftab, "FREQ_ID");
     1795    // get the SpectralCoordinate for the freqid, which we are iterating over
     1796    SpectralCoordinate sC = in->frequencies().getSpectralCoordinate(freqidCol(0));
     1797    FrequencyAligner<Float> fa( sC, nchan, refEpoch,
     1798                                direction, refPos, system );
     1799    // realign the SpectralCoordinate and put into the output Scantable
     1800    Vector<String> units(1);
     1801    units = String("Hz");
     1802    Bool linear=True;
     1803    SpectralCoordinate sc2 = fa.alignedSpectralCoordinate(linear);
     1804    sc2.setWorldAxisUnits(units);
     1805    const uInt id = out->frequencies().addEntry(sc2.referencePixel()[0],
     1806                                                sc2.referenceValue()[0],
     1807                                                sc2.increment()[0]);
    17811808    while ( !fiter.pastEnd() ) {
    1782       Table ftab = fiter.table();
    1783       ScalarColumn<uInt> freqidCol(ftab, "FREQ_ID");
    1784       // get the SpectralCoordinate for the freqid, which we are iterating over
    1785       SpectralCoordinate sC = in->frequencies().getSpectralCoordinate(freqidCol(0));
    1786       FrequencyAligner<Float> fa( sC, nchan, refEpoch,
    1787                                   direction, refPos, system );
    1788       // realign the SpectralCoordinate and put into the output Scantable
    1789       Vector<String> units(1);
    1790       units = String("Hz");
    1791       Bool linear=True;
    1792       SpectralCoordinate sc2 = fa.alignedSpectralCoordinate(linear);
    1793       sc2.setWorldAxisUnits(units);
    1794       uInt id = out->frequencies().addEntry(sc2.referencePixel()[0],
    1795                                             sc2.referenceValue()[0],
    1796                                             sc2.increment()[0]);
    1797       TableVector<uInt> tvec(ftab, "FREQ_ID");
    1798       tvec = id;
     1809      ftab = fiter.table();
     1810      // spectral coordinate for the current FREQ_ID
     1811      ScalarColumn<uInt> freqidCol2(ftab, "FREQ_ID");
     1812      sC = in->frequencies().getSpectralCoordinate(freqidCol2(0));
    17991813      // create the "global" abcissa for alignment with same FREQ_ID
    18001814      Vector<Double> abc(nchan);
    1801       Double w;
    18021815      for (uInt i=0; i<nchan; i++) {
    1803         sC.toWorld(w,Double(i));
    1804         abc[i] = w;
     1816           Double w;
     1817           sC.toWorld(w,Double(i));
     1818           abc[i] = w;
    18051819      }
     1820      TableVector<uInt> tvec(ftab, "FREQ_ID");
     1821      // assign new frequency id to all rows
     1822      tvec = id;
    18061823      // cache abcissa for same time stamps, so iterate over those
    18071824      TableIterator timeiter(ftab, "TIME");
     
    18121829        MEpoch::ROScalarColumn timeCol(tab, "TIME");
    18131830        // use align abcissa cache after the first row
     1831        // these rows should be just be POLNO
    18141832        bool first = true;
    1815         // these rows should be just be POLNO
    18161833        for (int i=0; i<int(tab.nrow()); ++i) {
    18171834          // input values
Note: See TracChangeset for help on using the changeset viewer.