Changeset 2593 for trunk/src


Ignore:
Timestamp:
07/09/12 16:54:10 (12 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes/No?

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

New class asapgrid2 is defined. Difference from asapgrid class is
that input and output is a scantable instance, not a table name.


Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STGrid.cpp

    r2478 r2593  
    11851185}
    11861186
     1187void STGrid::table( Table &tab, uInt i )
     1188{
     1189  if ( i >= 0 && i < nfile_ )
     1190    tab = Table( infileList_[i] ) ;
     1191}
     1192
    11871193void STGrid::selectData()
    11881194{
     
    11911197  tableList_.resize( nfile_ ) ;
    11921198  if ( ifno_ == -1 ) {
    1193     Table taborg( infileList_[0] ) ;
     1199    //Table taborg( infileList_[0] ) ;
     1200    Table taborg ;
     1201    table( taborg, 0 ) ;
    11941202    ROScalarColumn<uInt> ifnoCol( taborg, "IFNO" ) ;
    11951203    ifno_ = ifnoCol( 0 ) ;
     
    11981206  }
    11991207  for ( uInt i = 0 ; i < nfile_ ; i++ ) {
    1200     Table taborg( infileList_[i] ) ;
     1208    //Table taborg( infileList_[i] ) ;
     1209    Table taborg ;
     1210    table( taborg, i ) ;
    12011211    TableExprNode node ;
    12021212    if ( ifno != -1 || isMultiIF( taborg ) ) {
     
    16391649  Table tab ;
    16401650  prepareTable( tab, outfile_ ) ;
     1651  fillTable( tab ) ;
     1652
     1653  t1 = mathutil::gettimeofday_sec() ;
     1654  os << LogIO::DEBUGGING << "saveData: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
     1655
     1656  return outfile_ ;
     1657}
     1658
     1659void STGrid::prepareTable( Table &tab, String &name )
     1660{
     1661  Table t( infileList_[0], Table::Old ) ;
     1662  t.deepCopy( name, Table::New, False, t.endianFormat(), True ) ;
     1663  tab = Table( name, Table::Update ) ;
     1664  // 2012/02/13 TN
     1665  // explicitly copy subtables since no rows including subtables are
     1666  // copied by Table::deepCopy with noRows=True
     1667  TableCopy::copySubTables( tab, t ) ;
     1668}
     1669
     1670void STGrid::fillTable( Table &tab )
     1671{
    16411672  IPosition dshape = data_.shape() ;
    16421673  Int nrow = nx_ * ny_ * npol_ ;
     
    16871718  data_.freeStorage( data_p, bdata ) ;
    16881719
    1689   t1 = mathutil::gettimeofday_sec() ;
    1690   os << LogIO::DEBUGGING << "saveData: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    1691 
    16921720  fillMainColumns( tab ) ;
    1693 
    1694   return outfile_ ;
    1695 }
    1696 
    1697 void STGrid::prepareTable( Table &tab, String &name )
    1698 {
    1699   Table t( infileList_[0], Table::Old ) ;
    1700   t.deepCopy( name, Table::New, False, t.endianFormat(), True ) ;
    1701   tab = Table( name, Table::Update ) ;
    1702   // 2012/02/13 TN
    1703   // explicitly copy subtables since no rows including subtables are
    1704   // copied by Table::deepCopy with noRows=True
    1705   TableCopy::copySubTables( tab, t ) ;
    17061721}
    17071722
     
    17791794}
    17801795
    1781 }
     1796// STGrid2
     1797STGrid2::STGrid2()
     1798  : STGrid()
     1799{
     1800}
     1801
     1802STGrid2::STGrid2( const ScantableWrapper &s )
     1803  : STGrid()
     1804{
     1805  setScantable( s ) ;
     1806}
     1807
     1808STGrid2::STGrid2( const vector<ScantableWrapper> &v )
     1809  : STGrid()
     1810{
     1811  setScantableList( v ) ;
     1812}
     1813
     1814void STGrid2::setScantable( const ScantableWrapper &s )
     1815{
     1816  nfile_ = 1 ;
     1817  dataList_.resize( nfile_ ) ;
     1818  dataList_[0] = s ;
     1819  infileList_.resize( nfile_ ) ;
     1820  infileList_[0] = s.getCP()->table().tableName() ;
     1821}
     1822
     1823void STGrid2::setScantableList( const vector<ScantableWrapper> &v )
     1824{
     1825  nfile_ = v.size() ;
     1826  dataList_.resize( nfile_ ) ;
     1827  infileList_.resize( nfile_ ) ;
     1828  for ( uInt i = 0 ; i < nfile_ ; i++ ) {
     1829    dataList_[i] = v[i] ;
     1830    infileList_[i] = v[i].getCP()->table().tableName() ;
     1831  }
     1832}
     1833
     1834ScantableWrapper STGrid2::getResultAsScantable()
     1835{
     1836  CountedPtr<Scantable> s = new Scantable( Table::Plain ) ;
     1837  s->setHeader( dataList_[0].getCP()->getHeader() ) ;
     1838  Table tout, tin ;
     1839  String subt[] = { "FREQUENCIES", "FOCUS", "WEATHER",
     1840                    "TCAL", "MOLECULES", "HISTORY", "FIT" } ;
     1841  for ( uInt i = 0 ; i < 7 ; i++ ) {
     1842    tout = s->table().rwKeywordSet().asTable(subt[i]) ;
     1843    tin = dataList_[0].getCP()->table().rwKeywordSet().asTable(subt[i]) ;
     1844    TableCopy::copyRows( tout, tin ) ;
     1845  }
     1846  fillTable( s->table() ) ;
     1847  ScantableWrapper sw( s ) ;
     1848  return sw ;
     1849}
     1850
     1851void STGrid2::table( Table &tab, uInt i )
     1852{
     1853  if ( i < nfile_ )
     1854    tab = dataList_[i].getCP()->table() ;
     1855}
     1856
     1857}
  • trunk/src/STGrid.h

    r2413 r2593  
    2727#include <tables/Tables/ArrayColumn.h>
    2828
     29#include "ScantableWrapper.h"
     30#include "Scantable.h"
    2931#include "concurrent.h"
    3032
     
    6769  string saveData( string outfile="" ) ;
    6870
    69 private:
     71//private:
     72protected:
    7073  void init() ;
    7174
     
    196199  Bool isMultiIF( Table &tab ) ;
    197200  void fillMainColumns( Table &tab ) ;
     201  void fillTable( Table &tab ) ;
     202  virtual void table( Table &tab, uInt i ) ;
    198203  static bool produceChunk(void *ctx) throw(concurrent::PCException);
    199204  static void consumeChunk(void *ctx) throw(concurrent::PCException);
     
    257262  double eGGridSD_;
    258263};
     264
     265class STGrid2 : public STGrid
     266{
     267public:
     268  STGrid2() ;
     269  STGrid2( const ScantableWrapper &s ) ;
     270  STGrid2( const vector<ScantableWrapper> &v ) ;
     271  void setScantable( const ScantableWrapper &s ) ;
     272  void setScantableList( const vector<ScantableWrapper> &v ) ;
     273  void selectData() ;
     274  virtual void table( Table &tab, uInt i ) ;
     275  ScantableWrapper getResultAsScantable() ;
     276
     277private:
     278  Block<ScantableWrapper> dataList_ ;
     279};
    259280}
    260281#endif
  • trunk/src/python_STGrid.cpp

    r2526 r2593  
    99
    1010#include "STGrid.h"
    11 //#include "STGridWrapper.h"
     11#include "ScantableWrapper.h"
    1212
    1313using namespace boost::python;
     
    1717
    1818void python_STGrid() {
    19   //class_<STGridWrapper>("stgrid")
    2019  class_<STGrid>("stgrid")
    2120    .def( init <> () )
     
    3534    .def("_save", &STGrid::saveData)
    3635    ;
     36
     37  class_<STGrid2>("stgrid2")
     38    .def( init <> () )
     39    .def( init < const ScantableWrapper & > () )
     40    .def( init < const std::vector<ScantableWrapper> & > () )
     41    .def("_setif", &STGrid2::setIF)
     42    .def("_setpollist", &STGrid2::setPolList)
     43    .def("_setscanlist", &STGrid2::setScanList)
     44    .def("_defineimage", &STGrid2::defineImage)
     45    .def("_setfunc", &STGrid2::setFunc)
     46    .def("_grid", &STGrid2::grid)
     47    .def("_setin", &STGrid2::setScantable)
     48    .def("_setfiles", &STGrid2::setScantableList)
     49    .def("_setweight", &STGrid2::setWeight)
     50    .def("_enableclip", &STGrid2::enableClip)
     51    .def("_disableclip", &STGrid2::disableClip)
     52    .def("_get", &STGrid2::getResultAsScantable)
     53    ;
     54   
    3755};
    3856
Note: See TracChangeset for help on using the changeset viewer.