- Timestamp:
- 03/20/06 15:17:06 (19 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Makefile
r906 r907 1 TARGET := /tmp/asap/_asap.so1 TARGET := ../tmp/asap/_asap.so 2 2 3 3 # the casa environment AIPSPATH has to be defined … … 64 64 # python only 2.3 has been tested 65 65 PYVERSION := 2.3 66 PYTHONROOT := /usr 66 #PYTHONROOT := /usr 67 PYTHONROOT := /export/DEBIANlocal 67 68 PYTHONINC := -I$(PYTHONROOT)/include/python$(PYVERSION) 68 PYTHONLIB := -L$(PYTHONROOT)/lib -lpython$(PYVERSION) 69 PYTHONLIB := -L$(PYTHONROOT)/lib -lpython$(PYVERSION) -L/export/DEBIANlocal/gnu/lib/ 69 70 70 71 # has to be build with same g++ version as casa -
trunk/src/STLineFinder.cpp
r894 r907 150 150 // the value - current mean 151 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 // 152 155 public: 153 156 … … 189 192 void processCurLine(const casa::Vector<casa::Bool> &mask) 190 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(); 191 198 }; 192 199 … … 370 377 } 371 378 379 // get the sign of runningBox->aboveMean(). The RunningBox pointer 380 // should be defined 381 casa::Int LFAboveThreshold::getAboveMeanSign() const throw() 382 { 383 const Float buf=running_box->aboveMean(); 384 if (buf>0) return 1; 385 if (buf<0) return -1; 386 return 0; 387 } 388 372 389 373 390 // process a channel: update cur_line and is_detected before and … … 377 394 { 378 395 try { 379 if (detect) { 380 if (is_detected_before) 381 cur_line.second=running_box->getChannel()+1; 382 else { 383 is_detected_before=True; 384 cur_line.first=running_box->getChannel(); 385 cur_line.second=running_box->getChannel()+1; 386 } 387 } else processCurLine(mask); 396 if (is_detected_before) { 397 // we have to check that the current detection has the 398 // same sign of running_box->aboveMean 399 // otherwise it could be a spurious detection 400 if (last_sign && last_sign!=getAboveMeanSign()) 401 detect=False; 402 } 403 if (detect) { 404 last_sign=getAboveMeanSign(); 405 if (is_detected_before) 406 cur_line.second=running_box->getChannel()+1; 407 else { 408 is_detected_before=True; 409 cur_line.first=running_box->getChannel(); 410 cur_line.second=running_box->getChannel()+1; 411 } 412 } else processCurLine(mask); 388 413 } 389 414 catch (const AipsError &ae) { … … 490 515 threshold*offline_variance), mask); 491 516 else processCurLine(mask); // just finish what was accumulated before 517 518 signs[ch]=getAboveMeanSign(); 519 // os<<ch<<" "<<spectrum[ch]<<" "<<fabs(running_box->aboveMean())<<" "<< 520 // threshold*offline_variance<<endl; 521 492 522 const Float buf=running_box->aboveMean(); 493 523 if (buf>0) signs[ch]=1; … … 635 665 STLineFinder::~STLineFinder() throw(AipsError) {} 636 666 637 // set scan to work with (in_scan parameter), associated mask (in_mask 638 // parameter) and the edge channel rejection (in_edge parameter) 667 // set scan to work with (in_scan parameter) 668 void STLineFinder::setScan(const ScantableWrapper &in_scan) throw(AipsError) 669 { 670 scan=in_scan.getCP(); 671 AlwaysAssert(!scan.null(),AipsError); 672 673 } 674 675 // search for spectral lines. Number of lines found is returned 676 // in_edge and in_mask control channel rejection for a given row 639 677 // if in_edge has zero length, all channels chosen by mask will be used 640 678 // if in_edge has one element only, it represents the number of … … 642 680 // in_edge is introduced for convinience, although all functionality 643 681 // can be achieved using a spectrum mask only 644 void STLineFinder::setScan(const ScantableWrapper &in_scan, 645 const std::vector<bool> &in_mask, 646 const boost::python::tuple &in_edge) throw(AipsError) 647 { 648 try { 649 scan=in_scan.getCP(); 650 AlwaysAssert(!scan.null(),AipsError); 651 652 mask=in_mask; 653 if (mask.nelements()!=scan->nchan()) 654 throw AipsError("STLineFinder::setScan - in_scan and in_mask have different" 655 "number of spectral channels."); 656 657 // number of elements in the in_edge tuple 658 int n=extract<int>(in_edge.attr("__len__")()); 659 if (n>2 || n<0) 660 throw AipsError("STLineFinder::setScan - the length of the in_edge parameter" 661 "should not exceed 2"); 662 if (!n) { 663 // all spectra, no rejection 664 edge.first=0; 665 edge.second=scan->nchan(); 666 } else { 667 edge.first=extract<int>(in_edge.attr("__getitem__")(0)); 668 if (edge.first<0) 669 throw AipsError("STLineFinder::setScan - the in_edge parameter has a negative" 670 "number of channels to drop"); 671 if (edge.first>=scan->nchan()) 672 throw AipsError("STLineFinder::setScan - all channels are rejected by the in_edge parameter"); 673 if (n==2) { 674 edge.second=extract<int>(in_edge.attr("__getitem__")(1)); 675 if (edge.second<0) 676 throw AipsError("STLineFinder::setScan - the in_edge parameter has a negative" 677 "number of channels to drop"); 678 edge.second=scan->nchan()-edge.second; 679 } else edge.second=scan->nchan()-edge.first; 680 if (edge.second<0 || (edge.first>=edge.second)) 681 throw AipsError("STLineFinder::setScan - all channels are rejected by the in_edge parameter"); 682 } 683 } 684 catch(const AipsError &ae) { 685 // setScan is unsuccessfull, reset scan/mask/edge 686 scan=CountedConstPtr<Scantable>(); // null pointer 687 mask.resize(0); 688 edge=pair<int,int>(0,0); 689 throw; 690 } 691 } 692 693 // search for spectral lines. Number of lines found is returned 694 int STLineFinder::findLines(const casa::uInt &whichRow) throw(casa::AipsError) 682 int STLineFinder::findLines(const std::vector<bool> &in_mask, 683 const std::vector<int> &in_edge, 684 const casa::uInt &whichRow) throw(casa::AipsError) 695 685 { 696 686 const int minboxnchan=4; … … 698 688 throw AipsError("STLineFinder::findLines - a scan should be set first," 699 689 " use set_scan"); 700 DebugAssert(mask.nelements()==scan->nchan(), AipsError); 701 int max_box_nchan=int(scan->nchan()*box_size); // number of channels in running 690 691 // set up mask and edge rejection 692 mask=in_mask; 693 if (mask.nelements()!=scan->nchan(whichRow)) 694 throw AipsError("STLineFinder::findLines - in_scan and in_mask have different" 695 "number of spectral channels."); 696 697 // number of elements in in_edge 698 if (in_edge.size()>2) 699 throw AipsError("STLineFinder::findLines - the length of the in_edge parameter" 700 "should not exceed 2"); 701 if (!in_edge.size()) { 702 // all spectra, no rejection 703 edge.first=0; 704 edge.second=scan->nchan(whichRow); 705 } else { 706 edge.first=in_edge[0]; 707 if (edge.first<0) 708 throw AipsError("STLineFinder::findLines - the in_edge parameter has a negative" 709 "number of channels to drop"); 710 if (edge.first>=scan->nchan(whichRow)) 711 throw AipsError("STLineFinder::findLines - all channels are rejected by the in_edge parameter"); 712 if (in_edge.size()==2) { 713 edge.second=in_edge[1]; 714 if (edge.second<0) 715 throw AipsError("STLineFinder::findLines - the in_edge parameter has a negative" 716 "number of channels to drop"); 717 edge.second=scan->nchan(whichRow)-edge.second; 718 } else edge.second=scan->nchan(whichRow)-edge.first; 719 if (edge.second<0 || (edge.first>=edge.second)) 720 throw AipsError("STLineFinder::findLines - all channels are rejected by the in_edge parameter"); 721 } 722 723 // 724 int max_box_nchan=int(scan->nchan(whichRow)*box_size); // number of channels in running 702 725 // box 703 726 if (max_box_nchan<2) … … 833 856 throw AipsError("STLineFinder::getMask - a scan should be set first," 834 857 " use set_scan followed by find_lines"); 835 DebugAssert(mask.nelements()==scan->nchan( ), AipsError);858 DebugAssert(mask.nelements()==scan->nchan(last_row_used), AipsError); 836 859 /* 837 860 if (!lines.size()) … … 892 915 throw AipsError("STLineFinder::getLineRangesInChannels - a scan should be set first," 893 916 " use set_scan followed by find_lines"); 894 DebugAssert(mask.nelements()==scan->nchan( ), AipsError);917 DebugAssert(mask.nelements()==scan->nchan(last_row_used), AipsError); 895 918 896 919 if (!lines.size()) -
trunk/src/STLineFinder.h
r891 r907 158 158 const casa::Float &in_box_size=0.2) throw(); 159 159 160 // set the scan to work with (in_scan parameter), associated mask (in_mask 161 // parameter) and the edge channel rejection (in_edge parameter) 162 // if in_edge has zero length, all channels chosen by mask will be used 160 // set the scan to work with (in_scan parameter) 161 void setScan(const ScantableWrapper &in_scan) throw(casa::AipsError); 162 163 // search for spectral lines in a row specified by whichRow 164 // in_mask and in_edge parameters control channel rejection 165 // if in_edge has zero length, all channels chosen by mask will be used 163 166 // if in_edge has one element only, it represents the number of 164 167 // channels to drop from both sides of the spectrum 165 168 // in_edge is introduced for convinience, although all functionality 166 169 // can be achieved using a spectrum mask only 167 void setScan(const ScantableWrapper &in_scan,168 const std::vector<bool> &in_mask,169 const boost::python::tuple &in_edge) throw(casa::AipsError);170 171 // search for spectral lines for a row specified by whichRow and172 // Beam/IF/Pol specified by current cursor set for the scantable173 170 // Number of lines found is returned 174 int findLines(const casa::uInt &whichRow = 0) throw(casa::AipsError); 171 int findLines(const std::vector<bool> &in_mask, 172 const std::vector<int> &in_edge = std::vector<int>(), 173 const casa::uInt &whichRow = 0) throw(casa::AipsError); 175 174 176 175 // get the mask to mask out all lines that have been found (default)
Note:
See TracChangeset
for help on using the changeset viewer.