- Timestamp:
- 02/15/05 20:05:51 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDContainer.cc
r417 r449 39 39 #include <casa/Arrays/Matrix.h> 40 40 #include <casa/Arrays/VectorIter.h> 41 #include <casa/Arrays/ArrayAccessor.h>42 41 #include <casa/Arrays/ArrayMath.h> 43 42 #include <casa/BasicMath/Math.h> … … 325 324 } 326 325 327 Array<Float> SDContainer::getSpectrum(uInt whichBeam, uInt whichIF) const 328 { 329 Matrix<Float> spectra(nChan_, nPol_); 330 331 // Beam. 332 ArrayAccessor<Float, Axis<asap::BeamAxis> > i0(spectrum_); 333 i0.reset(i0.begin(whichBeam)); 334 335 // IF. 336 ArrayAccessor<Float, Axis<asap::IFAxis> > i1(i0); 337 i1.reset(i1.begin(whichIF)); 338 339 // Polarization. 340 ArrayAccessor<Float, Axis<asap::PolAxis> > i2(i1); 341 ArrayAccessor<Float, Axis<asap::IFAxis> > o1(spectra); 342 343 while (i2 != i2.end()) { 344 // Channel. 345 ArrayAccessor<Float, Axis<asap::ChanAxis> > i3(i2); 346 ArrayAccessor<Float, Axis<asap::BeamAxis> > o0(o1); 347 348 while (i3 != i3.end()) { 349 *o0 = *i3; 350 351 i3++; 352 o0++; 353 } 354 355 i2++; 356 o1++; 357 } 358 359 return spectra.copy(); 360 } 361 362 363 Array<uChar> SDContainer::getFlags(uInt whichBeam, uInt whichIF) const 364 { 365 Matrix<uChar> flagtra(nChan_, nPol_); 366 367 // Beam. 368 ArrayAccessor<uChar, Axis<asap::BeamAxis> > i0(flags_); 369 i0.reset(i0.begin(whichBeam)); 370 371 // IF. 372 ArrayAccessor<uChar, Axis<asap::IFAxis> > i1(i0); 373 i1.reset(i1.begin(whichIF)); 374 375 // Polarization. 376 ArrayAccessor<uChar, Axis<asap::PolAxis> > i2(i1); 377 ArrayAccessor<uChar, Axis<asap::IFAxis> > o1(flagtra); 378 379 while (i2 != i2.end()) { 380 // Channel. 381 ArrayAccessor<uChar, Axis<asap::ChanAxis> > i3(i2); 382 ArrayAccessor<uChar, Axis<asap::BeamAxis> > o0(o1); 383 384 while (i3 != i3.end()) { 385 *o0 = *i3; 386 387 i3++; 388 o0++; 389 } 390 391 i2++; 392 o1++; 393 } 394 395 return flagtra.copy(); 396 } 397 398 Array<Float> SDContainer::getTsys(uInt whichBeam, uInt whichIF) const 399 { 400 Vector<Float> tsys(nPol_); 401 402 // Beam. 403 ArrayAccessor<Float, Axis<asap::BeamAxis> > i0(tsys_); 404 i0.reset(i0.begin(whichBeam)); 405 406 // IF. 407 ArrayAccessor<Float, Axis<asap::IFAxis> > i1(i0); 408 i1.reset(i1.begin(whichIF)); 409 410 // Channel. 411 ArrayAccessor<Float, Axis<asap::ChanAxis> > i3(i1); 412 413 // Polarization. 414 ArrayAccessor<Float, Axis<asap::PolAxis> > i2(i3); 415 ArrayAccessor<Float, Axis<asap::BeamAxis> > o0(tsys); 416 417 while (i2 != i2.end()) { 418 *o0 = *i2; 419 420 i2++; 421 o0++; 422 } 423 return tsys.copy(); 424 } 425 426 Array<Double> SDContainer::getDirection(uInt whichBeam) const { 427 Vector<Double> direct(2); 428 ArrayAccessor<Double, Axis<asap::BeamAxis> > i0(direction_); 429 i0.reset(i0.begin(whichBeam)); 430 ArrayAccessor<Double, Axis<asap::BeamAxis> > o0(direct); 431 ArrayAccessor<Double, Axis<asap::IFAxis> > i1(i0); 432 while (i1 != i1.end()) { 433 *o0 = *i1; 434 i1++; 435 o0++; 436 } 437 return direct.copy(); 326 Array<Float> SDContainer::getSpectrum(uInt whichBeam, uInt whichIF) 327 // 328 // non-const function because of Array(start,end) slicer 329 // 330 // Input [nBeam,nIF,nPol,nChan] 331 // Output [nChan,nPol] 332 // 333 { 334 335 // Get reference to slice and check dim 336 337 IPosition start, end; 338 setSlice (start, end, spectrum_.shape(), whichBeam, whichIF); 339 // 340 Array<Float> dataIn = spectrum_(start,end); 341 Array<Float> dataOut(IPosition(2, nChan_, nPol_)); 342 // 343 ReadOnlyVectorIterator<Float> itIn(dataIn, asap::ChanAxis); 344 VectorIterator<Float> itOut(dataOut, 0); 345 while (!itOut.pastEnd()) { 346 itOut.vector() = itIn.vector(); 347 // 348 itIn.next(); 349 itOut.next(); 350 } 351 // 352 return dataOut.copy(); 353 } 354 355 Array<uChar> SDContainer::getFlags(uInt whichBeam, uInt whichIF) 356 // 357 // non-const function because of Array(start,end) slicer 358 // 359 // Input [nBeam,nIF,nPol,nChan] 360 // Output [nChan,nPol] 361 // 362 { 363 364 // Get reference to slice and check dim 365 366 IPosition start, end; 367 setSlice (start, end, flags_.shape(), whichBeam, whichIF); 368 // 369 Array<uChar> dataIn = flags_(start,end); 370 Array<uChar> dataOut(IPosition(2, nChan_, nPol_)); 371 // 372 ReadOnlyVectorIterator<uChar> itIn(dataIn, asap::ChanAxis); 373 VectorIterator<uChar> itOut(dataOut, 0); 374 while (!itOut.pastEnd()) { 375 itOut.vector() = itIn.vector(); 376 // 377 itIn.next(); 378 itOut.next(); 379 } 380 // 381 return dataOut.copy(); 382 } 383 384 Array<Float> SDContainer::getTsys(uInt whichBeam, uInt whichIF) 385 // 386 // Input [nBeam,nIF,nPol,nChan] 387 // Output [nPol] (drop channel dependency and select first value) 388 // 389 { 390 // Get reference to slice and check dim 391 392 IPosition start, end; 393 setSlice (start, end, spectrum_.shape(), whichBeam, whichIF); 394 // 395 Array<Float> dataIn = tsys_(start,end); 396 Vector<Float> dataOut(nPol_); 397 // 398 ReadOnlyVectorIterator<Float> itIn(dataIn, asap::ChanAxis); 399 VectorIterator<Float> itOut(dataOut, 0); 400 uInt i = 0; 401 while (!itIn.pastEnd()) { 402 dataOut[i++] = itIn.vector()[0]; 403 itIn.next(); 404 } 405 // 406 return dataOut.copy(); 407 } 408 409 410 411 Array<Double> SDContainer::getDirection(uInt whichBeam) const 412 // 413 // Input [nBeam,2] 414 // Output [nBeam] 415 // 416 { 417 Vector<Double> dataOut(2); 418 dataOut(0) = direction_(IPosition(2,whichBeam,0)); 419 dataOut(1) = direction_(IPosition(2,whichBeam,1)); 420 return dataOut.copy(); 438 421 } 439 422 … … 461 444 } 462 445 463 Bool SDContainer::setDirection(const Vector<Double>& point, uInt whichBeam) { 446 Bool SDContainer::setDirection(const Vector<Double>& point, uInt whichBeam) 447 // 448 // Input [2] 449 // Output [nBeam,2] 450 // 451 { 464 452 if (point.nelements() != 2) return False; 465 ArrayAccessor<Double, Axis<asap::BeamAxis> > aa0(direction_); 466 aa0.reset(aa0.begin(whichBeam)); 467 ArrayAccessor<Double, Axis<asap::BeamAxis> > jj(point); 468 for (ArrayAccessor<Double, Axis<asap::IFAxis> > i(aa0);i != i.end(); ++i) { 469 470 (*i) = (*jj); 471 jj++; 472 } 473 return True; 474 } 453 // 454 Vector<Double> dataOut(2); 455 direction_(IPosition(2,whichBeam,0)) = point[0]; 456 direction_(IPosition(2,whichBeam,1)) = point[1]; 457 return True; 458 } 459 475 460 476 461 Bool SDContainer::putDirection(const Array<Double>& dir) { … … 517 502 } 518 503 // 504 setSlice (start, end, shpOut, whichBeam, whichIF); 505 } 506 507 508 void SDContainer::setSlice (IPosition& start, IPosition& end, const IPosition& shape, 509 uInt whichBeam, uInt whichIF) const 510 { 511 AlwaysAssert(asap::nAxes==4,AipsError); 512 // 519 513 start.resize(asap::nAxes); 520 514 start = 0; … … 523 517 // 524 518 end.resize(asap::nAxes); 525 end = sh pOut-1;519 end = shape-1; 526 520 end(asap::BeamAxis) = whichBeam; 527 521 end(asap::IFAxis) = whichIF; -
trunk/src/SDContainer.h
r417 r449 149 149 150 150 casa::Array<casa::Float> getSpectrum(casa::uInt whichBeam, 151 casa::uInt whichIF) const;151 casa::uInt whichIF); 152 152 casa::Array<casa::uChar> getFlags(casa::uInt whichBeam, 153 casa::uInt whichIF) const;153 casa::uInt whichIF); 154 154 casa::Array<casa::Float> getTsys(casa::uInt whichBeam, 155 casa::uInt whichIF) const;155 casa::uInt whichIF); 156 156 casa::Array<casa::Double> getDirection(casa::uInt whichBeam) const; 157 157 … … 204 204 casa::uInt whichBeam, casa::uInt whichIF, casa::Bool checkPol, 205 205 casa::Bool xPol) const; 206 void setSlice (casa::IPosition& start, casa::IPosition& end, 207 const casa::IPosition& shape, 208 casa::uInt whichBeam, casa::uInt whichIF) const; 206 209 }; 207 210
Note:
See TracChangeset
for help on using the changeset viewer.