Ignore:
Timestamp:
02/23/09 20:55:35 (15 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)


File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.