Changeset 3106 for trunk/src/STLineFinder.cpp
- Timestamp:
- 10/04/16 18:20:50 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STLineFinder.cpp
r3086 r3106 42 42 43 43 using namespace asap; 44 using namespace casa ;44 using namespace casacore; 45 45 using namespace std; 46 46 … … 57 57 // The input data to work with. Use reference symantics to avoid 58 58 // an unnecessary copying 59 const casa ::Vector<casa::Float> &spectrum; // a buffer for the spectrum60 const casa ::Vector<casa::Bool> &mask; // associated mask59 const casacore::Vector<casacore::Float> &spectrum; // a buffer for the spectrum 60 const casacore::Vector<casacore::Bool> &mask; // associated mask 61 61 const std::pair<int,int> &edge; // start and stop+1 channels 62 62 // to work with 63 63 64 64 // statistics for running box filtering 65 casa ::Float sumf; // sum of fluxes66 casa ::Float sumf2; // sum of squares of fluxes67 casa ::Float sumch; // sum of channel numbers (for linear fit)68 casa ::Float sumch2; // sum of squares of channel numbers (for linear fit)69 casa ::Float sumfch; // sum of flux*(channel number) (for linear fit)65 casacore::Float sumf; // sum of fluxes 66 casacore::Float sumf2; // sum of squares of fluxes 67 casacore::Float sumch; // sum of channel numbers (for linear fit) 68 casacore::Float sumch2; // sum of squares of channel numbers (for linear fit) 69 casacore::Float sumfch; // sum of flux*(channel number) (for linear fit) 70 70 71 71 int box_chan_cntr; // actual number of channels in the box … … 73 73 // (calculated from boxsize and actual spectrum size) 74 74 // cache for derivative statistics 75 mutable casa ::Bool need2recalculate; // if true, values of the statistics75 mutable casacore::Bool need2recalculate; // if true, values of the statistics 76 76 // below are invalid 77 mutable casa ::Float linmean; // a value of the linear fit to the77 mutable casacore::Float linmean; // a value of the linear fit to the 78 78 // points in the running box 79 mutable casa ::Float linvariance; // the same for variance79 mutable casacore::Float linvariance; // the same for variance 80 80 int cur_channel; // the number of the current channel 81 81 int start_advance; // number of channel from which the box can … … 85 85 // set up the object with the references to actual data 86 86 // as well as the number of channels in the running box 87 RunningBox(const casa ::Vector<casa::Float> &in_spectrum,88 const casa ::Vector<casa::Bool> &in_mask,87 RunningBox(const casacore::Vector<casacore::Float> &in_spectrum, 88 const casacore::Vector<casacore::Bool> &in_mask, 89 89 const std::pair<int,int> &in_edge, 90 90 int in_max_box_nchan); 91 91 92 92 // access to the statistics 93 const casa ::Float& getLinMean() const;94 const casa ::Float& getLinVariance() const;95 casa ::Float aboveMean() const;93 const casacore::Float& getLinMean() const; 94 const casacore::Float& getLinVariance() const; 95 casacore::Float aboveMean() const; 96 96 int getChannel() const; 97 97 … … 104 104 105 105 // checking whether there are still elements 106 casa ::Bool haveMore() const;106 casacore::Bool haveMore() const; 107 107 108 108 // go to start … … 136 136 // was detected in the previous channels. 137 137 std::pair<int,int> cur_line; 138 casa ::Bool is_detected_before;138 casacore::Bool is_detected_before; 139 139 int min_nchan; // A minimum number of consequtive 140 140 // channels, which should satisfy 141 141 // the detection criterion, to be 142 142 // a detection 143 casa ::Float threshold; // detection threshold - the143 casacore::Float threshold; // detection threshold - the 144 144 // minimal signal to noise ratio 145 145 std::list<pair<int,int> > &lines; // list where detections are saved 146 146 // (pair: start and stop+1 channel) 147 147 RunningBox *running_box; // running box filter 148 casa ::Vector<Int> signs; // An array to store the signs of148 casacore::Vector<Int> signs; // An array to store the signs of 149 149 // the value - current mean 150 150 // (used to search wings) 151 casa ::Int last_sign; // a sign (+1, -1 or 0) of the151 casacore::Int last_sign; // a sign (+1, -1 or 0) of the 152 152 // last point of the detected line 153 153 // … … 163 163 LFAboveThreshold(std::list<pair<int,int> > &in_lines, 164 164 int in_min_nchan = 3, 165 casa ::Float in_threshold = 5,165 casacore::Float in_threshold = 5, 166 166 bool use_median = false, 167 167 int noise_sample_size = -1); … … 169 169 170 170 // replace the detection criterion 171 void setCriterion(int in_min_nchan, casa ::Float in_threshold);171 void setCriterion(int in_min_nchan, casacore::Float in_threshold); 172 172 173 173 // return the array with signs of the value-current mean … … 175 175 // This array is updated each time the findLines method is called and 176 176 // is used to search the line wings 177 const casa ::Vector<Int>& getSigns() const;177 const casacore::Vector<Int>& getSigns() const; 178 178 179 179 // find spectral lines and add them into list … … 182 182 // spectrum, mask and edge - reference to the data 183 183 // max_box_nchan - number of channels in the running box 184 void findLines(const casa ::Vector<casa::Float> &spectrum,185 const casa ::Vector<casa::Bool> &mask,184 void findLines(const casacore::Vector<casacore::Float> &spectrum, 185 const casacore::Vector<casacore::Bool> &mask, 186 186 const std::pair<int,int> &edge, 187 187 int max_box_nchan); … … 192 192 // add a new line to the list, if necessary using processCurLine() 193 193 // detect=true indicates that the current channel satisfies the criterion 194 void processChannel(Bool detect, const casa ::Vector<casa::Bool> &mask);194 void processChannel(Bool detect, const casacore::Vector<casacore::Bool> &mask); 195 195 196 196 // process the interval of channels stored in curline 197 197 // if it satisfies the criterion, add this interval as a new line 198 void processCurLine(const casa ::Vector<casa::Bool> &mask);198 void processCurLine(const casacore::Vector<casacore::Bool> &mask); 199 199 200 200 // get the sign of runningBox->aboveMean(). The RunningBox pointer 201 201 // should be defined 202 casa ::Int getAboveMeanSign() const;202 casacore::Int getAboveMeanSign() const; 203 203 }; 204 204 … … 457 457 // set up the object with the references to actual data 458 458 // and the number of channels in the running box 459 RunningBox::RunningBox(const casa ::Vector<casa::Float> &in_spectrum,460 const casa ::Vector<casa::Bool> &in_mask,459 RunningBox::RunningBox(const casacore::Vector<casacore::Float> &in_spectrum, 460 const casacore::Vector<casacore::Bool> &in_mask, 461 461 const std::pair<int,int> &in_edge, 462 462 int in_max_box_nchan) : … … 488 488 489 489 // access to the statistics 490 const casa ::Float& RunningBox::getLinMean() const490 const casacore::Float& RunningBox::getLinMean() const 491 491 { 492 492 DebugAssert(cur_channel<edge.second, AipsError); … … 495 495 } 496 496 497 const casa ::Float& RunningBox::getLinVariance() const497 const casacore::Float& RunningBox::getLinVariance() const 498 498 { 499 499 DebugAssert(cur_channel<edge.second, AipsError); … … 502 502 } 503 503 504 casa ::Float RunningBox::aboveMean() const504 casacore::Float RunningBox::aboveMean() const 505 505 { 506 506 DebugAssert(cur_channel<edge.second, AipsError); … … 561 561 562 562 // checking whether there are still elements 563 casa ::Bool RunningBox::haveMore() const563 casacore::Bool RunningBox::haveMore() const 564 564 { 565 565 return cur_channel<edge.second; … … 611 611 LFAboveThreshold::LFAboveThreshold(std::list<pair<int,int> > &in_lines, 612 612 int in_min_nchan, 613 casa ::Float in_threshold,613 casacore::Float in_threshold, 614 614 bool use_median, 615 615 int noise_sample_size) : … … 624 624 625 625 // replace the detection criterion 626 void LFAboveThreshold::setCriterion(int in_min_nchan, casa ::Float in_threshold)626 void LFAboveThreshold::setCriterion(int in_min_nchan, casacore::Float in_threshold) 627 627 { 628 628 min_nchan=in_min_nchan; … … 632 632 // get the sign of runningBox->aboveMean(). The RunningBox pointer 633 633 // should be defined 634 casa ::Int LFAboveThreshold::getAboveMeanSign() const634 casacore::Int LFAboveThreshold::getAboveMeanSign() const 635 635 { 636 636 const Float buf=running_box->aboveMean(); … … 644 644 // add a new line to the list, if necessary 645 645 void LFAboveThreshold::processChannel(Bool detect, 646 const casa ::Vector<casa::Bool> &mask)646 const casacore::Vector<casacore::Bool> &mask) 647 647 { 648 648 try { … … 675 675 // process the interval of channels stored in cur_line 676 676 // if it satisfies the criterion, add this interval as a new line 677 void LFAboveThreshold::processCurLine(const casa ::Vector<casa::Bool> &mask)677 void LFAboveThreshold::processCurLine(const casacore::Vector<casacore::Bool> &mask) 678 678 { 679 679 try { … … 709 709 // This array is updated each time the findLines method is called and 710 710 // is used to search the line wings 711 const casa ::Vector<Int>& LFAboveThreshold::getSigns() const711 const casacore::Vector<Int>& LFAboveThreshold::getSigns() const 712 712 { 713 713 return signs; … … 715 715 716 716 // find spectral lines and add them into list 717 void LFAboveThreshold::findLines(const casa ::Vector<casa::Float> &spectrum,718 const casa ::Vector<casa::Bool> &mask,717 void LFAboveThreshold::findLines(const casacore::Vector<casacore::Float> &spectrum, 718 const casacore::Vector<casacore::Bool> &mask, 719 719 const std::pair<int,int> &edge, 720 720 int max_box_nchan) … … 905 905 // in_median true if median statistics is used as opposed to average of 906 906 // the lowest 80% of deviations (default) 907 void STLineFinder::setOptions(const casa ::Float &in_threshold,908 const casa ::Int &in_min_nchan,909 const casa ::Int &in_avg_limit,910 const casa ::Float &in_box_size,911 const casa ::Float &in_noise_box,912 const casa ::Bool &in_median)907 void STLineFinder::setOptions(const casacore::Float &in_threshold, 908 const casacore::Int &in_min_nchan, 909 const casacore::Int &in_avg_limit, 910 const casacore::Float &in_box_size, 911 const casacore::Float &in_noise_box, 912 const casacore::Bool &in_median) 913 913 { 914 914 threshold=in_threshold; … … 949 949 int STLineFinder::findLines(const std::vector<bool> &in_mask, 950 950 const std::vector<int> &in_edge, 951 const casa ::uInt &whichRow)951 const casacore::uInt &whichRow) 952 952 { 953 953 if (useScantable && scan.null()) … … 1096 1096 // spectrum. It uses the Fitter class. This action is required before 1097 1097 // reducing the spectral resolution if the baseline shape is bad 1098 void STLineFinder::subtractBaseline(const casa ::Vector<casa::Bool> &temp_mask,1099 const casa ::Int &order)1098 void STLineFinder::subtractBaseline(const casacore::Vector<casacore::Bool> &temp_mask, 1099 const casacore::Int &order) 1100 1100 { 1101 1101 AlwaysAssert(spectrum.nelements(),AipsError); … … 1112 1112 sdf.setExpression("poly",order); 1113 1113 if (!sdf.lfit()) return; // fit failed, use old spectrum 1114 spectrum=casa ::Vector<casa::Float>(sdf.getResidual());1114 spectrum=casacore::Vector<casacore::Float>(sdf.getResidual()); 1115 1115 } 1116 1116 … … 1121 1121 // array specified, rather than the field of this class 1122 1122 // boxsize - a number of adjacent channels to average 1123 void STLineFinder::averageAdjacentChannels(casa ::Vector<casa::Bool> &mask2update,1124 const casa ::Int &boxsize)1123 void STLineFinder::averageAdjacentChannels(casacore::Vector<casacore::Bool> &mask2update, 1124 const casacore::Int &boxsize) 1125 1125 { 1126 1126 DebugAssert(mask2update.nelements()==spectrum.nelements(), AipsError); … … 1266 1266 // nothing will be done if it is empty 1267 1267 // max_box_nchan - channels in the running box for baseline filtering 1268 void STLineFinder::keepStrongestOnly(const casa ::Vector<casa::Bool> &temp_mask,1268 void STLineFinder::keepStrongestOnly(const casacore::Vector<casacore::Bool> &temp_mask, 1269 1269 std::list<std::pair<int, int> > &lines2update, 1270 1270 int max_box_nchan) … … 1371 1371 // merged together. Any masked channel stops the extension 1372 1372 void LFLineListOperations::searchForWings(std::list<std::pair<int, int> > &newlines, 1373 const casa ::Vector<casa::Int> &signs,1374 const casa ::Vector<casa::Bool> &mask,1373 const casacore::Vector<casacore::Int> &signs, 1374 const casacore::Vector<casacore::Bool> &mask, 1375 1375 const std::pair<int,int> &edge) 1376 1376 {
Note: See TracChangeset
for help on using the changeset viewer.