Changeset 1586


Ignore:
Timestamp:
06/30/09 15:46:14 (15 years ago)
Author:
Malte Marquarding
Message:

Ticket #165: have removed the hard-coding of parallactifying the data. NOTE THIS breaks the Table structure as I have moved the PARANGLE column from the main table into the FOCUS table. We need to have a new release. Also one needs to explicitly tell the scantable via rc or member function to enable parallactifying

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/__init__.py

    r1560 r1586  
    116116    'scantable.storage'   : ['memory', str],
    117117    'scantable.history'   : [True, _validate_bool],
    118     'scantable.reference'      : ['.*(e|w|_R)$', str]
     118    'scantable.reference'      : ['.*(e|w|_R)$', str],
     119    'scantable.parallactify'   : [False, _validate_bool]
    119120    # fitter
    120121    }
  • trunk/python/scantable.py

    r1584 r1586  
    1212    """
    1313
    14     def __init__(self, filename, average=None, unit=None):
     14    def __init__(self, filename, average=None, unit=None, parallactify=None):
    1515        """
    1616        Create a scantable from a saved one or make a reference
     
    3030                         (input rpfits/sdfits/ms) or replaces the value
    3131                         in existing scantables
     32            parallactify: Indcicate that the data had been parallatified.
     33                          Default is taken form rc file.
    3234        """
    3335        if average is None:
    3436            average = rcParams['scantable.autoaverage']
     37        if parallactify is None:
     38            parallactify = rcParams['scantable.parallactify']
    3539        varlist = vars()
    3640        from asap._asap import stmath
     
    7478                  and isinstance(filename[-1], str):
    7579                self._fill(filename, unit, average)
     80        self.parallactify(parallactify)
    7681        self._add_history("scantable", varlist)
    7782        print_log()
     
    12241229        return s
    12251230
     1231    def parallactify(self, pflag):
     1232        varlist = vars()
     1233        self._parallactify(pflag)
     1234        self._add_history("parallactify", varlist)
     1235
    12261236    def convert_pol(self, poltype=None):
    12271237        """
  • trunk/src/STFiller.cpp

    r1504 r1586  
    216216    }
    217217  }
    218      
     218  //table_->focus().setParallactify(true);
    219219}
    220220
     
    300300    /// @todo this has to change when nchan isn't global anymore
    301301    id = table_->frequencies().addEntry(Double(header_->nchan/2),
    302                                             pksrec.refFreq, pksrec.freqInc);
     302                                        pksrec.refFreq, pksrec.freqInc);
    303303    RecordFieldPtr<uInt> mfreqidCol(rec, "FREQ_ID");
    304304    *mfreqidCol = id;
     
    316316    RecordFieldPtr<uInt> mweatheridCol(rec, "WEATHER_ID");
    317317    *mweatheridCol = id;
     318
    318319    RecordFieldPtr<uInt> mfocusidCol(rec, "FOCUS_ID");
    319     id = table_->focus().addEntry(pksrec.focusAxi, pksrec.focusTan,
    320                                   pksrec.focusRot);
     320    id = table_->focus().addEntry(pksrec.parAngle, pksrec.focusAxi,
     321                                  pksrec.focusTan, pksrec.focusRot);
    321322    *mfocusidCol = id;
    322323    RecordFieldPtr<Array<Double> > dirCol(rec, "DIRECTION");
     
    326327    RecordFieldPtr<Float> elCol(rec, "ELEVATION");
    327328    *elCol = pksrec.elevation;
    328 
    329     RecordFieldPtr<Float> parCol(rec, "PARANGLE");
    330     *parCol = pksrec.parAngle;
    331329
    332330    RecordFieldPtr< Array<Float> > specCol(rec, "SPECTRA");
  • trunk/src/STFocus.cpp

    r957 r1586  
    3434}
    3535
    36 asap::STFocus::STFocus( casa::Table tab ) : STSubTable(tab, name_)
     36STFocus::STFocus( casa::Table tab ) :
     37  STSubTable(tab, name_)
    3738{
     39  parangleCol_.attach(table_,"PARANGLE");
    3840  rotationCol_.attach(table_,"ROTATION");
    3941  axisCol_.attach(table_,"AXIS");
     
    5052}
    5153
    52 STFocus& asap::STFocus::operator =( const STFocus & other )
     54STFocus& STFocus::operator =( const STFocus & other )
    5355{
    5456  if (this != &other) {
    5557    static_cast<STSubTable&>(*this) = other;
     58    parangleCol_.attach(table_,"PARANGLE");
    5659    rotationCol_.attach(table_,"ROTATION");
    5760    axisCol_.attach(table_,"AXIS");
     
    6568  return *this;
    6669}
    67 void asap::STFocus::setup( )
     70void STFocus::setup( )
    6871{
    6972  // add to base class table
     73  table_.addColumn(ScalarColumnDesc<Float>("PARANGLE"));
    7074  table_.addColumn(ScalarColumnDesc<Float>("ROTATION"));
    7175  table_.addColumn(ScalarColumnDesc<Float>("AXIS"));
     
    7680  table_.addColumn(ScalarColumnDesc<Float>("XYPHASE"));
    7781  table_.addColumn(ScalarColumnDesc<Float>("XYPHASEOFFSET"));
     82  table_.rwKeywordSet().define("PARALLACTIFY", False);
    7883
    7984  // new cached columns
     85  parangleCol_.attach(table_,"PARANGLE");
    8086  rotationCol_.attach(table_,"ROTATION");
    8187  axisCol_.attach(table_,"AXIS");
     
    8894}
    8995
    90 uInt STFocus::addEntry( Float fax, Float ftan, Float frot, Float hand,
    91                         Float user, Float mount,
    92                         Float xyphase, Float xyphaseoffset)
     96  uInt STFocus::addEntry( Float pa, Float fax, Float ftan, Float frot, Float hand,
     97                          Float user, Float mount,
     98                          Float xyphase, Float xyphaseoffset)
    9399{
    94   Table result = table_( near(table_.col("ROTATION"), frot)
    95                     && near(table_.col("AXIS"), fax)
    96                     && near(table_.col("TAN"), ftan)
    97                     && near(table_.col("HAND"), hand)
    98                     && near(table_.col("USERPHASE"), user)
    99                     && near(table_.col("MOUNT"), mount)
    100                     && near(table_.col("XYPHASE"), xyphase)
    101                     && near(table_.col("XYPHASEOFFSET"), xyphaseoffset)
    102                     );
     100  Table result = table_(  near(table_.col("PARANGLE"), pa)
     101                          && near(table_.col("ROTATION"), frot)
     102                          && near(table_.col("AXIS"), fax)
     103                          && near(table_.col("TAN"), ftan)
     104                          && near(table_.col("HAND"), hand)
     105                          && near(table_.col("USERPHASE"), user)
     106                          && near(table_.col("MOUNT"), mount)
     107                          && near(table_.col("XYPHASE"), xyphase)
     108                          && near(table_.col("XYPHASEOFFSET"), xyphaseoffset)
     109                          );
    103110  uInt resultid = 0;
    104111  if ( result.nrow() > 0) {
     
    113120      resultid++;
    114121    }
     122    parangleCol_.put(rno, pa);
    115123    rotationCol_.put(rno, frot);
    116124    axisCol_.put(rno, fax);
     
    126134}
    127135
    128 void asap::STFocus::getEntry( Float& rotation, Float& angle, Float& ftan,
    129                               Float& hand, Float& user, Float& mount,
    130                               Float& xyphase, Float& xyphaseoffset,
    131                               uInt id) const
     136  void STFocus::getEntry( Float& pa, Float& rotation, Float& angle, Float& ftan,
     137                                Float& hand, Float& user, Float& mount,
     138                                Float& xyphase, Float& xyphaseoffset,
     139                                uInt id) const
    132140{
    133141  Table t = table_(table_.col("ID") == Int(id) );
     
    138146  // get first row - there should only be one matching id
    139147  const TableRecord& rec = row.get(0);
     148  pa = rec.asFloat("PARANGLE");
    140149  rotation = rec.asFloat("ROTATION");
    141150  angle = rec.asFloat("AXIS");
     
    149158
    150159
    151 casa::Float asap::STFocus::getTotalFeedAngle( casa::uInt id ) const
     160casa::Float STFocus::getTotalAngle( casa::uInt id ) const
    152161{
    153162  Float total = 0.0f;
    154163  Table t = table_(table_.col("ID") == Int(id) );
    155164  if (t.nrow() == 0 ) {
    156     throw(AipsError("STFocus::getEntry - id out of range"));
     165    throw(AipsError("STFocus::getTotalAngle - id out of range"));
     166  }
     167  if (table_.keywordSet().asBool("PARALLACTIFY")) {
     168    return 0.0f;
    157169  }
    158170  ROTableRow row(t);
    159171  // get first row - there should only be one matching id
    160172  const TableRecord& rec = row.get(0);
     173  total += rec.asFloat("PARANGLE"); 
    161174  total += rec.asFloat("ROTATION");
    162175  total += rec.asFloat("USERPHASE");
     
    164177  return total;
    165178}
    166 }
    167179
    168 casa::Float asap::STFocus::getFeedHand( casa::uInt id ) const
     180
     181casa::Float STFocus::getFeedHand( casa::uInt id ) const
    169182{
    170183  Table t = table_(table_.col("ID") == Int(id) );
     
    177190}
    178191
     192void STFocus::setParallactify(bool istrue) {
     193  cout << "called setPara" << endl;
     194  table_.rwKeywordSet().define("PARALLACTIFY", Bool(istrue));
     195}
     196
     197}
  • trunk/src/STFocus.h

    r1353 r1586  
    3737  STFocus& operator=(const STFocus& other);
    3838
    39   casa::uInt addEntry( casa::Float faxis, casa::Float ftan,
     39  casa::uInt addEntry( casa::Float pa, casa::Float faxis, casa::Float ftan,
    4040                       casa::Float frot, casa::Float hand=1.0f,
    4141                       casa::Float mount=0.0f, casa::Float user=0.0f,
    42                        casa::Float xyphase=0.0f, casa::Float xyphaseoffset=0.0f);
     42                       casa::Float xyphase=0.0f,
     43                       casa::Float xyphaseoffset=0.0f);
    4344
    44   void getEntry( casa::Float& fax, casa::Float& ftan,
     45  void getEntry( casa::Float& pa, casa::Float& fax, casa::Float& ftan,
    4546                 casa::Float& frot, casa::Float& hand,
    4647                 casa::Float& mount, casa::Float& user,
     
    4849                 casa::uInt id) const;
    4950
    50   casa::Float getTotalFeedAngle(casa::uInt id) const;
     51  casa::Float getTotalAngle(casa::uInt id) const;
     52
     53  casa::Float getParAngle(casa::uInt id) const {
     54    return parangleCol_(id);
     55  }
    5156  casa::Float getFeedHand(casa::uInt id) const;
     57
     58  void setParallactify(bool istrue=false);
    5259
    5360  const casa::String& name() const { return name_; }
     
    5764  static const casa::String name_;
    5865  casa::ScalarColumn<casa::Float> rotationCol_, axisCol_,
    59                                   tanCol_,handCol_,
    60                                   mountCol_,userCol_,
    61                                   xyphCol_,xyphoffCol_;
     66    tanCol_,handCol_, parangleCol_,
     67    mountCol_,userCol_, xyphCol_,xyphoffCol_,;
    6268};
    6369
  • trunk/src/STMath.cpp

    r1579 r1586  
    15761576          id = out->molecules().addEntry(rf, name, fname);
    15771577          molidcol.put(k, id);
    1578           Float frot,fax,ftan,fhand,fmount,fuser, fxy, fxyp;
    1579           (*it)->focus().getEntry(fax, ftan, frot, fhand,
     1578          Float fpa,frot,fax,ftan,fhand,fmount,fuser, fxy, fxyp;
     1579          (*it)->focus().getEntry(fpa, fax, ftan, frot, fhand,
    15801580                                  fmount,fuser, fxy, fxyp,
    15811581                                  rec.asuInt("FOCUS_ID"));
    1582           id = out->focus().addEntry(fax, ftan, frot, fhand,
     1582          id = out->focus().addEntry(fpa, fax, ftan, frot, fhand,
    15831583                                     fmount,fuser, fxy, fxyp);
    15841584          focusidcol.put(k, id);
     
    16301630    ArrayColumn<Float> speccol(t, "SPECTRA");
    16311631    ScalarColumn<uInt> focidcol(t, "FOCUS_ID");
    1632     ScalarColumn<Float> parancol(t, "PARANGLE");
    16331632    Matrix<Float> pols(speccol.getColumn());
    16341633    try {
    16351634      stpol->setSpectra(pols);
    1636       Float fang,fhand,parang;
    1637       fang = in->focusTable_.getTotalFeedAngle(focidcol(0));
     1635      Float fang,fhand;
     1636      fang = in->focusTable_.getTotalAngle(focidcol(0));
    16381637      fhand = in->focusTable_.getFeedHand(focidcol(0));
    1639       parang = parancol(0);
    1640       /// @todo re-enable this
    1641       // disable total feed angle to support paralactifying Caswell style
    1642       stpol->setPhaseCorrections(parang, -parang, fhand);
     1638      stpol->setPhaseCorrections(fang, fhand);
    16431639      // use a member function pointer in STPol.  This only works on
    16441640      // the STPol pointer itself, not the Counted Pointer so
     
    19061902      uInt row = tab.rowNumbers()[0];
    19071903      stpol->setSpectra(in->getPolMatrix(row));
    1908       Float fang,fhand,parang;
    1909       fang = in->focusTable_.getTotalFeedAngle(in->mfocusidCol_(row));
     1904      Float fang,fhand;
     1905      fang = in->focusTable_.getTotalAngle(in->mfocusidCol_(row));
    19101906      fhand = in->focusTable_.getFeedHand(in->mfocusidCol_(row));
    1911       parang = in->paraCol_(row);
    1912       /// @todo re-enable this
    1913       // disable total feed angle to support paralactifying Caswell style
    1914       stpol->setPhaseCorrections(parang, -parang, fhand);
     1907      stpol->setPhaseCorrections(fang, fhand);
    19151908      Int npolout = 0;
    19161909      for (uInt i=0; i<tab.nrow(); ++i) {
  • trunk/src/STPol.h

    r1015 r1586  
    3535
    3636  typedef  void (STPol::*polOperation)( casa::Float phase );
    37   STPol(): totalfeed_(0.0),parangle_(0.0),feedhand_(1.0) {}
     37  STPol(): totalangle_(0.0),feedhand_(1.0) {}
    3838  virtual ~STPol() {}
    3939
     
    8383
    8484
    85   void setPhaseCorrections(casa::Float parangle=0.0, casa::Float totalfeed=0.0,
    86                            casa::Float feedhand=1.0)
    87     { totalfeed_=totalfeed;parangle_=parangle;feedhand_=feedhand;}
     85  void setPhaseCorrections(casa::Float totalang=0.0, casa::Float feedhand=1.0)
     86    { totalangle_=totalang;feedhand_=feedhand;}
    8887
    89   casa::Float getTotalPhase() const { return totalfeed_+parangle_; }
     88  casa::Float getTotalPhase() const { return totalangle_; }
    9089  casa::Float getFeedHand() const { return feedhand_; }
    9190
     
    9998  static std::map<std::string, std::map<int, std::string> > labelmap_;
    10099
    101   casa::Float totalfeed_,parangle_,feedhand_;
     100  casa::Float totalangle_,feedhand_;
    102101  std::string mode_;
    103102  casa::Matrix<casa::Float> basespectra_;
  • trunk/src/STWriter.cpp

    r1575 r1586  
    214214          inst->frequencies().getEntry(crpix,crval, pksrec.freqInc,
    215215                                     rec.asuInt("FREQ_ID"));
    216           inst->focus().getEntry(pksrec.focusAxi, pksrec.focusTan,
    217                                pksrec.focusRot, tmp0,tmp1,tmp2,tmp3,tmp4,
    218                                rec.asuInt("FOCUS_ID"));
     216          inst->focus().getEntry(pksrec.parAngle, pksrec.focusAxi, pksrec.focusTan,
     217                                 pksrec.focusRot, tmp0,tmp1,tmp2,tmp3,tmp4,
     218                                 rec.asuInt("FOCUS_ID"));
    219219          inst->molecules().getEntry(pksrec.restFreq,stmp0,stmp1,
    220220                                   rec.asuInt("MOLECULE_ID"));
     
    240240          pksrec.azimuth   = rec.asFloat("AZIMUTH");
    241241          pksrec.elevation = rec.asFloat("ELEVATION");
    242           pksrec.parAngle  = rec.asFloat("PARANGLE");
    243242          pksrec.refBeam   = rec.asInt("REFBEAMNO") + 1;
    244243          pksrec.sigma.resize(npol);
  • trunk/src/Scantable.cpp

    r1567 r1586  
    234234  td.addColumn(ScalarColumnDesc<Float>("AZIMUTH"));
    235235  td.addColumn(ScalarColumnDesc<Float>("ELEVATION"));
    236   td.addColumn(ScalarColumnDesc<Float>("PARANGLE"));
    237236  td.addColumn(ScalarColumnDesc<Float>("OPACITY"));
    238237
     
    277276  elCol_.attach(table_, "ELEVATION");
    278277  dirCol_.attach(table_, "DIRECTION");
    279   paraCol_.attach(table_, "PARANGLE");
    280278  fldnCol_.attach(table_, "FIELDNAME");
    281279  rbeamCol_.attach(table_, "REFBEAMNO");
     
    693691    specCol_.get(whichrow, arr);
    694692  } else {
    695     CountedPtr<STPol> stpol(STPol::getPolClass(Scantable::factories_, basetype));
     693    CountedPtr<STPol> stpol(STPol::getPolClass(Scantable::factories_,
     694                                               basetype));
    696695    uInt row = uInt(whichrow);
    697696    stpol->setSpectra(getPolMatrix(row));
    698697    Float fang,fhand,parang;
    699     fang = focusTable_.getTotalFeedAngle(mfocusidCol_(row));
     698    fang = focusTable_.getTotalAngle(mfocusidCol_(row));
    700699    fhand = focusTable_.getFeedHand(mfocusidCol_(row));
    701     parang = paraCol_(row);
    702     /// @todo re-enable this
    703     // disable total feed angle to support paralactifying Caswell style
    704     stpol->setPhaseCorrections(parang, -parang, fhand);
     700    stpol->setPhaseCorrections(fang, fhand);
    705701    arr = stpol->getSpectrum(requestedpol, ptype);
    706702  }
  • trunk/src/Scantable.h

    r1441 r1586  
    298298    { return azCol_(whichrow); }
    299299  float getParAngle(int whichrow) const
    300     { return paraCol_(whichrow); }
     300  { return focus().getParAngle(mfocusidCol_(whichrow)); }
    301301
    302302  std::string getSourceName(int whichrow) const
     
    402402  std::vector<double> getDirectionVector(int whichrow) const;
    403403
     404  /**
     405   * Set a flag indicating whether the data was parallactified
     406   * @param[in] flag true or false
     407   */
     408  void parallactify(bool flag)
     409  {focus().setParallactify(flag);}
    404410private:
    405411
     
    451457  std::vector<uint> getNumbers(casa::ScalarColumn<casa::uInt>& col);
    452458
    453   static const casa::uInt version_ = 2;
     459  static const casa::uInt version_ = 3;
    454460
    455461  STSelector selector_;
     
    475481  casa::ScalarColumn<casa::Float> azCol_;
    476482  casa::ScalarColumn<casa::Float> elCol_;
    477   casa::ScalarColumn<casa::Float> paraCol_;
    478483  casa::ScalarColumn<casa::String> srcnCol_, fldnCol_;
    479484  casa::ScalarColumn<casa::uInt> scanCol_, beamCol_, ifCol_, polCol_, cycleCol_;
  • trunk/src/ScantableWrapper.h

    r1430 r1586  
    212212    { return table_->getDirectionVector(whichrow); }
    213213
     214  void parallactify(bool flag)
     215    { table_->parallactify(flag); }
     216
    214217private:
    215218  casa::CountedPtr<Scantable> table_;
  • trunk/src/python_Scantable.cpp

    r1440 r1586  
    124124    .def("_setsourcetype", &ScantableWrapper::setSourceType)
    125125    .def("_getdirectionvec", &ScantableWrapper::getDirectionVector)
     126    .def("_parallactify", &ScantableWrapper::parallactify)
    126127  ;
    127128};
Note: See TracChangeset for help on using the changeset viewer.