Changeset 480


Ignore:
Timestamp:
02/18/05 17:13:45 (19 years ago)
Author:
kil064
Message:

add functions getRowRange and rowInRange
make gain/el correction the inverse of what it was
have gain/el and opacity also correct TSys

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMath.cc

    r478 r480  
    10741074     cout << "Jy/K = " << JyPerK << endl;
    10751075     Vector<Float> factors(in.nRow(), factor);
    1076      correctFromVector (pTabOut, in, doAll, factors);
     1076     scaleByVector(pTabOut, in, doAll, factors, False);
    10771077  } else if (etaAp>0.0) {
    10781078     Bool throwIt = True;
     
    10881088//
    10891089     Vector<Float> factors(in.nRow(), factor);
    1090      correctFromVector (pTabOut, in, doAll, factors);
     1090     scaleByVector(pTabOut, in, doAll, factors, False);
    10911091  } else {
    10921092
     
    11641164     Vector<Float> factor(nRow);
    11651165     for (uInt i=0; i<nRow; i++) {
    1166         factor[i] = (*pPoly)(x[i]);
     1166        factor[i] = 1.0 / (*pPoly)(x[i]);
    11671167     }
    11681168     delete pPoly;
    11691169//
    1170      correctFromVector (pTabOut, in, doAll, factor);
     1170     scaleByVector (pTabOut, in, doAll, factor, True);
    11711171  } else {
    11721172
     
    11791179
    11801180     cout << "Making correction from ascii Table" << endl;
    1181      correctFromAsciiTable (pTabOut, in, fileName, col0, col1,
    1182                             methodStr, doAll, x);
     1181     scaleFromAsciiTable (pTabOut, in, fileName, col0, col1,
     1182                          methodStr, doAll, x, True);
    11831183   }
    11841184//
     
    12141214// Correct
    12151215
    1216   correctFromVector (pTabOut, in, doAll, factor);
     1216  scaleByVector (pTabOut, in, doAll, factor, True);
    12171217//
    12181218  return pTabOut;
     
    17991799
    18001800
    1801 void SDMath::correctFromAsciiTable(SDMemTable* pTabOut,
    1802                                    const SDMemTable& in, const String& fileName,
    1803                                    const String& col0, const String& col1,
    1804                                    const String& methodStr, Bool doAll,
    1805                                    const Vector<Float>& xOut) const
     1801void SDMath::scaleFromAsciiTable(SDMemTable* pTabOut,
     1802                                 const SDMemTable& in, const String& fileName,
     1803                                 const String& col0, const String& col1,
     1804                                 const String& methodStr, Bool doAll,
     1805                                 const Vector<Float>& xOut, Bool doTSys) const
    18061806{
    18071807
     
    18101810  Table geTable = readAsciiFile (fileName);
    18111811//
    1812   correctFromTable (pTabOut, in, geTable, col0, col1, methodStr, doAll, xOut);
    1813 }
    1814 
    1815 void SDMath::correctFromTable(SDMemTable* pTabOut, const SDMemTable& in,
    1816                               const Table& tTable, const String& col0,
    1817                               const String& col1,
    1818                               const String& methodStr, Bool doAll,
    1819                               const Vector<Float>& xOut) const
     1812  scaleFromTable (pTabOut, in, geTable, col0, col1, methodStr, doAll, xOut, doTSys);
     1813}
     1814
     1815void SDMath::scaleFromTable(SDMemTable* pTabOut, const SDMemTable& in,
     1816                            const Table& tTable, const String& col0,
     1817                            const String& col1,
     1818                            const String& methodStr, Bool doAll,
     1819                            const Vector<Float>& xOut, Bool doTsys) const
    18201820{
    18211821
     
    18411841// Apply
    18421842
    1843    correctFromVector (pTabOut, in, doAll, yOut);
    1844 }
    1845 
    1846 
    1847 void SDMath::correctFromVector (SDMemTable* pTabOut, const SDMemTable& in,
    1848                                 Bool doAll, const Vector<Float>& factor) const
     1843   scaleByVector(pTabOut, in, doAll, Float(1.0)/yOut, doTsys);
     1844}
     1845
     1846
     1847void SDMath::scaleByVector(SDMemTable* pTabOut, const SDMemTable& in,
     1848                           Bool doAll, const Vector<Float>& factor,
     1849                           Bool doTSys) const
    18491850{
    18501851
     
    18531854  IPosition start, end;
    18541855  setCursorSlice (start, end, doAll, in);
     1856
     1857// Get Tsys column
     1858
     1859  const Table& tIn = in.table();
     1860  ArrayColumn<Float> tSysCol(tIn, "TSYS");
     1861  Array<Float> tSys;
    18551862
    18561863// Loop over rows and apply correction factor
     
    18631870     MaskedArray<Float> dataIn(in.rowAsMaskedArray(i));
    18641871     MaskedArray<Float> dataIn2 = dataIn(start,end);  // reference to dataIn
     1872//
     1873     if (doTSys) {
     1874        tSysCol.get(i, tSys);
     1875        Array<Float> tSys2 = tSys(start,end) * factor[i];
     1876        tSysCol.put(i, tSys);
     1877     }
    18651878
    18661879// Apply factor
     
    19711984   }
    19721985}
     1986
     1987Vector<uInt> SDMath::getRowRange (const SDMemTable& in) const
     1988{
     1989   Vector<uInt> range(2);
     1990   range[0] = 0;
     1991   range[1] = in.nRow()-1;
     1992   return range;
     1993}
     1994   
     1995
     1996Bool SDMath::rowInRange (uInt i, const Vector<uInt>& range) const
     1997{
     1998   return (i>=range[0] && i<=range[1]);
     1999}
  • trunk/src/SDMath.h

    r457 r480  
    159159                             const casa::String& interp) const;
    160160
    161 // Correct data from an ascii Table
    162    void correctFromAsciiTable(SDMemTable* pTabOut, const SDMemTable& in,
     161// Scale data with values from an ascii Table
     162   void scaleFromAsciiTable(SDMemTable* pTabOut, const SDMemTable& in,
    163163                              const casa::String& fileName,
    164164                              const casa::String& col0, const casa::String& col1,
    165165                              const casa::String& methodStr, casa::Bool doAll,
    166                               const casa::Vector<casa::Float>& xOut) const;
    167 
    168 // Correct data from a Table
    169    void correctFromTable(SDMemTable* pTabOut, const SDMemTable& in, const casa::Table& tTable,
     166                              const casa::Vector<casa::Float>& xOut, casa::Bool doTSys) const;
     167
     168// Scale data with values from a Table
     169   void scaleFromTable(SDMemTable* pTabOut, const SDMemTable& in, const casa::Table& tTable,
    170170                         const casa::String& col0, const casa::String& col1,
    171171                         const casa::String& methodStr, casa::Bool doAll,
    172                          const casa::Vector<casa::Float>& xOut) const;
    173 
    174 // Correct data from a Vector
    175    void correctFromVector (SDMemTable* pTabOut, const SDMemTable& in,
    176                            casa::Bool doAll, const casa::Vector<casa::Float>& factor) const;
     172                         const casa::Vector<casa::Float>& xOut, casa::Bool doTSys) const;
     173
     174// Scale data and optionally TSys by values in a Vector
     175   void scaleByVector (SDMemTable* pTabOut, const SDMemTable& in,
     176                       casa::Bool doAll, const casa::Vector<casa::Float>& factor,
     177                       casa::Bool doTSys) const;
    177178
    178179// Convert time String to Epoch
     
    215216                               casa::Bool perFreqID) const;
    216217
     218// Get row range from SDMemTable state
     219   casa::Vector<casa::uInt> getRowRange (const SDMemTable& in) const;
     220
     221// Is row in the row range ?
     222   casa::Bool rowInRange (casa::uInt i, const casa::Vector<casa::uInt>& range) const;
     223
    217224// Set slice to cursor or all axes
    218225    void setCursorSlice (casa::IPosition& start, casa::IPosition& end,
Note: See TracChangeset for help on using the changeset viewer.