Changeset 2459 for branches/hpc33/src


Ignore:
Timestamp:
04/09/12 18:49:51 (13 years ago)
Author:
Kana Sugimoto
Message:

merged Takeshi's fix to asapgrid and STGrid class form trunk

Location:
branches/hpc33/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/hpc33/src/STGrid.cpp

    r2398 r2459  
    1 #include <iostream>
    2 #include <fstream>
    3 #include <cfloat>
    4 
     1//
     2// C++ Implementation: STGrid
     3//
     4// Description:
     5//
     6//
     7// Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp>, (C) 2011
     8//
     9// Copyright: See COPYING file that comes with this distribution
     10//
     11//
    512#include <casa/BasicSL/String.h>
    613#include <casa/Arrays/Vector.h>
    7 #include <casa/Arrays/Matrix.h>
    8 #include <casa/Arrays/Cube.h>
    914#include <casa/Arrays/ArrayMath.h>
    10 #include <casa/Arrays/ArrayIter.h>
    1115#include <casa/Quanta/Quantum.h>
    1216#include <casa/Quanta/QuantumHolder.h>
     
    1620#include <tables/Tables/Table.h>
    1721#include <tables/Tables/TableRecord.h>
     22#include <tables/Tables/TableRow.h>
    1823#include <tables/Tables/ExprNode.h>
    1924#include <tables/Tables/ScalarColumn.h>
    2025#include <tables/Tables/ArrayColumn.h>
    21 #include <tables/Tables/TableIter.h>
     26#include <tables/Tables/TableCopy.h>
    2227
    2328#include <measures/Measures/MDirection.h>
    2429
    25 #include <MathUtils.h>
     30#include "MathUtils.h"
     31#include <atnf/PKSIO/SrcType.h>
    2632
    2733#include "STGrid.h"
     
    407413  selectData() ;
    408414  t1 = mathutil::gettimeofday_sec() ;
    409   os << "selectData: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
     415  os << LogIO::DEBUGGING << "selectData: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    410416
    411417  setupGrid() ;
     
    640646  setConvFunc( common.convFunc ) ;
    641647  t1 = mathutil::gettimeofday_sec() ;
    642   os << "setConvFunc: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
     648  os << LogIO::DEBUGGING << "setConvFunc: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    643649
    644650  // for performance check
     
    681687    os << "end table " << ifile << LogIO::POST ;   
    682688  }
    683   os << "initPol: elapsed time is " << eInitPol << " sec." << LogIO::POST ;
    684   os << "getData: elapsed time is " << eGetData_-eToInt-eGetWeight << " sec." << LogIO::POST ;
    685   os << "toPixel: elapsed time is " << eToPixel_ << " sec." << LogIO::POST ;
    686   os << "ggridsd: elapsed time is " << eGGridSD_ << " sec." << LogIO::POST ;
    687   os << "toInt: elapsed time is " << eToInt << " sec." << LogIO::POST ;
    688   os << "getWeight: elapsed time is " << eGetWeight << " sec." << LogIO::POST ;
     689  os << LogIO::DEBUGGING << "initPol: elapsed time is " << eInitPol << " sec." << LogIO::POST ;
     690  os << LogIO::DEBUGGING << "getData: elapsed time is " << eGetData_-eToInt-eGetWeight << " sec." << LogIO::POST ;
     691  os << LogIO::DEBUGGING << "toPixel: elapsed time is " << eToPixel_ << " sec." << LogIO::POST ;
     692  os << LogIO::DEBUGGING << "ggridsd: elapsed time is " << eGGridSD_ << " sec." << LogIO::POST ;
     693  os << LogIO::DEBUGGING << "toInt: elapsed time is " << eToInt << " sec." << LogIO::POST ;
     694  os << LogIO::DEBUGGING << "getWeight: elapsed time is " << eGetWeight << " sec." << LogIO::POST ;
    689695 
    690696  delete chanMap ;
     
    790796  setConvFunc( common.convFunc ) ;
    791797  t1 = mathutil::gettimeofday_sec() ;
    792   os << "setConvFunc: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
     798  os << LogIO::DEBUGGING << "setConvFunc: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    793799
    794800  // for performance check
     
    831837    os << "end table " << ifile << LogIO::POST ;   
    832838  }
    833   os << "initPol: elapsed time is " << eInitPol << " sec." << LogIO::POST ;
    834   os << "getData: elapsed time is " << eGetData_-eToInt-eGetWeight << " sec." << LogIO::POST ;
    835   os << "toPixel: elapsed time is " << eToPixel_ << " sec." << LogIO::POST ;
    836   os << "ggridsd2: elapsed time is " << eGGridSD_ << " sec." << LogIO::POST ;
    837   os << "toInt: elapsed time is " << eToInt << " sec." << LogIO::POST ;
    838   os << "getWeight: elapsed time is " << eGetWeight << " sec." << LogIO::POST ;
     839  os << LogIO::DEBUGGING << "initPol: elapsed time is " << eInitPol << " sec." << LogIO::POST ;
     840  os << LogIO::DEBUGGING << "getData: elapsed time is " << eGetData_-eToInt-eGetWeight << " sec." << LogIO::POST ;
     841  os << LogIO::DEBUGGING << "toPixel: elapsed time is " << eToPixel_ << " sec." << LogIO::POST ;
     842  os << LogIO::DEBUGGING << "ggridsd2: elapsed time is " << eGGridSD_ << " sec." << LogIO::POST ;
     843  os << LogIO::DEBUGGING << "toInt: elapsed time is " << eToInt << " sec." << LogIO::POST ;
     844  os << LogIO::DEBUGGING << "getWeight: elapsed time is " << eGetWeight << " sec." << LogIO::POST ;
    839845 
    840846  delete chanMap ;
     
    855861              common.clipCMax ) ;
    856862  t1 = mathutil::gettimeofday_sec() ;
    857   os << "clipMinMax: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
     863  os << LogIO::DEBUGGING << "clipMinMax: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    858864//   os << "AFTER CLIPPING" << LogIO::POST ;
    859865//   os << "gdataArrC=" << common.gdataArrC << LogIO::POST ;
     
    960966  }
    961967  else
    962     ptab_ = tab_( tab_.col("POLNO") == (uInt)ipol ) ;
     968    ptab_ = tab_( tab_.col("POLNO") == pollist_[ipol] ) ;
    963969
    964970  attach( ptab_ ) ;
     
    9961002  data_.putStorage( gwgt_p, b2 ) ;
    9971003  t1 = mathutil::gettimeofday_sec() ;
    998   os << "setData: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
     1004  os << LogIO::DEBUGGING << "setData: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
    9991005}
    10001006
     
    11111117  }
    11121118  cellx_ = qcellx.getValue( "rad" ) ;
     1119  // DEC correction
     1120  cellx_ /= cos( center_[1] ) ;
    11131121  celly_ = qcelly.getValue( "rad" ) ;
     1122  //os << "cellx_=" << cellx_ << ", celly_=" << celly_ << ", cos("<<center_(1)<<")=" << cos(center_(1)) << LogIO::POST ;
    11141123  if ( nx_ < 0 ) {
    11151124    if ( wx == 0.0 ) {
     
    11561165  Int ifno = ifno_ ;
    11571166  tableList_.resize( nfile_ ) ;
    1158   if ( ifno == -1 ) {
     1167  if ( ifno_ == -1 ) {
    11591168    Table taborg( infileList_[0] ) ;
    11601169    ROScalarColumn<uInt> ifnoCol( taborg, "IFNO" ) ;
    1161     ifno = ifnoCol( 0 ) ;
     1170    ifno_ = ifnoCol( 0 ) ;
    11621171    os << LogIO::WARN
    1163        << "IFNO is not given. Using default IFNO: " << ifno << LogIO::POST ;
     1172       << "IFNO is not given. Using default IFNO: " << ifno_ << LogIO::POST ;
    11641173  }
    11651174  for ( uInt i = 0 ; i < nfile_ ; i++ ) {
    11661175    Table taborg( infileList_[i] ) ;
    11671176    TableExprNode node ;
    1168     if ( isMultiIF( taborg ) ) {
     1177    if ( ifno != -1 || isMultiIF( taborg ) ) {
    11691178      os << "apply selection on IFNO" << LogIO::POST ;
    1170       node = taborg.col("IFNO") == ifno ;
     1179      node = taborg.col("IFNO") == ifno_ ;
    11711180    }
    11721181    if ( scanlist_.size() > 0 ) {
     
    11801189      tableList_[i] = taborg( node ) ;
    11811190    }
    1182     os << "tableList_[" << i << "].nrow()=" << tableList_[i].nrow() << LogIO::POST ;
     1191    os << LogIO::DEBUGGING << "tableList_[" << i << "].nrow()=" << tableList_[i].nrow() << LogIO::POST ;
    11831192    if ( tableList_[i].nrow() == 0 ) {
    11841193      os << LogIO::SEVERE
    1185          << "No corresponding rows for given selection: IFNO " << ifno ;
     1194         << "No corresponding rows for given selection: IFNO " << ifno_ ;
    11861195      if ( scanlist_.size() > 0 )
    11871196        os << " SCANNO " << scanlist_ ;
     
    15651574    // to take into account Gaussian tail
    15661575    if ( convSupport_ < 0 )
    1567       convSupport_ = 12 ; // 3 * 4
     1576      convSupport_ = 4 ; // 1 * 4
    15681577    else {
    15691578      convSupport_ = userSupport_ * 4 ;
     
    16501659
    16511660  t1 = mathutil::gettimeofday_sec() ;
    1652   os << "saveData: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
     1661  os << LogIO::DEBUGGING << "saveData: elapsed time is " << t1-t0 << " sec." << LogIO::POST ;
     1662
     1663  fillMainColumns( tab ) ;
    16531664
    16541665  return outfile_ ;
     
    16601671  t.deepCopy( name, Table::New, False, t.endianFormat(), True ) ;
    16611672  tab = Table( name, Table::Update ) ;
    1662 }
    1663 
    1664 }
     1673  // 2012/02/13 TN
     1674  // explicitly copy subtables since no rows including subtables are
     1675  // copied by Table::deepCopy with noRows=True
     1676  TableCopy::copySubTables( tab, t ) ;
     1677}
     1678
     1679void STGrid::fillMainColumns( Table &tab )
     1680{
     1681  // values for fill
     1682  Table t( infileList_[0], Table::Old ) ;
     1683  Table tsel = t( t.col( "IFNO" ) == (uInt)ifno_, 1 ) ;
     1684  ROTableRow row( tsel ) ;
     1685  row.get( 0 ) ;
     1686  const TableRecord &rec = row.record() ;
     1687  uInt freqId = rec.asuInt( "FREQ_ID" ) ;
     1688  uInt molId = rec.asuInt( "MOLECULE_ID" ) ;
     1689  uInt tcalId = rec.asuInt( "TCAL_ID" ) ;
     1690  uInt focusId = rec.asuInt( "FOCUS_ID" ) ;
     1691  uInt weatherId = rec.asuInt( "WEATHER_ID" ) ;
     1692  String srcname = rec.asString( "SRCNAME" ) ;
     1693  String fieldname = rec.asString( "FIELDNAME" ) ;
     1694  Vector<Float> defaultTsys( 1, 1.0 ) ;
     1695  // @todo how to set flagtra for gridded spectra?
     1696  Vector<uChar> flagtra = rec.asArrayuChar( "FLAGTRA" ) ;
     1697  flagtra = (uChar)0 ;
     1698  Float opacity = rec.asFloat( "OPACITY" ) ;
     1699  Double srcvel = rec.asDouble( "SRCVELOCITY" ) ;
     1700  Vector<Double> srcpm = rec.asArrayDouble( "SRCPROPERMOTION" ) ;
     1701  Vector<Double> srcdir = rec.asArrayDouble( "SRCDIRECTION" ) ;
     1702  Vector<Double> scanrate = rec.asArrayDouble( "SCANRATE" ) ;
     1703  Double time = rec.asDouble( "TIME" ) ;
     1704  Double interval = rec.asDouble( "INTERVAL" ) ;
     1705
     1706  // fill columns
     1707  Int nrow = tab.nrow() ;
     1708  ScalarColumn<uInt> scannoCol( tab, "SCANNO" ) ;
     1709  ScalarColumn<uInt> ifnoCol( tab, "IFNO" ) ;
     1710  ScalarColumn<uInt> freqIdCol( tab, "FREQ_ID" ) ;
     1711  ScalarColumn<uInt> molIdCol( tab, "MOLECULE_ID" ) ;
     1712  ScalarColumn<uInt> tcalidCol( tab, "TCAL_ID" ) ;
     1713  ScalarColumn<Int> fitidCol( tab, "FIT_ID" ) ;
     1714  ScalarColumn<uInt> focusidCol( tab, "FOCUS_ID" ) ;
     1715  ScalarColumn<uInt> weatheridCol( tab, "WEATHER_ID" ) ;
     1716  ArrayColumn<uChar> flagtraCol( tab, "FLAGTRA" ) ;
     1717  ScalarColumn<uInt> rflagCol( tab, "FLAGROW" ) ;
     1718  ArrayColumn<Float> tsysCol( tab, "TSYS" ) ;
     1719  ScalarColumn<String> srcnameCol( tab, "SRCNAME" ) ;
     1720  ScalarColumn<String> fieldnameCol( tab, "FIELDNAME" ) ;
     1721  ScalarColumn<Int> srctypeCol( tab, "SRCTYPE" ) ;
     1722  ScalarColumn<Float> opacityCol( tab, "OPACITY" ) ;
     1723  ScalarColumn<Double> srcvelCol( tab, "SRCVELOCITY" ) ;
     1724  ArrayColumn<Double> srcpmCol( tab, "SRCPROPERMOTION" ) ;
     1725  ArrayColumn<Double> srcdirCol( tab, "SRCDIRECTION" ) ;
     1726  ArrayColumn<Double> scanrateCol( tab, "SCANRATE" ) ;
     1727  ScalarColumn<Double> timeCol( tab, "TIME" ) ;
     1728  ScalarColumn<Double> intervalCol( tab, "INTERVAL" ) ;
     1729  for ( Int i = 0 ; i < nrow ; i++ ) {
     1730    scannoCol.put( i, (uInt)i ) ;
     1731    ifnoCol.put( i, (uInt)ifno_ ) ;
     1732    freqIdCol.put( i, freqId ) ;
     1733    molIdCol.put( i, molId ) ;
     1734    tcalidCol.put( i, tcalId ) ;
     1735    fitidCol.put( i, -1 ) ;
     1736    focusidCol.put( i, focusId ) ;
     1737    weatheridCol.put( i, weatherId ) ;
     1738    flagtraCol.put( i, flagtra ) ;
     1739    rflagCol.put( i, 0 ) ;
     1740    tsysCol.put( i, defaultTsys ) ;
     1741    srcnameCol.put( i, srcname ) ;
     1742    fieldnameCol.put( i, fieldname ) ;
     1743    srctypeCol.put( i, (Int)SrcType::PSON ) ;
     1744    opacityCol.put( i, opacity ) ;
     1745    srcvelCol.put( i, srcvel ) ;
     1746    srcpmCol.put( i, srcpm ) ;
     1747    srcdirCol.put( i, srcdir ) ;
     1748    scanrateCol.put( i, scanrate ) ;
     1749    timeCol.put( i, time ) ;
     1750    intervalCol.put( i, interval ) ;
     1751  }
     1752}
     1753
     1754}
  • branches/hpc33/src/STGrid.h

    r2398 r2459  
    195195  void initTable( uInt idx ) ;
    196196  Bool isMultiIF( Table &tab ) ;
     197  void fillMainColumns( Table &tab ) ;
    197198  static bool produceChunk(void *ctx) throw(concurrent::PCException);
    198199  static void consumeChunk(void *ctx) throw(concurrent::PCException);
Note: See TracChangeset for help on using the changeset viewer.