Changeset 1069 for trunk/src


Ignore:
Timestamp:
07/04/06 14:44:44 (18 years ago)
Author:
mar637
Message:

enhancement ticket #35. median scantable

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STMath.cpp

    r1066 r1069  
    189189}
    190190
     191CountedPtr< Scantable >
     192  STMath::averageChannel( const CountedPtr < Scantable > & in,
     193                          const std::string & mode )
     194{
     195  // clone as this is non insitu
     196  bool insitu = insitu_;
     197  setInsitu(false);
     198  CountedPtr< Scantable > out = getScantable(in, true);
     199  setInsitu(insitu);
     200  Table& tout = out->table();
     201  ArrayColumn<Float> specColOut(tout,"SPECTRA");
     202  ArrayColumn<uChar> flagColOut(tout,"FLAGTRA");
     203  ArrayColumn<Float> tsysColOut(tout,"TSYS");
     204
     205  Block<String> cols(3);
     206  cols[0] = String("BEAMNO");
     207  cols[1] = String("IFNO");
     208  cols[2] = String("POLNO");
     209  uInt outrowCount = 0;
     210  uChar userflag = 1 << 7;
     211  TableIterator iter(in->table(), cols);
     212  while (!iter.pastEnd()) {
     213    Table subt = iter.table();
     214    ROArrayColumn<Float> specCol, tsysCol;
     215    ROArrayColumn<uChar> flagCol;
     216    specCol.attach(subt,"SPECTRA");
     217    flagCol.attach(subt,"FLAGTRA");
     218    tsysCol.attach(subt,"TSYS");
     219    tout.addRow();
     220    TableCopy::copyRows(tout, subt, outrowCount, 0, 1);
     221    Vector<Float> tmp;
     222    specCol.get(0, tmp);
     223    uInt nchan = tmp.nelements();
     224    Vector<uChar> flags = flagCol.getColumn(Slicer(Slice(0)));
     225    Vector<Float> outspec(nchan);
     226    Vector<uChar> outflag(nchan,0);
     227    Vector<Float> outtsys(1);/// @fixme when tsys is channel based
     228    for (uInt i=0; i<nchan; ++i) {
     229      Vector<Float> specs = specCol.getColumn(Slicer(Slice(i)));
     230      MaskedArray<Float> ma = maskedArray(specs,flags);
     231      outspec[i] = median(ma);
     232      if ( allEQ(ma.getMask(), False) )
     233        outflag[i] = userflag;// flag data
     234    }
     235    outtsys[0] = median(tsysCol.getColumn());
     236    specColOut.put(outrowCount, outspec);
     237    flagColOut.put(outrowCount, outflag);
     238    tsysColOut.put(outrowCount, outtsys);
     239
     240    ++outrowCount;
     241    ++iter;
     242  }
     243  return out;
     244}
    191245
    192246CountedPtr< Scantable > STMath::getScantable(const CountedPtr< Scantable >& in,
     
    331385{
    332386  bool insitu = insitu_;
     387  if ( ! on->conformant(*off) ) {
     388    throw(AipsError("'on' and 'off' scantables are not conformant."));
     389  }
    333390  setInsitu(false);
    334391  CountedPtr< Scantable > out = getScantable(on, false);
  • trunk/src/STMath.h

    r1066 r1069  
    5858             const std::string& weight = "NONE",
    5959             const std::string& avmode = "SCAN");
     60
     61  casa::CountedPtr<Scantable>
     62    averageChannel( const casa::CountedPtr<Scantable> & in,
     63                     const std::string& mode = "MEDIAN");
    6064
    6165  casa::CountedPtr< Scantable >
  • trunk/src/STMathWrapper.h

    r1066 r1069  
    4646    return ScantableWrapper(STMath::average(sts, mask, weight, avmode));
    4747  }
     48
     49  ScantableWrapper
     50    averageChannel( const ScantableWrapper& in,
     51                    const std::string& mode = "MEDIAN")
     52  {
     53    return ScantableWrapper(STMath::averageChannel(in.getCP(), mode));
     54  }
     55
    4856  ScantableWrapper
    4957    averagePolarisations( const ScantableWrapper& in,
  • trunk/src/python_STMath.cpp

    r1066 r1069  
    4545        .def("_setinsitu", &STMathWrapper::setInsitu)
    4646        .def("_average", &STMathWrapper::average)
     47        .def("_averagechannel", &STMathWrapper::averageChannel)
    4748        .def("_averagepol", &STMathWrapper::averagePolarisations)
    4849        .def("_unaryop", &STMathWrapper::unaryOperate)
Note: See TracChangeset for help on using the changeset viewer.