Changeset 1333 for trunk


Ignore:
Timestamp:
04/18/07 16:18:40 (18 years ago)
Author:
mar637
Message:

Fix for Ticket #104; protect the user from flagging the whole scantable. This has performance penalties.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/RowAccumulator.cpp

    r1314 r1333  
    125125casa::Double asap::RowAccumulator::getTime( ) const
    126126{
    127   return timeSum_/max(n_);
     127  Float n = max(n_);
     128  if (n < 1.0) n = 1.0;
     129  return timeSum_/n;
    128130}
    129131
     
    135137casa::Vector< casa::Bool > RowAccumulator::getMask( ) const
    136138{
     139  // if no elements accumulated the mask is all True
     140  // we have to return everything False
     141  if (max(n_) < 1.0) return !spectrum_.getMask();
    137142  return spectrum_.getMask();
    138143}
  • trunk/src/STMath.cpp

    r1321 r1333  
    137137  ROScalarColumn<Double> mjdCol, intCol;
    138138  ROScalarColumn<Int> scanIDCol;
     139
     140  Vector<uInt> rowstodelete;
    139141
    140142  for (uInt i=0; i < tout.nrow(); ++i) {
     
    180182      }
    181183    }
     184    const Vector<Bool>& msk = acc.getMask();
     185    if ( allEQ(msk, False) ) {
     186      uint n = rowstodelete.nelements();
     187      rowstodelete.resize(n+1, True);
     188      rowstodelete[n] = i;
     189      continue;
     190    }
     191    cout << "write "<<  i << endl;
    182192    //write out
    183     specColOut.put(i, acc.getSpectrum());
    184     const Vector<Bool>& msk = acc.getMask();
    185193    Vector<uChar> flg(msk.shape());
    186194    convertArray(flg, !msk);
    187195    flagColOut.put(i, flg);
     196    specColOut.put(i, acc.getSpectrum());
    188197    tsysColOut.put(i, acc.getTsys());
    189198    intColOut.put(i, acc.getInterval());
     
    194203    cycColOut.put(i, uInt(0));
    195204    acc.reset();
     205  }
     206  if (rowstodelete.nelements() > 0) {
     207    cout << rowstodelete << endl;
     208    tout.removeRow(rowstodelete);
     209    if (tout.nrow() == 0) {
     210      throw(AipsError("Can't average fully flagged data."));
     211    }
    196212  }
    197213  return out;
  • trunk/src/Scantable.cpp

    r1325 r1333  
    618618void Scantable::flag(const std::vector<bool>& msk)
    619619{
    620   if ( selector_.empty()  && msk.size() == 0 )
     620  std::vector<bool>::const_iterator it;
     621  uInt ntrue = 0;
     622  for (it = msk.begin(); it != msk.end(); ++it) {
     623    if ( *it ) {
     624      ntrue++;
     625    }
     626  }
     627  if ( selector_.empty()  && (msk.size() == 0 || msk.size() == ntrue) )
    621628    throw(AipsError("Trying to flag whole scantable."));
    622629  if ( msk.size() == 0 ) {
Note: See TracChangeset for help on using the changeset viewer.