Changeset 717 for trunk


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

implemented use of SDLog

Location:
trunk/src
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile

    r684 r717  
    5050CCOBJECTS := MathUtils.o \
    5151             MathUtils2.o \
     52             SDLog.o \
    5253             SDAttr.o \
    5354             SDContainer.o \
     
    7273             python_SDFitTable.o \
    7374             python_SDLineFinder.o \
     75             python_SDLog.o \
    7476             python_SD.o
    7577
     
    9395             SDAsciiWriter.h \
    9496             SDLineFinder.h \
     97             SDLog.h \
    9598             python_SD.h
    9699
  • trunk/src/SDAsciiWriter.cc

    r496 r717  
    4141#include <casa/iostream.h>
    4242#include <casa/fstream.h>
     43#include <casa/sstream.h>
    4344
    4445#include <coordinates/Coordinates/CoordinateUtil.h>
     
    9697// Open and write header file
    9798
    98 
    9999   String rootName(fileName);
    100100   if (rootName.length()==0) rootName = String("ascii");
    101101   {
    102102      String fName = String(rootName) + String("_header.txt");
    103       cout << "Writing header to " << fName << endl;
     103      pushLog("Writing header to "+fName);
    104104      ofstream of(fName.chars(), ios::trunc);
    105105      std::string summary = sdTable.summary(true);
     
    193193      }
    194194   }
    195 //
     195
    196196   of.close();
    197    cout << "Wrote " << nRows << " rows into file " << fileName << endl;
    198 //   
     197   ostringstream oss;
     198   oss << "Wrote " << nRows << " rows into file " << fileName;
     199   pushLog(String(oss));
    199200   return True;
    200201}
     
    206207   MVAngle x1(lonLat(0));
    207208   String s1 = x1.string(MVAngle::TIME, 12);
    208 //
     209
    209210   MVAngle x2(lonLat(1));
    210211   String s2 = x2.string(MVAngle::ANGLE, 12);
    211 //
     212
    212213   String ss = s1 + String(" ") + s2;
    213214   return ss;
  • trunk/src/SDAsciiWriter.h

    r443 r717  
    3636#include <SDMemTable.h>
    3737
     38#include "SDLog.h"
     39
    3840template<class T> class casa::Vector;
    3941
     
    4143namespace asap {
    4244
    43 class SDAsciiWriter {
     45class SDAsciiWriter : public SDLog {
    4446public:
    4547// Constructor
  • trunk/src/SDAttr.cc

    r507 r717  
    3030//#---------------------------------------------------------------------------
    3131
    32 #include "SDAttr.h"
    3332#include <casa/aips.h>
    3433#include <casa/Arrays/Vector.h>
     
    4342#include <scimath/Mathematics/InterpolateArray1D.h>
    4443
     44#include "SDAttr.h"
     45
    4546using namespace casa;
    4647using namespace asap;
    4748
    48 SDAttr::SDAttr ()
     49SDAttr::SDAttr()
    4950{
    5051   initData();
     
    5354SDAttr::SDAttr(const SDAttr& other)
    5455{
    55    initData();                                 // state just private 'static' data
     56   initData();                     // state just private 'static' data
    5657}
    5758
     
    5960{
    6061  if (this != &other) {
    61     ;                                      // state just private 'static' data
     62    ;                             // state just private 'static' data
    6263  }
    6364  return *this;
     
    6869
    6970
    70 Float SDAttr::diameter (Instrument inst)  const
     71Float SDAttr::diameter(Instrument inst)  const
    7172{
    7273   Float D = 1.0;
     
    103104        }
    104105   }
    105 //
    106106   return D;
    107107}
    108108
    109 Vector<Float> SDAttr::beamEfficiency (Instrument inst, const MEpoch& dateObs, const Vector<Float>& freqs) const
    110 {
    111 
    112 // Look at date where appropriate
    113 
     109Vector<Float> SDAttr::beamEfficiency(Instrument inst, const MEpoch& dateObs,
     110                                      const Vector<Float>& freqs) const
     111{
     112
     113  // Look at date where appropriate
    114114   MVTime t(dateObs.getValue());
    115115   uInt year = t.year();
    116 //
     116
    117117   Vector<Float> facs(freqs.nelements(),1.0);
    118118   switch (inst) {
    119       case ATMOPRA:
    120         {
    121            if (year<2003) {
    122               cerr << "There is no beam efficiency data from before 2003 - using 2003 data" << endl;
    123               facs = interp (freqs/1.0e9f, MopEtaBeamX_, MopEtaBeam2003Y_);
    124            } else if (year==2003) {
    125               cerr << "Using beam efficiency data from 2003" << endl;
    126               facs = interp (freqs/1.0e9f, MopEtaBeamX_, MopEtaBeam2003Y_);
    127            } else {
    128               cerr << "Using beam efficiency data from 2004" << endl;
    129               facs = interp (freqs/1.0e9f, MopEtaBeamX_, MopEtaBeam2004Y_);
    130            }
    131         }
    132         break;
    133       default:
    134         {
    135            cerr << "No beam efficiency data for this instrument - assuming unity" << endl;
    136         }
    137    }
    138 //
    139    return facs;
    140 }
    141 
    142 Vector<Float> SDAttr::apertureEfficiency (Instrument inst, const MEpoch& dateObs, const Vector<Float>& freqs) const
    143 {
    144 
    145 // Look at date where appropriate
    146 
    147    MVTime t(dateObs.getValue());
    148    uInt year = t.year();
    149 //
    150    Vector<Float> facs(freqs.nelements(),1.0);
    151    switch (inst) {
    152       case ATMOPRA:
    153         {
    154            if (year<2004) {
    155               cerr << "There is no aperture efficiency data from before 2004 - using 2004 data" << endl;
    156               facs = interp (freqs/1.0e9f, MopEtaApX_, MopEtaAp2004Y_);
    157            } else {
    158               cerr << "Using aperture efficiency data from 2004" << endl;
    159               facs = interp (freqs/1.0e9f, MopEtaApX_, MopEtaAp2004Y_);
    160            }
    161         }
    162         break;
    163       case TIDBINBILLA:
    164         {
    165             facs = interp (freqs/1.0e9f, TidEtaApX_, TidEtaApY_);
    166         }
    167         break;
    168       default:
    169         {
    170            cerr << "No aperture efficiency data for this instrument - assuming unity" << endl;
    171         }
     119   case ATMOPRA:
     120        {
     121          if (year<2003) {
     122            pushLog("There is no beam efficiency data from before 2003"
     123                    " - using 2003 data");
     124            facs = interp(freqs/1.0e9f, MopEtaBeamX_, MopEtaBeam2003Y_);
     125          } else if (year==2003) {
     126            pushLog("Using beam efficiency data from 2003");
     127            facs = interp(freqs/1.0e9f, MopEtaBeamX_, MopEtaBeam2003Y_);
     128          } else {
     129            pushLog("Using beam efficiency data from 2004");
     130            facs = interp(freqs/1.0e9f, MopEtaBeamX_, MopEtaBeam2004Y_);
     131          }
     132        }
     133        break;
     134   default:
     135     {
     136       pushLog("No beam efficiency data for this instrument - assuming unity");
     137     }
    172138   }
    173139   return facs;
    174140}
    175141
    176 Vector<Float> SDAttr::JyPerK (Instrument inst, const MEpoch& dateObs, const Vector<Float>& freqs) const
    177 {
    178 
    179 // FInd what we need
    180 
    181    Vector<Float> etaAp = apertureEfficiency (inst, dateObs, freqs);
    182    Float D = diameter(inst);
    183 
    184 // Compute it
    185 
     142Vector<Float> SDAttr::apertureEfficiency(Instrument inst,
     143                                         const MEpoch& dateObs,
     144                                         const Vector<Float>& freqs) const
     145{
     146 
     147  // Look at date where appropriate
     148  MVTime t(dateObs.getValue());
     149  uInt year = t.year();
     150 
     151  Vector<Float> facs(freqs.nelements(),1.0);
     152  switch (inst) {
     153  case ATMOPRA:
     154    {
     155      if (year<2004) {
     156        pushLog("There is no aperture efficiency data from before 2004"
     157                " - using 2004 data");
     158        facs = interp(freqs/1.0e9f, MopEtaApX_, MopEtaAp2004Y_);
     159      } else {
     160        pushLog("Using aperture efficiency data from 2004");
     161        facs = interp(freqs/1.0e9f, MopEtaApX_, MopEtaAp2004Y_);
     162      }
     163    }
     164    break;
     165  case TIDBINBILLA:
     166    {
     167      facs = interp(freqs/1.0e9f, TidEtaApX_, TidEtaApY_);
     168    }
     169    break;
     170  default:
     171    {
     172      pushLog("No aperture efficiency data for this instrument"
     173              " - assuming unity");
     174    }
     175  }
     176  return facs;
     177}
     178
     179Vector<Float> SDAttr::JyPerK(Instrument inst, const MEpoch& dateObs,
     180                             const Vector<Float>& freqs) const
     181{
     182 
     183  // Find what we need
     184  Vector<Float> etaAp = apertureEfficiency(inst, dateObs, freqs);
     185  Float D = diameter(inst);
     186  // Compute it
    186187   Vector<Float> facs(freqs.nelements(),1.0);
    187188   for (uInt i=0; i<freqs.nelements(); i++) {
    188       facs(i) = SDAttr::findJyPerK (etaAp(i), D);
     189     facs(i) = SDAttr::findJyPerK(etaAp(i), D);
    189190   }
    190 //
    191191   return facs;
    192192}
    193193
    194194
    195 Float SDAttr::findJyPerK (Float etaAp, Float D)
    196 //
    197 // Converts K -> Jy
    198 // D in m
    199 //
    200 {
    201    Double kb = QC::k.getValue(Unit(String("erg/K")));
    202    Float gA = C::pi * D * D / 4.0;
    203    return (2.0 * 1.0e19 * kb / etaAp / gA);
    204 }
    205 
    206 
    207 Vector<Float> SDAttr::gainElevationPoly (Instrument inst) const
    208 {
    209 
    210 // Look at date where appropriate
    211 
    212    switch (inst) {
    213       case TIDBINBILLA:
    214         {
    215            return TidGainElPoly_.copy();
    216         }
    217         break;
    218       default:
    219         {
    220            Vector<Float> t;
    221            return t.copy();
    222         }
    223    }
    224 }
    225 
    226 FeedPolType SDAttr::feedPolType (Instrument inst) const
    227 {
    228    FeedPolType type = UNKNOWNFEED;
    229    switch (inst) {
    230       case ATMOPRA:
    231       case ATPKSMB:
    232       case ATPKSHOH:
    233         {
    234            type = LINEAR;
    235         }
    236         break;
    237       case TIDBINBILLA:
    238         {
    239            type = CIRCULAR;
    240         }
    241         break;
    242       default:
    243         {
    244            type = UNKNOWNFEED;
    245         }
    246    }
    247    return type;
    248 }
    249 
    250 
    251 
     195Float SDAttr::findJyPerK(Float etaAp, Float D)
     196  //
     197  // Converts K -> Jy
     198  // D in m
     199  //
     200{
     201  Double kb = QC::k.getValue(Unit(String("erg/K")));
     202  Float gA = C::pi * D * D / 4.0;
     203  return (2.0 * 1.0e19 * kb / etaAp / gA);
     204}
     205
     206
     207Vector<Float> SDAttr::gainElevationPoly(Instrument inst) const
     208{
     209
     210  // Look at date where appropriate
     211  switch (inst) {
     212  case TIDBINBILLA:
     213    {
     214      return TidGainElPoly_.copy();
     215    }
     216    break;
     217  default:
     218    {
     219      Vector<Float> t;
     220      return t.copy();
     221    }
     222  }
     223}
     224
     225FeedPolType SDAttr::feedPolType(Instrument inst) const
     226{
     227  FeedPolType type = UNKNOWNFEED;
     228  switch (inst) {
     229  case ATMOPRA:
     230  case ATPKSMB:
     231  case ATPKSHOH:
     232    {
     233      type = LINEAR;
     234    }
     235    break;
     236  case TIDBINBILLA:
     237    {
     238      type = CIRCULAR;
     239    }
     240    break;
     241  default:
     242    {
     243      type = UNKNOWNFEED;
     244    }
     245  }
     246  return type;
     247}
    252248
    253249
    254250// Private
    255 
    256 Vector<Float> SDAttr::interp (const Vector<Float>& xOut, const Vector<Float>& xIn,
    257                               const Vector<Float>& yIn) const
    258 {
    259    Int method = 1;                         // Linear
    260    Vector<Float> yOut;
    261    Vector<Bool> mOut;
    262 //
    263    Vector<Bool> mIn(xIn.nelements(),True);
    264 //
    265    InterpolateArray1D<Float,Float>::interpolate(yOut, mOut, xOut,
    266                                                  xIn, yIn, mIn,
    267                                                  method, True, True);
    268 //
    269    return yOut;
    270 }
    271 
    272 void SDAttr::initData ()
    273 //
    274 // Mopra data from Mopra web page
    275 // Tid  data from Tid web page
    276 // X in GHz
    277 //
    278 {
    279 
    280 // Beam efficiency
    281 
     251Vector<Float> SDAttr::interp(const Vector<Float>& xOut,
     252                             const Vector<Float>& xIn,
     253                             const Vector<Float>& yIn) const
     254{
     255  Int method = 1;  // Linear
     256  Vector<Float> yOut;
     257  Vector<Bool> mOut;
     258
     259  Vector<Bool> mIn(xIn.nelements(),True);
     260 
     261  InterpolateArray1D<Float,Float>::interpolate(yOut, mOut, xOut,
     262                                               xIn, yIn, mIn,
     263                                               method, True, True);
     264 
     265  return yOut;
     266}
     267
     268void SDAttr::initData()
     269  //
     270  // Mopra data from Mopra web page
     271  // Tid  data from Tid web page
     272  // X in GHz
     273  //
     274{
     275
     276  // Beam efficiency
    282277   MopEtaBeamX_.resize(3);
    283278   MopEtaBeamX_(0) = 86.0;
    284279   MopEtaBeamX_(1) = 100.0;
    285280   MopEtaBeamX_(2) = 115.0;
    286 //
     281
    287282   MopEtaBeam2003Y_.resize(3);
    288283   MopEtaBeam2003Y_(0) = 0.39;
    289284   MopEtaBeam2003Y_(1) = 0.37;
    290    MopEtaBeam2003Y_(2) = 0.37;                // replicated from (1)
    291 //
     285   MopEtaBeam2003Y_(2) = 0.37;          // replicated from (1)
     286   
    292287   MopEtaBeam2004Y_.resize(3);
    293288   MopEtaBeam2004Y_(0) = 0.49;
     
    295290   MopEtaBeam2004Y_(2) = 0.42;
    296291
    297 // Aperture efficiency
    298 
     292   // Aperture efficiency
    299293   MopEtaApX_.resize(2);
    300294   MopEtaApX_(0) = 86.0;
    301295   MopEtaApX_(1) = 115.0;
    302 //
     296
    303297   MopEtaAp2004Y_.resize(2);
    304298   MopEtaAp2004Y_(0) = 0.33;
    305299   MopEtaAp2004Y_(1) = 0.24;
    306 //
     300
    307301   TidEtaApX_.resize(2);
    308302   TidEtaApY_.resize(2);
     
    312306   TidEtaApY_(1) = 0.4848;
    313307
    314 // Gain elevation correction polynomial coefficients (for elevation in degrees)
     308   // Gain elevation correction polynomial coefficients (for elevation
     309   // in degrees)
    315310
    316311   TidGainElPoly_.resize(3);
     
    324319                                     Bool throwIt)
    325320{
    326    String t(instrument);
    327    t.upcase();
    328 
    329    // The strings are what SDReader returns, after cunning interrogation
    330    // of station names... :-(
    331    Instrument inst = asap::UNKNOWNINST;
    332    if (t==String("DSS-43")) {
    333       inst = TIDBINBILLA;
    334    } else if (t==String("ATPKSMB")) {
    335       inst = ATPKSMB;
    336    } else if (t==String("ATPKSHOH")) {
    337       inst = ATPKSHOH;
    338    } else if (t==String("ATMOPRA")) {
    339       inst = ATMOPRA;
    340    } else if (t==String("CEDUNA")) {
    341       inst = CEDUNA;
    342    } else if (t==String("HOBART")) {
    343       inst = HOBART;
    344    } else {
    345      if (throwIt) {
    346        throw AipsError("Unrecognized instrument - use function scan.set_instrument to set");
    347      }
    348    }
    349    return inst;
    350 }
    351 
    352 
     321  String t(instrument);
     322  t.upcase();
     323 
     324  // The strings are what SDReader returns, after cunning
     325  // interrogation of station names... :-(
     326  Instrument inst = asap::UNKNOWNINST;
     327  if (t==String("DSS-43")) {
     328    inst = TIDBINBILLA;
     329  } else if (t==String("ATPKSMB")) {
     330    inst = ATPKSMB;
     331  } else if (t==String("ATPKSHOH")) {
     332    inst = ATPKSHOH;
     333  } else if (t==String("ATMOPRA")) {
     334    inst = ATMOPRA;
     335  } else if (t==String("CEDUNA")) {
     336    inst = CEDUNA;
     337  } else if (t==String("HOBART")) {
     338    inst = HOBART;
     339  } else {
     340    if (throwIt) {
     341      throw AipsError("Unrecognized instrument"
     342                      " - use function scan.set_instrument to set");
     343    }
     344  }
     345  return inst;
     346}
  • trunk/src/SDAttr.h

    r507 r717  
    3232#define SDATTR_H
    3333
    34 #include "SDDefs.h"
    3534#include <casa/aips.h>
    3635#include <measures/Measures/MEpoch.h>
     36#include <casa/Utilities/CountedPtr.h>
     37
     38#include "SDLog.h"
     39#include "SDDefs.h"
    3740
    3841template<class T> class casa::Vector;
    39 //class casa::MEpoch;
    40 
    4142
    4243
    4344namespace asap {
    4445
    45 class SDAttr {
     46class SDAttr : public SDLog {
    4647
    4748 public:
    4849
    49 // Constructor
    50    SDAttr();
     50  // Constructor
     51  SDAttr();
     52 
     53  // Destructor
     54  ~SDAttr();
     55 
     56  // Copy Constructor (copy semantics)
     57  SDAttr(const SDAttr& other);
     58 
     59  // Assignment  (copy semantics)
     60  SDAttr &operator=(const SDAttr& other);
     61 
     62  // Telescope diameter(m). Throws exception if unknown.
     63  casa::Float diameter(Instrument inst) const;
     64 
     65  // Beam efficiency.  Frequency in Hz.  Returns 1 if unknown.
     66  casa::Vector<casa::Float>
     67  beamEfficiency(Instrument instr, const casa::MEpoch& dateObs,
     68                 const casa::Vector<casa::Float>& freqs) const;
     69 
     70  // Aperture efficiency. Frequency in Hz.  Returns 1 if unknown.
     71  casa::Vector<casa::Float>
     72  apertureEfficiency(Instrument instr,
     73                     const casa::MEpoch& dateObs,
     74                     const casa::Vector<casa::Float>& freqs) const;
     75 
     76  // Find factor to convert Jy -> K for this telescope, date of
     77  // observation and frequency (Hz)
     78  casa::Vector<casa::Float> JyPerK(Instrument instr,
     79                                   const casa::MEpoch& dateObs,
     80                                   const casa::Vector<casa::Float>& freqs)
     81    const;
    5182
    52 // Destructor
    53    ~SDAttr();
     83  // Gain Elevation polynomial correction coefficients (elevation in
     84  // degrees) Returns length 0 if not known.
     85   casa::Vector<casa::Float> gainElevationPoly(Instrument instr) const;
    5486
    55 // Copy Constructor (copy semantics)
    56    SDAttr (const SDAttr& other);
    57 
    58 // Assignment  (copy semantics)
    59    SDAttr &operator=(const SDAttr& other);
    60 
    61 // Telescope diameter (m). Throws exception if unknown.
    62    casa::Float diameter (Instrument inst) const;
    63 
    64 // Beam efficiency.  Frequency in Hz.  Returns 1 if unknown.
    65    casa::Vector<casa::Float> beamEfficiency (Instrument instr, const casa::MEpoch& dateObs,
    66                                              const casa::Vector<casa::Float>& freqs) const;
    67  
    68 // Aperture efficiency. Frequency in Hz.  Returns 1 if unknown.
    69    casa::Vector<casa::Float> apertureEfficiency (Instrument instr, const casa::MEpoch& dateObs,
    70                                                  const casa::Vector<casa::Float>& freqs) const;
    71 
    72 // Find factor to convert Jy -> K for this telescope, date of observation and frequency (Hz)
    73    casa::Vector<casa::Float> JyPerK (Instrument instr, const casa::MEpoch& dateObs,
    74                                      const casa::Vector<casa::Float>& freqs) const;
    75 
    76 // Gain Elevation polynomial correction coefficients (elevation in degrees)
    77 // Returns length 0 if not known.
    78    casa::Vector<casa::Float> gainElevationPoly (Instrument instr) const;
    79 
    80 // Find feed polarization type of feeds. In future this needs to come from the data themselves
    81    FeedPolType feedPolType (Instrument) const;
    82 
    83 // Helper function to check instrument (antenna) name and give enum
     87  // Find feed polarization type of feeds. In future this needs to come
     88  // from the data themselves
     89  FeedPolType feedPolType(Instrument) const;
     90 
     91  // Helper function to check instrument (antenna) name and give enum
    8492  static Instrument convertInstrument(const casa::String& instrument,
    8593                                      casa::Bool throwIt);
     94 
     95  // Helper function.  Finds factor to convert K -> Jy. Provide
     96  // aperture efficiency and dish geometric diameter (m)
     97  static casa::Float findJyPerK(casa::Float etaAp, casa::Float D);
     98 
     99private:
     100 
     101  // Static data 
     102  casa::Vector<casa::Float> MopEtaBeamX_;     // Beam efficiency
     103  casa::Vector<casa::Float> MopEtaBeam2003Y_;
     104  casa::Vector<casa::Float> MopEtaBeam2004Y_;
    86105
    87 // Helper function.  Finds factor to convert K -> Jy. Provide aperture efficiency and dish geometric diameter (m)
    88    static casa::Float findJyPerK (casa::Float etaAp, casa::Float D);
     106  casa::Vector<casa::Float> MopEtaApX_;       // Aperture efficiency
     107  casa::Vector<casa::Float> MopEtaAp2004Y_;
     108
     109  casa::Vector<casa::Float> TidEtaApX_;       // Aperture efficiency
     110  casa::Vector<casa::Float> TidEtaApY_;
     111
     112  casa::Vector<casa::Float> TidGainElPoly_;   // Gain-el correction poly coeffs
     113 
     114  // Init private data
     115  void initData();
     116
     117  // Linear interpolation
     118  casa::Vector<casa::Float> interp(const casa::Vector<casa::Float>& xOut,
     119                                   const casa::Vector<casa::Float>& xIn,
     120                                   const casa::Vector<casa::Float>& yIn) const;
    89121
    90122
    91  private:
    92 
    93 // Static data
    94 
    95    casa::Vector<casa::Float> MopEtaBeamX_;          // Beam efficiency
    96    casa::Vector<casa::Float> MopEtaBeam2003Y_;
    97    casa::Vector<casa::Float> MopEtaBeam2004Y_;
    98 //
    99    casa::Vector<casa::Float> MopEtaApX_;            // Aperture efficiency
    100    casa::Vector<casa::Float> MopEtaAp2004Y_;
    101 //
    102    casa::Vector<casa::Float> TidEtaApX_;            // Aperture efficiency
    103    casa::Vector<casa::Float> TidEtaApY_;
    104 //
    105    casa::Vector<casa::Float> TidGainElPoly_;        // Gain-el correction poly coeffs
    106 
    107 // Init private data
    108    void initData();
    109 
    110 // Linear interpolation
    111    casa::Vector<casa::Float> interp (const casa::Vector<casa::Float>& xOut, const casa::Vector<casa::Float>& xIn,
    112                                      const casa::Vector<casa::Float>& yIn) const;
    113123};
    114124
  • trunk/src/SDFITSImageWriter.cc

    r448 r717  
    120120   Directory dir(dirName2);
    121121   dir.create(True);
    122    cout << "Created directory '" << dirName2 << "' for output files" << endl;
    123 
    124 // Temps
     122   ostringstream oss;
     123   oss << "Created directory '" << dirName2 << "' for output files";
     124
     125   // Temps
    125126
    126127   Vector<Int> whichStokes(1,1);
     
    233234// Write out as FITS Image file
    234235
    235          ostringstream oss;
    236          oss << "row" << iRow << "_beam" << pos(0) << "_if"
     236         ostringstream oss2;
     237         oss2 << "row" << iRow << "_beam" << pos(0) << "_if"
    237238             << pos(1) << "_" << stokesName  << "_" << srcCol(iRow) << ".fits";
    238          String tS(oss);
     239         String tS(oss2);
    239240         String fileName = dirName2 + String("/") + tS;
    240          if (verbose) cout << "Writing row " << iRow
    241                            << " into file '" << tS << "'" << endl;
     241         if (verbose) oss << endl << "Writing row " << iRow
     242                           << " into file '" << tS << "'";
    242243//
    243244         Bool ok = ImageFITSConverter::ImageToFITS(errMsg, tIm, fileName,
     
    247248                                                   degLast, reallyVerbose);
    248249         if (!ok) {
    249             cerr << "Error writing fits - " << errMsg << endl;
     250           oss << endl<< "Error writing fits - " << errMsg;
    250251         }
    251252
     
    258259//
    259260   if (!verbose) {
    260       cout << "Wrote " << nRows << " into individual FITS files" << endl;
     261     oss << endl<< "Wrote " << nRows << " into individual FITS files";
    261262   }
    262 //   
     263   pushLog(String(oss));
    263264   return True;
    264265}
    265266
    266 
  • trunk/src/SDFITSImageWriter.h

    r443 r717  
    3636#include <SDMemTable.h>
    3737
     38#include "SDLog.h"
    3839
    3940namespace asap {
    4041
    41 class SDFITSImageWriter {
     42class SDFITSImageWriter : public SDLog {
    4243public:
    43 // Constructor
     44  // Constructor
    4445  SDFITSImageWriter();
    45 
    46 // Destructor
     46 
     47  // Destructor
    4748  ~SDFITSImageWriter();
    48 
    49 // Write out lots of FITS images, one per row, beam, IF and polarization
     49 
     50  // Write out lots of FITS images, one per row, beam, IF and polarization
    5051  casa::Bool write(const SDMemTable& table, const casa::String& rootName,
    5152                   casa::Bool toStokes, casa::Bool verbose=casa::True);
    52 
     53 
    5354private:
    54    casa::Int convertStokes(casa::Int val, casa::Bool toStokes, casa::Bool linear) const;
     55  casa::Int convertStokes(casa::Int val, casa::Bool toStokes,
     56                          casa::Bool linear) const;
    5557};
    5658
  • trunk/src/SDMemTable.cc

    r588 r717  
    887887  MFrequency::Types mft;
    888888  if (!MFrequency::getType(mft, rf)) {
    889     cerr << "Frequency type unknown assuming TOPO" << endl;
     889    ostringstream oss;
     890    pushLog("WARNING: Frequency type unknown assuming TOPO");
    890891    mft = MFrequency::TOPO;
    891892  }
     
    923924  if (!MFrequency::getType(mtype, frm)) {
    924925    // Should never happen
    925     cerr << "Frequency type unknown assuming TOPO" << endl;
     926    pushLog("WARNING: Frequency type unknown assuming TOPO");
    926927    mtype = MFrequency::TOPO;
    927928  }
     
    16551656  if (!MDirection::getType(mdr, mp[eq])) {   
    16561657    mdr = MDirection::J2000;
    1657     cerr  << "Unknown equinox using J2000" << endl;
     1658    pushLog("WARNING: Unknown equinox using J2000");
     1659   
    16581660  }
    16591661
     
    16671669  table_.keywordSet().get("Epoch",ep);
    16681670  if (!MEpoch::getType(met, ep)) {
    1669     cerr << "Epoch type unknown - using UTC" << endl;
     1671     pushLog("WARNING: Epoch type unknown - using UTC");
    16701672    met = MEpoch::UTC;
    16711673  }
     
    17211723   SDFrequencyTable sdft = getSDFreqTable();
    17221724
     1725   ostringstream oss;
    17231726   if (nRestFreqs>1) {
    17241727     // Replace restFreqs, one per IF
    1725       if (nRestFreqs != nIFs) {
    1726          throw (AipsError("Number of rest frequencies must be equal to the number of IFs"));
    1727       }
    1728       cout << "Replacing rest frequencies, one per IF, with given list : " << restFreqs << endl;
    1729       sdft.deleteRestFrequencies();
    1730       for (uInt i=0; i<nRestFreqs; i++) {
    1731          Quantum<Double> rf(restFreqs[i], unit);
    1732          sdft.addRestFrequency(rf.getValue("Hz"));
    1733       }
     1728     if (nRestFreqs != nIFs) {
     1729       throw (AipsError("Number of rest frequencies must be equal to the number of IFs"));
     1730     }
     1731     ostringstream oss;
     1732     oss << "Replacing rest frequencies, one per IF, with given list : " << restFreqs;
     1733     sdft.deleteRestFrequencies();
     1734     for (uInt i=0; i<nRestFreqs; i++) {
     1735       Quantum<Double> rf(restFreqs[i], unit);
     1736       sdft.addRestFrequency(rf.getValue("Hz"));
     1737     }
    17341738   } else {
    17351739
     
    17381742      idx = sdft.addRestFrequency(rf.getValue("Hz"));
    17391743      if (whichIF>=0) {
    1740          cout << "Selecting given rest frequency (" << restFreqs[0] << ") for IF " << whichIF << endl;
     1744         oss << "Selecting given rest frequency (" << restFreqs[0] << ") for IF " << whichIF << endl;
    17411745      } else {
    1742          cout << "Selecting given rest frequency (" << restFreqs[0] << ") for all IFs" << endl;
     1746         oss << "Selecting given rest frequency (" << restFreqs[0] << ") for all IFs" << endl;
    17431747      }
    17441748   }
    1745    
     1749   pushLog(String(oss));
    17461750   // Replace
    17471751   Bool empty = source.empty();
     
    17781782}
    17791783
    1780 void SDMemTable::spectralLines() const
     1784std::string SDMemTable::spectralLines() const
    17811785{
    17821786   Vector<String> lines = MeasTable::Lines();
    17831787   MFrequency lineFreq;
    17841788   Double freq;
    1785 
    1786    cout.flags(std::ios_base::left);
    1787    cout << "Line      Frequency (Hz)" << endl;
    1788    cout << "-----------------------" << endl;
     1789   ostringstream oss;
     1790
     1791   oss.flags(std::ios_base::left);
     1792   oss << "Line      Frequency (Hz)" << endl;
     1793   oss << "-----------------------" << endl;
    17891794   for (uInt i=0; i<lines.nelements(); i++) {
    17901795     MeasTable::Line(lineFreq, lines[i]);
    17911796     freq = lineFreq.getValue().getValue();          // Hz
    1792      cout << setw(11) << lines[i] << setprecision(10) << freq << endl;
     1797     oss << setw(11) << lines[i] << setprecision(10) << freq << endl;
    17931798   }
     1799   return String(oss);
    17941800}
    17951801
  • trunk/src/SDMemTable.h

    r539 r717  
    4646#include "SDDefs.h"
    4747#include "SDFitTable.h"
     48#include "SDLog.h"
    4849
    4950namespace asap {
     
    5556
    5657
    57 
    58 class SDMemTable {
     58class SDMemTable : private SDLog {
    5959public:
    6060  // create a new (empty) SDMemTable
     
    161161
    162162  // List lines
    163   void spectralLines() const;
     163  std::string spectralLines() const;
    164164
    165165  // Get/Set flux unit
  • trunk/src/SDMemTableWrapper.h

    r539 r717  
    179179  }
    180180 
    181   void spectralLines() const {table_->spectralLines();}
     181  std::string spectralLines() const {table_->spectralLines();}
    182182
    183183  std::vector<double> getRestFreqs() {
  • trunk/src/SDReader.cc

    r570 r717  
    8989
    9090void SDReader::close() {
    91   cerr << "disabled" << endl;
     91  //cerr << "disabled" << endl;
    9292}
    9393
     
    125125  // Get basic parameters.
    126126  if (haveXPol_) {
    127     cout << "Cross polarization present" << endl;
     127    pushLog("Cross polarization present");
    128128    nPol_ += 2;                          // Convert Complex -> 2 Floats
    129129  }
     
    150150  if ((header_->obstype).matches("*SW*")) {
    151151    // need robust way here - probably read ahead of next timestamp
    152     cout << "Header indicates frequency switched observation.\n"
    153       "setting # of IFs = 1 " << endl;
     152    pushLog("Header indicates frequency switched observation.\n"
     153               "setting # of IFs = 1 ");
    154154    nIF_ = 1;
    155155  }
     
    259259          // EOF.
    260260          if (row > 0 && row < stepsize-1)
    261             cerr << "incomplete scan data.\n Probably means not all Beams/IFs/Pols within a scan are present." << endl;
     261            pushLog("incomplete scan data.\n Probably means not all Beams/IFs/Pols within a scan are present.");
    262262
    263263          // flush frequency table
  • trunk/src/SDReader.h

    r420 r717  
    4343#include "SDMemTable.h"
    4444#include "SDContainer.h"
     45#include "SDLog.h"
    4546
    4647class PKSreader;
     
    4849namespace asap {
    4950
    50 class SDReader {
     51class SDReader : public SDLog {
    5152public:
    5253  SDReader();
     
    7374  }
    7475
     76
    7577protected:
    76 
     78 
    7779private:
    7880  casa::Int nBeam_,nIF_,nPol_,nChan_;
  • trunk/src/SDWriter.cc

    r701 r717  
    177177                               hdr.obstype, hdr.equinox, hdr.freqref,
    178178                               nChan, nPol, False, False)) {
    179     cerr << "Failed to create output file." << endl;
    180     return 1;
     179    throw(AipsError("Failed to create output file"));
    181180  }
    182181
     
    306305    }
    307306  }
    308 
    309   cout << "SDWriter: wrote " << count << " rows to " << filename << endl;
     307  ostringstream oss;
     308  oss << "SDWriter: wrote " << count << " rows to " << filename << endl;
     309  pushLog(String(oss));
    310310  cWriter->close();
    311311
  • trunk/src/SDWriter.h

    r442 r717  
    4040#include <SDMemTableWrapper.h>
    4141
     42#include <SDLog.h>
     43
    4244class PKSwriter;
    4345
    4446namespace asap {
    4547
    46 class SDWriter {
     48class SDWriter : public SDLog {
    4749public:
    4850  SDWriter(const string &format = "SDFITS");
  • trunk/src/python_SD.cc

    r576 r717  
    6161  asap::python::python_SDFitTable();
    6262  asap::python::python_SDLineFinder();
     63  asap::python::python_SDLog();
    6364
    6465  register_exception_translator<casa::AipsError>(&asap::python::translate_ex);
  • trunk/src/python_SD.h

    r465 r717  
    4444    void python_SDFitTable();
    4545    void python_SDLineFinder();
     46    void python_SDLog();
    4647
    4748  } // python
  • trunk/src/python_SDReader.cc

    r405 r717  
    4545        .def("_reset", &SDReaderWrapper::reset)
    4646        .def("_getdata", &SDReaderWrapper::getSDMemTable)
    47         .def("_header",  &SDReaderWrapper::pseudoHeader);
     47        .def("_header",  &SDReaderWrapper::pseudoHeader)
    4848      ;
    4949    };
Note: See TracChangeset for help on using the changeset viewer.