Changeset 527 for trunk


Ignore:
Timestamp:
03/01/05 15:02:15 (20 years ago)
Author:
mar637
Message:

ficed bug in getSDFitTable

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMemTable.cc

    r521 r527  
    9393  }
    9494  table_ = tab.copyToMemoryTable("dummy");
    95   //cerr << "hello from C SDMemTable @ " << this << endl;
    9695  attach();
    9796}
     
    116115
    117116  attach();
    118   //cerr << "hello from CC SDMemTable @ " << this << endl;
    119117}
    120118
     
    378376
    379377
    380 std::vector<float> SDMemTable::getStokesSpectrum(Int whichRow, Bool doPol) const
    381 //
    382 // Gets one STokes parameter depending on cursor polSel location
    383 //  doPol=False  : I,Q,U,V
    384 //  doPol=True   : I,P,PA,V   ; P = sqrt(Q**2+U**2), PA = 0.5*atan2(Q,U)
    385 //
     378std::vector<float> SDMemTable::getStokesSpectrum(Int whichRow,
     379                                                 Bool doPol) const
     380  //
     381  // Gets one STokes parameter depending on cursor polSel location
     382  //  doPol=False  : I,Q,U,V
     383  //  doPol=True   : I,P,PA,V   ; P = sqrt(Q**2+U**2), PA = 0.5*atan2(Q,U)
     384  //
    386385{
    387386  AlwaysAssert(asap::nAxes==4,AipsError);
    388387  if (nPol()!=1 && nPol()!=2 && nPol()!=4) {
    389      throw (AipsError("You must have 1,2 or 4 polarizations to get the Stokes parameters"));
    390   }
    391 
    392 // For full conversion we are only supporting linears at the moment
    393 
     388    throw (AipsError("You must have 1,2 or 4 polarizations to get the Stokes parameters"));
     389  }
     390 
     391  // For full conversion we are only supporting linears at the moment
     392 
    394393  if (nPol() > 2) {
    395      String antName;
    396      table_.keywordSet().get("AntennaName", antName);
    397      Instrument inst = SDAttr::convertInstrument (antName, True);
    398      SDAttr sdAtt;
    399      if (sdAtt.feedPolType(inst) != LINEAR) {
    400        throw(AipsError("Only linear polarizations are supported"));
    401      }
    402   }
    403 //
     394    String antName;
     395    table_.keywordSet().get("AntennaName", antName);
     396    Instrument inst = SDAttr::convertInstrument (antName, True);
     397    SDAttr sdAtt;
     398    if (sdAtt.feedPolType(inst) != LINEAR) {
     399      throw(AipsError("Only linear polarizations are supported"));
     400    }
     401  }
     402
    404403  Array<Float> arr;
    405404  stokesCol_.get(whichRow, arr);
    406 //
     405 
    407406  if (doPol && (polSel_==1 || polSel_==2)) {       //   Q,U --> P, P.A.
    408 
    409 // Set current cursor location
    410 
    411      const IPosition& shape = arr.shape();
    412      IPosition start, end;
    413      getCursorSlice(start, end, shape);
    414 
    415 // Get Q and U slices
    416 
    417      Array<Float> Q = SDPolUtil::getStokesSlice(arr,start,end,"Q");
    418      Array<Float> U = SDPolUtil::getStokesSlice(arr,start,end,"U");
    419 
    420 // Compute output
    421 
    422      Array<Float> out;
    423      if (polSel_==1) {                                        // P
    424         out = SDPolUtil::polarizedIntensity(Q,U);
    425      } else if (polSel_==2) {                                 // P.A.
    426         out = SDPolUtil::positionAngle(Q,U);
    427      }
    428 
    429      // Copy to output
    430 
    431      IPosition vecShape(1,shape(asap::ChanAxis));
    432      Vector<Float> outV = out.reform(vecShape);
    433      std::vector<float> stlout;
    434      outV.tovector(stlout);
    435      return stlout;
    436 
    437   } else {
    438 
     407   
     408    // Set current cursor location
     409   
     410    const IPosition& shape = arr.shape();
     411    IPosition start, end;
     412    getCursorSlice(start, end, shape);
     413   
     414    // Get Q and U slices
     415   
     416    Array<Float> Q = SDPolUtil::getStokesSlice(arr,start,end,"Q");
     417    Array<Float> U = SDPolUtil::getStokesSlice(arr,start,end,"U");
     418   
     419    // Compute output
     420   
     421    Array<Float> out;
     422    if (polSel_==1) {                                        // P
     423      out = SDPolUtil::polarizedIntensity(Q,U);
     424    } else if (polSel_==2) {                                 // P.A.
     425      out = SDPolUtil::positionAngle(Q,U);
     426    }
     427   
     428    // Copy to output
     429   
     430    IPosition vecShape(1,shape(asap::ChanAxis));
     431    Vector<Float> outV = out.reform(vecShape);
     432    std::vector<float> stlout;
     433    outV.tovector(stlout);
     434    return stlout;
     435   
     436  } else {   
    439437    // Selects at the cursor location
    440438    return getFloatSpectrum(arr);
     
    10851083
    10861084SDFitTable SDMemTable::getSDFitTable(uInt whichRow) const {
     1085  const Table& t = table_.keywordSet().asTable("FITS");
     1086  if (t.nrow() == 0 || whichRow >= t.nrow()) return SDFitTable();
    10871087  Array<Int> fitid;
    10881088  fitCol_.get(whichRow, fitid);
     
    10961096  Vector<Int> tmp = (fitid(start, end)).reform(IPosition(1,shp[3]));
    10971097
    1098   const Table& t = table_.keywordSet().asTable("FITS");
    10991098  Vector<Double> parms;
    11001099  Vector<Bool> parmask;
     
    11071106  ROArrayColumn<String> funcsCol(t, "FUNCTIONS");
    11081107  ROArrayColumn<String> finfoCol(t, "FRAMEINFO");
    1109   if (t.nrow() == 0) return SDFitTable();
    11101108  SDFitTable sdft;
    11111109  Int k=-1;
  • trunk/src/SDMemTable.h

    r504 r527  
    9898  int nStokes() const;
    9999
    100   // Get specific Stokes at cursor location. One of either I,Q,U,V or I,P,PA,V (doPol=True)
    101   // (determined by the polSel cursor location 0->3)
    102   // If the latter, you can add a PA offset (degrees)
     100  // Get specific Stokes at cursor location. One of either I,Q,U,V or
     101  // I,P,PA,V (doPol=True) (determined by the polSel cursor location
     102  // 0->3) If the latter, you can add a PA offset (degrees)
    103103  virtual std::vector<float> getStokesSpectrum(casa::Int whichRow=0,
    104104                                               casa::Bool doPol=casa::False) const;
    105105
    106   // Returns Label for polarization selected by polSel_ (or over-ridden
    107   // with arg. polIdx).  If doStokes is False,
    108   // returns label for raw correlations (linear or circular). If True returns label for
    109   // Stokes.  If doPol=False, I,Q,U,V else I,P,PA,V
    110   std::string getPolarizationLabel (casa::Bool linear, casa::Bool stokes,
    111                                     casa::Bool linPol, casa::Int polIdx=-1) const;
    112 
    113   // Convert Stokes to linear or circular polarizations (specified by polIdx=0:3).
    114   // Presently, only conversion to RR or LL is supported.
    115   virtual std::vector<float> stokesToPolSpectrum (casa::Int whichRow, casa::Bool toLinear,
    116                                                   casa::uInt polIdx) const;
     106  // Returns Label for polarization selected by polSel_ (or
     107  // over-ridden with arg. polIdx).  If doStokes is False, returns
     108  // label for raw correlations (linear or circular). If True returns
     109  // label for Stokes.  If doPol=False, I,Q,U,V else I,P,PA,V
     110  std::string getPolarizationLabel(casa::Bool linear, casa::Bool stokes,
     111                                   casa::Bool linPol,
     112                                   casa::Int polIdx=-1) const;
     113
     114  // Convert Stokes to linear or circular polarizations (specified by
     115  // polIdx=0:3).  Presently, only conversion to RR or LL is
     116  // supported.
     117  virtual std::vector<float> stokesToPolSpectrum(casa::Int whichRow,
     118                                                 casa::Bool toLinear,
     119                                                 casa::uInt polIdx) const;
    117120
    118121  // Get all Stokes at the specified Beam/IF cursor location (ignoring
  • trunk/src/SDMemTableWrapper.h

    r505 r527  
    8585    return table_->getSpectrum(whichRow);
    8686  }
    87 //
    88   std::vector<float> getStokesSpectrum(int whichRow=0, bool linPol=false) const {
     87
     88  std::vector<float> getStokesSpectrum(int whichRow=0,
     89                                       bool linPol=false) const {
    8990    return table_->getStokesSpectrum(whichRow, linPol);
    9091  }
    9192
    92   std::vector<float> stokesToPolSpectrum (int whichRow, bool linear,
    93                                           int polIdx) const {
     93  std::vector<float> stokesToPolSpectrum(int whichRow, bool linear,
     94                                         int polIdx) const {
    9495    return table_->stokesToPolSpectrum(whichRow, linear, polIdx);
    9596  }
    9697
    97 //  std::string getPolarizationLabel (bool linear, bool stokes, bool linPol, int polIdx) const {
    98 // Boost fails with 4 arguments.
    99   std::string getPolarizationLabel (bool linear, bool stokes, bool linPol) const {
    100      int polIdx = -1;
    101      return table_->getPolarizationLabel (linear, stokes, linPol, polIdx);
    102   }
    103 //
     98  //  std::string getPolarizationLabel(bool linear, bool stokes, bool linPol, int polIdx) const {
     99  // Boost fails with 4 arguments.
     100  std::string getPolarizationLabel(bool linear, bool stokes,
     101                                   bool linPol) const {
     102    int polIdx = -1;
     103    return table_->getPolarizationLabel(linear, stokes, linPol, polIdx);
     104  }
     105
    104106  std::vector<double> getAbcissa(int whichRow=0) const {
    105107    return table_->getAbcissa(whichRow);
Note: See TracChangeset for help on using the changeset viewer.