Changeset 1603 for branches/alma/src/STMath.cpp
- Timestamp:
- 07/18/09 06:35:47 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/src/STMath.cpp
r1516 r1603 297 297 bool droprows) 298 298 { 299 if (insitu_) return in; 299 if (insitu_) { 300 return in; 301 } 300 302 else { 301 303 // clone 302 Scantable* tabp = new Scantable(*in, Bool(droprows)); 303 return CountedPtr<Scantable>(tabp); 304 return CountedPtr<Scantable>(new Scantable(*in, Bool(droprows))); 304 305 } 305 306 } … … 1513 1514 ArrayColumn<Float> specCol(tab, "SPECTRA"); 1514 1515 ArrayColumn<uChar> flagCol(tab, "FLAGTRA"); 1516 ArrayColumn<Float> tsysCol(tab, "TSYS"); 1515 1517 for ( uInt i=0; i<tab.nrow(); ++i) { 1516 1518 Float zdist = Float(C::pi_2) - elev(i); … … 1520 1522 specCol.put(i, ma.getArray()); 1521 1523 flagCol.put(i, flagsFromMA(ma)); 1524 Vector<Float> tsys; 1525 tsysCol.get(i, tsys); 1526 tsys *= factor; 1527 tsysCol.put(i, tsys); 1522 1528 } 1523 1529 return out; … … 1614 1620 while ( it != in.end() ){ 1615 1621 if ( ! (*it)->conformant(*out) ) { 1616 // log message: "ignoring scantable i, as it isn't 1617 // conformant with the other(s)" 1618 cerr << "oh oh" << endl; 1619 ++it; 1620 continue; 1622 // non conformant. 1623 pushLog(String("Warning: Can't merge scantables as header info differs.")); 1621 1624 } 1622 1625 out->appendToHistoryTable((*it)->history()); … … 1628 1631 Table thetab = freqit.table(); 1629 1632 uInt nrow = tout.nrow(); 1630 //tout.addRow(thetab.nrow());1633 tout.addRow(thetab.nrow()); 1631 1634 TableCopy::copyRows(tout, thetab, nrow, 0, thetab.nrow()); 1632 1635 ROTableRow row(thetab); … … 1826 1829 1827 1830 InterpolateArray1D<Double,Float>::InterpolationMethod interp = stringToIMethod(method); 1831 /* 1832 // Comment from MV. 1833 // the following code has been commented out because different FREQ_IDs have to be aligned together even 1834 // if the frame doesn't change. So far, lack of this check didn't cause any problems. 1828 1835 // test if user frame is different to base frame 1829 1836 if ( in->frequencies().getFrameString(true) … … 1832 1839 " (use set_freqframe) or it is aligned already.")); 1833 1840 } 1841 */ 1834 1842 MFrequency::Types system = in->frequencies().getFrame(); 1835 1843 MVTime mvt(refEpoch.getValue()); … … 1857 1865 1858 1866 ROArrayColumn<Float> sCol(t, "SPECTRA"); 1859 MDirection direction = dirCol(0); 1860 uInt nchan = sCol(0).nelements(); 1867 const MDirection direction = dirCol(0); 1868 const uInt nchan = sCol(0).nelements(); 1869 1870 // skip operations if there is nothing to align 1871 if (fiter.pastEnd()) { 1872 continue; 1873 } 1874 1875 Table ftab = fiter.table(); 1876 // align all frequency ids with respect to the first encountered id 1877 ScalarColumn<uInt> freqidCol(ftab, "FREQ_ID"); 1878 // get the SpectralCoordinate for the freqid, which we are iterating over 1879 SpectralCoordinate sC = in->frequencies().getSpectralCoordinate(freqidCol(0)); 1880 FrequencyAligner<Float> fa( sC, nchan, refEpoch, 1881 direction, refPos, system ); 1882 // realign the SpectralCoordinate and put into the output Scantable 1883 Vector<String> units(1); 1884 units = String("Hz"); 1885 Bool linear=True; 1886 SpectralCoordinate sc2 = fa.alignedSpectralCoordinate(linear); 1887 sc2.setWorldAxisUnits(units); 1888 const uInt id = out->frequencies().addEntry(sc2.referencePixel()[0], 1889 sc2.referenceValue()[0], 1890 sc2.increment()[0]); 1861 1891 while ( !fiter.pastEnd() ) { 1862 Table ftab = fiter.table(); 1863 ScalarColumn<uInt> freqidCol(ftab, "FREQ_ID"); 1864 // get the SpectralCoordinate for the freqid, which we are iterating over 1865 SpectralCoordinate sC = in->frequencies().getSpectralCoordinate(freqidCol(0)); 1866 FrequencyAligner<Float> fa( sC, nchan, refEpoch, 1867 direction, refPos, system ); 1868 // realign the SpectralCoordinate and put into the output Scantable 1869 Vector<String> units(1); 1870 units = String("Hz"); 1871 Bool linear=True; 1872 SpectralCoordinate sc2 = fa.alignedSpectralCoordinate(linear); 1873 sc2.setWorldAxisUnits(units); 1874 uInt id = out->frequencies().addEntry(sc2.referencePixel()[0], 1875 sc2.referenceValue()[0], 1876 sc2.increment()[0]); 1877 TableVector<uInt> tvec(ftab, "FREQ_ID"); 1878 tvec = id; 1892 ftab = fiter.table(); 1893 // spectral coordinate for the current FREQ_ID 1894 ScalarColumn<uInt> freqidCol2(ftab, "FREQ_ID"); 1895 sC = in->frequencies().getSpectralCoordinate(freqidCol2(0)); 1879 1896 // create the "global" abcissa for alignment with same FREQ_ID 1880 1897 Vector<Double> abc(nchan); 1881 Double w;1882 1898 for (uInt i=0; i<nchan; i++) { 1883 sC.toWorld(w,Double(i)); 1884 abc[i] = w; 1885 } 1899 Double w; 1900 sC.toWorld(w,Double(i)); 1901 abc[i] = w; 1902 } 1903 TableVector<uInt> tvec(ftab, "FREQ_ID"); 1904 // assign new frequency id to all rows 1905 tvec = id; 1886 1906 // cache abcissa for same time stamps, so iterate over those 1887 1907 TableIterator timeiter(ftab, "TIME"); … … 1892 1912 MEpoch::ROScalarColumn timeCol(tab, "TIME"); 1893 1913 // use align abcissa cache after the first row 1914 // these rows should be just be POLNO 1894 1915 bool first = true; 1895 // these rows should be just be POLNO1896 1916 for (int i=0; i<int(tab.nrow()); ++i) { 1897 1917 // input values
Note: See TracChangeset
for help on using the changeset viewer.