Changeset 1514 for branches


Ignore:
Timestamp:
02/23/09 20:55:35 (16 years ago)
Author:
Kana Sugimoto
Message:

New Development: No

JIRA Issue: Yes (CAS-1079)

Ready to Release: Yes

Interface Changes: Yes

What Interface Changed:
Added the new functions to get min/max position (channel) of spectra.

  1. std::vector<int> asap::python::stmath::_minmaxpos(ScantableWrapper& in,

std::vector<bool>& mask, std::string& which)

@python_STMath.cpp

  1. std::vector<int> STMathWrapper::minMaxPos(ScantableWrapper& in,

std::vector<bool>& mask, std::string& which)

@STMathWrapper.h

  1. std::vector<int> STMath::minMaxPos(CountedPtr< Scantable > & in,

std::vector< bool > & mask, std::string& which)

@STMath.h & .cpp

  1. IPosition mathutil::minMaxPos(String& which, MaskedArray<Float>& data) @MathUtils.h & .cpp

Test Programs:

Run scantable.stats() with the parameter stat='minpos' or 'maxpos',
and you'll get min/max value with its psition.

Put in Release Notes: No

Module(s): scantable.stats()

Description:

These modifications are to return min/max value with its
position (channel/frequency/velocity) by running scantable.stats().

Diagram:
scantable.stats() ->asap::python::stmath::_minmaxpos
-> STMathWrapper::minMaxPos -> STMath::minMaxPos() -> mathutil::minMaxPos()
-> casa::minMax (@casacore/casa/casa/Arrays/MaskArrMath.tcc)


Location:
branches/alma/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/alma/src/MathUtils.cpp

    r1446 r1514  
    7676}
    7777
     78IPosition mathutil::minMaxPos(const String& which,
     79                           const MaskedArray<Float>& data)
     80{
     81   Float minVal, maxVal;
     82   IPosition minPos(data.ndim(), 0), maxPos(data.ndim(), 0);
     83   minMax(minVal, maxVal, minPos, maxPos, data);
     84   String str(which);
     85   str.upcase();
     86   if (str.matches(String("MINPOS"))) {
     87     return minPos;
     88   } else if (str.matches(String("MAXPOS"))) {
     89     return maxPos;
     90   } else {
     91      String msg = str + " is not a valid type of statistics";
     92      throw(AipsError(msg));
     93   }
     94   //return 0.0;
     95}
    7896
    7997void mathutil::replaceMaskByZero(Vector<Float>& data, const Vector<Bool>& mask)
  • branches/alma/src/MathUtils.h

    r1446 r1514  
    3737#include <casa/Arrays/Vector.h>
    3838#include <casa/BasicSL/String.h>
     39#include <casa/Arrays/IPosition.h>
    3940
    4041namespace mathutil {
     
    7778                 const casa::MaskedArray<casa::Float>& data);
    7879
     80// Return a position of min or max value
     81 casa::IPosition minMaxPos(const casa::String& which,
     82                 const casa::MaskedArray<casa::Float>& data);
     83
    7984// Replace masked value by zero
    8085void replaceMaskByZero(casa::Vector<casa::Float>& data,
  • branches/alma/src/STMath.cpp

    r1459 r1514  
    10931093    }
    10941094    out.push_back(outstat);
     1095  }
     1096  return out;
     1097}
     1098
     1099std::vector< int > STMath::minMaxPos( const CountedPtr< Scantable > & in,
     1100                                        const std::vector< bool > & mask,
     1101                                        const std::string& which )
     1102{
     1103
     1104  Vector<Bool> m(mask);
     1105  const Table& tab = in->table();
     1106  ROArrayColumn<Float> specCol(tab, "SPECTRA");
     1107  ROArrayColumn<uChar> flagCol(tab, "FLAGTRA");
     1108  std::vector<int> out;
     1109  for (uInt i=0; i < tab.nrow(); ++i ) {
     1110    Vector<Float> spec; specCol.get(i, spec);
     1111    Vector<uChar> flag; flagCol.get(i, flag);
     1112    MaskedArray<Float> ma  = maskedArray(spec, flag);
     1113    if (ma.ndim() != 1) {
     1114      throw (ArrayError(
     1115          "std::vector<int> STMath::minMaxPos("
     1116          "ContedPtr<Scantable> &in, std::vector<bool> &mask, "
     1117          " std::string &which)"
     1118          " - MaskedArray is not 1D"));
     1119    }
     1120    IPosition outpos(1,0);
     1121    if ( spec.nelements() == m.nelements() ) {
     1122      outpos = mathutil::minMaxPos(which, ma(m));
     1123    } else {
     1124      outpos = mathutil::minMaxPos(which, ma);
     1125    }
     1126    out.push_back(outpos[0]);
    10951127  }
    10961128  return out;
  • branches/alma/src/STMath.h

    r1446 r1514  
    207207                               const std::string& which);
    208208
     209  std::vector< int > minMaxPos(const casa::CountedPtr<Scantable>& in,
     210                               const std::vector<bool>& mask,
     211                               const std::string& which);
     212
    209213  casa::CountedPtr<Scantable> bin( const casa::CountedPtr<Scantable>& in,
    210214                                   int width=5);
  • branches/alma/src/STMathWrapper.h

    r1446 r1514  
    121121  { return STMath::statistic(in.getCP(), mask, which); }
    122122
     123  std::vector<int> minMaxPos(const ScantableWrapper& in,
     124                               const std::vector<bool>& mask,
     125                               const std::string& which)
     126  { return STMath::minMaxPos(in.getCP(), mask, which); }
     127
    123128  ScantableWrapper bin( const ScantableWrapper& in, int width=5)
    124129  { return ScantableWrapper(STMath::bin(in.getCP(), width)); }
  • branches/alma/src/python_STMath.cpp

    r1446 r1514  
    5757        .def("_dofs", &STMathWrapper::dofs)
    5858        .def("_stats", &STMathWrapper::statistic)
     59        .def("_minmaxpos", &STMathWrapper::minMaxPos)
    5960        .def("_freqswitch", &STMathWrapper::freqSwitch)
    6061        .def("_bin", &STMathWrapper::bin)
Note: See TracChangeset for help on using the changeset viewer.