Changeset 2890 for trunk/src


Ignore:
Timestamp:
01/10/14 20:26:37 (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:

Module(s): sd

Description: (1) fixed Scantable::do{CubicSpline}LeastSquareFitting() to correctly avoid using NaN/Inf data (in calculating sigma of residual spectrum). (2) clean-up parse_spw_selection() code in scantable.py.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Scantable.cpp

    r2888 r2890  
    35563556  for (int i = 0; i < nChan; ++i) {
    35573557    maskArray[i] = mask[i] ? 1 : 0;
     3558    if (isnan(data[i])) maskArray[i] = 0;
     3559    if (isinf(data[i])) maskArray[i] = 0;
     3560
     3561    finalMask[i] = (maskArray[i] == 1);
     3562    if (finalMask[i]) {
     3563      j++;
     3564    }
     3565
     3566    /*
     3567    maskArray[i] = mask[i] ? 1 : 0;
    35583568    if (mask[i]) {
    35593569      j++;
    35603570    }
    35613571    finalMask[i] = mask[i];
     3572    */
    35623573  }
    35633574
     
    36113622    }
    36123623
     3624    //compute inverse matrix of the left half of xMatrix
    36133625    std::vector<double> invDiag(nDOF);
    36143626    for (int i = 0; i < nDOF; ++i) {
     
    36693681    double stdDev = 0.0;
    36703682    for (int i = 0; i < nChan; ++i) {
    3671       stdDev += residual[i]*residual[i]*(double)maskArray[i];
     3683      if (maskArray[i] == 0) continue;
     3684      stdDev += residual[i]*residual[i];
    36723685    }
    36733686    stdDev = sqrt(stdDev/(double)nData);
     
    36903703      }
    36913704      if (newNData == nData) {
    3692         break; //no more flag to add. iteration stops.
     3705        break; //no more flag to add. stop iteration.
    36933706      } else {
    36943707        nData = newNData;
     
    37123725
    37133726  return result;
    3714 }
     3727} //xMatrix
    37153728
    37163729void Scantable::cubicSplineBaseline(const std::vector<bool>& mask, int nPiece,
     
    39553968  for (int i = 0; i < nChan; ++i) {
    39563969    maskArray[i] = mask[i] ? 1 : 0;
     3970    if (isnan(data[i])) maskArray[i] = 0;
     3971    if (isinf(data[i])) maskArray[i] = 0;
     3972
     3973    finalMask[i] = (maskArray[i] == 1);
     3974    if (finalMask[i]) {
     3975      x[j] = i;
     3976      j++;
     3977    }
     3978
     3979    /*
     3980    maskArray[i] = mask[i] ? 1 : 0;
    39573981    if (mask[i]) {
    39583982      x[j] = i;
     
    39603984    }
    39613985    finalMask[i] = mask[i];
     3986    */
    39623987  }
    39633988
     
    41704195    double stdDev = 0.0;
    41714196    for (int i = 0; i < nChan; ++i) {
    4172       stdDev += residual[i]*residual[i]*(double)maskArray[i];
     4197      if (maskArray[i] == 0) continue;
     4198      stdDev += residual[i]*residual[i];
    41734199    }
    41744200    stdDev = sqrt(stdDev/(double)nData);
Note: See TracChangeset for help on using the changeset viewer.