Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Scantable.cpp

    r1819 r1947  
    101101  fitTable_ = STFit(*this);
    102102  table_.rwKeywordSet().defineTable("FIT", fitTable_.table());
     103  table_.tableInfo().setType( "Scantable" ) ;
    103104  originalTable_ = table_;
    104105  attach();
     
    120121    table_ = tab;
    121122  }
     123  table_.tableInfo().setType( "Scantable" ) ;
    122124
    123125  attachSubtables();
     
    165167      table_.markForDelete();
    166168  }
     169  table_.tableInfo().setType( "Scantable" ) ;
    167170  /// @todo reindex SCANNO, recompute nbeam, nif, npol
    168171  if ( clear ) copySubtables(other);
     
    681684std::string Scantable::formatTime(const MEpoch& me, bool showdate) const
    682685{
     686  return formatTime(me, showdate, 0);
     687}
     688
     689std::string Scantable::formatTime(const MEpoch& me, bool showdate, uInt prec) const
     690{
    683691  MVTime mvt(me.getValue());
    684692  if (showdate)
    685     mvt.setFormat(MVTime::YMD);
     693    //mvt.setFormat(MVTime::YMD);
     694    mvt.setFormat(MVTime::YMD, prec);
    686695  else
    687     mvt.setFormat(MVTime::TIME);
     696    //mvt.setFormat(MVTime::TIME);
     697    mvt.setFormat(MVTime::TIME, prec);
    688698  ostringstream oss;
    689699  oss << mvt;
     
    10321042}
    10331043
    1034 std::string Scantable::getTime(int whichrow, bool showdate) const
    1035 {
    1036   MEpoch::ROScalarColumn timeCol(table_, "TIME");
     1044// std::string Scantable::getTime(int whichrow, bool showdate) const
     1045// {
     1046//   MEpoch::ROScalarColumn timeCol(table_, "TIME");
     1047//   MEpoch me;
     1048//   if (whichrow > -1) {
     1049//     me = timeCol(uInt(whichrow));
     1050//   } else {
     1051//     Double tm;
     1052//     table_.keywordSet().get("UTC",tm);
     1053//     me = MEpoch(MVEpoch(tm));
     1054//   }
     1055//   return formatTime(me, showdate);
     1056// }
     1057
     1058std::string Scantable::getTime(int whichrow, bool showdate, uInt prec) const
     1059{
    10371060  MEpoch me;
    1038   if (whichrow > -1) {
    1039     me = timeCol(uInt(whichrow));
    1040   } else {
    1041     Double tm;
    1042     table_.keywordSet().get("UTC",tm);
    1043     me = MEpoch(MVEpoch(tm));
    1044   }
    1045   return formatTime(me, showdate);
     1061  me = getEpoch(whichrow);
     1062  return formatTime(me, showdate, prec);
    10461063}
    10471064
     
    17091726}
    17101727
     1728bool Scantable::getFlagtraFast(int whichrow)
     1729{
     1730  uChar flag;
     1731  Vector<uChar> flags;
     1732  flagsCol_.get(uInt(whichrow), flags);
     1733  for (int i = 0; i < flags.size(); i++) {
     1734    if (i==0) {
     1735      flag = flags[i];
     1736    }
     1737    else {
     1738      flag &= flags[i];
     1739    }
     1740    return ((flag >> 7) == 1);
     1741   }
     1742}
     1743
     1744void Scantable::doPolyBaseline(const std::vector<bool>& mask, int order, int rowno, Fitter& fitter)
     1745{
     1746  fitter.setExpression("poly", order);
     1747
     1748  std::vector<double> abcsd = getAbcissa(rowno);
     1749  std::vector<float> abcs;
     1750  for (int i = 0; i < abcsd.size(); i++) {
     1751    abcs.push_back((float)abcsd[i]);
     1752  }
     1753  std::vector<float> spec = getSpectrum(rowno);
     1754  std::vector<bool> fmask = getMask(rowno);
     1755  if (fmask.size() != mask.size()) {
     1756    throw(AipsError("different mask sizes"));
     1757  }
     1758  for (int i = 0; i < fmask.size(); i++) {
     1759    fmask[i] = fmask[i] && mask[i];
     1760  }
     1761  fitter.setData(abcs, spec, fmask);
     1762
     1763  fitter.lfit();
     1764}
     1765
     1766void Scantable::polyBaselineBatch(const std::vector<bool>& mask, int order)
     1767{
     1768  Fitter fitter = Fitter();
     1769  for (uInt rowno=0; rowno < nrow(); ++rowno) {
     1770    doPolyBaseline(mask, order, rowno, fitter);
     1771    setSpectrum(fitter.getResidual(), rowno);
     1772  }
     1773}
     1774
     1775STFitEntry Scantable::polyBaseline(const std::vector<bool>& mask, int order, int rowno)
     1776{
     1777  Fitter fitter = Fitter();
     1778  doPolyBaseline(mask, order, rowno, fitter);
     1779  setSpectrum(fitter.getResidual(), rowno);
     1780  return fitter.getFitEntry();
     1781}
     1782
    17111783}
    17121784//namespace asap
Note: See TracChangeset for help on using the changeset viewer.