Changeset 1643 for trunk


Ignore:
Timestamp:
10/03/09 16:03:32 (15 years ago)
Author:
Max Voronkov
Message:

line finder: new noise estimation code has been resonably debugged and plugged in. Same functionality as before.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STLineFinder.cpp

    r1642 r1643  
    317317  // buffer size
    318318  const size_t nSamples = itsBufferFull ? itsVariances.size(): itsSampleNumber;
    319   AlwaysAssert( (nSamples > 0) && (nSamples < itsVariances.size()), AipsError);
     319  AlwaysAssert( (nSamples > 0) && (nSamples <= itsVariances.size()), AipsError);
    320320  return nSamples;
    321321}
     
    423423  // buffer size
    424424  const size_t nSamples = numberOfSamples();
    425   AlwaysAssert(nSamples < itsSortedIndices.size(), AipsError);
     425  AlwaysAssert(nSamples <= itsSortedIndices.size(), AipsError);
    426426  for (size_t i=0; i<nSamples; ++i) {
    427427       itsSortedIndices[i]=i;
     
    711711      // an assumption made: lines occupy a small part of the spectrum
    712712
    713       std::vector<float> variances(edge.second-edge.first);
    714       DebugAssert(variances.size(),AipsError);
    715 
    716       for (;running_box->haveMore();running_box->next())
    717            variances[running_box->getChannel()-edge.first]=
    718                                 running_box->getLinVariance();
    719 
    720       // in the future we probably should do a proper Chi^2 estimation
    721       // now a simple 80% of smaller values will be used.
    722       // it may degrade the performance of the algorithm for weak lines
    723       // due to a bias of the Chi^2 distribution.
    724       stable_sort(variances.begin(),variances.end());
    725 
    726       Float offline_variance=0;
    727       uInt offline_cnt=uInt(0.8*variances.size());
    728       if (!offline_cnt) offline_cnt=variances.size(); // no much else left,
    729                                     // although it is very inaccurate
    730       for (uInt n=0;n<offline_cnt;++n)
    731            offline_variance+=variances[n];
    732       offline_variance/=Float(offline_cnt);
     713      DebugAssert(edge.second-edge.first,AipsError);
     714      LFNoiseEstimator ne(edge.second-edge.first);
     715
     716      for (;running_box->haveMore();running_box->next()) {
     717           ne.add(running_box->getLinVariance());
     718      }
     719
     720      const Float offline_variance = ne.meanLowest80Percent();
    733721
    734722      // actual search algorithm
     
    909897                const casa::uInt &whichRow) throw(casa::AipsError)
    910898{
    911   //const int minboxnchan=4;
    912899  if (scan.null())
    913900      throw AipsError("STLineFinder::findLines - a scan should be set first,"
Note: See TracChangeset for help on using the changeset viewer.