source: trunk/src/STLineFinder.cpp @ 1643

Last change on this file since 1643 was 1643, checked in by Max Voronkov, 15 years ago

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

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 49.5 KB
Line 
1//#---------------------------------------------------------------------------
2//# STLineFinder.cc: A class for automated spectral line search
3//#--------------------------------------------------------------------------
4//# Copyright (C) 2004
5//# ATNF
6//#
7//# This program is free software; you can redistribute it and/or modify it
8//# under the terms of the GNU General Public License as published by the Free
9//# Software Foundation; either version 2 of the License, or (at your option)
10//# any later version.
11//#
12//# This program is distributed in the hope that it will be useful, but
13//# WITHOUT ANY WARRANTY; without even the implied warranty of
14//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
15//# Public License for more details.
16//#
17//# You should have received a copy of the GNU General Public License along
18//# with this program; if not, write to the Free Software Foundation, Inc.,
19//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20//#
21//# Correspondence concerning this software should be addressed as follows:
22//#        Internet email: Malte.Marquarding@csiro.au
23//#        Postal address: Malte Marquarding,
24//#                        Australia Telescope National Facility,
25//#                        P.O. Box 76,
26//#                        Epping, NSW, 2121,
27//#                        AUSTRALIA
28//#
29//# $Id: STLineFinder.cpp 1643 2009-10-03 06:03:32Z MaximVoronkov $
30//#---------------------------------------------------------------------------
31
32
33// ASAP
34#include "STLineFinder.h"
35#include "STFitter.h"
36#include "IndexedCompare.h"
37
38// STL
39#include <functional>
40#include <algorithm>
41#include <iostream>
42#include <fstream>
43
44using namespace asap;
45using namespace casa;
46using namespace std;
47
48namespace asap {
49
50///////////////////////////////////////////////////////////////////////////////
51//
52// RunningBox -    a running box calculator. This class implements
53//                 iterations over the specified spectrum and calculates
54//                 running box filter statistics.
55//
56
57class RunningBox {
58   // The input data to work with. Use reference symantics to avoid
59   // an unnecessary copying
60   const casa::Vector<casa::Float>  &spectrum; // a buffer for the spectrum
61   const casa::Vector<casa::Bool>   &mask; // associated mask
62   const std::pair<int,int>         &edge; // start and stop+1 channels
63                                           // to work with
64
65   // statistics for running box filtering
66   casa::Float sumf;       // sum of fluxes
67   casa::Float sumf2;     // sum of squares of fluxes
68   casa::Float sumch;       // sum of channel numbers (for linear fit)
69   casa::Float sumch2;     // sum of squares of channel numbers (for linear fit)
70   casa::Float sumfch;     // sum of flux*(channel number) (for linear fit)
71
72   int box_chan_cntr;     // actual number of channels in the box
73   int max_box_nchan;     // maximum allowed number of channels in the box
74                          // (calculated from boxsize and actual spectrum size)
75   // cache for derivative statistics
76   mutable casa::Bool need2recalculate; // if true, values of the statistics
77                                       // below are invalid
78   mutable casa::Float linmean;  // a value of the linear fit to the
79                                 // points in the running box
80   mutable casa::Float linvariance; // the same for variance
81   int cur_channel;       // the number of the current channel
82   int start_advance;     // number of channel from which the box can
83                          // be moved (the middle of the box, if there is no
84                          // masking)
85public:
86   // set up the object with the references to actual data
87   // as well as the number of channels in the running box
88   RunningBox(const casa::Vector<casa::Float>  &in_spectrum,
89                 const casa::Vector<casa::Bool>   &in_mask,
90                 const std::pair<int,int>         &in_edge,
91                 int in_max_box_nchan) throw(AipsError);
92
93   // access to the statistics
94   const casa::Float& getLinMean() const throw(AipsError);
95   const casa::Float& getLinVariance() const throw(AipsError);
96   const casa::Float aboveMean() const throw(AipsError);
97   int getChannel() const throw();
98
99   // actual number of channels in the box (max_box_nchan, if no channels
100   // are masked)
101   int getNumberOfBoxPoints() const throw();
102
103   // next channel
104   void next() throw(AipsError);
105
106   // checking whether there are still elements
107   casa::Bool haveMore() const throw();
108
109   // go to start
110   void rewind() throw(AipsError);
111
112protected:
113   // supplementary function to control running mean calculations.
114   // It adds a specified channel to the running mean box and
115   // removes (ch-maxboxnchan+1)'th channel from there
116   // Channels, for which the mask is false or index is beyond the
117   // allowed range, are ignored
118   void advanceRunningBox(int ch) throw(casa::AipsError);
119
120   // calculate derivative statistics. This function is const, because
121   // it updates the cache only
122   void updateDerivativeStatistics() const throw(AipsError);
123};
124
125//
126///////////////////////////////////////////////////////////////////////////////
127
128///////////////////////////////////////////////////////////////////////////////
129//
130// LFAboveThreshold   An algorithm for line detection using running box
131//                    statistics.  Line is detected if it is above the
132//                    specified threshold at the specified number of
133//                    consequtive channels. Prefix LF stands for Line Finder
134//
135class LFAboveThreshold : protected LFLineListOperations {
136   // temporary line edge channels and flag, which is True if the line
137   // was detected in the previous channels.
138   std::pair<int,int> cur_line;
139   casa::Bool is_detected_before;
140   int  min_nchan;                         // A minimum number of consequtive
141                                           // channels, which should satisfy
142                                           // the detection criterion, to be
143                                           // a detection
144   casa::Float threshold;                  // detection threshold - the
145                                           // minimal signal to noise ratio
146   std::list<pair<int,int> > &lines;       // list where detections are saved
147                                           // (pair: start and stop+1 channel)
148   RunningBox *running_box;                // running box filter
149   casa::Vector<Int> signs;                // An array to store the signs of
150                                           // the value - current mean
151                                           // (used to search wings)
152   casa::Int last_sign;                    // a sign (+1, -1 or 0) of the
153                                           // last point of the detected line
154                                           //
155public:
156
157   // set up the detection criterion
158   LFAboveThreshold(std::list<pair<int,int> > &in_lines,
159                    int in_min_nchan = 3,
160                    casa::Float in_threshold = 5) throw();
161   virtual ~LFAboveThreshold() throw();
162
163   // replace the detection criterion
164   void setCriterion(int in_min_nchan, casa::Float in_threshold) throw();
165
166   // return the array with signs of the value-current mean
167   // An element is +1 if value>mean, -1 if less, 0 if equal.
168   // This array is updated each time the findLines method is called and
169   // is used to search the line wings
170   const casa::Vector<Int>& getSigns() const throw();
171
172   // find spectral lines and add them into list
173   // if statholder is not NULL, the accumulate function of it will be
174   // called for each channel to save statistics
175   //    spectrum, mask and edge - reference to the data
176   //    max_box_nchan  - number of channels in the running box
177   void findLines(const casa::Vector<casa::Float> &spectrum,
178                  const casa::Vector<casa::Bool> &mask,
179                  const std::pair<int,int> &edge,
180                  int max_box_nchan) throw(casa::AipsError);
181
182protected:
183
184   // process a channel: update curline and is_detected before and
185   // add a new line to the list, if necessary using processCurLine()
186   // detect=true indicates that the current channel satisfies the criterion
187   void processChannel(Bool detect, const casa::Vector<casa::Bool> &mask)
188                                                  throw(casa::AipsError);
189
190   // process the interval of channels stored in curline
191   // if it satisfies the criterion, add this interval as a new line
192   void processCurLine(const casa::Vector<casa::Bool> &mask)
193                                                 throw(casa::AipsError);
194
195   // get the sign of runningBox->aboveMean(). The RunningBox pointer
196   // should be defined
197   casa::Int getAboveMeanSign() const throw();
198};
199
200//
201///////////////////////////////////////////////////////////////////////////////
202
203///////////////////////////////////////////////////////////////////////////////
204//
205// LFNoiseEstimator  a helper class designed to estimate off-line variance
206//                   using statistics depending on the distribution of
207//                   values (e.g. like a median)
208//
209//                   Two statistics are supported: median and an average of
210//                   80% of smallest values.
211//
212
213struct LFNoiseEstimator {
214   // construct an object
215   // size - maximum sample size. After a size number of elements is processed
216   // any new samples would cause the algorithm to drop the oldest samples in the
217   // buffer.
218   explicit LFNoiseEstimator(size_t size);
219
220   // add a new sample
221   // in - the new value
222   void add(float in);
223
224   // median of the distribution
225   float median() const;
226
227   // mean of lowest 80% of the samples
228   float meanLowest80Percent() const;
229
230protected:
231   // update cache of sorted indices
232   // (it is assumed that itsSampleNumber points to the newly
233   // replaced element)
234   void updateSortedCache() const;
235
236   // build sorted cache from the scratch
237   void buildSortedCache() const;
238
239   // number of samples accumulated so far
240   // (can be less than the buffer size)
241   size_t numberOfSamples() const;
242
243   // this helper method builds the cache if
244   // necessary using one of the methods
245   void fillCacheIfNecessary() const;
246
247private:
248   // buffer with samples (unsorted)
249   std::vector<float> itsVariances;
250   // current sample number (<=itsVariances.size())
251   size_t itsSampleNumber;
252   // true, if the buffer all values in the sample buffer are used
253   bool itsBufferFull;
254   // cached indices into vector of samples
255   mutable std::vector<size_t> itsSortedIndices;
256   // true if any of the statistics have been obtained at least
257   // once. This flag allows to implement a more efficient way of
258   // calculating statistics, if they are needed at once and not
259   // after each addition of a new element
260   mutable bool itsStatisticsAccessed;
261};
262
263//
264///////////////////////////////////////////////////////////////////////////////
265
266
267} // namespace asap
268
269///////////////////////////////////////////////////////////////////////////////
270//
271// LFNoiseEstimator  a helper class designed to estimate off-line variance
272//                   using statistics depending on the distribution of
273//                   values (e.g. like a median)
274//
275//                   Two statistics are supported: median and an average of
276//                   80% of smallest values.
277//
278
279// construct an object
280// size - maximum sample size. After a size number of elements is processed
281// any new samples would cause the algorithm to drop the oldest samples in the
282// buffer.
283LFNoiseEstimator::LFNoiseEstimator(size_t size) : itsVariances(size),
284     itsSampleNumber(0), itsBufferFull(false), itsSortedIndices(size),
285     itsStatisticsAccessed(false)
286{
287   AlwaysAssert(size>0,AipsError);
288}
289
290
291// add a new sample
292// in - the new value
293void LFNoiseEstimator::add(float in)
294{
295   itsVariances[itsSampleNumber] = in;
296
297   if (itsStatisticsAccessed) {
298       // only do element by element addition if on-the-fly
299       // statistics are needed
300       updateSortedCache();
301   }
302
303   // advance itsSampleNumber now
304   ++itsSampleNumber;
305   if (itsSampleNumber == itsVariances.size()) {
306       itsSampleNumber = 0;
307       itsBufferFull = true;
308   }
309   AlwaysAssert(itsSampleNumber<itsVariances.size(),AipsError);
310}
311
312// number of samples accumulated so far
313// (can be less than the buffer size)
314size_t LFNoiseEstimator::numberOfSamples() const
315{
316  // the number of samples accumulated so far may be less than the
317  // buffer size
318  const size_t nSamples = itsBufferFull ? itsVariances.size(): itsSampleNumber;
319  AlwaysAssert( (nSamples > 0) && (nSamples <= itsVariances.size()), AipsError);
320  return nSamples;
321}
322
323// this helper method builds the cache if
324// necessary using one of the methods
325void LFNoiseEstimator::fillCacheIfNecessary() const
326{
327  if (!itsStatisticsAccessed) {
328      if ((itsSampleNumber!=0) || itsBufferFull) {
329          // build the whole cache efficiently
330          buildSortedCache();
331      } else {
332          updateSortedCache();
333      }
334      itsStatisticsAccessed = true;
335  } // otherwise, it is updated in 'add' using on-the-fly method
336}
337
338// median of the distribution
339float LFNoiseEstimator::median() const
340{
341  fillCacheIfNecessary();
342  // the number of samples accumulated so far may be less than the
343  // buffer size
344  const size_t nSamples = numberOfSamples();
345  const size_t medSample = nSamples / 2;
346  AlwaysAssert(medSample < itsSortedIndices.size(), AipsError);
347  return itsVariances[itsSortedIndices[medSample]];
348}
349
350// mean of lowest 80% of the samples
351float LFNoiseEstimator::meanLowest80Percent() const
352{
353  fillCacheIfNecessary();
354  // the number of samples accumulated so far may be less than the
355  // buffer size
356  const size_t nSamples = numberOfSamples();
357  float result = 0;
358  size_t numpt=size_t(0.8*nSamples);
359  if (!numpt) {
360      numpt=nSamples; // no much else left,
361                     // although it is very inaccurate
362  }
363  AlwaysAssert( (numpt > 0) && (numpt<itsSortedIndices.size()), AipsError);
364  for (size_t ch=0; ch<numpt; ++ch) {
365       result += itsVariances[itsSortedIndices[ch]];
366  }
367  result /= float(numpt);
368  return result;
369}
370
371// update cache of sorted indices
372// (it is assumed that itsSampleNumber points to the newly
373// replaced element)
374void LFNoiseEstimator::updateSortedCache() const
375{
376  // the number of samples accumulated so far may be less than the
377  // buffer size
378  const size_t nSamples = numberOfSamples();
379
380  if (itsBufferFull) {
381      // first find the index of the element which is being replaced
382      size_t index = nSamples;
383      for (size_t i=0; i<nSamples; ++i) {
384           AlwaysAssert(i < itsSortedIndices.size(), AipsError);
385           if (itsSortedIndices[i] == itsSampleNumber) {
386               index = i;
387               break;
388           }
389      }
390      AlwaysAssert( index < nSamples, AipsError);
391
392      const vector<size_t>::iterator indStart = itsSortedIndices.begin();
393      // merge this element with preceeding block first
394      if (index != 0) {
395          // merge indices on the basis of variances
396          inplace_merge(indStart,indStart+index,indStart+index+1,
397                        indexedCompare<size_t>(itsVariances.begin()));
398      }
399      // merge with the following block
400      if (index + 1 != nSamples) {
401          // merge indices on the basis of variances
402          inplace_merge(indStart,indStart+index+1,indStart+nSamples,
403                        indexedCompare<size_t>(itsVariances.begin()));
404      }
405  } else {
406      // itsSampleNumber is the index of the new element
407      AlwaysAssert(itsSampleNumber < itsSortedIndices.size(), AipsError);
408      itsSortedIndices[itsSampleNumber] = itsSampleNumber;
409      if (itsSampleNumber >= 1) {
410          // we have to place this new sample in
411          const vector<size_t>::iterator indStart = itsSortedIndices.begin();
412          // merge indices on the basis of variances
413          inplace_merge(indStart,indStart+itsSampleNumber,indStart+itsSampleNumber+1,
414                        indexedCompare<size_t>(itsVariances.begin()));
415      }
416  }
417}
418
419// build sorted cache from the scratch
420void LFNoiseEstimator::buildSortedCache() const
421{
422  // the number of samples accumulated so far may be less than the
423  // buffer size
424  const size_t nSamples = numberOfSamples();
425  AlwaysAssert(nSamples <= itsSortedIndices.size(), AipsError);
426  for (size_t i=0; i<nSamples; ++i) {
427       itsSortedIndices[i]=i;
428  }
429
430  // sort indices, but check the array of variances
431  const vector<size_t>::iterator indStart = itsSortedIndices.begin();
432  stable_sort(indStart,indStart+nSamples, indexedCompare<size_t>(itsVariances.begin()));
433}
434
435//
436///////////////////////////////////////////////////////////////////////////////
437
438///////////////////////////////////////////////////////////////////////////////
439//
440// RunningBox -    a running box calculator. This class implements
441//                 interations over the specified spectrum and calculates
442//                 running box filter statistics.
443//
444
445// set up the object with the references to actual data
446// and the number of channels in the running box
447RunningBox::RunningBox(const casa::Vector<casa::Float>  &in_spectrum,
448                       const casa::Vector<casa::Bool>   &in_mask,
449                       const std::pair<int,int>         &in_edge,
450                       int in_max_box_nchan) throw(AipsError) :
451        spectrum(in_spectrum), mask(in_mask), edge(in_edge),
452        max_box_nchan(in_max_box_nchan)
453{
454  rewind();
455}
456
457void RunningBox::rewind() throw(AipsError) {
458  // fill statistics for initial box
459  box_chan_cntr=0; // no channels are currently in the box
460  sumf=0.;           // initialize statistics
461  sumf2=0.;
462  sumch=0.;
463  sumch2=0.;
464  sumfch=0.;
465  int initial_box_ch=edge.first;
466  for (;initial_box_ch<edge.second && box_chan_cntr<max_box_nchan;
467        ++initial_box_ch)
468       advanceRunningBox(initial_box_ch);
469
470  if (initial_box_ch==edge.second)
471      throw AipsError("RunningBox::rewind - too much channels are masked");
472
473  cur_channel=edge.first;
474  start_advance=initial_box_ch-max_box_nchan/2;
475}
476
477// access to the statistics
478const casa::Float& RunningBox::getLinMean() const throw(AipsError)
479{
480  DebugAssert(cur_channel<edge.second, AipsError);
481  if (need2recalculate) updateDerivativeStatistics();
482  return linmean;
483}
484
485const casa::Float& RunningBox::getLinVariance() const throw(AipsError)
486{
487  DebugAssert(cur_channel<edge.second, AipsError);
488  if (need2recalculate) updateDerivativeStatistics();
489  return linvariance;
490}
491
492const casa::Float RunningBox::aboveMean() const throw(AipsError)
493{
494  DebugAssert(cur_channel<edge.second, AipsError);
495  if (need2recalculate) updateDerivativeStatistics();
496  return spectrum[cur_channel]-linmean;
497}
498
499int RunningBox::getChannel() const throw()
500{
501  return cur_channel;
502}
503
504// actual number of channels in the box (max_box_nchan, if no channels
505// are masked)
506int RunningBox::getNumberOfBoxPoints() const throw()
507{
508  return box_chan_cntr;
509}
510
511// supplementary function to control running mean calculations.
512// It adds a specified channel to the running mean box and
513// removes (ch-max_box_nchan+1)'th channel from there
514// Channels, for which the mask is false or index is beyond the
515// allowed range, are ignored
516void RunningBox::advanceRunningBox(int ch) throw(AipsError)
517{
518  if (ch>=edge.first && ch<edge.second)
519      if (mask[ch]) { // ch is a valid channel
520          ++box_chan_cntr;
521          sumf+=spectrum[ch];
522          sumf2+=square(spectrum[ch]);
523          sumch+=Float(ch);
524          sumch2+=square(Float(ch));
525          sumfch+=spectrum[ch]*Float(ch);
526          need2recalculate=True;
527      }
528  int ch2remove=ch-max_box_nchan;
529  if (ch2remove>=edge.first && ch2remove<edge.second)
530      if (mask[ch2remove]) { // ch2remove is a valid channel
531          --box_chan_cntr;
532          sumf-=spectrum[ch2remove];
533          sumf2-=square(spectrum[ch2remove]);
534          sumch-=Float(ch2remove);
535          sumch2-=square(Float(ch2remove));
536          sumfch-=spectrum[ch2remove]*Float(ch2remove);
537          need2recalculate=True;
538      }
539}
540
541// next channel
542void RunningBox::next() throw(AipsError)
543{
544   AlwaysAssert(cur_channel<edge.second,AipsError);
545   ++cur_channel;
546   if (cur_channel+max_box_nchan/2<edge.second && cur_channel>=start_advance)
547       advanceRunningBox(cur_channel+max_box_nchan/2); // update statistics
548}
549
550// checking whether there are still elements
551casa::Bool RunningBox::haveMore() const throw()
552{
553   return cur_channel<edge.second;
554}
555
556// calculate derivative statistics. This function is const, because
557// it updates the cache only
558void RunningBox::updateDerivativeStatistics() const throw(AipsError)
559{
560  AlwaysAssert(box_chan_cntr, AipsError);
561
562  Float mean=sumf/Float(box_chan_cntr);
563
564  // linear LSF formulae
565  Float meanch=sumch/Float(box_chan_cntr);
566  Float meanch2=sumch2/Float(box_chan_cntr);
567  if (meanch==meanch2 || box_chan_cntr<3) {
568      // vertical line in the spectrum, can't calculate linmean and linvariance
569      linmean=0.;
570      linvariance=0.;
571  } else {
572      Float coeff=(sumfch/Float(box_chan_cntr)-meanch*mean)/
573                (meanch2-square(meanch));
574      linmean=coeff*(Float(cur_channel)-meanch)+mean;
575      linvariance=sqrt(sumf2/Float(box_chan_cntr)-square(mean)-
576                    square(coeff)*(meanch2-square(meanch)));
577  }
578  need2recalculate=False;
579}
580
581
582//
583///////////////////////////////////////////////////////////////////////////////
584
585///////////////////////////////////////////////////////////////////////////////
586//
587// LFAboveThreshold - a running mean algorithm for line detection
588//
589//
590
591
592// set up the detection criterion
593LFAboveThreshold::LFAboveThreshold(std::list<pair<int,int> > &in_lines,
594                                   int in_min_nchan,
595                                   casa::Float in_threshold) throw() :
596             min_nchan(in_min_nchan), threshold(in_threshold),
597             lines(in_lines), running_box(NULL) {}
598
599LFAboveThreshold::~LFAboveThreshold() throw()
600{
601  if (running_box!=NULL) delete running_box;
602}
603
604// replace the detection criterion
605void LFAboveThreshold::setCriterion(int in_min_nchan, casa::Float in_threshold)
606                                 throw()
607{
608  min_nchan=in_min_nchan;
609  threshold=in_threshold;
610}
611
612// get the sign of runningBox->aboveMean(). The RunningBox pointer
613// should be defined
614casa::Int LFAboveThreshold::getAboveMeanSign() const throw()
615{
616  const Float buf=running_box->aboveMean();
617  if (buf>0) return 1;
618  if (buf<0) return -1;
619  return 0;
620}
621
622
623// process a channel: update cur_line and is_detected before and
624// add a new line to the list, if necessary
625void LFAboveThreshold::processChannel(Bool detect,
626                 const casa::Vector<casa::Bool> &mask) throw(casa::AipsError)
627{
628  try {
629       if (is_detected_before) {
630          // we have to check that the current detection has the
631          // same sign of running_box->aboveMean
632          // otherwise it could be a spurious detection
633          if (last_sign && last_sign!=getAboveMeanSign())
634              detect=False;
635       }
636       if (detect) {
637           last_sign=getAboveMeanSign();
638           if (is_detected_before)
639               cur_line.second=running_box->getChannel()+1;
640           else {
641               is_detected_before=True;
642               cur_line.first=running_box->getChannel();
643               cur_line.second=running_box->getChannel()+1;
644           }
645       } else processCurLine(mask);
646  }
647  catch (const AipsError &ae) {
648      throw;
649  }
650  catch (const exception &ex) {
651      throw AipsError(String("LFAboveThreshold::processChannel - STL error: ")+ex.what());
652  }
653}
654
655// process the interval of channels stored in cur_line
656// if it satisfies the criterion, add this interval as a new line
657void LFAboveThreshold::processCurLine(const casa::Vector<casa::Bool> &mask)
658                                   throw(casa::AipsError)
659{
660  try {
661       if (is_detected_before) {
662           if (cur_line.second-cur_line.first>=min_nchan) {
663               // it was a detection. We need to change the list
664               Bool add_new_line=False;
665               if (lines.size()) {
666                   for (int i=lines.back().second;i<cur_line.first;++i)
667                        if (mask[i]) { // one valid channel in between
668                                //  means that we deal with a separate line
669                            add_new_line=True;
670                            break;
671                        }
672               } else add_new_line=True;
673               if (add_new_line)
674                   lines.push_back(cur_line);
675               else lines.back().second=cur_line.second;
676           }
677           is_detected_before=False;
678       }
679  }
680  catch (const AipsError &ae) {
681      throw;
682  }
683  catch (const exception &ex) {
684      throw AipsError(String("LFAboveThreshold::processCurLine - STL error: ")+ex.what());
685  }
686}
687
688// return the array with signs of the value-current mean
689// An element is +1 if value>mean, -1 if less, 0 if equal.
690// This array is updated each time the findLines method is called and
691// is used to search the line wings
692const casa::Vector<Int>& LFAboveThreshold::getSigns() const throw()
693{
694  return signs;
695}
696
697// find spectral lines and add them into list
698void LFAboveThreshold::findLines(const casa::Vector<casa::Float> &spectrum,
699                              const casa::Vector<casa::Bool> &mask,
700                              const std::pair<int,int> &edge,
701                              int max_box_nchan)
702                        throw(casa::AipsError)
703{
704  const int minboxnchan=4;
705  try {
706
707      if (running_box!=NULL) delete running_box;
708      running_box=new RunningBox(spectrum,mask,edge,max_box_nchan);
709
710      // determine the off-line variance first
711      // an assumption made: lines occupy a small part of the spectrum
712
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();
721
722      // actual search algorithm
723      is_detected_before=False;
724
725      // initiate the signs array
726      signs.resize(spectrum.nelements());
727      signs=Vector<Int>(spectrum.nelements(),0);
728
729      //ofstream os("dbg.dat");
730      for (running_box->rewind();running_box->haveMore();
731                                 running_box->next()) {
732           const int ch=running_box->getChannel();
733           if (running_box->getNumberOfBoxPoints()>=minboxnchan)
734               processChannel(mask[ch] && (fabs(running_box->aboveMean()) >=
735                  threshold*offline_variance), mask);
736           else processCurLine(mask); // just finish what was accumulated before
737
738           signs[ch]=getAboveMeanSign();
739            //os<<ch<<" "<<spectrum[ch]<<" "<<fabs(running_box->aboveMean())<<" "<<
740            //threshold*offline_variance<<endl;
741      }
742      if (lines.size())
743          searchForWings(lines,signs,mask,edge);
744  }
745  catch (const AipsError &ae) {
746      throw;
747  }
748  catch (const exception &ex) {
749      throw AipsError(String("LFAboveThreshold::findLines - STL error: ")+ex.what());
750  }
751}
752
753//
754///////////////////////////////////////////////////////////////////////////////
755
756///////////////////////////////////////////////////////////////////////////////
757//
758// LFLineListOperations::IntersectsWith  -  An auxiliary object function
759//                to test whether two lines have a non-void intersection
760//
761
762
763// line1 - range of the first line: start channel and stop+1
764LFLineListOperations::IntersectsWith::IntersectsWith(const std::pair<int,int> &in_line1) :
765                          line1(in_line1) {}
766
767
768// return true if line2 intersects with line1 with at least one
769// common channel, and false otherwise
770// line2 - range of the second line: start channel and stop+1
771bool LFLineListOperations::IntersectsWith::operator()(const std::pair<int,int> &line2)
772                          const throw()
773{
774  if (line2.second<line1.first) return false; // line2 is at lower channels
775  if (line2.first>line1.second) return false; // line2 is at upper channels
776  return true; // line2 has an intersection or is adjacent to line1
777}
778
779//
780///////////////////////////////////////////////////////////////////////////////
781
782///////////////////////////////////////////////////////////////////////////////
783//
784// LFLineListOperations::BuildUnion - An auxiliary object function to build a union
785// of several lines to account for a possibility of merging the nearby lines
786//
787
788// set an initial line (can be a first line in the sequence)
789LFLineListOperations::BuildUnion::BuildUnion(const std::pair<int,int> &line1) :
790                             temp_line(line1) {}
791
792// update temp_line with a union of temp_line and new_line
793// provided there is no gap between the lines
794void LFLineListOperations::BuildUnion::operator()(const std::pair<int,int> &new_line)
795                                   throw()
796{
797  if (new_line.first<temp_line.first) temp_line.first=new_line.first;
798  if (new_line.second>temp_line.second) temp_line.second=new_line.second;
799}
800
801// return the result (temp_line)
802const std::pair<int,int>& LFLineListOperations::BuildUnion::result() const throw()
803{
804  return temp_line;
805}
806
807//
808///////////////////////////////////////////////////////////////////////////////
809
810///////////////////////////////////////////////////////////////////////////////
811//
812// LFLineListOperations::LaterThan - An auxiliary object function to test whether a
813// specified line is at lower spectral channels (to preserve the order in
814// the line list)
815//
816
817// setup the line to compare with
818LFLineListOperations::LaterThan::LaterThan(const std::pair<int,int> &in_line1) :
819                         line1(in_line1) {}
820
821// return true if line2 should be placed later than line1
822// in the ordered list (so, it is at greater channel numbers)
823bool LFLineListOperations::LaterThan::operator()(const std::pair<int,int> &line2)
824                          const throw()
825{
826  if (line2.second<line1.first) return false; // line2 is at lower channels
827  if (line2.first>line1.second) return true; // line2 is at upper channels
828
829  // line2 intersects with line1. We should have no such situation in
830  // practice
831  return line2.first>line1.first;
832}
833
834//
835///////////////////////////////////////////////////////////////////////////////
836
837
838///////////////////////////////////////////////////////////////////////////////
839//
840// STLineFinder  -  a class for automated spectral line search
841//
842//
843
844STLineFinder::STLineFinder() throw() : edge(0,0)
845{
846  setOptions();
847}
848
849// set the parameters controlling algorithm
850// in_threshold a single channel threshold default is sqrt(3), which
851//              means together with 3 minimum channels at least 3 sigma
852//              detection criterion
853//              For bad baseline shape, in_threshold may need to be
854//              increased
855// in_min_nchan minimum number of channels above the threshold to report
856//              a detection, default is 3
857// in_avg_limit perform the averaging of no more than in_avg_limit
858//              adjacent channels to search for broad lines
859//              Default is 8, but for a bad baseline shape this
860//              parameter should be decreased (may be even down to a
861//              minimum of 1 to disable this option) to avoid
862//              confusing of baseline undulations with a real line.
863//              Setting a very large value doesn't usually provide
864//              valid detections.
865// in_box_size  the box size for running mean calculation. Default is
866//              1./5. of the whole spectrum size
867void STLineFinder::setOptions(const casa::Float &in_threshold,
868                              const casa::Int &in_min_nchan,
869                              const casa::Int &in_avg_limit,
870                              const casa::Float &in_box_size) throw()
871{
872  threshold=in_threshold;
873  min_nchan=in_min_nchan;
874  avg_limit=in_avg_limit;
875  box_size=in_box_size;
876}
877
878STLineFinder::~STLineFinder() throw(AipsError) {}
879
880// set scan to work with (in_scan parameter)
881void STLineFinder::setScan(const ScantableWrapper &in_scan) throw(AipsError)
882{
883  scan=in_scan.getCP();
884  AlwaysAssert(!scan.null(),AipsError);
885
886}
887
888// search for spectral lines. Number of lines found is returned
889// in_edge and in_mask control channel rejection for a given row
890//   if in_edge has zero length, all channels chosen by mask will be used
891//   if in_edge has one element only, it represents the number of
892//      channels to drop from both sides of the spectrum
893//   in_edge is introduced for convinience, although all functionality
894//   can be achieved using a spectrum mask only
895int STLineFinder::findLines(const std::vector<bool> &in_mask,
896                const std::vector<int> &in_edge,
897                const casa::uInt &whichRow) throw(casa::AipsError)
898{
899  if (scan.null())
900      throw AipsError("STLineFinder::findLines - a scan should be set first,"
901                      " use set_scan");
902
903  uInt nchan = scan->nchan(scan->getIF(whichRow));
904  // set up mask and edge rejection
905  // no mask given...
906  if (in_mask.size() == 0) {
907    mask = Vector<Bool>(nchan,True);
908  } else {
909    // use provided mask
910    mask=Vector<Bool>(in_mask);
911  }
912  if (mask.nelements()!=nchan)
913      throw AipsError("STLineFinder::findLines - in_scan and in_mask have different"
914            "number of spectral channels.");
915
916  // taking flagged channels into account
917  vector<bool> flaggedChannels = scan->getMask(whichRow);
918  if (flaggedChannels.size()) {
919      // there is a mask set for this row
920      if (flaggedChannels.size() != mask.nelements()) {
921          throw AipsError("STLineFinder::findLines - internal inconsistency: number of mask elements do not match the number of channels");
922      }
923      for (size_t ch = 0; ch<mask.nelements(); ++ch) {
924           mask[ch] &= flaggedChannels[ch];
925      }
926  }
927
928  // number of elements in in_edge
929  if (in_edge.size()>2)
930      throw AipsError("STLineFinder::findLines - the length of the in_edge parameter"
931                      "should not exceed 2");
932      if (!in_edge.size()) {
933           // all spectra, no rejection
934           edge.first=0;
935           edge.second=nchan;
936      } else {
937           edge.first=in_edge[0];
938           if (edge.first<0)
939               throw AipsError("STLineFinder::findLines - the in_edge parameter has a negative"
940                                "number of channels to drop");
941           if (edge.first>=int(nchan))
942               throw AipsError("STLineFinder::findLines - all channels are rejected by the in_edge parameter");
943           if (in_edge.size()==2) {
944               edge.second=in_edge[1];
945               if (edge.second<0)
946                   throw AipsError("STLineFinder::findLines - the in_edge parameter has a negative"
947                                   "number of channels to drop");
948               edge.second=nchan-edge.second;
949           } else edge.second=nchan-edge.first;
950           if (edge.second<0 || (edge.first>=edge.second))
951               throw AipsError("STLineFinder::findLines - all channels are rejected by the in_edge parameter");
952       }
953
954  //
955  int max_box_nchan=int(nchan*box_size); // number of channels in running
956                                                 // box
957  if (max_box_nchan<2)
958      throw AipsError("STLineFinder::findLines - box_size is too small");
959
960  spectrum.resize();
961  spectrum = Vector<Float>(scan->getSpectrum(whichRow));
962
963  lines.resize(0); // search from the scratch
964  last_row_used=whichRow;
965  Vector<Bool> temp_mask(mask);
966
967  Bool first_pass=True;
968  Int avg_factor=1; // this number of adjacent channels is averaged together
969                    // the total number of the channels is not altered
970                    // instead, min_nchan is also scaled
971                    // it helps to search for broad lines
972  Vector<Int> signs; // a buffer for signs of the value - mean quantity
973                     // see LFAboveThreshold for details
974                     // We need only signs resulted from last iteration
975                     // because all previous values may be corrupted by the
976                     // presence of spectral lines
977  while (true) {
978     // a buffer for new lines found at this iteration
979     std::list<pair<int,int> > new_lines;
980
981     try {
982         // line find algorithm
983         LFAboveThreshold lfalg(new_lines,avg_factor*min_nchan, threshold);
984         lfalg.findLines(spectrum,temp_mask,edge,max_box_nchan);
985         signs.resize(lfalg.getSigns().nelements());
986         signs=lfalg.getSigns();
987         first_pass=False;
988         if (!new_lines.size())
989              throw AipsError("spurious"); // nothing new - use the same
990                                           // code as for a real exception
991     }
992     catch(const AipsError &ae) {
993         if (first_pass) throw;
994         // nothing new - proceed to the next step of averaging, if any
995         // (to search for broad lines)
996         if (avg_factor>=avg_limit) break; // averaging up to avg_limit
997                                          // adjacent channels,
998                                          // stop after that
999         avg_factor*=2; // twice as more averaging
1000         subtractBaseline(temp_mask,9);
1001         averageAdjacentChannels(temp_mask,avg_factor);
1002         continue;
1003     }
1004     keepStrongestOnly(temp_mask,new_lines,max_box_nchan);
1005     // update the list (lines) merging intervals, if necessary
1006     addNewSearchResult(new_lines,lines);
1007     // get a new mask
1008     temp_mask=getMask();
1009  }
1010
1011  // an additional search for wings because in the presence of very strong
1012  // lines temporary mean used at each iteration will be higher than
1013  // the true mean
1014
1015  if (lines.size())
1016      LFLineListOperations::searchForWings(lines,signs,mask,edge);
1017
1018  return int(lines.size());
1019}
1020
1021// auxiliary function to fit and subtract a polynomial from the current
1022// spectrum. It uses the Fitter class. This action is required before
1023// reducing the spectral resolution if the baseline shape is bad
1024void STLineFinder::subtractBaseline(const casa::Vector<casa::Bool> &temp_mask,
1025                      const casa::Int &order) throw(casa::AipsError)
1026{
1027  AlwaysAssert(spectrum.nelements(),AipsError);
1028  // use the fact that temp_mask excludes channels rejected at the edge
1029  Fitter sdf;
1030  std::vector<float> absc(spectrum.nelements());
1031  for (unsigned int i=0;i<absc.size();++i)
1032       absc[i]=float(i)/float(spectrum.nelements());
1033  std::vector<float> spec;
1034  spectrum.tovector(spec);
1035  std::vector<bool> std_mask;
1036  temp_mask.tovector(std_mask);
1037  sdf.setData(absc,spec,std_mask);
1038  sdf.setExpression("poly",order);
1039  if (!sdf.fit()) return; // fit failed, use old spectrum
1040  spectrum=casa::Vector<casa::Float>(sdf.getResidual());
1041}
1042
1043// auxiliary function to average adjacent channels and update the mask
1044// if at least one channel involved in summation is masked, all
1045// output channels will be masked. This function works with the
1046// spectrum and edge fields of this class, but updates the mask
1047// array specified, rather than the field of this class
1048// boxsize - a number of adjacent channels to average
1049void STLineFinder::averageAdjacentChannels(casa::Vector<casa::Bool> &mask2update,
1050                                   const casa::Int &boxsize)
1051                            throw(casa::AipsError)
1052{
1053  DebugAssert(mask2update.nelements()==spectrum.nelements(), AipsError);
1054  DebugAssert(boxsize!=0,AipsError);
1055
1056  for (int n=edge.first;n<edge.second;n+=boxsize) {
1057       DebugAssert(n<spectrum.nelements(),AipsError);
1058       int nboxch=0; // number of channels currently in the box
1059       Float mean=0; // buffer for mean calculations
1060       for (int k=n;k<n+boxsize && k<edge.second;++k)
1061            if (mask2update[k]) {  // k is a valid channel
1062                mean+=spectrum[k];
1063                ++nboxch;
1064            }
1065       if (nboxch<boxsize) // mask these channels
1066           for (int k=n;k<n+boxsize && k<edge.second;++k)
1067                mask2update[k]=False;
1068       else {
1069          mean/=Float(boxsize);
1070           for (int k=n;k<n+boxsize && k<edge.second;++k)
1071                spectrum[k]=mean;
1072       }
1073  }
1074}
1075
1076
1077// get the mask to mask out all lines that have been found (default)
1078// if invert=true, only channels belong to lines will be unmasked
1079// Note: all channels originally masked by the input mask (in_mask
1080//       in setScan) or dropped out by the edge parameter (in_edge
1081//       in setScan) are still excluded regardless on the invert option
1082std::vector<bool> STLineFinder::getMask(bool invert)
1083                                        const throw(casa::AipsError)
1084{
1085  try {
1086       if (scan.null())
1087           throw AipsError("STLineFinder::getMask - a scan should be set first,"
1088                      " use set_scan followed by find_lines");
1089       DebugAssert(mask.nelements()==scan->getChannels(last_row_used), AipsError);
1090       /*
1091       if (!lines.size())
1092           throw AipsError("STLineFinder::getMask - one have to search for "
1093                           "lines first, use find_lines");
1094       */
1095       std::vector<bool> res_mask(mask.nelements());
1096       // iterator through lines
1097       std::list<std::pair<int,int> >::const_iterator cli=lines.begin();
1098       for (int ch=0;ch<int(res_mask.size());++ch) {
1099            if (ch<edge.first || ch>=edge.second) res_mask[ch]=false;
1100            else if (!mask[ch]) res_mask[ch]=false;
1101            else {
1102                    res_mask[ch]=!invert; // no line by default
1103                    if (cli!=lines.end())
1104                        if (ch>=cli->first && ch<cli->second)
1105                             res_mask[ch]=invert; // this is a line
1106            }
1107            if (cli!=lines.end())
1108                if (ch>=cli->second) {
1109                    ++cli; // next line in the list
1110                }
1111       }
1112       return res_mask;
1113  }
1114  catch (const AipsError &ae) {
1115      throw;
1116  }
1117  catch (const exception &ex) {
1118      throw AipsError(String("STLineFinder::getMask - STL error: ")+ex.what());
1119  }
1120}
1121
1122// get range for all lines found. The same units as used in the scan
1123// will be returned (e.g. velocity instead of channels).
1124std::vector<double> STLineFinder::getLineRanges()
1125                             const throw(casa::AipsError)
1126{
1127  // convert to required abscissa units
1128  std::vector<double> vel=scan->getAbcissa(last_row_used);
1129  std::vector<int> ranges=getLineRangesInChannels();
1130  std::vector<double> res(ranges.size());
1131
1132  std::vector<int>::const_iterator cri=ranges.begin();
1133  std::vector<double>::iterator outi=res.begin();
1134  for (;cri!=ranges.end() && outi!=res.end();++cri,++outi)
1135       if (uInt(*cri)>=vel.size())
1136          throw AipsError("STLineFinder::getLineRanges - getAbcissa provided less channels than reqired");
1137       else *outi=vel[*cri];
1138  return res;
1139}
1140
1141// The same as getLineRanges, but channels are always used to specify
1142// the range
1143std::vector<int> STLineFinder::getLineRangesInChannels()
1144                                   const throw(casa::AipsError)
1145{
1146  try {
1147       if (scan.null())
1148           throw AipsError("STLineFinder::getLineRangesInChannels - a scan should be set first,"
1149                      " use set_scan followed by find_lines");
1150       DebugAssert(mask.nelements()==scan->getChannels(last_row_used), AipsError);
1151
1152       if (!lines.size())
1153           throw AipsError("STLineFinder::getLineRangesInChannels - one have to search for "
1154                           "lines first, use find_lines");
1155
1156       std::vector<int> res(2*lines.size());
1157       // iterator through lines & result
1158       std::list<std::pair<int,int> >::const_iterator cli=lines.begin();
1159       std::vector<int>::iterator ri=res.begin();
1160       for (;cli!=lines.end() && ri!=res.end();++cli,++ri) {
1161            *ri=cli->first;
1162            if (++ri!=res.end())
1163                *ri=cli->second-1;
1164       }
1165       return res;
1166  }
1167  catch (const AipsError &ae) {
1168      throw;
1169  }
1170  catch (const exception &ex) {
1171      throw AipsError(String("STLineFinder::getLineRanges - STL error: ")+ex.what());
1172  }
1173}
1174
1175
1176
1177// an auxiliary function to remove all lines from the list, except the
1178// strongest one (by absolute value). If the lines removed are real,
1179// they will be find again at the next iteration. This approach
1180// increases the number of iterations required, but is able to remove
1181// spurious detections likely to occur near strong lines.
1182// Later a better criterion may be implemented, e.g.
1183// taking into consideration the brightness of different lines. Now
1184// use the simplest solution
1185// temp_mask - mask to work with (may be different from original mask as
1186// the lines previously found may be masked)
1187// lines2update - a list of lines to work with
1188//                 nothing will be done if it is empty
1189// max_box_nchan - channels in the running box for baseline filtering
1190void STLineFinder::keepStrongestOnly(const casa::Vector<casa::Bool> &temp_mask,
1191                  std::list<std::pair<int, int> > &lines2update,
1192                  int max_box_nchan)
1193                                   throw (casa::AipsError)
1194{
1195  try {
1196      if (!lines2update.size()) return; // ignore an empty list
1197
1198      // current line
1199      std::list<std::pair<int,int> >::iterator li=lines2update.begin();
1200      // strongest line
1201      std::list<std::pair<int,int> >::iterator strongli=lines2update.begin();
1202      // the flux (absolute value) of the strongest line
1203      Float peak_flux=-1; // negative value - a flag showing uninitialized
1204                          // value
1205      // the algorithm below relies on the list being ordered
1206      Float tmp_flux=-1; // a temporary peak
1207      for (RunningBox running_box(spectrum,temp_mask,edge,max_box_nchan);
1208           running_box.haveMore(); running_box.next()) {
1209
1210           if (li==lines2update.end()) break; // no more lines
1211           const int ch=running_box.getChannel();
1212           if (ch>=li->first && ch<li->second)
1213               if (temp_mask[ch] && tmp_flux<fabs(running_box.aboveMean()))
1214                   tmp_flux=fabs(running_box.aboveMean());
1215           if (ch==li->second-1) {
1216               if (peak_flux<tmp_flux) { // if peak_flux=-1, this condition
1217                   peak_flux=tmp_flux;   // will be satisfied
1218                   strongli=li;
1219               }
1220               ++li;
1221               tmp_flux=-1;
1222           }
1223      }
1224      std::list<std::pair<int,int> > res;
1225      res.splice(res.end(),lines2update,strongli);
1226      lines2update.clear();
1227      lines2update.splice(lines2update.end(),res);
1228  }
1229  catch (const AipsError &ae) {
1230      throw;
1231  }
1232  catch (const exception &ex) {
1233      throw AipsError(String("STLineFinder::keepStrongestOnly - STL error: ")+ex.what());
1234  }
1235
1236}
1237
1238//
1239///////////////////////////////////////////////////////////////////////////////
1240
1241
1242///////////////////////////////////////////////////////////////////////////////
1243//
1244// LFLineListOperations - a class incapsulating  operations with line lists
1245//                        The LF prefix stands for Line Finder
1246//
1247
1248// concatenate two lists preserving the order. If two lines appear to
1249// be adjacent, they are joined into the new one
1250void LFLineListOperations::addNewSearchResult(const std::list<pair<int, int> > &newlines,
1251                         std::list<std::pair<int, int> > &lines_list)
1252                        throw(AipsError)
1253{
1254  try {
1255      for (std::list<pair<int,int> >::const_iterator cli=newlines.begin();
1256           cli!=newlines.end();++cli) {
1257
1258           // the first item, which has a non-void intersection or touches
1259           // the new line
1260           std::list<pair<int,int> >::iterator pos_beg=find_if(lines_list.begin(),
1261                          lines_list.end(), IntersectsWith(*cli));
1262           // the last such item
1263           std::list<pair<int,int> >::iterator pos_end=find_if(pos_beg,
1264                          lines_list.end(), not1(IntersectsWith(*cli)));
1265
1266           // extract all lines which intersect or touch a new one into
1267           // a temporary buffer. This may invalidate the iterators
1268           // line_buffer may be empty, if no lines intersects with a new
1269           // one.
1270           std::list<pair<int,int> > lines_buffer;
1271           lines_buffer.splice(lines_buffer.end(),lines_list, pos_beg, pos_end);
1272
1273           // build a union of all intersecting lines
1274           pair<int,int> union_line=for_each(lines_buffer.begin(),
1275                   lines_buffer.end(),BuildUnion(*cli)).result();
1276
1277           // search for a right place for the new line (union_line) and add
1278           std::list<pair<int,int> >::iterator pos2insert=find_if(lines_list.begin(),
1279                          lines_list.end(), LaterThan(union_line));
1280           lines_list.insert(pos2insert,union_line);
1281      }
1282  }
1283  catch (const AipsError &ae) {
1284      throw;
1285  }
1286  catch (const exception &ex) {
1287      throw AipsError(String("LFLineListOperations::addNewSearchResult - STL error: ")+ex.what());
1288  }
1289}
1290
1291// extend all line ranges to the point where a value stored in the
1292// specified vector changes (e.g. value-mean change its sign)
1293// This operation is necessary to include line wings, which are below
1294// the detection threshold. If lines becomes adjacent, they are
1295// merged together. Any masked channel stops the extension
1296void LFLineListOperations::searchForWings(std::list<std::pair<int, int> > &newlines,
1297           const casa::Vector<casa::Int> &signs,
1298           const casa::Vector<casa::Bool> &mask,
1299           const std::pair<int,int> &edge) throw(casa::AipsError)
1300{
1301  try {
1302      for (std::list<pair<int,int> >::iterator li=newlines.begin();
1303           li!=newlines.end();++li) {
1304           // update the left hand side
1305           for (int n=li->first-1;n>=edge.first;--n) {
1306                if (!mask[n]) break;
1307                if (signs[n]==signs[li->first] && signs[li->first])
1308                    li->first=n;
1309                else break;
1310           }
1311           // update the right hand side
1312           for (int n=li->second;n<edge.second;++n) {
1313                if (!mask[n]) break;
1314                if (signs[n]==signs[li->second-1] && signs[li->second-1])
1315                    li->second=n;
1316                else break;
1317           }
1318      }
1319      // need to search for possible mergers.
1320      std::list<std::pair<int, int> >  result_buffer;
1321      addNewSearchResult(newlines,result_buffer);
1322      newlines.clear();
1323      newlines.splice(newlines.end(),result_buffer);
1324  }
1325  catch (const AipsError &ae) {
1326      throw;
1327  }
1328  catch (const exception &ex) {
1329      throw AipsError(String("LFLineListOperations::extendLines - STL error: ")+ex.what());
1330  }
1331}
1332
1333//
1334///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.