Changeset 430


Ignore:
Timestamp:
02/14/05 17:34:45 (19 years ago)
Author:
kil064
Message:

add function getCircularSepctrum
fix bug in getSTokesSPectrum where beamSel and IFSel were ignored

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMemTable.cc

    r428 r430  
    340340std::vector<float> SDMemTable::getSpectrum(Int whichRow) const
    341341{
     342
    342343  Array<Float> arr;
    343344  specCol_.get(whichRow, arr);
    344 //
    345345  return getFloatSpectrum (arr);
    346346}
     
    353353//
    354354{
     355  AlwaysAssert(asap::nAxes==4,AipsError);
    355356  if (nPol()!=1 && nPol()!=2 && nPol()!=4) {
    356357     throw (AipsError("You must have 1,2 or 4 polarizations to get the Stokes parameters"));
     
    359360  stokesCol_.get(whichRow, arr);
    360361//
    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
    362366     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
    374377     Array<Float> out;
    375378     if (polSel_==1) {                                        // P
     
    378381        out = SDPolUtil::positionAngle(Q,U) + paOffset;
    379382     }
    380 //
     383
     384// Copy to output
     385
    381386     IPosition vecShape(1,shape(asap::ChanAxis));
    382387     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);
    388389  } else {
    389      return getFloatSpectrum (arr);
    390   }
     390
     391// Selects at the cursor location
     392
     393    return getFloatSpectrum (arr);
     394  }
     395}
     396
     397std::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);
    391431}
    392432
    393433std::vector<float> SDMemTable::getFloatSpectrum (const Array<Float>& arr) const
     434//
     435// Get spectrum at cursor location
     436//
    394437{
    395438
     
    15681611//
    15691612// phase in degrees
     1613// Applies to all Beams and IFs
     1614// Might want to optionally select on Beam/IF
    15701615//
    15711616{
     
    16021647   }
    16031648}
     1649
     1650
     1651void 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
     1672std::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  
    9494  virtual std::vector<float> getSpectrum(casa::Int whichRow=0) const;
    9595  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)
    97108  // If the latter, you can add a PA offset (degrees)
    98109  virtual std::vector<float> getStokesSpectrum(casa::Int whichRow=0,
    99110                                               casa::Bool doPol=casa::False,
    100111                                               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;
    101116
    102117  virtual casa::Float getTsys(casa::Int whichRow=0) const;
     
    238253  void attach();
    239254  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
    240263  // the current cursor into the array
    241264  casa::Int IFSel_,beamSel_,polSel_;
Note: See TracChangeset for help on using the changeset viewer.