Changeset 972


Ignore:
Timestamp:
04/03/06 15:07:08 (18 years ago)
Author:
mar637
Message:

Completed Ticket #7 - storing of fits.

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STFiller.cpp

    r942 r972  
    227227    TableRow row(table_->table());
    228228    TableRecord& rec = row.record();
     229    RecordFieldPtr<Int> fitCol(rec, "FIT_ID");
     230    *fitCol = -1;
    229231    RecordFieldPtr<uInt> scanoCol(rec, "SCANNO");
    230232    *scanoCol = scanNo-1;
  • trunk/src/STFit.cpp

    r960 r972  
    8484{
    8585  uInt rno = table_.nrow();
    86   uInt resultid;
     86  uInt resultid = 0;
    8787  bool foundentry = false;
     88  // replace
    8889  if ( id > -1 ) {
    8990    Table t = table_(table_.col("ID") == id );
     
    9495    }
    9596  }
     97  // doesn't exist
    9698  if ( rno > 0  && !foundentry ) {
    9799    idCol_.get(rno-1, resultid);
    98100    resultid++;
    99101  }
    100   if ( !foundentry )table_.addRow();
    101 
     102  // add new row if new id
     103  if ( !foundentry ) table_.addRow();
     104  cout << rno << "   " << resultid << endl;
    102105  funcCol_.put(rno, mathutil::toVectorString(fit.getFunctions()));
    103106  compCol_.put(rno, Vector<Int>(fit.getComponents()));
     
    109112}
    110113
    111 void STFit::getEntry( STFitEntry& fit, uInt id )
     114void STFit::getEntry( STFitEntry& fit, uInt id ) const
    112115{
    113116  Table t = table_(table_.col("ID") == Int(id) );
  • trunk/src/STFit.h

    r960 r972  
    3939
    4040  casa::uInt addEntry( const STFitEntry& fit, casa::Int id=-1 );
    41   void getEntry( STFitEntry& fit, casa::uInt id );
     41  void getEntry( STFitEntry& fit, casa::uInt id ) const;
    4242
    4343  const casa::String& name() const { return name_; }
     
    4646  void setup();
    4747  static const casa::String name_;
    48   //casa::Table table_;
    4948  casa::ArrayColumn<casa::String> funcCol_;
    5049  casa::ArrayColumn<casa::Int> compCol_;
  • trunk/src/STFitEntry.cpp

    r955 r972  
    22// C++ Implementation: STFitEntry
    33//
    4 // Description: 
     4// Description:
    55//
    66//
     
    1717{
    1818}
     19STFitEntry::STFitEntry(const STFitEntry& other)
     20{
     21  if ( this != &other ) {
     22    this->functions_ = other.functions_;
     23    this->components_ = other.components_;
     24    this->parameters_ = other.parameters_;
     25    this->parmasks_ = other.parmasks_;
     26    this->frameinfo_ = other.frameinfo_;
     27  }
     28}
    1929
    2030
  • trunk/src/STFitEntry.h

    r960 r972  
    2626public:
    2727  STFitEntry();
    28  
     28  STFitEntry(const STFitEntry& other);
     29
    2930  ~STFitEntry();
    30  
     31
    3132  void setFunctions(const std::vector<std::string>& f)
    3233    { functions_ = f; }
  • trunk/src/Scantable.cpp

    r959 r972  
    9494  originalTable_ = table_;
    9595  attach();
     96  TableVector<Int> v(table_,"FIT_ID");v=666;
     97  table_.flush();
     98  Vector<Int> v2 = mfitidCol_.getColumn();cout << v2 << endl;
    9699}
    97100
     
    153156  t = table_.rwKeywordSet().asTable("HISTORY");
    154157  TableCopy::copyRows(t, other.historyTable_.table());
     158  t = table_.rwKeywordSet().asTable("FIT");
     159  TableCopy::copyRows(t, other.fitTable_.table());
    155160}
    156161
     
    163168  moleculeTable_ = STMolecules(table_);
    164169  historyTable_ = STHistory(table_);
     170  fitTable_ = STFit(table_);
    165171}
    166172
     
    183189  td.addColumn(ScalarColumnDesc<uInt>("BEAMNO"));
    184190  td.addColumn(ScalarColumnDesc<uInt>("IFNO"));
     191  // linear, circular, stokes
    185192  td.rwKeywordSet().define("POLTYPE", String("linear"));
    186193  td.addColumn(ScalarColumnDesc<uInt>("POLNO"));
     
    188195  td.addColumn(ScalarColumnDesc<uInt>("FREQ_ID"));
    189196  td.addColumn(ScalarColumnDesc<uInt>("MOLECULE_ID"));
    190   // linear, circular, stokes [I Q U V], stokes1 [I Plinear Pangle V]
    191197  td.addColumn(ScalarColumnDesc<Int>("REFBEAMNO"));
    192198
     
    223229
    224230  td.addColumn(ScalarColumnDesc<uInt>("TCAL_ID"));
    225   td.addColumn(ScalarColumnDesc<uInt>("FIT_ID"));
     231  ScalarColumnDesc<Int> fitColumn("FIT_ID");
     232  fitColumn.setDefault(Int(666));
     233  td.addColumn(fitColumn);
    226234
    227235  td.addColumn(ScalarColumnDesc<uInt>("FOCUS_ID"));
     
    234242  table_ = Table(aNewTab, type_, 0);
    235243  originalTable_ = table_;
    236 
    237244}
    238245
     
    259266
    260267  mfitidCol_.attach(table_,"FIT_ID");
    261   //fitidCol_.attach(fitTable_,"FIT_ID");
    262 
    263268  mfreqidCol_.attach(table_, "FREQ_ID");
    264 
    265269  mtcalidCol_.attach(table_, "TCAL_ID");
    266 
    267270  mfocusidCol_.attach(table_, "FOCUS_ID");
    268 
    269271  mmolidCol_.attach(table_, "MOLECULE_ID");
    270272}
     
    841843    Vector<String> wau(1);wau = u.getName();
    842844    spc.setWorldAxisUnits(wau);
    843 
    844845    s = CoordinateUtil::axisLabel(spc,0,True,True,False);
    845846  }
     
    895896{
    896897  return MEpoch::castType(timeCol_.getMeasRef().getType());
    897   }
    898 
     898}
     899
     900void asap::Scantable::addFit( const STFitEntry & fit, int row )
     901{
     902  cout << mfitidCol_(uInt(row)) << endl;
     903  uInt id = fitTable_.addEntry(fit, mfitidCol_(uInt(row)));
     904  mfitidCol_.put(uInt(row), id);
     905}
    899906
    900907} //namespace asap
  • trunk/src/Scantable.h

    r960 r972  
    4141#include "STPol.h"
    4242#include "STFit.h"
     43#include "STFitEntry.h"
    4344
    4445namespace asap {
     
    306307  STMolecules& molecules() { return moleculeTable_; }
    307308  STHistory& history() { return historyTable_; }
     309  STFit& fit() { return fitTable_; }
    308310
    309311  std::vector<std::string> columnNames() const;
     312
     313  void addFit(const STFitEntry& fit, int row);
     314  STFitEntry getFit(int row) const
     315    { STFitEntry fe; fitTable_.getEntry(fe, mfitidCol_(row)); return fe; }
    310316
    311317private:
     
    393399
    394400  casa::ArrayColumn<casa::String> histitemCol_;
    395   casa::ScalarColumn<casa::uInt> mfitidCol_;
    396   // id in weather table and main table
     401  casa::ScalarColumn<casa::Int> mfitidCol_;
    397402  casa::ScalarColumn<casa::uInt> mweatheridCol_;
    398403
  • trunk/src/ScantableWrapper.h

    r925 r972  
    166166  void addHistory(const std::string& hist)
    167167    { table_->addHistory(hist); }
    168   /*
    169   void addFit(int whichrow, const std::vector<double>& p,
    170               const std::vector<bool>& m, const std::vector<string>& f,
    171               const std::vector<int>& c) {
    172168
    173     casa::Vector<casa::Double> p2(p);
    174     casa::Vector<casa::Bool> m2(m);
    175     casa::Vector<casa::String> f2 = mathutil::toVectorString(f);
    176     casa::Vector<casa::Int> c2(c);
    177     table_->addFit(casa::uInt(whichrow), p2,m2,f2,c2);
    178   }
    179   SDFitTable getSDFitTable(int whichrow) {
    180     return table_->getSDFitTable(casa::uInt(whichrow));
    181   }
    182   */
     169  void addFit(const STFitEntry& fit, int row)
     170    { table_->addFit(fit, row); }
     171
     172  STFitEntry getFit(int whichrow) const
     173  { return table_->getFit(whichrow); }
     174
    183175  void calculateAZEL() { table_->calculateAZEL(); };
    184176
  • trunk/src/python_STFitEntry.cpp

    r960 r972  
    2727//#                        AUSTRALIA
    2828//#
    29 //# $Id:$
     29//# $Id$
    3030//#---------------------------------------------------------------------------
    3131#include <boost/python.hpp>
     
    4141      class_<STFitEntry>("fitentry")
    4242        .def( init <> () )
     43        .def( init < const STFitEntry& > () )
    4344        .def("getfixedparameters", &STFitEntry::getParmasks)
    4445        .def("getparameters", &STFitEntry::getParameters)
     
    4647        .def("getcomponents", &STFitEntry::getComponents)
    4748        .def("getframeinfo", &STFitEntry::getFrameinfo)
     49        .def("setfixedparameters", &STFitEntry::setParmasks)
     50        .def("setparameters", &STFitEntry::setParameters)
     51        .def("setfunctions", &STFitEntry::setFunctions)
     52        .def("setcomponents", &STFitEntry::setComponents)
     53        .def("setframeinfo", &STFitEntry::setFrameinfo)
    4854      ;
    4955    };
  • trunk/src/python_Scantable.cpp

    r925 r972  
    103103    .def("_getselection", &ScantableWrapper::getSelection)
    104104    .def("_setselection", &ScantableWrapper::setSelection)
    105     /*
    106105    .def("_addfit", &ScantableWrapper::addFit)
    107     .def("_getfit", &ScantableWrapper::getSDFitTable)
    108     */
     106    .def("_getfit", &ScantableWrapper::getFit)
    109107    .def("_recalcazel", &ScantableWrapper::calculateAZEL)
    110108  ;
Note: See TracChangeset for help on using the changeset viewer.