Changeset 493 for trunk/src/SDMemTable.cc
- Timestamp:
- 02/21/05 18:05:23 (19 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.