Changeset 2735


Ignore:
Timestamp:
01/17/13 18:54:24 (11 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-4770

Ready for Test: Yes

Interface Changes: Yes/No?

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

  • clean up log messages
  • interface changes to be easier to call from Python layer
  • added reset and completeReset method
Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STApplyCal.cpp

    r2733 r2735  
    6565  caltype_ = STCalEnum::NoType;
    6666  doTsys_ = False;
    67   interp_.resize((int)STCalEnum::NumAxis);
    68   // default is linear interpolation
    69   for (unsigned int i = 0; i < interp_.size(); i++) {
    70     interp_[i] = STCalEnum::LinearInterpolation;
    71   }
     67}
     68
     69void STApplyCal::reset()
     70{
     71}
     72
     73void STApplyCal::completeReset()
     74{
     75  reset();
     76  target_ = 0;
    7277}
    7378
     
    8590void STApplyCal::push(STCalSkyTable *table)
    8691{
     92  os_.origin(LogOrigin("STApplyCal","push",WHERE));
    8793  skytable_.push_back(table);
    8894  STCalEnum::CalType caltype = STApplyTable::getCalType(table);
     
    102108}
    103109
    104 void STApplyCal::setInterpolation(STCalEnum::InterpolationAxis axis, STCalEnum::InterpolationType itype, Int order)
    105 {
    106   interp_[(int)axis] = itype;
     110void STApplyCal::setTimeInterpolation(STCalEnum::InterpolationType itype, Int order)
     111{
     112  iTime_ = itype;
    107113  order_ = order;
    108114}
    109115
     116void STApplyCal::setFrequencyInterpolation(STCalEnum::InterpolationType itype, Int order)
     117{
     118  iFreq_ = itype;
     119  order_ = order;
     120}
     121
    110122void STApplyCal::setTsysTransfer(uInt from, Vector<uInt> to)
    111123{
     124  os_.origin(LogOrigin("STApplyCal","setTsysTransfer",WHERE));
    112125  os_ << "from=" << from << ", to=" << to << LogIO::POST;
    113126  map<uInt, Vector<uInt> >::iterator i = spwmap_.find(from);
     
    128141void STApplyCal::apply(Bool insitu)
    129142{
     143  os_.origin(LogOrigin("STApplyCal","apply",WHERE));
    130144  // calibrator
    131145  if (caltype_ == STCalEnum::CalPSAlma)
     
    143157  target_->setSelection(sel_);
    144158
    145   os_ << "sel_.print()=" << sel_.print() << LogIO::POST;
     159  //os_ << "sel_.print()=" << sel_.print() << LogIO::POST;
    146160
    147161  // working data
     
    151165    work_ = new Scantable(*target_, false);
    152166
    153   os_ << "work_->nrow()=" << work_->nrow() << LogIO::POST;
     167  //os_ << "work_->nrow()=" << work_->nrow() << LogIO::POST;
    154168
    155169  // list of apply tables for sky calibration
     
    157171  uInt numSkyCal = 0;
    158172  uInt nrowSky = 0;
     173
    159174  // list of apply tables for Tsys calibration
    160 //   Vector<uInt> tsyscalList;
    161 
    162175  for (uInt i = 0 ; i < skytable_.size(); i++) {
    163176    STCalEnum::CalType caltype = STApplyTable::getCalType(skytable_[i]);
     
    179192    Vector<uInt> ids = iter->current();
    180193    Vector<uInt> rows = iter->getRows(SHARE);
    181     os_ << "ids=" << ids << LogIO::POST;
    182194    if (rows.nelements() > 0)
    183195      doapply(ids[0], ids[2], ids[1], rows, skycalList);
     
    192204                         Vector<uInt> &skylist)
    193205{
    194   os_ << "skylist=" << skylist << LogIO::POST;
    195   os_ << "rows=" << rows << LogIO::POST;
     206  os_.origin(LogOrigin("STApplyCal","doapply",WHERE));
    196207  Bool doTsys = doTsys_;
    197208
    198   //STSelector sel = sel_;
    199209  STSelector sel;
    200210  vector<int> id(1);
     
    205215  id[0] = polno;
    206216  sel.setPolarizations(id); 
    207   os_ << "sel=" << sel.print() << LogIO::POST;
    208217
    209218  // apply selection to apply tables
     
    233242    ftsys = tsystable_[0]->getBaseFrequency(0);
    234243    interpolatorF_->setX(ftsys.data(), nchanTsys);
    235     os_ << "nchanTsys=" << nchanTsys << LogIO::POST;
    236244    id[0] = (int)tsysifno;
    237245    sel.setIFs(id);
     
    239247      tsystable_[i]->setSelection(sel);
    240248      nrowTsys += tsystable_[i]->nrow();
    241       os_ << "nrowTsys=" << nrowTsys << LogIO::POST;
    242249    }
    243250  }
    244251
    245252  uInt nchanSp = skytable_[skylist[0]]->nchan(ifno);
    246   os_ << "nchanSp = " << nchanSp << LogIO::POST;
    247253  Vector<Double> timeSky(nrowSky);
    248254  Matrix<Float> spoff(nchanSp, nrowSky);
    249255  Vector<Float> iOff(nchanSp);
    250256  nrowSky = 0;
    251   os_ << "spoff.shape()=" << spoff.shape() << LogIO::POST;
    252257  for (uInt i = 0 ; i < skylist.nelements(); i++) {
    253258    STCalSkyTable *p = skytable_[skylist[i]];
    254     os_ << "table " << i << ": nrow=" << p->nrow() << LogIO::POST;
    255259    Vector<Double> t = p->getTime();
    256260    Matrix<Float> sp = p->getSpectra();
    257     os_ << "sp.shape()=" << sp.shape() << LogIO::POST;
    258     os_ << "t.nelements()=" << t.nelements() << LogIO::POST;
    259261    for (uInt j = 0; j < t.nelements(); j++) {
    260262      timeSky[nrowSky] = t[j];
    261       os_ << "timeSky[" << nrowSky << "]-timeSky[0]=" << timeSky[nrowSky] - timeSky[0] << LogIO::POST;
    262263      spoff.column(nrowSky) = sp.column(j);
    263264      nrowSky++;
    264265    }
    265266  }
    266   os_ << "timeSky-timeSky[0]=" << timeSky-timeSky[0] << LogIO::POST;
    267267
    268268  Vector<uInt> skyIdx = timeSort(timeSky);
    269   os_ << "skyIdx = " << skyIdx << LogIO::POST;
    270269
    271270  Double *xa = new Double[skyIdx.nelements()];
     
    276275  for (uInt i = 0 ; i < skyIdx.nelements(); i++) {
    277276    timeSkySorted[i] = timeSky[skyIdx[i]];
    278     os_ << "timeSkySorted[" << i << "]-timeSkySorted[0]=" << timeSkySorted[i] - timeSkySorted[0] << LogIO::POST;
    279   }
    280   os_ << "timeSkySorted-timeSkySorted[0]=" << timeSkySorted-timeSkySorted[0] << LogIO::POST;
     277  }
    281278
    282279  interpolatorS_->setX(xa, skyIdx.nelements());
    283280
    284   os_ << "doTsys = " << doTsys << LogIO::POST;
    285281  Vector<uInt> tsysIdx;
    286282  Vector<Double> timeTsys(nrowTsys);
     
    295291    for (uInt i = 0 ; i < tsystable_.size(); i++) {
    296292      STCalTsysTable *p = tsystable_[i];
    297       os_ << "p->nrow()=" << p->nrow() << LogIO::POST;
    298293      Vector<Double> t = p->getTime();
    299       os_ << "t=" << t << LogIO::POST;
    300294      Matrix<Float> ts = p->getTsys();
    301295      for (uInt j = 0; j < t.nelements(); j++) {
     
    306300    }
    307301    tsysIdx = timeSort(timeTsys);
    308     os_ << "tsysIdx = " << tsysIdx << LogIO::POST;
    309302
    310303    Double *xb = new Double[tsysIdx.nelements()];
     
    315308    for (uInt i = 0 ; i < tsysIdx.nelements(); i++) {
    316309      timeTsysSorted[i] = timeTsys[tsysIdx[i]];
    317       os_ << "timeTsysSorted[" << i << "]-timeTsysSorted[0]=" << timeTsysSorted[i] - timeTsysSorted[0] << LogIO::POST;
    318     }
    319     os_ << "timeTsysSorted=" << timeTsysSorted << LogIO::POST;
     310    }
    320311    interpolatorT_->setX(xb, tsysIdx.nelements());
    321312  }
     
    323314  Table tab = work_->table();
    324315  ArrayColumn<Float> spCol(tab, "SPECTRA");
     316  ArrayColumn<Float> tsysCol(tab, "TSYS");
    325317  ScalarColumn<Double> timeCol(tab, "TIME");
    326318  Vector<Float> on;
    327319  for (uInt i = 0; i < rows.nelements(); i++) {
    328     os_ << "start row " << i << LogIO::POST;
     320    os_ << "start i = " << i << " (row = " << rows[i] << ")" << LogIO::POST;
    329321    uInt irow = rows[i];
    330322
     
    362354        iTsysT[ichan] = interpolatorT_->interpolate(t0);
    363355      }
    364       os_ << "iTsysT=" << iTsysT << LogIO::POST;
    365356      if (nchanSp == 1) {
    366357        // take average
     
    369360      else {
    370361        // interpolation on frequency axis
    371         os_ << "getBaseFrequency for target" << LogIO::POST;
    372362        Vector<Double> fsp = getBaseFrequency(rows[i]);
    373         os_ << "fsp = " << fsp << LogIO::POST;
    374363        interpolatorF_->setY(yt, nchanTsys);
    375364        for (uInt ichan = 0; ichan < nchanSp; ichan++) {
     
    381370      iTsys = 1.0;
    382371    }
    383     os_ << "iTsys=" << iTsys << LogIO::POST;
     372    //os_ << "iTsys=" << iTsys << LogIO::POST;
    384373    calibrator_->setScaler(iTsys);
    385374 
     
    388377
    389378    // update table
    390     os_ << "calibrated=" << calibrator_->getCalibrated() << LogIO::POST;
     379    //os_ << "calibrated=" << calibrator_->getCalibrated() << LogIO::POST;
    391380    spCol.put(irow, calibrator_->getCalibrated());
    392    
     381    tsysCol.put(irow, iTsys);
    393382  }
    394383 
     
    421410       i != spwmap_.end(); i++) {
    422411    Vector<uInt> tolist = i->second;
    423     os_ << i->first << ": tolist=" << tolist << LogIO::POST;
     412    os_ << "from=" << i->first << ": tolist=" << tolist << LogIO::POST;
    424413    for (uInt j = 0; j < tolist.nelements(); j++) {
    425414      if (tolist[j] == to)
     
    458447void STApplyCal::initInterpolator()
    459448{
    460   int ta = (int)STCalEnum::TimeAxis;
    461   int fa = (int)STCalEnum::FrequencyAxis;
     449  os_.origin(LogOrigin("STApplyCal","initInterpolator",WHERE));
    462450  int order = (order_ > 0) ? order_ : 1;
    463   switch (interp_[ta]) {
     451  switch (iTime_) {
    464452  case STCalEnum::NearestInterpolation:
    465453    {
     
    507495  }
    508496   
    509   switch (interp_[fa]) {
     497  switch (iFreq_) {
    510498  case STCalEnum::NearestInterpolation:
    511499    {
  • trunk/src/STApplyCal.h

    r2733 r2735  
    5858
    5959  // set interpolation method
    60   void setInterpolation(STCalEnum::InterpolationAxis axis, STCalEnum::InterpolationType itype, casa::Int order=-1);
     60  //void setInterpolation(STCalEnum::InterpolationAxis axis, STCalEnum::InterpolationType itype, casa::Int order=-1);
     61  void setTimeInterpolation(STCalEnum::InterpolationType itype, casa::Int order=-1);
     62  void setFrequencyInterpolation(STCalEnum::InterpolationType itype, casa::Int order=-1);
    6163
    6264  // set IF (spw) mapping for Tsys transfer
     
    6971  void save(const casa::String &name);
    7072
     73  // reset all settings except target scantable
     74  void reset();
     75
     76  // reset all settings
     77  void completeReset();
     78 
    7179private:
    7280  // initialization
     
    100108
    101109  // interpolation method
    102   std::vector<STCalEnum::InterpolationType> interp_;
    103   casa::Bool is2d_;
     110  STCalEnum::InterpolationType iTime_;
     111  STCalEnum::InterpolationType iFreq_;
    104112  casa::Int order_;
    105113  casa::CountedPtr<Interpolator1D<casa::Double, casa::Float> > interpolatorT_;
Note: See TracChangeset for help on using the changeset viewer.