Changeset 209


Ignore:
Timestamp:
01/18/05 17:31:59 (20 years ago)
Author:
mar637
Message:
  • now using asap::AxisNo enum instead of fixed axis indeces
Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/MathUtils.cc

    r176 r209  
    4040using namespace casa;
    4141
    42 
    43 
    44 float mathutil::statistics (const String& which,  const MaskedArray<Float>& data)
     42float mathutil::statistics(const String& which, 
     43                           const MaskedArray<Float>& data)
    4544{
    4645   String str(which);
     
    7170 
    7271
    73 void mathutil::replaceMaskByZero (Vector<Float>& data, const Vector<Bool>& mask)
     72void mathutil::replaceMaskByZero(Vector<Float>& data, const Vector<Bool>& mask)
    7473{
    7574   for (uInt i=0; i<data.nelements(); i++) {
  • trunk/src/MathUtils2.cc

    r137 r209  
    3737
    3838using namespace casa;
    39 //using namespace asap;
    4039
    4140template <class T>
    4241void mathutil::hanning(Vector<T>& out, Vector<Bool>& outmask,
    43              const Vector<T>& in, const Vector<Bool>& mask,
    44              Bool relaxed, Bool ignoreOther) {
     42                       const Vector<T>& in, const Vector<Bool>& mask,
     43                       Bool relaxed, Bool ignoreOther) {
    4544
    4645  Vector< Vector<T> > weights(8);
  • trunk/src/SDAsciiWriter.cc

    r198 r209  
    3030//#---------------------------------------------------------------------------
    3131
    32 #include "SDAsciiWriter.h"
    33 
    3432#include <casa/aips.h>
    3533#include <casa/Arrays/Array.h>
     
    4038#include <casa/Quanta/MVAngle.h>
    4139
     40
     41#include <casa/iostream.h>
     42#include <casa/fstream.h>
     43
    4244#include <coordinates/Coordinates/CoordinateUtil.h>
    4345#include <coordinates/Coordinates/SpectralCoordinate.h>
     
    5153#include <tables/Tables/ArrayColumn.h>
    5254
     55#include "Definitions.h"
    5356#include "SDContainer.h"
    5457#include "SDMemTable.h"
    55 
    56 #include <casa/iostream.h>
    57 #include <casa/fstream.h>
    58 
     58#include "SDAsciiWriter.h"
    5959
    6060using namespace casa;
     
    6969
    7070
    71 Bool SDAsciiWriter::write(const SDMemTable& sdTable,  const String& fileName)
     71Bool SDAsciiWriter::write(const SDMemTable& sdTable, const String& fileName)
    7272{
    7373
     
    8686   ROScalarColumn<String> src(tab, "SRCNAME");
    8787
    88 // Axes (should be in header)
    89 
    90    const uInt beamAxis = 0;
    91    const uInt ifAxis = 1;
    92    const uInt polAxis = 2;
    93    const uInt chanAxis = 3;
    94 
    9588// Temps
    9689
     
    109102// Write header
    110103
    111    of << "row beam IF pol source longitude latitude time nchan spectrum mask" << endl;
    112 
     104   of << "row beam IF pol source longitude latitude time nchan spectrum mask"
     105      << endl;
     106   
    113107// Loop over rows
    114108
     
    131125// Iterate through data in this row by spectra
    132126
    133       ReadOnlyVectorIterator<Float> itData(values, chanAxis);
    134       ReadOnlyVectorIterator<Bool> itMask(mask, chanAxis);
     127      ReadOnlyVectorIterator<Float> itData(values, asap::ChanAxis);
     128      ReadOnlyVectorIterator<Bool> itMask(mask, asap::ChanAxis);
    135129      while (!itData.pastEnd()) {
    136130         const IPosition& pos = itData.pos();
     
    144138 
    145139         dir.get(iRow, whichDir);
    146          posDir(0) = pos(beamAxis);
     140         posDir(0) = pos(asap::BeamAxis);
    147141         posDir(1) = 0;
    148142         lonLat[0] = whichDir(posDir);
    149143//
    150          posDir(0) = pos(beamAxis);
     144         posDir(0) = pos(asap::BeamAxis);
    151145         posDir(1) = 1;
    152146         lonLat[1] = whichDir(posDir);
    153147
    154 // Write.  This formats the vectors as [,,,,]  which we probably don't want.
    155 
    156          of << iRow << "  " << pos(beamAxis) << " " <<  pos(ifAxis) << " " << pos(polAxis) << " " <<
    157                src(iRow) <<  " " << formatDirection(lonLat) << " " << dTmp << " " <<
    158                itData.vector().nelements() << " " << itData.vector() << "  " << itMask.vector() << endl;
     148         // Write.  This formats the vectors as [,,,,] which we
     149         // probably don't want.
     150         uInt ba = uInt(asap::BeamAxis);
     151         uInt ia = uInt(asap::IFAxis);
     152         uInt pa = uInt(asap::PolAxis);
     153
     154         of << iRow << "  " << pos(ba) << " "
     155            << pos(ia) << " " << pos(pa) << " "
     156            << src(iRow) <<  " " << formatDirection(lonLat) << " "
     157            << dTmp << " "
     158            << itData.vector().nelements() << " " << itData.vector()
     159            << "  " << itMask.vector() << endl;
    159160
    160161// Next spectrum
     
    172173
    173174
    174 Int SDAsciiWriter::convertStokes (Int val)
     175Int SDAsciiWriter::convertStokes(Int val)
    175176{
    176177   Stokes::StokesTypes stokes = Stokes::RR;
     
    191192
    192193
    193 String SDAsciiWriter::formatDirection (const Vector<Double>& lonLat)
     194String SDAsciiWriter::formatDirection(const Vector<Double>& lonLat)
    194195{
    195196   MVAngle x1(lonLat(0));
  • trunk/src/SDAsciiWriter.h

    r198 r209  
    5353
    5454private:
    55    casa::Int convertStokes (casa::Int val);
    56    casa::String formatDirection (const casa::Vector<casa::Double>& lonLat);
     55   casa::Int convertStokes(casa::Int val);
     56   casa::String formatDirection(const casa::Vector<casa::Double>& lonLat);
    5757};
    5858
  • trunk/src/SDFITSImageWriter.cc

    r197 r209  
    5656#include <tables/Tables/ArrayColumn.h>
    5757
     58#include "Definitions.h"
    5859#include "SDContainer.h"
    5960#include "SDMemTable.h"
     
    100101// Axes (should be in header)
    101102
    102    const uInt beamAxis = 0;
    103    const uInt ifAxis = 1;
    104    const uInt stokesAxis = 2;
    105    const uInt chanAxis = 3;
     103   const uInt beamAxis = asap::BeamAxis;
     104   const uInt ifAxis = asap::IFAxis;
     105   const uInt stokesAxis = asap::PolAxis;
     106   const uInt chanAxis = asap::ChanAxis;
    106107   const Unit RAD(String("rad"));
    107108
     
    207208// Write out as FITS Image file
    208209
    209    
    210210         ostringstream oss;
    211          oss << "row" << iRow << "_beam" << pos(0) << "_if" << pos(1) << "_pol" << pos(2) << "_" << src(iRow) << ".fits";
     211         oss << "row" << iRow << "_beam" << pos(0) << "_if"
     212             << pos(1) << "_pol" << pos(2) << "_" << src(iRow) << ".fits";
    212213         String fileName;
    213214         if (rootName.length()>0) {
     
    216217            fileName = String(oss);
    217218         }
    218          if (verbose) cerr << "Writing row " << iRow << " into file " << fileName << endl;
    219 //
    220          Bool ok = ImageFITSConverter::ImageToFITS (errMsg, tIm, fileName, maxMem, preferVelocity,
    221                                                     opticalVelocity, bitPix, minPix, maxPix, overWrite,
    222                                                     degLast, reallyVerbose);
     219         if (verbose) cerr << "Writing row " << iRow
     220                           << " into file " << fileName << endl;
     221//
     222         Bool ok = ImageFITSConverter::ImageToFITS(errMsg, tIm, fileName,
     223                                                   maxMem, preferVelocity,
     224                                                   opticalVelocity, bitPix,
     225                                                   minPix, maxPix, overWrite,
     226                                                   degLast, reallyVerbose);
    223227         if (!ok) {
    224228            cerr << "Error writing fits - " << errMsg << endl;
     
    240244
    241245
    242 Int SDFITSImageWriter::convertStokes (Int val)
     246Int SDFITSImageWriter::convertStokes(Int val)
    243247{
    244248   Stokes::StokesTypes stokes = Stokes::RR;
  • trunk/src/SDFITSImageWriter.h

    r191 r209  
    5252
    5353private:
    54    casa::Int convertStokes (casa::Int val);
     54   casa::Int convertStokes(casa::Int val);
    5555};
    5656
  • trunk/src/SDMath.cc

    r185 r209  
    5959
    6060#include "MathUtils.h"
     61#include "Definitions.h"
    6162#include "SDContainer.h"
    6263#include "SDMemTable.h"
     
    109110// Setup
    110111
    111   const uInt axis = 3;                                     // Spectral axis
     112  const uInt axis = asap::ChanAxis;                      // Spectral axis
    112113  IPosition shp = in[0]->rowAsMaskedArray(0).shape();      // Must not change
    113114  Array<Float> arr(shp);
     
    479480// Loop over rows and bin along channel axis
    480481 
    481   const uInt axis = 3;
     482  const uInt axis = asap::ChanAxis;
    482483  for (uInt i=0; i < in.nRow(); ++i) {
    483484    SDContainer sc = in.getSDContainer(i);
     
    588589
    589590   const uInt nRows = in.nRow();
    590    const uInt polAxis = 2;                     // Polarization axis
    591    const uInt chanAxis = 3;                    // Spectrum axis
     591   const uInt polAxis = asap::PolAxis;                     // Polarization axis
     592   const uInt chanAxis = asap::ChanAxis;                    // Spectrum axis
    592593
    593594// Create output Table and reshape number of polarizations
     
    719720// Number of channels
    720721
    721    const uInt chanAxis = 3;                                     // Spectral axis
     722   const uInt chanAxis = asap::ChanAxis;  // Spectral axis
    722723   SDHeader sh = in.getSDHeader();
    723724   const uInt nChan = sh.nchan;
  • trunk/src/SDMathWrapper.cc

    r178 r209  
    5252//
    5353  SDMath sdm;
    54   SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(factor), Bool(doAll), what);
     54  SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(factor),
     55                                        Bool(doAll), what);
    5556  *pIn = *pOut;
    5657   delete pOut;
     
    6364  const uInt what = 0;
    6465  SDMath sdm;
    65   return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(factor), Bool(doAll), what));
     66  return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn,
     67                                                  Float(factor),
     68                                                  Bool(doAll), what));
    6669}
    6770
     
    7477//
    7578  SDMath sdm;
    76   SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(offset), Bool(doAll), what);
     79  SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(offset),
     80                                        Bool(doAll), what);
    7781  *pIn = *pOut;
    7882   delete pOut;
     
    8589  const uInt what = 1;
    8690  SDMath sdm;
    87   return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(offset), Bool(doAll), what));
     91  return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(offset),
     92                                                  Bool(doAll), what));
    8893}
    8994
    9095
    91 void SDMathWrapper::smoothInSitu(SDMemTableWrapper& in, const std::string& kernel, float width, bool doAll)
     96void SDMathWrapper::smoothInSitu(SDMemTableWrapper& in,
     97                                 const std::string& kernel, float width,
     98                                 bool doAll)
    9299{
    93100  SDMemTable* pIn = in.getPtr();
    94101  SDMath sdm;
    95   SDMemTable* pOut = sdm.smooth(*pIn, String(kernel), Float(width), Bool(doAll));
     102  SDMemTable* pOut = sdm.smooth(*pIn, String(kernel),
     103                                Float(width), Bool(doAll));
    96104  *pIn = *pOut;
    97105   delete pOut;
     
    99107
    100108
    101 SDMemTableWrapper SDMathWrapper::smooth (const SDMemTableWrapper& in, const std::string& kernel,
     109SDMemTableWrapper SDMathWrapper::smooth (const SDMemTableWrapper& in,
     110                                         const std::string& kernel,
    102111                                         float width, bool doAll)
    103112{
    104113  const CountedPtr<SDMemTable>& pIn = in.getCP();
    105114  SDMath sdm;
    106   return CountedPtr<SDMemTable>(sdm.smooth(*pIn, String(kernel), Float(width), Bool(doAll)));
     115  return CountedPtr<SDMemTable>(sdm.smooth(*pIn, String(kernel),
     116                                           Float(width), Bool(doAll)));
    107117}
    108118
     
    127137
    128138
    129 void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in, const std::vector<bool>& mask)
     139void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in,
     140                                     const std::vector<bool>& mask)
    130141{
    131142  SDMemTable* pIn = in.getPtr();
     
    136147}
    137148
    138 SDMemTableWrapper SDMathWrapper::averagePol (const SDMemTableWrapper& in, const std::vector<bool>& mask)
     149SDMemTableWrapper SDMathWrapper::averagePol (const SDMemTableWrapper& in,
     150                                             const std::vector<bool>& mask)
    139151
    140152{
  • trunk/src/SDMathWrapper.h

    r178 r209  
    5757
    5858// Smooth
    59   void smoothInSitu (SDMemTableWrapper& in, const std::string& kernel, float width, bool doAll);
    60   SDMemTableWrapper smooth (const SDMemTableWrapper& in, const std::string& kernel, float width, bool doAll);
     59  void smoothInSitu(SDMemTableWrapper& in, const std::string& kernel,
     60                     float width, bool doAll);
     61  SDMemTableWrapper smooth(const SDMemTableWrapper& in,
     62                           const std::string& kernel, float width, bool doAll);
    6163
    6264// Bin up
    63   void binInSitu (SDMemTableWrapper& in, int width);
     65  void binInSitu(SDMemTableWrapper& in, int width);
    6466  SDMemTableWrapper bin(const SDMemTableWrapper& in, int width);
    6567
    6668// Average in time
    67   SDMemTableWrapper average (boost::python::tuple tpl,
    68                              const std::vector<bool>& mask,
    69                              bool scanAv, const std::string& wt);
     69  SDMemTableWrapper average(boost::python::tuple tpl,
     70                            const std::vector<bool>& mask,
     71                            bool scanAv, const std::string& wt);
    7072
    7173// Average polarizations
    72   void averagePolInSitu (SDMemTableWrapper& in,  const std::vector<bool>& mask);
    73   SDMemTableWrapper averagePol (const SDMemTableWrapper& in, const std::vector<bool>& mask);
     74  void averagePolInSitu(SDMemTableWrapper& in,  const std::vector<bool>& mask);
     75  SDMemTableWrapper averagePol(const SDMemTableWrapper& in,
     76                               const std::vector<bool>& mask);
    7477
    7578// Statistics
Note: See TracChangeset for help on using the changeset viewer.