Changeset 493 for trunk


Ignore:
Timestamp:
02/21/05 18:05:23 (20 years ago)
Author:
kil064
Message:

function stokesLength() -> nStokes()

getStokesSpectrumLabel and getCircularSpectrumLabel combined into

getPolarizationLabel

getCircularSpectrum -> stokesToPolSpectrum

This is a more consistent set. Move some functionality to SDPolUtil

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMemTable.cc

    r490 r493  
    371371
    372372
    373 int SDMemTable::stokesLength() const
     373int SDMemTable::nStokes() const
    374374{
    375375   return stokesCol_.shape(0).nelements();        // All rows same shape
     
    428428}
    429429
    430 std::string SDMemTable::getStokesSpectrumLabel (Bool doPol) const
     430std::string SDMemTable::getPolarizationLabel (Bool linear, Bool stokes, Bool linPol, Int polIdx) const
     431{
     432   uInt idx = polSel_;   
     433   if (polIdx >=0) idx = polIdx;
    431434//
    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
     440std::vector<float> SDMemTable::stokesToPolSpectrum (Int whichRow, Bool toLinear, uInt polIdx) const
    435441//
     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//
    436451{
    437452  AlwaysAssert(asap::nAxes==4,AipsError);
    438   if (nPol()!=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"));
    440455  }
    441456//
    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;
    493458  stokesCol_.get(whichRow, arr);
    494459
    495   // Set current cursor location
     460// Set current cursor location
    496461
    497462  const IPosition& shape = arr.shape();
     
    499464  getCursorSlice(start, end, shape);
    500465
    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);
    522492//
    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}
    537495
    538496
  • trunk/src/SDMemTable.h

    r490 r493  
    9494  virtual std::vector<bool> getMask(casa::Int whichRow=0) const;
    9595
    96   // When we can handle input correlations being either circular or
    97   // linear, we should probably have functions; getLinear,
    98   // getCircular, getStokes since one can inter-convert between all
    99   // three regardless of the input provided there are 4
    100   // polarizations. For now, we are assuming, if there are 4
    101   // polarizations, that we have linears.  getSpectrum is then
    102   // 'getLinear', getStokesSpectrum is 'getStokes' and
    103   // getCircularSpectrum is 'getCircular'
    104 
    10596  // Get length of STokes spectrum. XX & YY -> I
    10697  // Anything else the length stays the same.
    107   int stokesLength() const;
     98  int nStokes() const;
    10899
    109100  // Get specific Stokes at cursor location. One of either I,Q,U,V or I,P,PA,V (doPol=True)
     
    114105                                               casa::Float paOffset=0.0) const;
    115106
    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;
    125118
    126119  // Get all Stokes at the specified Beam/IF cursor location (ignoring
Note: See TracChangeset for help on using the changeset viewer.