Changeset 2986 for trunk


Ignore:
Timestamp:
08/15/14 19:24:40 (10 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-6582

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

STMath::average is changed so that empty averaged result (data to be
averaged are all flagged) is kept with all channel flags of 128 and
row flag of 1.


Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/RowAccumulator.cpp

    r2970 r2986  
    2020using namespace casa;
    2121using namespace asap;
     22
     23namespace {
     24inline uInt nNominal(MaskedArray<uInt> nvalid, MaskedArray<uInt> ninvalid)
     25{
     26  return max((allEQ(nvalid, uInt(0))) ? ninvalid : nvalid);
     27}
     28} // anonymous namespace
    2229
    2330RowAccumulator::RowAccumulator(WeightType wt) : weightType_(wt), initialized_(False)
     
    200207  Float totalWeight = 1.0;
    201208  Vector<Bool> m = data.getMask();
     209  Float tsysWeight = addTsys(tsys, inverseMask);
     210  Float intervalWeight = addInterval(interval, inverseMask);
     211  addTime(time, inverseMask);
    202212  if (!allEQ(m, False)) {  // only add these if not everything masked
    203     totalWeight *= addTsys(tsys, inverseMask);
    204     totalWeight *= addInterval(interval, inverseMask);
    205     addTime(time, inverseMask);
     213    totalWeight *= tsysWeight;
     214    totalWeight *= intervalWeight;
    206215
    207216    if (weightType_ == W_VAR) {
     
    263272Double RowAccumulator::getTime() const
    264273{
    265   return timeSum_/Double(max(n_));
     274  return timeSum_/Double(nNominal(n_, nNoMask_));
    266275}
    267276
     
    280289{
    281290  // @fixme this assumes tsys.nelements() == 1
    282   return tsysSum_/Float(max(n_));
     291  return tsysSum_/Float(nNominal(n_, nNoMask_));
    283292}
    284293
     
    311320  spectrum_.setData(v, Vector<Bool>(v.nelements(), True));
    312321  weightSum_.setData(w, Vector<Bool>(w.nelements(), True));
    313 }
     322
     323  tsysSum_ = tsysSumNoMask_;
     324  intervalSum_ = intervalSumNoMask_;
     325}
  • trunk/src/STMath.cpp

    r2978 r2986  
    372372    }
    373373    const Vector<Bool>& msk = acc.getMask();
     374    uInt outFlagRow = 0;
    374375    if ( allEQ(msk, False) ) {
    375376      rowstodelB[nrowdel] = i ;
    376377      nrowdel++ ;
    377       outrowCount++;
    378       acc.reset();
    379       iter.next();
    380       continue;
     378      outFlagRow = 1;
    381379    }
    382380    //write out
     
    406404      // which requires resetting this value
    407405      cycColOut.put(i, uInt(0));
    408       // completely flagged rows are removed anyway
    409       flagRowColOut.put(i, uInt(0));
     406      flagRowColOut.put(i, outFlagRow);
    410407    } else {
    411408      os << "For output row="<<i<<", all input rows of data are flagged. no averaging" << LogIO::POST;
     
    420417
    421418  if ( nrowdel > 0 ) {
    422     Vector<uInt> rowstodelete( IPosition(1,nrowdel), rowstodelB.storage(), SHARE ) ;
    423     //os << rowstodelete << LogIO::POST ;
    424     tout.removeRow(rowstodelete);
     419    if (nrowdel == tout.nrow()) {
     420      os << LogIO::WARN << "Output data are fully flagged." << LogIO::POST;
     421    }
    425422    if (tout.nrow() == 0) {
    426423      throw(AipsError("Can't average fully flagged data."));
Note: See TracChangeset for help on using the changeset viewer.