Changeset 716


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

added frequency switching; implemented use of SDLog

Location:
trunk/src
Files:
5 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++) {
  • trunk/src/SDMath.h

    r653 r716  
    3939
    4040#include "SDDefs.h"
     41#include "SDLog.h"
    4142
    4243class casa::Table;
     
    4849template<class T> class casa::ROArrayColumn;
    4950
    50 
    51 
    5251namespace asap {
    5352
    5453class SDMemTable;
    5554class SDDataDesc;
    56 
    57 class SDMath {
    58 
    59  public:
    60 
    61 // Default constructor
    62    SDMath();
    63 
    64 // Copy Constructor (copy semantics)
    65    SDMath (const SDMath& other);
    66 
    67 // Assignment  (copy semantics)
    68    SDMath &operator=(const SDMath& other);
    69 
    70 // Destructor
    71    ~SDMath();
    72 
    73 // Binary Table operators. op=ADD, SUB, MUL, DIV, QUOTIENT
    74    casa::CountedPtr<SDMemTable> binaryOperate (const casa::CountedPtr<SDMemTable>& left,
    75                                                const casa::CountedPtr<SDMemTable>& right,
    76                                                const casa::String& op, casa::Bool preserve,
    77                                                casa::Bool tSys) const;
    78 
    79 // Average in time
    80    casa::CountedPtr<SDMemTable>
    81    average(const std::vector<casa::CountedPtr<SDMemTable> >& in,
    82            const casa::Vector<casa::Bool>& mask,
    83            casa::Bool scanAverage,
    84            const casa::String& weightStr,
    85            casa::Bool align=casa::False) const;
    86 
    87 // Statistics. If row<0, all rows are done otherwise, just the
    88 // specified row.
    89    std::vector<float> statistic(const casa::CountedPtr<SDMemTable>& in,
    90                                 const casa::Vector<casa::Bool>& mask,
    91                                 const casa::String& which, casa::Int row) const;
    92 
     55 
     56class SDMath : private SDLog {
     57
     58public:
     59 
     60  // Default constructor
     61  SDMath();
     62 
     63  // Copy Constructor (copy semantics)
     64  SDMath(const SDMath& other);
     65 
     66  // Assignment  (copy semantics)
     67  SDMath &operator=(const SDMath& other);
     68 
     69  // Destructor
     70  ~SDMath();
     71 
     72  // Binary Table operators. op=ADD, SUB, MUL, DIV, QUOTIENT
     73  casa::CountedPtr<SDMemTable> binaryOperate(const casa::CountedPtr<SDMemTable>& left,
     74                                             const casa::CountedPtr<SDMemTable>& right,
     75                                             const casa::String& op, casa::Bool preserve,
     76                                             casa::Bool tSys);
     77   
     78    // Average in time
     79    casa::CountedPtr<SDMemTable> average(const std::vector<casa::CountedPtr<SDMemTable> >& in,
     80                                         const casa::Vector<casa::Bool>& mask,
     81                                         casa::Bool scanAverage,
     82                                         const casa::String& weightStr,
     83                                         casa::Bool align=casa::False);
     84   
     85  // Statistics. If row<0, all rows are done otherwise, just the
     86  // specified row.
     87  std::vector<float> statistic(const casa::CountedPtr<SDMemTable>& in,
     88                               const casa::Vector<casa::Bool>& mask,
     89                               const casa::String& which, casa::Int row) const;
     90                               
    9391// Bin up spectra
    94    SDMemTable* bin(const SDMemTable& in, casa::Int width) const;
    95 
    96 // Resample spectra
     92   SDMemTable* bin(const SDMemTable& in, casa::Int width);
     93
     94  // Resample spectra
    9795   SDMemTable* resample(const SDMemTable& in, const casa::String& method,
    98                         casa::Float factor) const;
     96                        casa::Float factor);
    9997
    10098// Smooth
    101    SDMemTable* smooth (const SDMemTable& in, const casa::String& kernel,
    102                        casa::Float width, casa::Bool doAll) const;
     99  SDMemTable* smooth(const SDMemTable& in, const casa::String& kernel,
     100                      casa::Float width, casa::Bool doAll);
    103101
    104102// Flux conversion between Jansky and Kelvin
    105    SDMemTable* convertFlux (const SDMemTable& in, casa::Float D, casa::Float etaAp,
    106                             casa::Float JyPerK, casa::Bool doAll) const;
     103   SDMemTable* convertFlux(const SDMemTable& in, casa::Float D,
     104                           casa::Float etaAp,
     105                           casa::Float JyPerK, casa::Bool doAll);
    107106
    108107// Gain-elevation correction
    109    SDMemTable* gainElevation (const SDMemTable& in, const casa::Vector<casa::Float>& coeffs,
    110                               const casa::String& fileName,
    111                               const casa::String& method, casa::Bool doAll) const;
     108   SDMemTable* gainElevation(const SDMemTable& in,
     109                             const casa::Vector<casa::Float>& coeffs,
     110                             const casa::String& fileName,
     111                             const casa::String& method,
     112                             casa::Bool doAll);
    112113
    113114// Frequency Alignment
    114    SDMemTable* frequencyAlignment (const SDMemTable& in, const casa::String& refTime,
    115                                    const casa::String& method, casa::Bool perFreqID) const;
     115   SDMemTable* frequencyAlignment(const SDMemTable& in, const casa::String& refTime,
     116                                   const casa::String& method, casa::Bool perFreqID);
    116117
    117118// Opacity correction
    118    SDMemTable* opacity (const SDMemTable& in, casa::Float tau, casa::Bool doAll) const;
     119   SDMemTable* opacity(const SDMemTable& in, casa::Float tau, casa::Bool doAll);
    119120
    120121// Simple unary mathematical operations.  what=0 (mul) or 1 (add)
    121122   SDMemTable* unaryOperate(const SDMemTable& in, casa::Float offset,
    122                             casa::Bool doAll, casa::uInt what, casa::Bool tSys) const;
    123 
    124 // Average polarizations.
    125    SDMemTable* averagePol(const SDMemTable& in, const casa::Vector<casa::Bool>& mask,
    126                           const casa::String& wtStr) const;
     123                            casa::Bool doAll, casa::uInt what, casa::Bool tSys);
     124
     125  // Average polarizations.
     126  SDMemTable* averagePol(const SDMemTable& in,
     127                         const casa::Vector<casa::Bool>& mask,
     128                         const casa::String& wtStr);
     129
     130  SDMemTable* frequencySwitch(const SDMemTable& in);
     131 
    127132
    128133// Rotate XY phase. Value in degrees.
    129    void rotateXYPhase (SDMemTable& in, casa::Float value, casa::Bool doAll);
     134   void rotateXYPhase(SDMemTable& in, casa::Float value, casa::Bool doAll);
    130135
    131136// Rotate Q & U by operating on the raw correlations.Value in degrees.
    132    void rotateLinPolPhase (SDMemTable& in, casa::Float value, casa::Bool doAll);
    133 
    134 
     137   void rotateLinPolPhase(SDMemTable& in, casa::Float value, casa::Bool doAll);
     138
     139 
    135140 private:
    136141
     
    155160                  casa::uInt iTab, casa::uInt iRow,
    156161                  casa::uInt axis, casa::uInt nAxesSub,
    157                   casa::Bool useMask, WeightType wtType) const;
     162                  casa::Bool useMask, WeightType wtType);
    158163
    159164// Work out conversion factor for converting Jy<->K per IF per row and apply
    160    void convertBrightnessUnits (SDMemTable* pTabOut, const SDMemTable& in,
    161                                 casa::Bool toKelvin, casa::Float sFac, casa::Bool doAll) const;
     165    void convertBrightnessUnits(SDMemTable* pTabOut, const SDMemTable& in,
     166                                casa::Bool toKelvin, casa::Float sFac, casa::Bool doAll);
    162167
    163168// Convert weight string to enum value
    164169
    165    void convertWeightString (WeightType& wt, const casa::String& weightStr,
    166                              casa::Bool listType) const;
     170   void convertWeightString(WeightType& wt, const casa::String& weightStr,
     171                             casa::Bool listType);;
    167172
    168173// Convert interpolation type string
    169 //   void convertInterpString(casa::Int& type, const casa::String& interp) const;
     174//   void convertInterpString(casa::Int& type, const casa::String& interp);
    170175   void convertInterpString(casa::InterpolateArray1D<casa::Double,casa::Float>::InterpolationMethod& method, 
    171                              const casa::String& interp) const;
     176                             const casa::String& interp);
    172177
    173178// Scale data with values from an ascii Table
     
    176181                              const casa::String& col0, const casa::String& col1,
    177182                              const casa::String& methodStr, casa::Bool doAll,
    178                               const casa::Vector<casa::Float>& xOut, casa::Bool doTSys) const;
     183                              const casa::Vector<casa::Float>& xOut, casa::Bool doTSys);
    179184
    180185// Scale data with values from a Table
     
    182187                         const casa::String& col0, const casa::String& col1,
    183188                         const casa::String& methodStr, casa::Bool doAll,
    184                          const casa::Vector<casa::Float>& xOut, casa::Bool doTSys) const;
     189                         const casa::Vector<casa::Float>& xOut, casa::Bool doTSys);
    185190
    186191// Scale data and optionally TSys by values in a Vector
    187    void scaleByVector (SDMemTable* pTabOut, const SDMemTable& in,
     192   void scaleByVector(SDMemTable* pTabOut, const SDMemTable& in,
    188193                       casa::Bool doAll, const casa::Vector<casa::Float>& factor,
    189                        casa::Bool doTSys) const;
     194                       casa::Bool doTSys);
    190195
    191196// Convert time String to Epoch
    192    casa::MEpoch epochFromString (const casa::String& str, casa::MEpoch::Types timeRef) const;
     197   casa::MEpoch epochFromString(const casa::String& str, casa::MEpoch::Types timeRef);
    193198
    194199// Function to fill Scan Container when averaging in time
    195200
    196   void fillSDC (SDContainer& sc, const casa::Array<casa::Bool>& mask,
     201  void fillSDC(SDContainer& sc, const casa::Array<casa::Bool>& mask,
    197202                const casa::Array<casa::Float>& data,
    198203                const casa::Array<casa::Float>& tSys,
    199204                casa::Int scanID, casa::Double timeStamp,
    200205                casa::Double interval, const casa::String& sourceName,
    201                 const casa::Vector<casa::uInt>& freqID) const;
     206                const casa::Vector<casa::uInt>& freqID);
    202207
    203208// Format EPoch
    204    casa::String formatEpoch(const casa::MEpoch& epoch)  const;
     209   casa::String formatEpoch(const casa::MEpoch& epoch) const;
    205210
    206211// Align in Frequency
    207    SDMemTable* frequencyAlign (const SDMemTable& in,
     212   SDMemTable* frequencyAlign(const SDMemTable& in,
    208213                              casa::MFrequency::Types system,
    209214                              const casa::String& timeRef,
    210215                              const casa::String& method,
    211                                casa::Bool perIF) const;
     216                               casa::Bool perIF);
    212217
    213218// Generate frequency aligners
    214    void generateFrequencyAligners (casa::PtrBlock<casa::FrequencyAligner<casa::Float>* >& a,
     219   void generateFrequencyAligners(casa::PtrBlock<casa::FrequencyAligner<casa::Float>* >& a,
    215220                                   const SDDataDesc& dDesc,
    216221                                   const SDMemTable& in, casa::uInt nChan,
     
    218223                                   const casa::MPosition& refPos,
    219224                                   const casa::MEpoch& refEpoch,
    220                                    casa::Bool perFreqID) const;
    221 
    222 // Generate data description table (combines source and freqID)
    223    void generateDataDescTable (casa::Matrix<casa::uInt>& ddIdx,
     225                                   casa::Bool perFreqID);
     226
     227// Generate data description table(combines source and freqID);
     228   void generateDataDescTable(casa::Matrix<casa::uInt>& ddIdx,
    224229                               SDDataDesc& dDesc,
    225230                               casa::uInt nIF,
     
    228233                               const casa::ROScalarColumn<casa::String>& srcCol,
    229234                               const casa::ROArrayColumn<casa::uInt>& fqIDCol,
    230                                casa::Bool perFreqID) const;
     235                               casa::Bool perFreqID);
    231236
    232237// Get row range from SDMemTable state
    233    casa::Vector<casa::uInt> getRowRange (const SDMemTable& in) const;
     238  casa::Vector<casa::uInt> getRowRange(const SDMemTable& in) const;
    234239
    235240// Is row in the row range ?
    236    casa::Bool rowInRange (casa::uInt i, const casa::Vector<casa::uInt>& range) const;
     241  casa::Bool rowInRange(casa::uInt i, const casa::Vector<casa::uInt>& range) const;
    237242
    238243// Set slice to cursor or all axes
    239     void setCursorSlice (casa::IPosition& start, casa::IPosition& end,
    240                          casa::Bool doAll, const SDMemTable& in) const;
     244    void setCursorSlice(casa::IPosition& start, casa::IPosition& end,
     245                        casa::Bool doAll, const SDMemTable& in) const;
    241246
    242247// Function to normalize data when averaging in time
    243248
    244   void normalize (casa::MaskedArray<casa::Float>& data,
     249  void normalize(casa::MaskedArray<casa::Float>& data,
    245250                  const casa::Array<casa::Float>& sumSq,
    246251                  const casa::Array<casa::Float>& tSysSumSq,
    247252                  const casa::Array<casa::Float>& nPts,
    248253                  casa::Double intSum,
    249                   WeightType wtType, casa::Int axis, casa::Int nAxes) const;
     254                 WeightType wtType, casa::Int axis, casa::Int nAxes);
    250255
    251256// Put the data and mask into the SDContainer
    252    void putDataInSDC (SDContainer& sc, const casa::Array<casa::Float>& data,
    253                       const casa::Array<casa::Bool>& mask) const;
     257   void putDataInSDC(SDContainer& sc, const casa::Array<casa::Float>& data,
     258                     const casa::Array<casa::Bool>& mask);
    254259
    255260// Read ascii file into a Table
    256261
    257    casa::Table readAsciiFile (const casa::String& fileName) const;
    258 };
    259 
    260 
    261 
     262  casa::Table readAsciiFile(const casa::String& fileName) const;
     263
     264}; // class
    262265
    263266} // namespace
  • trunk/src/SDMathWrapper.cc

    r502 r716  
    3030//#---------------------------------------------------------------------------
    3131
    32 
    3332#include "SDMathWrapper.h"
    34 #include "SDMath.h"
    35 
    3633
    3734using namespace asap;
    3835using namespace casa;
     36
    3937
    4038SDMemTableWrapper SDMathWrapper::quotient(const SDMemTableWrapper& on,
     
    4240                                          Bool preserveContinuum)
    4341{
    44     SDMath sdm;
     42   
    4543    Bool doTSys = True;
    46     return SDMemTableWrapper(sdm.binaryOperate(on.getCP(), off.getCP(),
    47                              String("QUOTIENT"), preserveContinuum, doTSys));
     44    return SDMemTableWrapper(sdmath.binaryOperate(on.getCP(), off.getCP(),
     45                                                  String("QUOTIENT"),
     46                                                  preserveContinuum, doTSys));
    4847}
    4948
     
    5150SDMemTableWrapper SDMathWrapper::binaryOperate(const SDMemTableWrapper& left,
    5251                                               const SDMemTableWrapper& right,
    53                                                const std::string& op, bool doTSys)
    54 {
    55     SDMath sdm;
    56     return SDMemTableWrapper(sdm.binaryOperate(left.getCP(), right.getCP(),
    57                                                String(op), False, Bool(doTSys)));
    58 }
    59 
    60 
    61 void SDMathWrapper::scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll, bool doTSys)
     52                                               const std::string& op,
     53                                               bool doTSys)
     54{
     55   
     56    return SDMemTableWrapper(sdmath.binaryOperate(left.getCP(), right.getCP(),
     57                                                  String(op), False,
     58                                                  Bool(doTSys)));
     59}
     60
     61
     62void SDMathWrapper::scaleInSitu(SDMemTableWrapper& in, float factor,
     63                                bool doAll, bool doTSys)
    6264{
    6365  SDMemTable* pIn = in.getPtr();
    6466  const uInt what = 0;
    65 //
    66   SDMath sdm;
    67   SDMemTable* pOut = sdm.unaryOperate (*pIn, Float(factor),
     67 
     68  SDMemTable* pOut = sdmath.unaryOperate (*pIn, Float(factor),
    6869                                        Bool(doAll), what, Bool(doTSys));
    6970  *pIn = *pOut;
     
    7677  const CountedPtr<SDMemTable>& pIn = in.getCP();
    7778  const uInt what = 0;
    78   SDMath sdm;
    79   return CountedPtr<SDMemTable>(sdm.unaryOperate(*pIn, Float(factor), Bool(doAll),
     79 
     80  return CountedPtr<SDMemTable>(sdmath.unaryOperate(*pIn, Float(factor), Bool(doAll),
    8081                                                 what, Bool (doTSys)));
    8182}
     
    8687  SDMemTable* pIn = in.getPtr();
    8788  const uInt what = 1;
    88 //
    89   SDMath sdm;
     89 
    9090  Bool doTSys = False;
    91   SDMemTable* pOut = sdm.unaryOperate (*pIn, Float(offset),
     91  SDMemTable* pOut = sdmath.unaryOperate (*pIn, Float(offset),
    9292                                        Bool(doAll), what, doTSys);
    9393  *pIn = *pOut;
     
    100100  const CountedPtr<SDMemTable>& pIn = in.getCP();
    101101  const uInt what = 1;
    102   SDMath sdm;
     102 
    103103  Bool doTSys = False;
    104   return CountedPtr<SDMemTable>(sdm.unaryOperate(*pIn, Float(offset),
     104  return CountedPtr<SDMemTable>(sdmath.unaryOperate(*pIn, Float(offset),
    105105                                                  Bool(doAll), what, doTSys));
    106106}
     
    112112{
    113113  SDMemTable* pIn = in.getPtr();
    114   SDMath sdm;
    115   SDMemTable* pOut = sdm.smooth(*pIn, String(kernel),
     114 
     115  SDMemTable* pOut = sdmath.smooth(*pIn, String(kernel),
    116116                                Float(width), Bool(doAll));
    117117  *pIn = *pOut;
     
    125125{
    126126  const CountedPtr<SDMemTable>& pIn = in.getCP();
    127   SDMath sdm;
    128   return CountedPtr<SDMemTable>(sdm.smooth(*pIn, String(kernel),
     127 
     128  return CountedPtr<SDMemTable>(sdmath.smooth(*pIn, String(kernel),
    129129                                           Float(width), Bool(doAll)));
    130130}
     
    135135{
    136136  SDMemTable* pIn = in.getPtr();
    137   SDMath sdm;
    138   SDMemTable* pOut = sdm.bin (*pIn, Int(width));
     137 
     138  SDMemTable* pOut = sdmath.bin (*pIn, Int(width));
    139139  *pIn = *pOut;
    140140   delete pOut;
     
    145145{
    146146  const CountedPtr<SDMemTable>& pIn = in.getCP();
    147   SDMath sdm;
    148   return CountedPtr<SDMemTable>(sdm.bin(*pIn, Int(width)));
     147 
     148  return CountedPtr<SDMemTable>(sdmath.bin(*pIn, Int(width)));
    149149}
    150150
     
    153153{
    154154  SDMemTable* pIn = in.getPtr();
    155   SDMath sdm;
    156   SDMemTable* pOut = sdm.resample(*pIn, String(method), Float(width));
     155 
     156  SDMemTable* pOut = sdmath.resample(*pIn, String(method), Float(width));
    157157  *pIn = *pOut;
    158158   delete pOut;
     
    163163{
    164164  const CountedPtr<SDMemTable>& pIn = in.getCP();
    165   SDMath sdm;
    166   return CountedPtr<SDMemTable>(sdm.resample(*pIn, String(method), Float(width)));
     165 
     166  return CountedPtr<SDMemTable>(sdmath.resample(*pIn, String(method), Float(width)));
    167167}
    168168
     
    173173{
    174174  SDMemTable* pIn = in.getPtr();
    175   SDMath sdm;
     175 
    176176  Vector<Bool> tMask(mask);
    177   SDMemTable* pOut = sdm.averagePol (*pIn, tMask, String(weightStr));
     177  SDMemTable* pOut = sdmath.averagePol (*pIn, tMask, String(weightStr));
    178178  *pIn = *pOut;
    179179   delete pOut;
     
    185185{
    186186  const CountedPtr<SDMemTable>& pIn = in.getCP();
    187   SDMath sdm;
     187 
    188188  Vector<Bool> tMask(mask);
    189   return CountedPtr<SDMemTable>(sdm.averagePol(*pIn, tMask, String(weightStr)));
     189  return CountedPtr<SDMemTable>(sdmath.averagePol(*pIn, tMask, String(weightStr)));
    190190}
    191191
     
    195195                                            const std::string& which, int row)
    196196{
    197   SDMath sdm;
     197 
    198198  Vector<Bool> tMask(mask);
    199   return sdm.statistic(in.getCP(), tMask, String(which), Int(row));
     199  return sdmath.statistic(in.getCP(), tMask, String(which), Int(row));
    200200}
    201201
     
    205205{
    206206  SDMemTable* pIn = in.getPtr();
    207   SDMath sdm;
    208   SDMemTable* pOut = sdm.convertFlux (*pIn, Float(D), Float(eta), Float(JyPerK), Bool(doAll));
     207 
     208  SDMemTable* pOut = sdmath.convertFlux (*pIn, Float(D), Float(eta), Float(JyPerK), Bool(doAll));
    209209  *pIn = *pOut;
    210210  delete pOut;
     
    216216{
    217217  const CountedPtr<SDMemTable>& pIn = in.getCP();
    218   SDMath sdm;
    219   return CountedPtr<SDMemTable>(sdm.convertFlux(*pIn, Float(D), Float(eta), Float(JyPerK), Bool(doAll)));
     218 
     219  return CountedPtr<SDMemTable>(sdmath.convertFlux(*pIn, Float(D), Float(eta), Float(JyPerK), Bool(doAll)));
    220220}
    221221
     
    228228  SDMemTable* pIn = in.getPtr();
    229229  Vector<Float> tCoeffs(coeffs);
    230   SDMath sdm;
    231   SDMemTable* pOut = sdm.gainElevation(*pIn, tCoeffs, String(fileName),
     230 
     231  SDMemTable* pOut = sdmath.gainElevation(*pIn, tCoeffs, String(fileName),
    232232                                       String(method), Bool(doAll));
    233233  *pIn = *pOut;
     
    243243  const CountedPtr<SDMemTable>& pIn = in.getCP();
    244244  Vector<Float> tCoeffs(coeffs);
    245   SDMath sdm;
    246   return CountedPtr<SDMemTable>(sdm.gainElevation(*pIn, tCoeffs, String(fileName),
     245 
     246  return CountedPtr<SDMemTable>(sdmath.gainElevation(*pIn, tCoeffs, String(fileName),
    247247                                                  String(method), Bool(doAll)));
    248248}
     
    252252{
    253253  SDMemTable* pIn = in.getPtr();
    254   SDMath sdm;
    255   SDMemTable* pOut = sdm.frequencyAlignment(*pIn, String(refTime), String(method),
     254 
     255  SDMemTable* pOut = sdmath.frequencyAlignment(*pIn, String(refTime), String(method),
    256256                                            Bool(perFreqID));
    257257  *pIn = *pOut;
     
    266266{
    267267  const CountedPtr<SDMemTable>& pIn = in.getCP();
    268   SDMath sdm;
    269   return CountedPtr<SDMemTable>(sdm.frequencyAlignment(*pIn, String(refTime),
     268 
     269  return CountedPtr<SDMemTable>(sdmath.frequencyAlignment(*pIn, String(refTime),
    270270                                                       String(method), Bool(perFreqID)));
    271271}
     
    274274{
    275275  SDMemTable* pIn = in.getPtr();
    276   SDMath sdm;
    277   sdm.rotateXYPhase(*pIn, Float(angle), Bool(doAll));
     276 
     277  sdmath.rotateXYPhase(*pIn, Float(angle), Bool(doAll));
    278278}
    279279
     
    282282{
    283283  SDMemTable* pIn = in.getPtr();
    284   SDMath sdm;
    285   sdm.rotateLinPolPhase(*pIn, Float(angle), Bool(doAll));
     284 
     285  sdmath.rotateLinPolPhase(*pIn, Float(angle), Bool(doAll));
    286286}
    287287
     
    292292{
    293293  SDMemTable* pIn = in.getPtr();
    294   SDMath sdm;
    295   SDMemTable* pOut = sdm.opacity(*pIn, Float(tau), Bool(doAll));
    296   *pIn = *pOut;
    297   delete pOut;
    298 }
    299 
     294 
     295  SDMemTable* pOut = sdmath.opacity(*pIn, Float(tau), Bool(doAll));
     296  *pIn = *pOut;
     297  delete pOut;
     298}
    300299
    301300SDMemTableWrapper SDMathWrapper::opacity(const SDMemTableWrapper& in,
     
    303302{
    304303  const CountedPtr<SDMemTable>& pIn = in.getCP();
     304 
     305  return CountedPtr<SDMemTable>(sdmath.opacity(*pIn, Float(tau), Bool(doAll)));
     306}
     307
     308void SDMathWrapper::frequencySwitchInSitu(SDMemTableWrapper& in)
     309{
     310  SDMemTable* pIn = in.getPtr();
    305311  SDMath sdm;
    306   return CountedPtr<SDMemTable>(sdm.opacity(*pIn, Float(tau), Bool(doAll)));
    307 }
    308 
     312  SDMemTable* pOut = sdm.frequencySwitch(*pIn);
     313  *pIn = *pOut;
     314  delete pOut;
     315}
     316
     317SDMemTableWrapper SDMathWrapper::frequencySwitch(const SDMemTableWrapper& in)
     318{
     319  const CountedPtr<SDMemTable>& pIn = in.getCP();
     320  SDMath sdm;
     321  return CountedPtr<SDMemTable>(sdm.frequencySwitch(*pIn));
     322}
  • trunk/src/SDMathWrapper.h

    r503 r716  
    3838
    3939#include "SDMemTableWrapper.h"
     40#include "SDMath.h"
    4041
    4142namespace asap {
     
    4344namespace SDMathWrapper {
    4445
    45 // Quotient
     46
     47  static SDMath sdmath;
     48  // Quotient
    4649  SDMemTableWrapper quotient(const SDMemTableWrapper& on,
    4750                             const SDMemTableWrapper& off,
    4851                             casa::Bool preserveContinuum);
    4952
    50 // Simple binary operations
    51   SDMemTableWrapper binaryOperate (const SDMemTableWrapper& left,
    52                                    const SDMemTableWrapper& right,
    53                                    const std::string& op, bool doTSys);
    54 
    55 // Multiply
    56   void scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll, bool doTSys);
    57   SDMemTableWrapper scale(const SDMemTableWrapper& in, float factor, bool all, bool doTSys);
    58 
    59 // Add
     53  // Simple binary operations
     54  SDMemTableWrapper binaryOperate(const SDMemTableWrapper& left,
     55                                  const SDMemTableWrapper& right,
     56                                  const std::string& op, bool doTSys);
     57 
     58  // Multiply
     59  void scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll,
     60                   bool doTSys);
     61  SDMemTableWrapper scale(const SDMemTableWrapper& in, float factor,
     62                          bool all, bool doTSys);
     63 
     64  // Add
    6065  void addInSitu(SDMemTableWrapper& in, float offset, bool doAall);
    6166  SDMemTableWrapper add(const SDMemTableWrapper& in, float offset, bool all);
     
    7277
    7378// Resample
    74   void resampleInSitu(SDMemTableWrapper& in, const std::string& method, float width);
    75   SDMemTableWrapper resample(const SDMemTableWrapper& in, const std::string& method,
     79  void resampleInSitu(SDMemTableWrapper& in, const std::string& method,
     80                      float width);
     81  SDMemTableWrapper resample(const SDMemTableWrapper& in,
     82                             const std::string& method,
    7683                             float width);
    7784
    7885// Convert brightness between Jy and K
    79   void convertFluxInSitu(SDMemTableWrapper& in, float D, float eta, float JyPerK, bool doAll);
    80   SDMemTableWrapper convertFlux(const SDMemTableWrapper& in, float D, float eta, float JyPerK, bool doAll);
     86  void convertFluxInSitu(SDMemTableWrapper& in, float D, float eta,
     87                         float JyPerK, bool doAll);
     88  SDMemTableWrapper convertFlux(const SDMemTableWrapper& in, float D,
     89                                float eta, float JyPerK, bool doAll);
    8190
    8291// Apply gain elevation correction
     
    101110
    102111// Apply opacity correction
    103   void opacityInSitu (SDMemTableWrapper& in, float tau, bool doAll);
    104   SDMemTableWrapper opacity (const SDMemTableWrapper& in, float tau, bool doAll);
     112  void opacityInSitu(SDMemTableWrapper& in, float tau, bool doAll);
     113  SDMemTableWrapper opacity(const SDMemTableWrapper& in, float tau,
     114                            bool doAll);
    105115
    106116// Average in time
     
    116126                               const std::string& weightStr);
    117127
    118 // Statistics
     128  // Frequency Switching
     129  void SDMathWrapper::frequencySwitchInSitu(SDMemTableWrapper& in);
     130
     131  SDMemTableWrapper
     132  SDMathWrapper::frequencySwitch(const SDMemTableWrapper& in);
     133
     134  // Statistics
    119135  std::vector<float> statistic(const SDMemTableWrapper& in,
    120136                               const std::vector<bool>& mask,
    121137                               const std::string& which, int row);
     138
    122139};
    123140
  • trunk/src/python_SDMath.cc

    r653 r716  
    5858      }
    5959      Vector<Bool> msk(mask);
    60       //
    61       SDMath sdm;
    62       return SDMemTableWrapper(sdm.average(b, msk, Bool(scanAv), weightStr));
     60     
     61      return SDMemTableWrapper(sdmath.average(b, msk, Bool(scanAv), weightStr));
    6362    };
    6463  } // namespace SDMathWrapper
     
    6766    void python_SDMath() {
    6867      def("b_operate", &SDMathWrapper::binaryOperate);
    69       //
     68     
    7069      def("quotient", &SDMathWrapper::quotient);
    71 //
     70
    7271      def("scale", &SDMathWrapper::scale);
    7372      def("scale_insitu", &SDMathWrapper::scaleInSitu);
    74 //
     73
    7574      def("add", &SDMathWrapper::add);
    7675      def("add_insitu", &SDMathWrapper::addInSitu);
    77 //
     76
    7877      def("smooth", &SDMathWrapper::smooth);
    7978      def("smooth_insitu", &SDMathWrapper::smoothInSitu);
    80 //
     79
    8180      def("convertflux", &SDMathWrapper::convertFlux);
    8281      def("convertflux_insitu", &SDMathWrapper::convertFluxInSitu);
    83 //
     82
    8483      def("gainel", &SDMathWrapper::gainElevation);
    8584      def("gainel_insitu", &SDMathWrapper::gainElevationInSitu);
    86 //
     85
    8786      def("freq_align", &SDMathWrapper::frequencyAlignment);
    8887      def("freq_align_insitu", &SDMathWrapper::frequencyAlignmentInSitu);
    89 //
     88
    9089      def("opacity", &SDMathWrapper::opacity);
    9190      def("opacity_insitu", &SDMathWrapper::opacityInSitu);
    92 //
     91
    9392      def("average", &SDMathWrapper::average);
    94 //
     93
    9594      def("averagepol", &SDMathWrapper::averagePol);
    9695      def("averagepol_insitu", &SDMathWrapper::averagePolInSitu);
    97 //
     96
    9897      def("bin", &SDMathWrapper::bin);
    9998      def("bin_insitu", &SDMathWrapper::binInSitu);
    100 //
     99
    101100      def("resample", &SDMathWrapper::resample);
    102101      def("resample_insitu", &SDMathWrapper::resampleInSitu);
    103 //
     102
    104103      def("stats", &SDMathWrapper::statistic);
    105 //
    106       def ("_rotate_xyphase", &SDMathWrapper::rotateXYPhaseInSitu);
    107       def ("_rotate_linpolphase", &SDMathWrapper::rotateLinPolPhaseInSitu);
     104 
     105      def("_rotate_xyphase", &SDMathWrapper::rotateXYPhaseInSitu);
     106      def("_rotate_linpolphase", &SDMathWrapper::rotateLinPolPhaseInSitu);
     107
     108      def("_frequency_switch", &SDMathWrapper::frequencySwitch);
    108109    };
    109110
Note: See TracChangeset for help on using the changeset viewer.