Changeset 2459 for branches/hpc33
- Timestamp:
- 04/09/12 18:49:51 (13 years ago)
- Location:
- branches/hpc33
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/hpc33/python/asapgrid.py
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/python/asapgrid.py merged eligible /branches/alma/python/asapgrid.py 1386-1818 /branches/asap4casa3.1.0/python/asapgrid.py 1935-1936,1940
r2397 r2459 105 105 numerical value and unit, e.g. '0.5arcmin', or numerical value. 106 106 If those values are specified as numerical value, their units 107 will be assumed to 'arc min'. If which of those is not specified,107 will be assumed to 'arcsec'. If which of those is not specified, 108 108 it will be set to the same value as the other. If none of them 109 109 are specified, it will be determined from map extent and number … … 130 130 """ 131 131 if not isinstance( cellx, str ): 132 cellx = '%sarc min'%(cellx)132 cellx = '%sarcsec'%(cellx) 133 133 if not isinstance( celly, str ): 134 celly = '%sarc min'%(celly)134 celly = '%sarcsec'%(celly) 135 135 self.gridder._defineimage( nx, ny, cellx, celly, center ) 136 136 … … 145 145 'box': 1 pixel 146 146 'sf': 3 pixels 147 'gauss': 3 pixels(width is used as HWHM)147 'gauss': 1 pixel (width is used as HWHM) 148 148 149 149 func -- Function type ('box', 'sf', 'gauss'). … … 265 265 idx = 0 266 266 d0 = s.get_direction( 0 ).split()[-1] 267 while ( s.get_direction(self.npol*idx).split()[-1] == d0 ): 267 while ( s.get_direction(self.npol*idx) is not None \ 268 and s.get_direction(self.npol*idx).split()[-1] == d0 ): 268 269 idx += 1 269 270 … … 276 277 #print self.blc 277 278 #print self.trc 278 incrx = s.get_directionval( self.npol ) 279 incry = s.get_directionval( self.nx*self.npol ) 279 if nrow > 1: 280 incrx = s.get_directionval( self.npol ) 281 incry = s.get_directionval( self.nx*self.npol ) 282 else: 283 incrx = [0.0,0.0] 284 incry = [0.0,0.0] 280 285 self.cellx = abs( self.blc[0] - incrx[0] ) 281 286 self.celly = abs( self.blc[1] - incry[1] ) … … 287 292 else: 288 293 opt = 'pol %s'%(pol) 289 if chan < 0: 294 if type(chan) is list: 295 opt += ', averaged over channel %s-%s'%(chan[0],chan[1]) 296 elif chan < 0: 290 297 opt += ', averaged over channel' 291 298 else: 292 299 opt += ', channel %s'%(chan) 293 data = self.getData( chan, pol ) 300 data = self.getData( chan, pol ) 301 data = numpy.fliplr( data ) 294 302 title = 'Gridded Image (%s)'%(opt) 295 303 pl.figure(10) … … 319 327 #print irow 320 328 # show image 321 extent=[self. blc[0]-0.5*self.cellx,322 self. trc[0]+0.5*self.cellx,329 extent=[self.trc[0]+0.5*self.cellx, 330 self.blc[0]-0.5*self.cellx, 323 331 self.blc[1]-0.5*self.celly, 324 332 self.trc[1]+0.5*self.celly] 333 deccorr = 1.0/numpy.cos(0.5*(self.blc[1]+self.trc[1])) 325 334 pl.imshow(data,extent=extent,origin='lower',interpolation='nearest') 326 335 pl.colorbar() 327 336 pl.xlabel('R.A. [rad]') 328 337 pl.ylabel('Dec. [rad]') 338 ax = pl.axes() 339 ax.set_aspect(deccorr) 329 340 pl.title( title ) 330 341 … … 359 370 360 371 def getData( self, chan=-1, pol=-1 ): 361 if chan == -1: 372 if type(chan) == list: 373 spectra = self.__chanAverage(start=chan[0],end=chan[1]) 374 elif chan == -1: 362 375 spectra = self.__chanAverage() 363 376 else: … … 370 383 return retval 371 384 372 def __chanAverage( self ):385 def __chanAverage( self, start=-1, end=-1 ): 373 386 s = scantable( self.outfile, average=False ) 374 387 nrow = s.nrow() … … 376 389 irow = 0 377 390 sp = [0 for i in xrange(self.nchan)] 391 if start < 0: 392 start = 0 393 if end < 0: 394 end = self.nchan 378 395 for i in xrange(nrow/self.npol): 379 396 for ip in xrange(self.npol): 380 sp = s._getspectrum( irow ) 397 sp = s._getspectrum( irow )[start:end] 381 398 spectra[ip,i] = numpy.mean( sp ) 382 399 irow += 1 400 383 401 return spectra 384 402 -
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/hpc33/src/STGrid.cpp
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/src/STGrid.cpp merged eligible /branches/alma/src/STGrid.cpp 1386-1818 /branches/asap4casa3.1.0/src/STGrid.cpp 1935-1936,1940 /branches/parallel/src/STGrid.cpp 2196-2288
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 // 5 12 #include <casa/BasicSL/String.h> 6 13 #include <casa/Arrays/Vector.h> 7 #include <casa/Arrays/Matrix.h>8 #include <casa/Arrays/Cube.h>9 14 #include <casa/Arrays/ArrayMath.h> 10 #include <casa/Arrays/ArrayIter.h>11 15 #include <casa/Quanta/Quantum.h> 12 16 #include <casa/Quanta/QuantumHolder.h> … … 16 20 #include <tables/Tables/Table.h> 17 21 #include <tables/Tables/TableRecord.h> 22 #include <tables/Tables/TableRow.h> 18 23 #include <tables/Tables/ExprNode.h> 19 24 #include <tables/Tables/ScalarColumn.h> 20 25 #include <tables/Tables/ArrayColumn.h> 21 #include <tables/Tables/Table Iter.h>26 #include <tables/Tables/TableCopy.h> 22 27 23 28 #include <measures/Measures/MDirection.h> 24 29 25 #include <MathUtils.h> 30 #include "MathUtils.h" 31 #include <atnf/PKSIO/SrcType.h> 26 32 27 33 #include "STGrid.h" … … 407 413 selectData() ; 408 414 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 ; 410 416 411 417 setupGrid() ; … … 640 646 setConvFunc( common.convFunc ) ; 641 647 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 ; 643 649 644 650 // for performance check … … 681 687 os << "end table " << ifile << LogIO::POST ; 682 688 } 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 ; 689 695 690 696 delete chanMap ; … … 790 796 setConvFunc( common.convFunc ) ; 791 797 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 ; 793 799 794 800 // for performance check … … 831 837 os << "end table " << ifile << LogIO::POST ; 832 838 } 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 ; 839 845 840 846 delete chanMap ; … … 855 861 common.clipCMax ) ; 856 862 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 ; 858 864 // os << "AFTER CLIPPING" << LogIO::POST ; 859 865 // os << "gdataArrC=" << common.gdataArrC << LogIO::POST ; … … 960 966 } 961 967 else 962 ptab_ = tab_( tab_.col("POLNO") == (uInt)ipol) ;968 ptab_ = tab_( tab_.col("POLNO") == pollist_[ipol] ) ; 963 969 964 970 attach( ptab_ ) ; … … 996 1002 data_.putStorage( gwgt_p, b2 ) ; 997 1003 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 ; 999 1005 } 1000 1006 … … 1111 1117 } 1112 1118 cellx_ = qcellx.getValue( "rad" ) ; 1119 // DEC correction 1120 cellx_ /= cos( center_[1] ) ; 1113 1121 celly_ = qcelly.getValue( "rad" ) ; 1122 //os << "cellx_=" << cellx_ << ", celly_=" << celly_ << ", cos("<<center_(1)<<")=" << cos(center_(1)) << LogIO::POST ; 1114 1123 if ( nx_ < 0 ) { 1115 1124 if ( wx == 0.0 ) { … … 1156 1165 Int ifno = ifno_ ; 1157 1166 tableList_.resize( nfile_ ) ; 1158 if ( ifno == -1 ) {1167 if ( ifno_ == -1 ) { 1159 1168 Table taborg( infileList_[0] ) ; 1160 1169 ROScalarColumn<uInt> ifnoCol( taborg, "IFNO" ) ; 1161 ifno = ifnoCol( 0 ) ;1170 ifno_ = ifnoCol( 0 ) ; 1162 1171 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 ; 1164 1173 } 1165 1174 for ( uInt i = 0 ; i < nfile_ ; i++ ) { 1166 1175 Table taborg( infileList_[i] ) ; 1167 1176 TableExprNode node ; 1168 if ( i sMultiIF( taborg ) ) {1177 if ( ifno != -1 || isMultiIF( taborg ) ) { 1169 1178 os << "apply selection on IFNO" << LogIO::POST ; 1170 node = taborg.col("IFNO") == ifno ;1179 node = taborg.col("IFNO") == ifno_ ; 1171 1180 } 1172 1181 if ( scanlist_.size() > 0 ) { … … 1180 1189 tableList_[i] = taborg( node ) ; 1181 1190 } 1182 os << "tableList_[" << i << "].nrow()=" << tableList_[i].nrow() << LogIO::POST ;1191 os << LogIO::DEBUGGING << "tableList_[" << i << "].nrow()=" << tableList_[i].nrow() << LogIO::POST ; 1183 1192 if ( tableList_[i].nrow() == 0 ) { 1184 1193 os << LogIO::SEVERE 1185 << "No corresponding rows for given selection: IFNO " << ifno ;1194 << "No corresponding rows for given selection: IFNO " << ifno_ ; 1186 1195 if ( scanlist_.size() > 0 ) 1187 1196 os << " SCANNO " << scanlist_ ; … … 1565 1574 // to take into account Gaussian tail 1566 1575 if ( convSupport_ < 0 ) 1567 convSupport_ = 12 ; // 3* 41576 convSupport_ = 4 ; // 1 * 4 1568 1577 else { 1569 1578 convSupport_ = userSupport_ * 4 ; … … 1650 1659 1651 1660 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 ) ; 1653 1664 1654 1665 return outfile_ ; … … 1660 1671 t.deepCopy( name, Table::New, False, t.endianFormat(), True ) ; 1661 1672 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 1679 void 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 } -
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/hpc33/src/STGrid.h
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/src/STGrid.h merged eligible /branches/alma/src/STGrid.h 1386-1818 /branches/asap4casa3.1.0/src/STGrid.h 1935-1936,1940 /branches/parallel/src/STGrid.h 2196-2288
r2398 r2459 195 195 void initTable( uInt idx ) ; 196 196 Bool isMultiIF( Table &tab ) ; 197 void fillMainColumns( Table &tab ) ; 197 198 static bool produceChunk(void *ctx) throw(concurrent::PCException); 198 199 static void consumeChunk(void *ctx) throw(concurrent::PCException); -
Property svn:mergeinfo
set to (toggle deleted branches)
Note:
See TracChangeset
for help on using the changeset viewer.