Changeset 716 for trunk/src/SDMath.cc


Ignore:
Timestamp:
11/17/05 14:37:33 (19 years ago)
Author:
mar637
Message:

added frequency switching; implemented use of SDLog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMath.cc

    r701 r716  
    3131#include <vector>
    3232
     33
    3334#include <casa/aips.h>
    3435#include <casa/iostream.h>
     36#include <casa/sstream.h>
    3537#include <casa/iomanip.h>
    3638#include <casa/BasicSL/String.h>
     
    8991
    9092SDMath::SDMath()
    91 {;}
     93{
     94}
    9295
    9396SDMath::SDMath(const SDMath& other)
     
    113116                                       const String& refTime,
    114117                                       const String& method,
    115                                        Bool perFreqID) const
     118                                       Bool perFreqID)
    116119{
    117120  // Get frame info from Table
     
    136139SDMath::average(const std::vector<CountedPtr<SDMemTable> >& in,
    137140                const Vector<Bool>& mask, Bool scanAv,
    138                 const String& weightStr, Bool alignFreq) const
     141                const String& weightStr, Bool alignFreq)
    139142// Weighted averaging of spectra from one or more Tables.
    140143{
     
    365368SDMath::binaryOperate(const CountedPtr<SDMemTable>& left,
    366369                      const CountedPtr<SDMemTable>& right,
    367                       const String& op, Bool preserve, Bool doTSys) const
     370                      const String& op, Bool preserve, Bool doTSys)
    368371{
    369372
     
    509512  IPosition start, end;
    510513  Bool doAll = False;
    511   setCursorSlice (start, end, doAll, *in);
     514  setCursorSlice(start, end, doAll, *in);
    512515
    513516// Loop over rows
     
    554557
    555558
    556 SDMemTable* SDMath::bin(const SDMemTable& in, Int width) const
     559SDMemTable* SDMath::bin(const SDMemTable& in, Int width)
    557560{
    558561  SDHeader sh = in.getSDHeader();
     
    615618
    616619SDMemTable* SDMath::resample(const SDMemTable& in, const String& methodStr,
    617                              Float width) const
     620                             Float width)
    618621//
    619622// Should add the possibility of width being specified in km/s. This means
     
    729732
    730733SDMemTable* SDMath::unaryOperate(const SDMemTable& in, Float val, Bool doAll,
    731                                  uInt what, Bool doTSys) const
     734                                 uInt what, Bool doTSys)
    732735//
    733736// what = 0   Multiply
     
    776779
    777780SDMemTable* SDMath::averagePol(const SDMemTable& in, const Vector<Bool>& mask,
    778                                const String& weightStr) const
     781                               const String& weightStr)
    779782//
    780783// Average all polarizations together, weighted by variance
     
    973976SDMemTable* SDMath::smooth(const SDMemTable& in,
    974977                           const casa::String& kernelType,
    975                            casa::Float width, Bool doAll) const
     978                           casa::Float width, Bool doAll)
    976979//
    977980// Should smooth TSys as well
     
    10471050
    10481051SDMemTable* SDMath::convertFlux(const SDMemTable& in, Float D, Float etaAp,
    1049                                 Float JyPerK, Bool doAll) const
     1052                                Float JyPerK, Bool doAll)
    10501053//
    10511054// etaAp = aperture efficiency (-1 means find)
     
    10661069  Bool toKelvin = True;
    10671070  Double cFac = 1.0;   
     1071
    10681072  if (fluxUnit==JY) {
    1069     cout << "Converting to K" << endl;
    1070    
     1073    pushLog("Converting to K");
    10711074    Quantum<Double> t(1.0,fluxUnit);
    10721075    Quantum<Double> t2 = t.get(JY);
     
    10761079    sh.fluxunit = "K";
    10771080  } else if (fluxUnit==K) {
    1078     cout << "Converting to Jy" << endl;
    1079    
     1081    pushLog("Converting to Jy");
    10801082    Quantum<Double> t(1.0,fluxUnit);
    10811083    Quantum<Double> t2 = t.get(K);
     
    10871089    throw(AipsError("Unrecognized brightness units in Table - must be consistent with Jy or K"));
    10881090  }
     1091
    10891092  pTabOut->putSDHeader(sh);
    10901093 
     
    10961099    factor *= JyPerK;
    10971100    if (toKelvin) factor = 1.0 / JyPerK;
    1098     cout << "Jy/K = " << JyPerK << endl;
     1101    ostringstream oss;
     1102    oss << "Jy/K = " << JyPerK;
     1103    pushLog(String(oss));
    10991104    Vector<Float> factors(in.nRow(), factor);
    11001105    scaleByVector(pTabOut, in, doAll, factors, False);
    11011106  } else if (etaAp>0.0) {
    11021107    Bool throwIt = True;
    1103     Instrument inst = SDAttr::convertInstrument (sh.antennaname, throwIt);
     1108    Instrument inst = SDAttr::convertInstrument(sh.antennaname, throwIt);
    11041109    SDAttr sda;
    11051110    if (D < 0) D = sda.diameter(inst);
    1106     Float JyPerK = SDAttr::findJyPerK (etaAp,D);
    1107     cout << "Jy/K = " << JyPerK << endl;
     1111    Float JyPerK = SDAttr::findJyPerK(etaAp,D);
     1112    ostringstream oss;
     1113    oss << "Jy/K = " << JyPerK;
     1114    pushLog(String(oss));
    11081115    factor *= JyPerK;
    11091116    if (toKelvin) {
     
    11201127    // change per integration.
    11211128   
    1122     cout << "Looking up conversion factors" << endl;
     1129    pushLog("Looking up conversion factors");
    11231130    convertBrightnessUnits (pTabOut, in, toKelvin, cFac, doAll);
    11241131  }
    1125 
    11261132  return pTabOut;
    11271133}
     
    11311137                                  const Vector<Float>& coeffs,
    11321138                                  const String& fileName,
    1133                                   const String& methodStr, Bool doAll) const
     1139                                  const String& methodStr, Bool doAll)
    11341140{
    11351141
     
    11761182       throw(AipsError("There is no known gain-elevation polynomial known for this instrument"));
    11771183     }
    1178      cout << "Making polynomial correction with " << msg << " coefficients" << endl;
     1184     pushLog("Making polynomial correction with "+msg+" coefficients");
    11791185     const uInt nRow = in.nRow();
    11801186     Vector<Float> factor(nRow);
     
    11931199    // Read and correct
    11941200   
    1195     cout << "Making correction from ascii Table" << endl;
     1201    pushLog("Making correction from ascii Table");
    11961202    scaleFromAsciiTable (pTabOut, in, fileName, col0, col1,
    11971203                         methodStr, doAll, x, True);
     
    12021208 
    12031209
    1204 SDMemTable* SDMath::opacity(const SDMemTable& in, Float tau, Bool doAll) const
     1210SDMemTable* SDMath::opacity(const SDMemTable& in, Float tau, Bool doAll)
    12051211{
    12061212
     
    12451251
    12461252   SDHeader sh = in.getSDHeader();
    1247    Instrument inst = SDAttr::convertInstrument (sh.antennaname, False);
     1253   Instrument inst = SDAttr::convertInstrument(sh.antennaname, False);
    12481254   SDAttr sdAtt;
    12491255   if (sdAtt.feedPolType(inst) != LINEAR) {
     
    12991305//
    13001306   SDHeader sh = in.getSDHeader();
    1301    Instrument inst = SDAttr::convertInstrument (sh.antennaname, False);
     1307   Instrument inst = SDAttr::convertInstrument(sh.antennaname, False);
    13021308   SDAttr sdAtt;
    13031309   if (sdAtt.feedPolType(inst) != LINEAR) {
     
    13781384
    13791385void SDMath::convertBrightnessUnits (SDMemTable* pTabOut, const SDMemTable& in,
    1380                                      Bool toKelvin, Float cFac, Bool doAll) const
     1386                                     Bool toKelvin, Float cFac, Bool doAll)
    13811387{
    13821388
     
    13891395
    13901396   Bool throwIt = True;
    1391    Instrument inst = SDAttr::convertInstrument (sh.antennaname, throwIt);
     1397   Instrument inst = SDAttr::convertInstrument(sh.antennaname, throwIt);
    13921398
    13931399// Get Diameter (m)
    13941400
    13951401   SDAttr sdAtt;
    1396 
    13971402// Get epoch of first row
    13981403
     
    14101415//
    14111416   Vector<Float> JyPerK = sdAtt.JyPerK(inst, dateObs, freqs);
    1412    cout << "Jy/K = " << JyPerK << endl;
     1417   ostringstream oss;
     1418   oss << "Jy/K = " << JyPerK;
     1419   pushLog(String(oss));
    14131420   Vector<Float> factors = cFac * JyPerK;
    14141421   if (toKelvin) factors = Float(1.0) / factors;
     
    14741481                                   const String& refTime,
    14751482                                   const String& methodStr,
    1476                                    Bool perFreqID) const
     1483                                   Bool perFreqID)
    14771484{
    14781485// Get Header
     
    15111518     refEpoch = in.getEpoch(0);
    15121519   }
    1513    cout << "Aligning at reference Epoch " << formatEpoch(refEpoch)
    1514         << " in frame " << MFrequency::showType(freqSystem) << endl;
     1520   pushLog("Aligning at reference Epoch "+formatEpoch(refEpoch)
     1521                  +" in frame "+MFrequency::showType(freqSystem));
    15151522   
    15161523   // Get Reference Position
     
    15611568   // New output Table
    15621569   
    1563    cout << "Create output table" << endl;
     1570   pushLog("Create output table");
    15641571   SDMemTable* pTabOut = new SDMemTable(in,True);
    15651572   pTabOut->putSDFreqTable(freqTabOut);
     
    15801587   for (uInt iRow=0; iRow<nRows; ++iRow) {
    15811588     if (iRow%10==0) {
    1582        cout << "Processing row " << iRow << endl;
     1589       pushLog("Processing row "+iRow);
    15831590     }
    15841591     
     
    16881695
    16891696
    1690 SDMemTable* SDMath::frequencySwitch(const SDMemTable& in) const
     1697SDMemTable* SDMath::frequencySwitch(const SDMemTable& in)
    16911698{
    16921699  if (in.nIF() != 2) {
     
    17481755                     Int scanID, Double timeStamp,
    17491756                     Double interval, const String& sourceName,
    1750                      const Vector<uInt>& freqID) const
     1757                     const Vector<uInt>& freqID)
    17511758{
    17521759// Data and mask
     
    17771784                        uInt iTab, uInt iRow, uInt axis,
    17781785                        uInt nAxesSub, Bool useMask,
    1779                         WeightType wtType) const
     1786                        WeightType wtType)
    17801787{
    17811788
     
    18861893                       Double intSum,
    18871894                       WeightType wtType, Int axis,
    1888                        Int nAxesSub) const
     1895                       Int nAxesSub)
    18891896{
    18901897   IPosition pos2(nAxesSub,0);
     
    19641971
    19651972void SDMath::convertWeightString(WeightType& wtType, const String& weightStr,
    1966                                  Bool listType) const
     1973                                 Bool listType)
    19671974{
    19681975  String tStr(weightStr);
     
    19891996  }
    19901997//
    1991   if (listType) cout << msg << endl;
     1998  if (listType) pushLog(msg);
    19921999}
    19932000
    19942001
    19952002void SDMath::convertInterpString(casa::InterpolateArray1D<Double,Float>::InterpolationMethod& type, 
    1996                                  const casa::String& interp) const
     2003                                 const casa::String& interp)
    19972004{
    19982005  String tStr(interp);
     
    20122019
    20132020void SDMath::putDataInSDC(SDContainer& sc, const Array<Float>& data,
    2014                           const Array<Bool>& mask) const
     2021                          const Array<Bool>& mask)
    20152022{
    20162023    sc.putSpectrum(data);
     
    20212028}
    20222029
    2023 Table SDMath::readAsciiFile (const String& fileName) const
     2030Table SDMath::readAsciiFile(const String& fileName) const
    20242031{
    20252032   String formatString;
     
    20342041                                 const String& col0, const String& col1,
    20352042                                 const String& methodStr, Bool doAll,
    2036                                  const Vector<Float>& xOut, Bool doTSys) const
     2043                                 const Vector<Float>& xOut, Bool doTSys)
    20372044{
    20382045
     
    20482055                            const String& col1,
    20492056                            const String& methodStr, Bool doAll,
    2050                             const Vector<Float>& xOut, Bool doTsys) const
     2057                            const Vector<Float>& xOut, Bool doTsys)
    20512058{
    20522059
     
    20782085void SDMath::scaleByVector(SDMemTable* pTabOut, const SDMemTable& in,
    20792086                           Bool doAll, const Vector<Float>& factor,
    2080                            Bool doTSys) const
     2087                           Bool doTSys)
    20812088{
    20822089
     
    21312138                                    const ROScalarColumn<String>& srcCol,
    21322139                                    const ROArrayColumn<uInt>& fqIDCol,
    2133                                     Bool perFreqID) const
     2140                                    Bool perFreqID)
    21342141{
    21352142   const uInt nRows = tabIn.nrow();
     
    21652172
    21662173
    2167 MEpoch SDMath::epochFromString(const String& str, MEpoch::Types timeRef) const
     2174MEpoch SDMath::epochFromString(const String& str, MEpoch::Types timeRef)
    21682175{
    21692176   Quantum<Double> qt;
     
    21922199                                       const MPosition& refPos,
    21932200                                       const MEpoch& refEpoch,
    2194                                        Bool perFreqID) const
     2201                                       Bool perFreqID)
    21952202{
    21962203   for (uInt i=0; i<dDesc.length(); i++) {
Note: See TracChangeset for help on using the changeset viewer.