Changeset 2774


Ignore:
Timestamp:
02/25/13 17:35:27 (11 years ago)
Author:
WataruKawasaki
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): sd

Description: fixed a bug in Scantable::getCompositeChanMask().


Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STLineFinder.cpp

    r2580 r2774  
    10061006               throw AipsError("STLineFinder::findLines - the in_edge parameter has a negative"
    10071007                                "number of channels to drop");
    1008            if (edge.first>=int(nchan))
     1008           if (edge.first>=int(nchan)) {
    10091009               throw AipsError("STLineFinder::findLines - all channels are rejected by the in_edge parameter");
     1010           }
    10101011           if (in_edge.size()==2) {
    10111012               edge.second=in_edge[1];
     
    10151016               edge.second=nchan-edge.second;
    10161017           } else edge.second=nchan-edge.first;
    1017            if (edge.second<0 || (edge.first>=edge.second))
     1018           if (edge.second<0 || (edge.first>=edge.second)) {
    10181019               throw AipsError("STLineFinder::findLines - all channels are rejected by the in_edge parameter");
     1020           }
    10191021       }
    10201022
  • trunk/src/Scantable.cpp

    r2773 r2774  
    26412641}
    26422642
    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).
     2643std::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{
    26592658  if (uself) {
    26602659    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);
    26652661    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  }
    26912664
    26922665  std::vector<float> res;
     
    29332906                               STLineFinder& lineFinder)
    29342907{
    2935   if (edge.size() < getIFNos().size()*2) {
     2908  if ((edge.size() > 2) && (edge.size() < getIFNos().size()*2)) {
    29362909    throw(AipsError("Length of edge element info is less than that of IFs"));
    29372910  }
     
    29472920                             const std::string& bltable)
    29482921{
    2949   /****/
     2922  /****
    29502923  double TimeStart = mathutil::gettimeofday_sec();
    2951   /****/
     2924  ****/
    29522925
    29532926  try {
     
    30072980  }
    30082981
    3009   /****/
     2982  /****
    30102983  double TimeEnd = mathutil::gettimeofday_sec();
    30112984  double elapse1 = TimeEnd - TimeStart;
    30122985  std::cout << "poly-new   : " << elapse1 << " (sec.)" << endl;
    3013   /****/
     2986  ****/
    30142987}
    30152988
     
    30913064                                  const std::string& bltable)
    30923065{
    3093   //
     3066  /*
    30943067  double TimeStart = mathutil::gettimeofday_sec();
    3095   //
     3068  */
    30963069
    30973070  try {
     
    31513124  }
    31523125
     3126  /*
    31533127  double TimeEnd = mathutil::gettimeofday_sec();
    31543128  double elapse1 = TimeEnd - TimeStart;
    31553129  std::cout << "cheby   : " << elapse1 << " (sec.)" << endl;
     3130  */
    31563131}
    31573132
     
    32263201}
    32273202
    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)
     3203double 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)
    32293212{
    32303213  std::vector<float> sp = getSpectrum(whichrow);
     
    32333216
    32343217  if (useLineFinder) {
    3235     int minEdgeSize = getIFNos().size()*2;
    3236 
    3237     int edgeSize = edge.size();
     3218    STLineFinder lineFinder = STLineFinder();
     3219    initLineFinder(edge, threshold, chanAvgLimit, lineFinder);
    32383220    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);
    32603222  } else {
    3261 
    32623223    chanMask = getCompositeChanMask(whichrow, inMask);
    32633224  }
     
    37353696                                    const std::string& bltable)
    37363697{
    3737   /****/
     3698  /****
    37383699  double TimeStart = mathutil::gettimeofday_sec();
    3739   /****/
     3700  ****/
    37403701
    37413702  try {
     
    37963757  }
    37973758
    3798   /****/
     3759  /****
    37993760  double TimeEnd = mathutil::gettimeofday_sec();
    38003761  double elapse1 = TimeEnd - TimeStart;
    38013762  std::cout << "cspline-new   : " << elapse1 << " (sec.)" << endl;
    3802   /****/
     3763  ****/
    38033764}
    38043765
     
    44454406                                 const std::string& bltable)
    44464407{
    4447   /****/
     4408  /****
    44484409  double TimeStart = mathutil::gettimeofday_sec();
    4449   /****/
     4410  ****/
    44504411
    44514412  try {
     
    45184479  }
    45194480
    4520   /****/
     4481  /****
    45214482  double TimeEnd = mathutil::gettimeofday_sec();
    45224483  double elapse1 = TimeEnd - TimeStart;
    45234484  std::cout << "sinusoid-old   : " << elapse1 << " (sec.)" << endl;
    4524   /****/
     4485  ****/
    45254486}
    45264487
     
    47444705{
    47454706  std::vector<uint> ifNos = getIFNos();
    4746   if (edge.size() < ifNos.size()*2) {
     4707  if ((edge.size() > 2) && (edge.size() < ifNos.size()*2)) {
    47474708    throw(AipsError("Length of edge element info is less than that of IFs"));
    47484709  }
    47494710
    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    }
    47624725  }
    47634726
Note: See TracChangeset for help on using the changeset viewer.