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

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.