Changeset 1534


Ignore:
Timestamp:
03/24/09 12:33:56 (15 years ago)
Author:
Malte Marquarding
Message:

Fix for Ticket #90; treating integer as double columns now

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/linecatalog.py

    r1259 r1534  
    11"""
    2 A representation of a spectra line catalog.
     2A representation of a spectral line catalog.
    33
    44Author: Malte Marquarding
     
    3434            else:
    3535                raise IOError(msg)
     36
     37    def __repr__(self):
     38        return lcbase.summary(self, -1)
    3639
    3740    def summary(self):
  • trunk/src/LineCatalog.cpp

    r1259 r1534  
    6262void LineCatalog::setPattern(const std::string& name, const std::string& stype)
    6363{
    64   //std::string mode = stype+"('"+name+"')";
    65   std::string taql = "SELECT FROM $1 WHERE Column1 == pattern('"+name+"')";
    66   cerr << taql << endl;
     64  std::string mode = stype+"('"+name+"')";
     65  std::string taql = "SELECT FROM $1 WHERE Column1 == " + mode;
    6766  Table tmp = tableCommand(taql, table_);
    6867  if (tmp.nrow() > 0) table_ = tmp.sort("Column2");
     
    110109      }
    111110  }
    112   /// @todo implement me
    113111  return String(oss);
    114112}
    115113
    116 /*!
    117     \fn asap::LineCatalog::getName(int row)
    118  */
     114
    119115std::string LineCatalog::getName(uint row) const
    120116{
     
    123119}
    124120
    125 double asap::LineCatalog::getFrequency(uint row) const
     121double LineCatalog::getFrequency(uint row) const
    126122{
    127   ROScalarColumn<Double> col(table_, "Column2");
    128   return col(row);
     123  return getDouble("Column2", row);
    129124}
    130125
    131 double asap::LineCatalog::getStrength(uint row) const
     126double LineCatalog::getStrength(uint row) const
    132127{
    133   ROScalarColumn<Double> col(table_, "Column3");
    134   return col(row);
     128  return getDouble("Column4", row);
    135129}
    136130
     131double LineCatalog::getDouble(const std::string& colname, uint row) const {
     132  DataType dtype = table_.tableDesc().columnDesc(colname).dataType();
     133  if (dtype == TpDouble) {
     134    ROScalarColumn<Double> col(table_, colname);
     135    return col(row);
     136  } else if (dtype == TpInt) {
     137    ROScalarColumn<Int> col(table_, colname);
     138    return Double(col(row));
     139  } else {
     140    throw AipsError("Column " + colname + "doesn't contain numerical values." );
     141  }
     142}
    137143
    138144} // namespace
  • trunk/src/LineCatalog.h

    r1353 r1534  
    111111  casa::Table setLimits(double lmin, double lmax, const std::string& colname);
    112112
     113  double getDouble(const std::string& colname, uint row) const;
     114
    113115  // the table with seelection
    114116  casa::Table table_;
Note: See TracChangeset for help on using the changeset viewer.