Changeset 171


Ignore:
Timestamp:
01/06/05 14:05:54 (20 years ago)
Author:
kil064
Message:

implement insitu version of Hanning smoothing

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMath.cc

    r170 r171  
    349349// Output Table cloned from input
    350350
    351   SDMemTable* sdmt = new SDMemTable(*on, True);
     351  SDMemTable* pTabOut = new SDMemTable(*on, True);
    352352
    353353// Loop over rows
     
    383383// Put new row in output Table
    384384
    385      sdmt->putSDContainer(sc);
    386   }
    387 //
    388   return CountedPtr<SDMemTable>(sdmt);
    389 }
    390 
    391 
    392 
    393 CountedPtr<SDMemTable>
    394 SDMath::hanning(const CountedPtr<SDMemTable>& in)
     385     pTabOut->putSDContainer(sc);
     386  }
     387//
     388  return CountedPtr<SDMemTable>(pTabOut);
     389}
     390
     391
     392
     393SDMemTable* SDMath::hanning(const SDMemTable& in)
    395394//
    396395// Hanning smooth each row
     
    398397//
    399398{
    400   SDMemTable* sdmt = new SDMemTable(*in,True);
     399  SDMemTable* pTabOut = new SDMemTable(in,True);
    401400
    402401// Loop over rows in Table
    403402
    404   for (uInt ri=0; ri < in->nRow(); ++ri) {
     403  for (uInt ri=0; ri < in.nRow(); ++ri) {
    405404
    406405// Get data
    407406   
    408     const MaskedArray<Float>& marr(in->rowAsMaskedArray(ri));
     407    const MaskedArray<Float>& marr(in.rowAsMaskedArray(ri));
    409408    Array<Float> arr = marr.getArray();
    410409    Array<Bool> barr = marr.getMask();
     
    428427// Create and put back
    429428
    430     SDContainer sc = in->getSDContainer(ri);
     429    SDContainer sc = in.getSDContainer(ri);
    431430    putDataInSDC (sc, arr, barr);
    432431//
    433     sdmt->putSDContainer(sc);
    434   }
    435   return CountedPtr<SDMemTable>(sdmt);
     432    pTabOut->putSDContainer(sc);
     433  }
     434//
     435  return pTabOut;
    436436}
    437437
  • trunk/src/SDMath.h

    r170 r171  
    5555
    5656// Quotient
    57 
    5857   casa::CountedPtr<SDMemTable> quotient(const casa::CountedPtr<SDMemTable>& on,
    5958                                         const casa::CountedPtr<SDMemTable>& off);
    6059
    61 //  Hanning
    62 
    63    casa::CountedPtr<SDMemTable> hanning(const casa::CountedPtr<SDMemTable>& in);
    64 
    6560// Average in time
    66 
    6761   casa::CountedPtr<SDMemTable>  average (const casa::Block<casa::CountedPtr<SDMemTable> >& in,
    6862                                          const casa::Vector<casa::Bool>& mask,
     
    7064
    7165// Statistics
    72 
    7366   std::vector<float> statistic(const casa::CountedPtr<SDMemTable>& in,
    7467                                const std::vector<bool>& mask, const std::string& which);
    7568
     69//  Hanning
     70   SDMemTable* hanning(const SDMemTable& in);
     71
     72
     73// Bin up spectra
     74   SDMemTable* bin (const SDMemTable& in, casa::Int width);
    7675
    7776// Simple mathematical operations.  what=0 (mul) or 1 (add)
    78 
    7977   SDMemTable* simpleOperate (const SDMemTable& in, casa::Float offset,
    8078                              casa::Bool doAll, casa::uInt what);
    8179
    8280// Average polarizations
    83 
    8481   SDMemTable* averagePol (const SDMemTable& in, const casa::Vector<casa::Bool>& mask);
    85 
    86 // Bin up spectra
    87 
    88    SDMemTable* bin (const SDMemTable& in, casa::Int width);
    89 
    9082
    9183 private:
  • trunk/src/SDMathWrapper.cc

    r170 r171  
    8888}
    8989
     90void SDMathWrapper::hanningInSitu(SDMemTableWrapper& in)
     91{
     92  SDMemTable* pIn = in.getPtr();
     93  SDMath sdm;
     94  SDMemTable* pOut = sdm.hanning (*pIn);
     95  *pIn = *pOut;
     96   delete pOut;
     97}
    9098
    91 SDMemTableWrapper SDMathWrapper::hanning(const SDMemTableWrapper& in)
     99SDMemTableWrapper SDMathWrapper::hanning (const SDMemTableWrapper& in)
    92100{
     101  const CountedPtr<SDMemTable>& pIn = in.getCP();
    93102  SDMath sdm;
    94   return SDMemTableWrapper(sdm.hanning(in.getCP()));
     103  return CountedPtr<SDMemTable>(sdm.hanning(*pIn));
    95104}
     105
    96106
    97107
  • trunk/src/SDMathWrapper.h

    r170 r171  
    4848
    4949// Multiply
    50 
    5150  void scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll);
    5251  SDMemTableWrapper scale(const SDMemTableWrapper& in,
     
    5453
    5554// Add
    56 
    5755  void addInSitu(SDMemTableWrapper& in, float offset, bool all);
    5856  SDMemTableWrapper add(const SDMemTableWrapper& in, float offset, bool all);
    5957
    6058// Hanning
    61 
     59  void hanningInSitu (SDMemTableWrapper& in);
    6260  SDMemTableWrapper hanning(const SDMemTableWrapper& in);
    6361
    6462// Bin up
    65 
    6663  void binInSitu (SDMemTableWrapper& in, int width);
    6764  SDMemTableWrapper bin(const SDMemTableWrapper& in, int width);
    6865
    6966// Average in time
    70 
    7167  SDMemTableWrapper average (boost::python::tuple tpl,
    7268                             const std::vector<bool>& mask,
     
    7470
    7571// Average polarizations
    76 
    7772  void averagePolInSitu (SDMemTableWrapper& in,  const std::vector<bool>& mask);
    7873  SDMemTableWrapper averagePol (const SDMemTableWrapper& in, const std::vector<bool>& mask);
    7974
    8075// Statistics
    81 
    8276  std::vector<float> statistic(const SDMemTableWrapper& in,
    8377                               const std::vector<bool>& mask,
Note: See TracChangeset for help on using the changeset viewer.