Changeset 493
- Timestamp:
- 02/21/05 18:05:23 (20 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/SDMemTable.cc
r490 r493 371 371 372 372 373 int SDMemTable:: stokesLength() const373 int SDMemTable::nStokes() const 374 374 { 375 375 return stokesCol_.shape(0).nelements(); // All rows same shape … … 428 428 } 429 429 430 std::string SDMemTable::getStokesSpectrumLabel (Bool doPol) const 430 std::string SDMemTable::getPolarizationLabel (Bool linear, Bool stokes, Bool linPol, Int polIdx) const 431 { 432 uInt idx = polSel_; 433 if (polIdx >=0) idx = polIdx; 431 434 // 432 // Gets STokes label depending on cursor polSel location 433 // doPol=False : I,Q,U,V 434 // doPol=True : I,P,PA,V ; P = sqrt(Q**2+U**2), PA = 0.5*atan2(Q,U) 435 return SDPolUtil::polarizationLabel (idx, linear, stokes, linPol); 436 } 437 438 439 440 std::vector<float> SDMemTable::stokesToPolSpectrum (Int whichRow, Bool toLinear, uInt polIdx) const 435 441 // 442 // polIdx 443 // 0:3 -> RR,LL,Real(RL),Imag(RL) 444 // XX,YY,Real(XY),Image(XY) 445 // 446 // Gets only 447 // RR = I + V 448 // LL = I - V 449 // at the moment 450 // 436 451 { 437 452 AlwaysAssert(asap::nAxes==4,AipsError); 438 if (n Pol()!=1 && nPol()!=2 && nPol()!=4) {439 throw (AipsError("You must have 1,2 or 4 polarizations to get the Stokes parameters"));453 if (nStokes()!=4) { 454 throw (AipsError("You must have 4 Stokes to convert to linear or circular")); 440 455 } 441 456 // 442 Stokes::StokesTypes type = Stokes::Undefined; 443 switch (polSel_) { 444 case 0: 445 { 446 type = Stokes::I; 447 } 448 break; 449 case 1: 450 { 451 if (doPol) { 452 type = Stokes::Plinear; 453 } else { 454 type = Stokes::Q; 455 } 456 } 457 case 2: 458 { 459 if (doPol) { 460 type = Stokes::Pangle; 461 } else { 462 type = Stokes::U; 463 } 464 } 465 break; 466 case 3: 467 { 468 type = Stokes::V; 469 } 470 break; 471 default: 472 { 473 throw(AipsError("Unknown Stokes type")); 474 } 475 } 476 // 477 return SDPolUtil::stokesString(type); 478 } 479 480 481 482 std::vector<float> SDMemTable::getCircularSpectrum(Int whichRow, 483 Bool doRR) const 484 // Gets 485 // RR = I + V 486 // LL = I - V 487 { 488 AlwaysAssert(asap::nAxes==4,AipsError); 489 if (nPol()!=4) { 490 throw (AipsError("You must have 4 polarizations to get RR or LL")); 491 } 492 Array<Float> arr; 457 Array<Float> arr, out; 493 458 stokesCol_.get(whichRow, arr); 494 459 495 460 // Set current cursor location 496 461 497 462 const IPosition& shape = arr.shape(); … … 499 464 getCursorSlice(start, end, shape); 500 465 501 // Get I and V slices 502 503 Array<Float> I = SDPolUtil::getStokesSlice(arr,start,end,"I"); 504 Array<Float> V = SDPolUtil::getStokesSlice(arr,start,end,"V"); 505 506 // Compute output 507 508 Array<Float> out = SDPolUtil::circularPolarizationFromStokes(I, V, doRR); 509 510 // Copy to output 511 512 IPosition vecShape(1,shape(asap::ChanAxis)); 513 Vector<Float> outV = out.reform(vecShape); 514 std::vector<float> stlout; 515 outV.tovector(stlout); 516 517 return stlout; 518 } 519 520 521 std::string SDMemTable::getCircularSpectrumLabel (Bool doRR) const 466 // Get the slice 467 468 if (toLinear) { 469 throw(AipsError("Conversion to linears not yet supported")); 470 } else { 471 Bool doRR = (polIdx==0); 472 if(polIdx>1) { 473 throw(AipsError("Only conversion to RR & LL is currently supported")); 474 } 475 476 // Get I and V slices 477 478 Array<Float> I = SDPolUtil::getStokesSlice(arr,start,end,"I"); 479 Array<Float> V = SDPolUtil::getStokesSlice(arr,start,end,"V"); 480 481 // Compute output 482 483 out = SDPolUtil::circularPolarizationFromStokes(I, V, doRR); 484 } 485 486 // Copy to output 487 488 IPosition vecShape(1,shape(asap::ChanAxis)); 489 Vector<Float> outV = out.reform(vecShape); 490 std::vector<float> stlout; 491 outV.tovector(stlout); 522 492 // 523 // Gets Circular label 524 // 525 { 526 Stokes::StokesTypes type = Stokes::Undefined; 527 if (doRR) { 528 type = Stokes::RR; 529 } else { 530 type = Stokes::LL; 531 } 532 // 533 return SDPolUtil::stokesString(type); 534 } 535 536 493 return stlout; 494 } 537 495 538 496 -
trunk/src/SDMemTable.h
r490 r493 94 94 virtual std::vector<bool> getMask(casa::Int whichRow=0) const; 95 95 96 // When we can handle input correlations being either circular or97 // linear, we should probably have functions; getLinear,98 // getCircular, getStokes since one can inter-convert between all99 // three regardless of the input provided there are 4100 // polarizations. For now, we are assuming, if there are 4101 // polarizations, that we have linears. getSpectrum is then102 // 'getLinear', getStokesSpectrum is 'getStokes' and103 // getCircularSpectrum is 'getCircular'104 105 96 // Get length of STokes spectrum. XX & YY -> I 106 97 // Anything else the length stays the same. 107 int stokesLength() const;98 int nStokes() const; 108 99 109 100 // Get specific Stokes at cursor location. One of either I,Q,U,V or I,P,PA,V (doPol=True) … … 114 105 casa::Float paOffset=0.0) const; 115 106 116 // Returns String for selected Stokes (polSel_) 117 std::string getStokesSpectrumLabel (casa::Bool doPol) const; 118 119 // Get RR or LL at cursor location (except not polSel_) 120 virtual std::vector<float> getCircularSpectrum(casa::Int whichRow=0, 121 casa::Bool rr=casa::True) const; 122 123 // Get circular label 124 std::string getCircularSpectrumLabel (casa::Bool rr=casa::True) const; 107 // Returns Label for polarization selected by polSel_ (or over-ridden 108 // with arg. polIdx). If doStokes is False, 109 // returns label for raw correlations (linear or circular). If True returns label for 110 // Stokes. If doPol=False, I,Q,U,V else I,P,PA,V 111 std::string getPolarizationLabel (casa::Bool linear, casa::Bool stokes, 112 casa::Bool linPol, casa::Int polIdx=-1) const; 113 114 // Convert Stokes to linear or circular polarizations (specified by polIdx=0:3). 115 // Presently, only conversion to RR or LL is supported. 116 virtual std::vector<float> stokesToPolSpectrum (casa::Int whichRow, casa::Bool toLinear, 117 casa::uInt polIdx) const; 125 118 126 119 // Get all Stokes at the specified Beam/IF cursor location (ignoring
Note:
See TracChangeset
for help on using the changeset viewer.