Changeset 175


Ignore:
Timestamp:
01/06/05 16:40:42 (20 years ago)
Author:
kil064
Message:

Add cursor selection to function 'hanning' (arg. 'all')

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMath.cc

    r171 r175  
    391391
    392392
    393 SDMemTable* SDMath::hanning(const SDMemTable& in)
     393SDMemTable* SDMath::hanning(const SDMemTable& in, Bool doAll)
    394394//
    395395// Hanning smooth each row
     
    397397//
    398398{
     399
     400// New Table
     401
    399402  SDMemTable* pTabOut = new SDMemTable(in,True);
    400403
     404// Get cursor location
     405         
     406  IPosition start, end;
     407  getCursorLocation (start, end, in);
     408//
     409  const uInt chanAxis = 3;                    // Spectrum axis
     410  IPosition shapeOut(4,1);
     411
    401412// Loop over rows in Table
    402413
    403414  for (uInt ri=0; ri < in.nRow(); ++ri) {
    404415
    405 // Get data
     416// Get copy of data
    406417   
    407     const MaskedArray<Float>& marr(in.rowAsMaskedArray(ri));
    408     Array<Float> arr = marr.getArray();
    409     Array<Bool> barr = marr.getMask();
     418    const MaskedArray<Float>& dataIn(in.rowAsMaskedArray(ri));
     419    Array<Float> valuesIn = dataIn.getArray();
     420    Array<Bool> maskIn = dataIn.getMask();
    410421
    411422// Smooth along the channels axis
    412423
    413     uInt axis = 3;
    414     VectorIterator<Float> itData(arr, axis);
    415     VectorIterator<Bool> itMask(barr, axis);
    416     Vector<Float> outv;
    417     Vector<Bool> outm;
    418     while (!itData.pastEnd()) {
    419        mathutil::hanning(outv, outm, itData.vector(), itMask.vector());
    420        itData.vector() = outv;                                                 
    421        itMask.vector() = outm;
    422 //
    423        itData.next();
    424        itMask.next();
     424    Vector<Float> outValues;
     425    Vector<Bool> outMask;
     426    if (doAll) {
     427       uInt axis = 3;
     428       VectorIterator<Float> itValues(valuesIn, axis);
     429       VectorIterator<Bool> itMask(maskIn, axis);
     430       while (!itValues.pastEnd()) {
     431          mathutil::hanning(outValues, outMask, itValues.vector(), itMask.vector());
     432          itValues.vector() = outValues;
     433          itMask.vector() = outMask;
     434//
     435          itValues.next();
     436          itMask.next();
     437       }
     438    } else {
     439
     440// Set multi-dim Vector shape
     441
     442       shapeOut(chanAxis) = valuesIn.shape()(chanAxis);
     443
     444// Stuff about with shapes so that we don't have conformance run-time errors
     445
     446       Vector<Float> valuesIn2 = valuesIn(start,end).nonDegenerate();
     447       Vector<Bool> maskIn2 = maskIn(start,end).nonDegenerate();
     448       mathutil::hanning(outValues, outMask, valuesIn2, maskIn2);
     449
     450// Write back
     451
     452       valuesIn(start,end) = outValues.reform(shapeOut);
     453       maskIn(start,end) = outMask.reform(shapeOut);
    425454    }
    426455
     
    428457
    429458    SDContainer sc = in.getSDContainer(ri);
    430     putDataInSDC (sc, arr, barr);
     459    putDataInSDC (sc, valuesIn, maskIn);
    431460//
    432461    pTabOut->putSDContainer(sc);
  • trunk/src/SDMath.h

    r171 r175  
    5959
    6060// Average in time
    61    casa::CountedPtr<SDMemTable>  average (const casa::Block<casa::CountedPtr<SDMemTable> >& in,
    62                                           const casa::Vector<casa::Bool>& mask,
    63                                           bool scanAverage, const std::string& weightStr);
     61   casa::CountedPtr<SDMemTable>  average(const casa::Block<casa::CountedPtr<SDMemTable> >& in,
     62                                         const casa::Vector<casa::Bool>& mask,
     63                                         bool scanAverage, const std::string& weightStr);
    6464
    6565// Statistics
     
    6767                                const std::vector<bool>& mask, const std::string& which);
    6868
    69 //  Hanning
    70    SDMemTable* hanning(const SDMemTable& in);
    71 
     69// Hanning
     70   SDMemTable* hanning(const SDMemTable& in, casa::Bool doAll);
    7271
    7372// Bin up spectra
    74    SDMemTable* bin (const SDMemTable& in, casa::Int width);
     73   SDMemTable* bin(const SDMemTable& in, casa::Int width);
    7574
    7675// Simple mathematical operations.  what=0 (mul) or 1 (add)
    77    SDMemTable* simpleOperate (const SDMemTable& in, casa::Float offset,
    78                               casa::Bool doAll, casa::uInt what);
     76   SDMemTable* simpleOperate(const SDMemTable& in, casa::Float offset,
     77                             casa::Bool doAll, casa::uInt what);
    7978
    8079// Average polarizations
    81    SDMemTable* averagePol (const SDMemTable& in, const casa::Vector<casa::Bool>& mask);
     80   SDMemTable* averagePol(const SDMemTable& in, const casa::Vector<casa::Bool>& mask);
    8281
    8382 private:
  • trunk/src/SDMathWrapper.cc

    r171 r175  
    8888}
    8989
    90 void SDMathWrapper::hanningInSitu(SDMemTableWrapper& in)
     90void SDMathWrapper::hanningInSitu(SDMemTableWrapper& in, bool doAll)
    9191{
    9292  SDMemTable* pIn = in.getPtr();
    9393  SDMath sdm;
    94   SDMemTable* pOut = sdm.hanning (*pIn);
     94  SDMemTable* pOut = sdm.hanning (*pIn, Bool(doAll));
    9595  *pIn = *pOut;
    9696   delete pOut;
    9797}
    9898
    99 SDMemTableWrapper SDMathWrapper::hanning (const SDMemTableWrapper& in)
     99SDMemTableWrapper SDMathWrapper::hanning (const SDMemTableWrapper& in, bool doAll)
    100100{
    101101  const CountedPtr<SDMemTable>& pIn = in.getCP();
    102102  SDMath sdm;
    103   return CountedPtr<SDMemTable>(sdm.hanning(*pIn));
     103  return CountedPtr<SDMemTable>(sdm.hanning(*pIn, Bool(doAll)));
    104104}
    105105
  • trunk/src/SDMathWrapper.h

    r171 r175  
    5353
    5454// Add
    55   void addInSitu(SDMemTableWrapper& in, float offset, bool all);
     55  void addInSitu(SDMemTableWrapper& in, float offset, bool doAall);
    5656  SDMemTableWrapper add(const SDMemTableWrapper& in, float offset, bool all);
    5757
    5858// Hanning
    59   void hanningInSitu (SDMemTableWrapper& in);
    60   SDMemTableWrapper hanning(const SDMemTableWrapper& in);
     59  void hanningInSitu (SDMemTableWrapper& in, bool doAll);
     60  SDMemTableWrapper hanning(const SDMemTableWrapper& in, bool doAll);
    6161
    6262// Bin up
Note: See TracChangeset for help on using the changeset viewer.