- Timestamp:
- 02/14/05 17:34:45 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMemTable.cc
r428 r430 340 340 std::vector<float> SDMemTable::getSpectrum(Int whichRow) const 341 341 { 342 342 343 Array<Float> arr; 343 344 specCol_.get(whichRow, arr); 344 //345 345 return getFloatSpectrum (arr); 346 346 } … … 353 353 // 354 354 { 355 AlwaysAssert(asap::nAxes==4,AipsError); 355 356 if (nPol()!=1 && nPol()!=2 && nPol()!=4) { 356 357 throw (AipsError("You must have 1,2 or 4 polarizations to get the Stokes parameters")); … … 359 360 stokesCol_.get(whichRow, arr); 360 361 // 361 if (doPol && (polSel_==1 || polSel_==2)) { 362 if (doPol && (polSel_==1 || polSel_==2)) { // Q,U --> P, P.A. 363 364 // Set current cursor location 365 362 366 const IPosition& shape = arr.shape(); 363 IPosition start(asap::nAxes,0); 364 IPosition end(shape-1); 365 // 366 start(asap::PolAxis) = 1; // Q 367 end (asap::PolAxis) = 1; 368 Array<Float> Q = arr(start,end); 369 // 370 start(asap::PolAxis) = 2; // U 371 end (asap::PolAxis) = 2; 372 Array<Float> U = arr(start,end); 373 // 367 IPosition start, end; 368 setCursorSlice (start, end, shape); 369 370 // Get Q and U slices 371 372 Array<Float> Q = SDPolUtil::getStokesSlice (arr,start,end,"Q"); 373 Array<Float> U = SDPolUtil::getStokesSlice (arr,start,end,"U"); 374 375 // Compute output 376 374 377 Array<Float> out; 375 378 if (polSel_==1) { // P … … 378 381 out = SDPolUtil::positionAngle(Q,U) + paOffset; 379 382 } 380 // 383 384 // Copy to output 385 381 386 IPosition vecShape(1,shape(asap::ChanAxis)); 382 387 Vector<Float> outV = out.reform(vecShape); 383 std::vector<float> spectrum(out.nelements()); 384 for (uInt i=0; i<out.nelements(); i++) { 385 spectrum[i] = outV[i]; 386 } 387 return spectrum; 388 return convertVector(outV); 388 389 } else { 389 return getFloatSpectrum (arr); 390 } 390 391 // Selects at the cursor location 392 393 return getFloatSpectrum (arr); 394 } 395 } 396 397 std::vector<float> SDMemTable::getCircularSpectrum(Int whichRow, Bool doRR) const 398 // 399 // Gets 400 // RR = I + V 401 // LL = I - V 402 // 403 { 404 AlwaysAssert(asap::nAxes==4,AipsError); 405 if (nPol()!=4) { 406 throw (AipsError("You must have 4 polarizations to get RR or LL")); 407 } 408 Array<Float> arr; 409 stokesCol_.get(whichRow, arr); 410 411 // Set current cursor location 412 413 const IPosition& shape = arr.shape(); 414 IPosition start, end; 415 setCursorSlice (start, end, shape); 416 417 // Get I and V slices 418 419 Array<Float> I = SDPolUtil::getStokesSlice (arr,start,end,"I"); 420 Array<Float> V = SDPolUtil::getStokesSlice (arr,start,end,"V"); 421 422 // Compute output 423 424 Array<Float> out = SDPolUtil::circularPolarizationFromStokes (I, V, doRR); 425 426 // Copy to output 427 428 IPosition vecShape(1,shape(asap::ChanAxis)); 429 Vector<Float> outV = out.reform(vecShape); 430 return convertVector(outV); 391 431 } 392 432 393 433 std::vector<float> SDMemTable::getFloatSpectrum (const Array<Float>& arr) const 434 // 435 // Get spectrum at cursor location 436 // 394 437 { 395 438 … … 1568 1611 // 1569 1612 // phase in degrees 1613 // Applies to all Beams and IFs 1614 // Might want to optionally select on Beam/IF 1570 1615 // 1571 1616 { … … 1602 1647 } 1603 1648 } 1649 1650 1651 void SDMemTable::setCursorSlice (IPosition& start, IPosition& end, 1652 const IPosition& shape) const 1653 { 1654 const uInt nDim = shape.nelements(); 1655 start.resize(nDim); 1656 end.resize(nDim); 1657 // 1658 start(asap::BeamAxis) = beamSel_; 1659 end(asap::BeamAxis) = beamSel_; 1660 // 1661 start(asap::IFAxis) = IFSel_; 1662 end(asap::IFAxis) = IFSel_; 1663 // 1664 start(asap::PolAxis) = polSel_; 1665 end(asap::PolAxis) = polSel_; 1666 // 1667 start(asap::ChanAxis) = 0; 1668 end(asap::ChanAxis) = shape(asap::ChanAxis) - 1; 1669 } 1670 1671 1672 std::vector<float> SDMemTable::convertVector (const Vector<Float>& in) const 1673 { 1674 std::vector<float> out(in.nelements()); 1675 for (uInt i=0; i<in.nelements(); i++) { 1676 out[i] = in[i]; 1677 } 1678 return out; 1679 } 1680 -
trunk/src/SDMemTable.h
r426 r430 94 94 virtual std::vector<float> getSpectrum(casa::Int whichRow=0) const; 95 95 virtual std::vector<bool> getMask(casa::Int whichRow=0) const; 96 // Get STokes at cursor location. One of either I,Q,U,V or I,P,PA,V (doPol=True) 96 97 98 // When we can handle input correlations being either circular or 99 // linear, we should probably have functions; getLinear, getCircular, getStokes 100 // since one can inter-convert between all three regardless of the input 101 // provided there are 4 polarizations. For now, we are assuming, if 102 // there are 4 polarizations, that we have linears. getSpectrum 103 // is then 'getLinear', getStokesSpectrum is 'getStokes' and getCircularSpectrum 104 // is 'getCircular' 105 106 107 // Get Stokes at cursor location. One of either I,Q,U,V or I,P,PA,V (doPol=True) 97 108 // If the latter, you can add a PA offset (degrees) 98 109 virtual std::vector<float> getStokesSpectrum(casa::Int whichRow=0, 99 110 casa::Bool doPol=casa::False, 100 111 casa::Float paOffset=0.0) const; 112 113 // Get RR or LL at cursor location (not polSel_) 114 virtual std::vector<float> getCircularSpectrum(casa::Int whichRow=0, 115 casa::Bool rr=casa::True) const; 101 116 102 117 virtual casa::Float getTsys(casa::Int whichRow=0) const; … … 238 253 void attach(); 239 254 void renumber(); 255 256 // Generate start and end for shape and current cursor selection 257 void setCursorSlice(casa::IPosition& start, casa::IPosition& end, const casa::IPosition& shape) const; 258 259 // Convert Vector to vector 260 std::vector<float> convertVector (const casa::Vector<casa::Float>& in) const; 261 262 240 263 // the current cursor into the array 241 264 casa::Int IFSel_,beamSel_,polSel_;
Note:
See TracChangeset
for help on using the changeset viewer.