Changeset 2359
- Timestamp:
- 12/02/11 19:49:49 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STGrid.cpp
r2356 r2359 147 147 148 148 // grid parameter 149 cout << "----------" << endl ; 150 cout << "Grid parameter summary" << endl ; 151 cout << " (nx,ny) = (" << nx_ << "," << ny_ << ")" << endl ; 152 cout << " (cellx,celly) = (" << cellx_ << "," << celly_ << ")" << endl ; 153 cout << " center = " << center_ << endl ; 154 cout << "----------" << endl ; 149 // cout << "----------" << endl ; 150 // cout << "Grid parameter summary" << endl ; 151 // cout << " (nx,ny) = (" << nx_ << "," << ny_ << ")" << endl ; 152 // cout << " (cellx,celly) = (" << cellx_ << "," << celly_ << ")" << endl ; 153 // cout << " center = " << center_ << endl ; 154 // cout << "----------" << endl ; 155 156 // convolution kernel 157 Vector<Float> convFunc ; 158 setConvFunc( convFunc ) ; 159 //cout << "convSupport=" << convSupport_ << endl ; 160 //cout << "convFunc=" << convFunc << endl ; 155 161 156 162 // world -> pixel … … 162 168 //cout << "min(xypos.row(1))=" << min(xypos.row(1)) << endl ; 163 169 // for ( Int irow = 0 ; irow < nrow ; irow++ ) { 164 // cout << irow << ": xypos=" << xypos.column( irow ) 165 // << " data = " << spectra.column( irow ) << endl ; 170 // if ( spectra.column( irow )(0) > 0.0 ) { 171 // cout << irow << ": xypos=" << xypos.column( irow ) 172 // << " data = " << spectra.column( irow ) << endl ; 173 // } 166 174 // } 167 175 168 // convolution kernel169 Vector<Float> convFunc ;170 setConvFunc( convFunc ) ;171 //cout << "convSupport=" << convSupport_ << endl ;172 //cout << "convFunc=" << convFunc << endl ;173 174 176 // weighting factor 175 177 Matrix<Float> weight( IPosition( 2, nchan, nrow ), 1.0 ) ; … … 186 188 Float *conv_p = convFunc.getStorage( deleteConv ) ; 187 189 Int npol = 1 ; 188 IPosition gshape( 4, nx_, ny_, npol, nchan ) ; 190 // Extend grid plane with convSupport_ 191 //IPosition gshape( 4, nx_, ny_, npol, nchan ) ; 192 Int gnx = nx_+convSupport_*2 ; 193 Int gny = ny_+convSupport_*2 ; 194 IPosition gshape( 4, gnx, gny, npol, nchan ) ; 189 195 Array<Complex> gdataArrC( gshape, 0.0 ) ; 190 196 Array<Float> gwgtArr( gshape, 0.0 ) ; … … 229 235 gdata_p, 230 236 wdata_p, 231 &nx_, 232 &ny_, 237 //&nx_, 238 //&ny_, 239 &gnx, 240 &gny, 233 241 &npol, 234 242 &nchan, … … 250 258 gwgtArr.putStorage( wdata_p, deleteWgtG ) ; 251 259 Array<Float> gdataArr = real( gdataArrC ) ; 252 //Array<Float> gdataArrN( gdataArr.shape(), 0.0 ) ;253 260 data_.resize( gdataArr.shape() ) ; 254 261 data_ = 0.0 ; … … 258 265 for ( Int ic = 0 ; ic < nchan ; ic++ ) { 259 266 IPosition pos( 4, ix, iy, ip, ic ) ; 260 if ( gwgtArr( pos ) > 0.0 ) 261 //gdataArrN( pos ) = gdataArr( pos ) / gwgtArr( pos ) ; 262 data_( pos ) = gdataArr( pos ) / gwgtArr( pos ) ; 267 //if ( gwgtArr( pos ) > 0.0 ) 268 // data_( pos ) = gdataArr( pos ) / gwgtArr( pos ) ; 269 IPosition gpos( 4, ix+convSupport_, iy+convSupport_, ip, ic ) ; 270 if ( gwgtArr( gpos ) > 0.0 ) 271 data_( pos ) = gdataArr( gpos ) / gwgtArr( gpos ) ; 263 272 } 264 273 } … … 269 278 //cout << "gdataArr = " << gdataArr << endl ; 270 279 //cout << "gwgtArr = " << gwgtArr << endl ; 271 //cout << " gdataArr/gwgtArr = " << gdataArrN<< endl ;280 //cout << "data_ " << data_ << endl ; 272 281 } 273 282 … … 283 292 { 284 293 //cout << "nx=" << nx << ", ny=" << ny << endl ; 285 Double wx = xmax - xmin ; 286 Double wy = ymax - ymin ; 287 // take some margin 294 295 // center position 296 if ( center.size() == 0 ) { 297 center_(0) = 0.5 * ( xmin + xmax ) ; 298 center_(1) = 0.5 * ( ymin + ymax ) ; 299 } 300 else { 301 String::size_type pos0 = center.find( " " ) ; 302 if ( pos0 == String::npos ) { 303 throw AipsError( "bad string format in parameter center" ) ; 304 } 305 String::size_type pos1 = center.find( " ", pos0+1 ) ; 306 String typestr, xstr, ystr ; 307 if ( pos1 != String::npos ) { 308 typestr = center.substr( 0, pos0 ) ; 309 xstr = center.substr( pos0+1, pos1-pos0 ) ; 310 ystr = center.substr( pos1+1 ) ; 311 // todo: convert to J2000 (or direction ref for DIRECTION column) 312 } 313 else { 314 typestr = "J2000" ; 315 xstr = center.substr( 0, pos0 ) ; 316 ystr = center.substr( pos0+1 ) ; 317 } 318 QuantumHolder qh ; 319 String err ; 320 qh.fromString( err, xstr ) ; 321 Quantum<Double> xcen = qh.asQuantumDouble() ; 322 qh.fromString( err, ystr ) ; 323 Quantum<Double> ycen = qh.asQuantumDouble() ; 324 center_(0) = xcen.getValue( "rad" ) ; 325 center_(1) = ycen.getValue( "rad" ) ; 326 } 327 328 329 //Double wx = xmax - xmin ; 330 //Double wy = ymax - ymin ; 331 Double wx = max( abs(xmax-center_(0)), abs(xmin-center_(0)) ) * 2 ; 332 Double wy = max( abs(ymax-center_(1)), abs(ymin-center_(1)) ) * 2 ; 333 // take 10% margin 288 334 wx *= 1.10 ; 289 335 wy *= 1.10 ; … … 331 377 nx_ = Int( ceil( wx/cellx_ ) ) ; 332 378 ny_ = Int( ceil( wy/celly_ ) ) ; 333 }334 335 if ( center.size() == 0 ) {336 center_(0) = 0.5 * ( xmin + xmax ) ;337 center_(1) = 0.5 * ( ymin + ymax ) ;338 }339 else {340 String::size_type pos0 = center.find( " " ) ;341 if ( pos0 == String::npos ) {342 throw AipsError( "bad string format in parameter center" ) ;343 }344 String::size_type pos1 = center.find( " ", pos0+1 ) ;345 String typestr, xstr, ystr ;346 if ( pos1 != String::npos ) {347 typestr = center.substr( 0, pos0 ) ;348 xstr = center.substr( pos0+1, pos1-pos0 ) ;349 ystr = center.substr( pos1+1 ) ;350 // todo: convert to J2000 (or direction ref for DIRECTION column)351 }352 else {353 typestr = "J2000" ;354 xstr = center.substr( 0, pos0 ) ;355 ystr = center.substr( pos0+1 ) ;356 }357 QuantumHolder qh ;358 String err ;359 qh.fromString( err, xstr ) ;360 Quantum<Double> xcen = qh.asQuantumDouble() ;361 qh.fromString( err, ystr ) ;362 Quantum<Double> ycen = qh.asQuantumDouble() ;363 center_(0) = xcen.getValue( "rad" ) ;364 center_(1) = ycen.getValue( "rad" ) ;365 379 } 366 380 } … … 419 433 void STGrid::toPixel( Matrix<Double> &world, Matrix<Double> &pixel ) 420 434 { 435 // gridding will be done on (nx_+2*convSupport_) x (ny_+2*convSupport_) 436 // grid plane to avoid unexpected behavior on grid edge 421 437 Vector<Double> pixc( 2 ) ; 422 pixc(0) = Double( nx_-1 ) * 0.5 ; 423 pixc(1) = Double( ny_-1 ) * 0.5 ; 438 //pixc(0) = Double( nx_-1 ) * 0.5 ; 439 //pixc(1) = Double( ny_-1 ) * 0.5 ; 440 pixc(0) = Double( nx_+2*convSupport_-1 ) * 0.5 ; 441 pixc(1) = Double( ny_+2*convSupport_-1 ) * 0.5 ; 424 442 uInt nrow = world.shape()[1] ; 425 443 Vector<Double> cell( 2 ) ; … … 502 520 gaussFunc( convFunc ) ; 503 521 } 504 else if ( convType_ == "PB" ) 522 else if ( convType_ == "PB" ) { 523 if ( convSupport_ < 0 ) 524 convSupport_ = 0 ; 505 525 pbFunc( convFunc ) ; 526 } 506 527 else { 507 528 throw AipsError( "Unsupported convolution function" ) ;
Note:
See TracChangeset
for help on using the changeset viewer.