Changeset 3023 for trunk


Ignore:
Timestamp:
02/09/15 15:48:01 (10 years ago)
Author:
Kana Sugimoto
Message:

New Development: No

JIRA Issue: No (Bug fixes)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: Added a function Scantable::nValidMask(const std::vector<bool>& mask);

Test Programs:

Put in Release Notes: Yes

Module(s): scantable, sdbaseline

Description:

  • Added a new function Scantable::nValidMask(const std::vector<bool>& mask) that returns the number of elements in true in the input bool vector, mask.
  • Fixed a bug in Scantable::isAllChannelsFlagged that fails to detect completely flagged channels when BDF flag and the other flag is mixed in a spectrum.
  • Fixed a bug in *Baseline functions that caused an error of baseline subtraction in case there is a spectrum of which all channels are flagged.


Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Scantable.cpp

    r3018 r3023  
    25522552  if (rflag > 0)
    25532553    return true;
    2554   uChar flag;
     2554  bool flag;
    25552555  Vector<uChar> flags;
    25562556  flagsCol_.get(whichrow, flags);
    2557   flag = flags[0];
     2557  flag = (flags[0]>0);
    25582558  for (uInt i = 1; i < flags.size(); ++i) {
    2559     flag &= flags[i];
     2559    flag &= (flags[i]>0);
    25602560  }
    25612561  //  return ((flag >> 7) == 1);
    25622562  return (flag > 0);
    25632563}
     2564
     2565std::size_t Scantable::nValidMask(const std::vector<bool>& mask)
     2566{
     2567  std::size_t nvalid=0;
     2568  assert(static_cast<std::size_t>(true)==1);
     2569  assert(static_cast<std::size_t>(false)==0);
     2570  for (uInt i = 1; i < mask.size(); ++i) {
     2571    nvalid += static_cast<std::size_t>(mask[i]);
     2572  }
     2573  return nvalid;
     2574}
     2575
    25642576
    25652577std::vector<std::string> Scantable::applyBaselineTable(const std::string& bltable, const bool returnfitresult, const std::string& outbltable, const bool outbltableexists, const bool overwrite)
     
    30513063      std::vector<float> params;
    30523064
    3053       if (flagrowCol_(whichrow) == 0) {
     3065      //if (flagrowCol_(whichrow) == 0) {
     3066      if (flagrowCol_(whichrow)==0 && nValidMask(chanMask)>0) {
    30543067        int nClipped = 0;
    30553068        std::vector<float> res;
     
    31443157      std::vector<float> params;
    31453158
    3146       if (flagrowCol_(whichrow) == 0) {
     3159      //if (flagrowCol_(whichrow) == 0) {
     3160      if (flagrowCol_(whichrow)==0 && nValidMask(chanMask)>0) {
    31473161        int nClipped = 0;
    31483162        std::vector<float> res;
     
    32293243      std::vector<float> params;
    32303244
    3231       if (flagrowCol_(whichrow) == 0) {
     3245      //      if (flagrowCol_(whichrow) == 0) {
     3246      if (flagrowCol_(whichrow)==0 && nValidMask(chanMask)>0) {
    32323247        int nClipped = 0;
    32333248        std::vector<float> res;
     
    33223337      std::vector<float> params;
    33233338
    3324       if (flagrowCol_(whichrow) == 0) {
     3339      //      if (flagrowCol_(whichrow) == 0) {
     3340      if (flagrowCol_(whichrow)==0 && nValidMask(chanMask)>0) {
    33253341        int nClipped = 0;
    33263342        std::vector<float> res;
     
    39113927      std::vector<float> params;
    39123928
    3913       if (flagrowCol_(whichrow) == 0) {
     3929      //if (flagrowCol_(whichrow) == 0) {
     3930      if (flagrowCol_(whichrow)==0 && nValidMask(chanMask)>0) {
    39143931        int nClipped = 0;
    39153932        std::vector<float> res;
     
    40094026      std::vector<float> params;
    40104027
    4011       if (flagrowCol_(whichrow) == 0) {
     4028      //if (flagrowCol_(whichrow) == 0) {
     4029      if (flagrowCol_(whichrow)==0 && nValidMask(chanMask)>0) {
    40124030        int nClipped = 0;
    40134031        std::vector<float> res;
     
    46904708      std::vector<float> params;
    46914709
    4692       if (flagrowCol_(whichrow) == 0) {
     4710      //if (flagrowCol_(whichrow) == 0) {
     4711      if (flagrowCol_(whichrow)==0 && nValidMask(chanMask)>0) {
    46934712        int nClipped = 0;
    46944713        std::vector<float> res;
     
    47994818      std::vector<float> params;
    48004819
    4801       if (flagrowCol_(whichrow) == 0) {
     4820      //if (flagrowCol_(whichrow) == 0) {
     4821      if (flagrowCol_(whichrow)==0 && nValidMask(chanMask)>0) {
    48024822        int nClipped = 0;
    48034823        std::vector<float> res;
     
    49764996                                                  STLineFinder& lineFinder)
    49774997{
     4998  if (isAllChannelsFlagged(whichrow)) {//all channels flagged
     4999    std::vector<bool> res_mask(inMask.size(),false);
     5000    return res_mask;
     5001  } else if (nValidMask(inMask)==0){ //no valid mask channels
     5002    std::vector<bool> res_mask(inMask);
     5003    return res_mask;
     5004  }
     5005
    49785006  std::vector<uint> ifNos = getIFNos();
    49795007  if ((edge.size() > 2) && (edge.size() < ifNos.size()*2)) {
  • trunk/src/Scantable.h

    r2969 r3023  
    724724
    725725  std::vector<uint> getNumbers(const casa::ScalarColumn<casa::uInt>& col) const;
     726
     727  /**
     728   * Returns a number of elements with "true" in a bool vector.
     729   * @param[in] mask (boolean vector)
     730   * @return the numerb of elements in true
     731   */
     732  std::size_t nValidMask(const std::vector<bool>& mask);
    726733
    727734  static const casa::uInt version_ = 4;
Note: See TracChangeset for help on using the changeset viewer.