Changeset 1069 for trunk


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

enhancement ticket #35. median scantable

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/__init__.py

    r1059 r1069  
    306306    del gui
    307307
     308
    308309__date__ = '$Date$'.split()[1]
    309 __version__  = '2.0.1'
     310__version__  = '2.1a'
    310311
    311312if rcParams['verbose']:
     
    367368            average_time    - return the (weighted) time average of a scan
    368369                              or a list of scans
     370            average_channel - return the (median) average of a scantable
    369371            average_pol     - average the polarisations together.
    370372                              The dimension won't be reduced and
     
    373375            convert_pol     - convert to a different polarisation type
    374376            auto_quotient   - return the on/off quotient with
    375                               automatic detection of the on/off scans
    376                               (matched pairs and 1 off - n on)
     377                              automatic detection of the on/off scans (closest
     378                              in time off is selected)
    377379            scale, *, /     - return a scan scaled by a given factor
    378380            add, +, -       - return a scan with given value added
     
    419421            simple_math     - simple mathematical operations on two scantables,
    420422                              'add', 'sub', 'mul', 'div'
     423            quotient        - build quotient of the given on and off scans
     424                              (matched pairs and 1 off/n on are valid)
     425
    421426     [Fitting]
    422427        fitter
  • 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.