Changeset 1126


Ignore:
Timestamp:
08/10/06 14:16:19 (18 years ago)
Author:
mar637
Message:

added linecatalog to python inteface

Location:
trunk/src
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/LineCatalog.cpp

    r1113 r1126  
    3838  std::string inname = path.expandedName();
    3939  File f(inname);
    40   if (f.isDirectory()) { //assume its a table
     40  if (f.isDirectory()) { //assume it's a table
    4141    table_ = Table(inname);
    4242  } else {
    4343    String formatString;
    4444    // formatSring , TableType, ascii file name, TableDesc name, table name, autoheader
    45   table_ = readAsciiTable(formatString, Table::Plain, inname, "", "", True);
     45    table_ = readAsciiTable(formatString, Table::Plain, inname, "", "", True);
     46    // do not keep aips++ table
     47    table_.markForDelete();
    4648  }
    4749  baseTable_ = table_;
    4850}
    4951
    50 void LineCatalog::setStrengthLimits(float smin, float smax)
     52void LineCatalog::setStrengthLimits(double smin, double smax)
    5153{
    5254  table_ = setLimits(smin, smax, "Column4");
    5355}
    5456
    55 void LineCatalog::setFrequencyLimits(float fmin, float fmax)
     57void LineCatalog::setFrequencyLimits(double fmin, double fmax)
    5658{
    5759  table_ = setLimits(fmin, fmax, "Column2");
     
    6062void LineCatalog::setPattern(const std::string& name, const std::string& stype)
    6163{
    62   std::string mode = stype+"('"+name+"')";
    63   std::string taql = "SELECT from $1 WHERE Column1 == "+mode;
     64  //std::string mode = stype+"('"+name+"')";
     65  std::string taql = "SELECT FROM $1 WHERE Column1 == pattern('"+name+"')";
     66  cerr << taql << endl;
    6467  Table tmp = tableCommand(taql, table_);
    65   if (tmp.nrow() > 0) table_ = tmp;
     68  if (tmp.nrow() > 0) table_ = tmp.sort("Column2");
    6669  else throw(AipsError("No match."));
    6770}
    6871
    69 Table LineCatalog::setLimits(float lmin, float lmax, const std::string& colname)
     72Table LineCatalog::setLimits(double lmin, double lmax, const std::string& colname)
    7073{
    71   Table tmp = table_(table_.col(colname) > lmin && table_.col(colname) > lmax);
    72   if (tmp.nrow() > 0) return tmp;
     74  Table tmp = table_(table_.col(colname) > lmin && table_.col(colname) < lmax);
     75  if (tmp.nrow() > 0) return tmp.sort("Column2");
    7376  else throw(AipsError("No match."));
    7477}
     
    8992  oss << asap::SEPERATOR << endl << endl;
    9093  if (row == -1) {
    91     Vector<uInt> rownrs = table_.rowNumbers(baseTable_);
    92     for (uint i=0; i<rownrs.nelements(); ++i) {
    93       oss << std::right << setw(7) << rownrs[i];
    94       oss << std::left << setw(12) << getName(i);
     94    for (uint i=0; i<table_.nrow(); ++i) {
     95      oss << std::right << setw(7) << i << setw(2) << "";
     96      oss << std::left << setw(20) << getName(i);
    9597      oss << setw(12) << setprecision(8) << std::left << getFrequency(i);
    9698      oss << endl;
    9799    }
    98100  } else {
    99     oss << std::right << setw(7) << row;
    100     oss << std::left << setw(12) << getName(row);
    101     oss << setw(12) << setprecision(8) << std::left << getFrequency(row);
    102     oss << endl;
     101      if ( row < table_.nrow() ) {
     102        oss << std::right << setw(7) << row << setw(2) << "";
     103        oss << std::left << setw(20) << getName(row);
     104        oss << setw(12) << setprecision(8) << std::left << getFrequency(row);
     105        oss << endl;
     106      } else {
     107        throw(AipsError("Row doesn't exist"));
     108      }
    103109  }
    104110  /// @todo implement me
  • trunk/src/LineCatalog.h

    r1113 r1126  
    4949   * @param fmax the upper frequency bound
    5050   */
    51   void setFrequencyLimits(float fmin, float fmax);
     51  void setFrequencyLimits(double fmin, double fmax);
    5252  /**
    5353    * select a subset of the table by line strength range
     
    5555    * @param smin the upper strength bound
    5656    */
    57   void setStrengthLimits(float smin, float smax);
     57  void setStrengthLimits(double smin, double smax);
    5858  /**
    5959    * select a subset of the data by name pattern match (unix-style)
     
    7171  /**
    7272    * Return a string representation of this table
    73     * @param an integer descriing the row number to show
     73    * @param row an integer describing the row number to show
    7474    * default -1 is all rows
    7575    * @return std::string
     
    7777  std::string summary(int row=-1) const;
    7878
     79  /**
     80   * Return the rest frequency value for a specific row
     81   * @param row the row number
     82   * @return a double rest frequency value
     83   */
    7984  double getFrequency(uint row) const;
    8085
     86  /**
     87   *
     88   * @param row
     89   * @return
     90   */
    8191  std::string getName(uint row) const;
     92
     93  int nrow() const  { return table_.nrow(); }
     94
     95  void reset() { table_ = baseTable_; }
    8296
    8397private:
    8498  /**
    85    * utility function to hadle range limits
     99   * utility function to handle range limits
    86100   * @param lmin the lower limit
    87101   * @param lmax the upper limit
     
    89103   * @return a new casa::Table
    90104   */
    91   casa::Table setLimits(float lmin, float lmax, const std::string& colname);
     105  casa::Table setLimits(double lmin, double lmax, const std::string& colname);
    92106
    93107  // the table with seelection
  • trunk/src/python_asap.cpp

    r1112 r1126  
    6363  asap::python::python_STLineFinder();
    6464  asap::python::python_STFitEntry();
    65 
    6665  asap::python::python_STWriter();
     66  asap::python::python_LineCatalog();
    6767
    6868  asap::python::python_Logger();
  • trunk/src/python_asap.h

    r988 r1126  
    4444    void python_STLineFinder();
    4545    void python_STFitEntry();
    46 
    4746    void python_STWriter();
     47    void python_LineCatalog();
    4848    void python_Logger();
    4949
Note: See TracChangeset for help on using the changeset viewer.