- Timestamp:
- 02/25/13 17:35:27 (12 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STLineFinder.cpp
r2580 r2774 1006 1006 throw AipsError("STLineFinder::findLines - the in_edge parameter has a negative" 1007 1007 "number of channels to drop"); 1008 if (edge.first>=int(nchan)) 1008 if (edge.first>=int(nchan)) { 1009 1009 throw AipsError("STLineFinder::findLines - all channels are rejected by the in_edge parameter"); 1010 } 1010 1011 if (in_edge.size()==2) { 1011 1012 edge.second=in_edge[1]; … … 1015 1016 edge.second=nchan-edge.second; 1016 1017 } else edge.second=nchan-edge.first; 1017 if (edge.second<0 || (edge.first>=edge.second)) 1018 if (edge.second<0 || (edge.first>=edge.second)) { 1018 1019 throw AipsError("STLineFinder::findLines - all channels are rejected by the in_edge parameter"); 1020 } 1019 1021 } 1020 1022 -
trunk/src/Scantable.cpp
r2773 r2774 2641 2641 } 2642 2642 2643 std::vector<float> Scantable::doSubtractBaseline(std::vector<float>& spec, 2644 std::vector<bool>& mask, 2645 const STBaselineFunc::FuncName ftype, 2646 std::vector<int>& fpar, 2647 std::vector<float>& params, 2648 float&rms, 2649 std::vector<bool>& finalmask, 2650 float clipth, 2651 int clipn, 2652 bool uself, 2653 int irow, 2654 float lfth, 2655 std::vector<int>& lfedge, 2656 int lfavg) 2657 { 2658 //--- replacing mask with (mask AND mask_linefinder). 2643 std::vector<float> Scantable::doSubtractBaseline(std::vector<float>& spec, 2644 std::vector<bool>& mask, 2645 const STBaselineFunc::FuncName ftype, 2646 std::vector<int>& fpar, 2647 std::vector<float>& params, 2648 float&rms, 2649 std::vector<bool>& finalmask, 2650 float clipth, 2651 int clipn, 2652 bool uself, 2653 int irow, 2654 float lfth, 2655 std::vector<int>& lfedge, 2656 int lfavg) 2657 { 2659 2658 if (uself) { 2660 2659 STLineFinder lineFinder = STLineFinder(); 2661 lineFinder.setOptions(lfth, 3, lfavg); 2662 2663 int minEdgeSize = getIFNos().size()*2; 2664 int edgeSize = lfedge.size(); 2660 initLineFinder(lfedge, lfth, lfavg, lineFinder); 2665 2661 std::vector<int> currentEdge; 2666 currentEdge.clear(); 2667 if (edgeSize >= 2) { 2668 int idx = 0; 2669 if (edgeSize > 2) { 2670 if (edgeSize < minEdgeSize) { 2671 throw(AipsError("Length of edge element info is less than that of IFs")); 2672 } 2673 idx = 2 * getIF(irow); 2674 } 2675 currentEdge.push_back(lfedge[idx]); 2676 currentEdge.push_back(lfedge[idx+1]); 2677 } else { 2678 throw(AipsError("Wrong length of edge element")); 2679 } 2680 lineFinder.setData(spec); 2681 lineFinder.findLines(getCompositeChanMask(irow, mask), currentEdge, irow); 2682 2683 std::vector<bool> lfcompmask = lineFinder.getMask(); 2684 mask.clear(); 2685 mask.resize(lfcompmask.size()); 2686 for (uInt i = 0; i < mask.size(); ++i) { 2687 mask[i] = lfcompmask[i]; 2688 } 2689 } 2690 //--- 2662 mask = getCompositeChanMask(irow, mask, lfedge, currentEdge, lineFinder); 2663 } 2691 2664 2692 2665 std::vector<float> res; … … 2933 2906 STLineFinder& lineFinder) 2934 2907 { 2935 if ( edge.size() < getIFNos().size()*2) {2908 if ((edge.size() > 2) && (edge.size() < getIFNos().size()*2)) { 2936 2909 throw(AipsError("Length of edge element info is less than that of IFs")); 2937 2910 } … … 2947 2920 const std::string& bltable) 2948 2921 { 2949 /**** /2922 /**** 2950 2923 double TimeStart = mathutil::gettimeofday_sec(); 2951 /****/2924 ****/ 2952 2925 2953 2926 try { … … 3007 2980 } 3008 2981 3009 /**** /2982 /**** 3010 2983 double TimeEnd = mathutil::gettimeofday_sec(); 3011 2984 double elapse1 = TimeEnd - TimeStart; 3012 2985 std::cout << "poly-new : " << elapse1 << " (sec.)" << endl; 3013 /****/2986 ****/ 3014 2987 } 3015 2988 … … 3091 3064 const std::string& bltable) 3092 3065 { 3093 / /3066 /* 3094 3067 double TimeStart = mathutil::gettimeofday_sec(); 3095 //3068 */ 3096 3069 3097 3070 try { … … 3151 3124 } 3152 3125 3126 /* 3153 3127 double TimeEnd = mathutil::gettimeofday_sec(); 3154 3128 double elapse1 = TimeEnd - TimeStart; 3155 3129 std::cout << "cheby : " << elapse1 << " (sec.)" << endl; 3130 */ 3156 3131 } 3157 3132 … … 3226 3201 } 3227 3202 3228 double Scantable::calculateModelSelectionCriteria(const std::string& valname, const std::string& blfunc, int order, const std::vector<bool>& inMask, int whichrow, bool useLineFinder, const std::vector<int>& edge, float threshold, int chanAvgLimit) 3203 double Scantable::calculateModelSelectionCriteria(const std::string& valname, 3204 const std::string& blfunc, 3205 int order, 3206 const std::vector<bool>& inMask, 3207 int whichrow, 3208 bool useLineFinder, 3209 const std::vector<int>& edge, 3210 float threshold, 3211 int chanAvgLimit) 3229 3212 { 3230 3213 std::vector<float> sp = getSpectrum(whichrow); … … 3233 3216 3234 3217 if (useLineFinder) { 3235 int minEdgeSize = getIFNos().size()*2; 3236 3237 int edgeSize = edge.size(); 3218 STLineFinder lineFinder = STLineFinder(); 3219 initLineFinder(edge, threshold, chanAvgLimit, lineFinder); 3238 3220 std::vector<int> currentEdge; 3239 currentEdge.clear(); 3240 if (edgeSize >= 2) { 3241 int idx = 0; 3242 if (edgeSize > 2) { 3243 if (edgeSize < minEdgeSize) { 3244 throw(AipsError("Length of edge element info is less than that of IFs")); 3245 } 3246 idx = 2 * getIF(whichrow); 3247 } 3248 currentEdge.push_back(edge[idx]); 3249 currentEdge.push_back(edge[idx+1]); 3250 } else { 3251 throw(AipsError("Wrong length of edge element")); 3252 } 3253 3254 STLineFinder lineFinder = STLineFinder(); 3255 lineFinder.setData(sp); 3256 lineFinder.setOptions(threshold, 3, chanAvgLimit); 3257 lineFinder.findLines(getCompositeChanMask(whichrow, inMask), currentEdge, whichrow); 3258 chanMask = lineFinder.getMask(); 3259 3221 chanMask = getCompositeChanMask(whichrow, inMask, edge, currentEdge, lineFinder); 3260 3222 } else { 3261 3262 3223 chanMask = getCompositeChanMask(whichrow, inMask); 3263 3224 } … … 3735 3696 const std::string& bltable) 3736 3697 { 3737 /**** /3698 /**** 3738 3699 double TimeStart = mathutil::gettimeofday_sec(); 3739 /****/3700 ****/ 3740 3701 3741 3702 try { … … 3796 3757 } 3797 3758 3798 /**** /3759 /**** 3799 3760 double TimeEnd = mathutil::gettimeofday_sec(); 3800 3761 double elapse1 = TimeEnd - TimeStart; 3801 3762 std::cout << "cspline-new : " << elapse1 << " (sec.)" << endl; 3802 /****/3763 ****/ 3803 3764 } 3804 3765 … … 4445 4406 const std::string& bltable) 4446 4407 { 4447 /**** /4408 /**** 4448 4409 double TimeStart = mathutil::gettimeofday_sec(); 4449 /****/4410 ****/ 4450 4411 4451 4412 try { … … 4518 4479 } 4519 4480 4520 /**** /4481 /**** 4521 4482 double TimeEnd = mathutil::gettimeofday_sec(); 4522 4483 double elapse1 = TimeEnd - TimeStart; 4523 4484 std::cout << "sinusoid-old : " << elapse1 << " (sec.)" << endl; 4524 /****/4485 ****/ 4525 4486 } 4526 4487 … … 4744 4705 { 4745 4706 std::vector<uint> ifNos = getIFNos(); 4746 if ( edge.size() < ifNos.size()*2) {4707 if ((edge.size() > 2) && (edge.size() < ifNos.size()*2)) { 4747 4708 throw(AipsError("Length of edge element info is less than that of IFs")); 4748 4709 } 4749 4710 4750 int ifVal = getIF(whichrow); 4751 bool foundIF = false; 4752 uint idx; 4753 for (uint i = 0; i < ifNos.size(); ++i) { 4754 if (ifVal == (int)ifNos[i]) { 4755 idx = 2*i; 4756 foundIF = true; 4757 break; 4758 } 4759 } 4760 if (!foundIF) { 4761 throw(AipsError("bad IF number")); 4711 uint idx = 0; 4712 if (edge.size() > 2) { 4713 int ifVal = getIF(whichrow); 4714 bool foundIF = false; 4715 for (uint i = 0; i < ifNos.size(); ++i) { 4716 if (ifVal == (int)ifNos[i]) { 4717 idx = 2*i; 4718 foundIF = true; 4719 break; 4720 } 4721 } 4722 if (!foundIF) { 4723 throw(AipsError("bad IF number")); 4724 } 4762 4725 } 4763 4726
Note:
See TracChangeset
for help on using the changeset viewer.