Changeset 2735
- Timestamp:
- 01/17/13 18:54:24 (12 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STApplyCal.cpp
r2733 r2735 65 65 caltype_ = STCalEnum::NoType; 66 66 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 69 void STApplyCal::reset() 70 { 71 } 72 73 void STApplyCal::completeReset() 74 { 75 reset(); 76 target_ = 0; 72 77 } 73 78 … … 85 90 void STApplyCal::push(STCalSkyTable *table) 86 91 { 92 os_.origin(LogOrigin("STApplyCal","push",WHERE)); 87 93 skytable_.push_back(table); 88 94 STCalEnum::CalType caltype = STApplyTable::getCalType(table); … … 102 108 } 103 109 104 void STApplyCal::set Interpolation(STCalEnum::InterpolationAxis axis,STCalEnum::InterpolationType itype, Int order)105 { 106 i nterp_[(int)axis]= itype;110 void STApplyCal::setTimeInterpolation(STCalEnum::InterpolationType itype, Int order) 111 { 112 iTime_ = itype; 107 113 order_ = order; 108 114 } 109 115 116 void STApplyCal::setFrequencyInterpolation(STCalEnum::InterpolationType itype, Int order) 117 { 118 iFreq_ = itype; 119 order_ = order; 120 } 121 110 122 void STApplyCal::setTsysTransfer(uInt from, Vector<uInt> to) 111 123 { 124 os_.origin(LogOrigin("STApplyCal","setTsysTransfer",WHERE)); 112 125 os_ << "from=" << from << ", to=" << to << LogIO::POST; 113 126 map<uInt, Vector<uInt> >::iterator i = spwmap_.find(from); … … 128 141 void STApplyCal::apply(Bool insitu) 129 142 { 143 os_.origin(LogOrigin("STApplyCal","apply",WHERE)); 130 144 // calibrator 131 145 if (caltype_ == STCalEnum::CalPSAlma) … … 143 157 target_->setSelection(sel_); 144 158 145 os_ << "sel_.print()=" << sel_.print() << LogIO::POST;159 //os_ << "sel_.print()=" << sel_.print() << LogIO::POST; 146 160 147 161 // working data … … 151 165 work_ = new Scantable(*target_, false); 152 166 153 os_ << "work_->nrow()=" << work_->nrow() << LogIO::POST;167 //os_ << "work_->nrow()=" << work_->nrow() << LogIO::POST; 154 168 155 169 // list of apply tables for sky calibration … … 157 171 uInt numSkyCal = 0; 158 172 uInt nrowSky = 0; 173 159 174 // list of apply tables for Tsys calibration 160 // Vector<uInt> tsyscalList;161 162 175 for (uInt i = 0 ; i < skytable_.size(); i++) { 163 176 STCalEnum::CalType caltype = STApplyTable::getCalType(skytable_[i]); … … 179 192 Vector<uInt> ids = iter->current(); 180 193 Vector<uInt> rows = iter->getRows(SHARE); 181 os_ << "ids=" << ids << LogIO::POST;182 194 if (rows.nelements() > 0) 183 195 doapply(ids[0], ids[2], ids[1], rows, skycalList); … … 192 204 Vector<uInt> &skylist) 193 205 { 194 os_ << "skylist=" << skylist << LogIO::POST; 195 os_ << "rows=" << rows << LogIO::POST; 206 os_.origin(LogOrigin("STApplyCal","doapply",WHERE)); 196 207 Bool doTsys = doTsys_; 197 208 198 //STSelector sel = sel_;199 209 STSelector sel; 200 210 vector<int> id(1); … … 205 215 id[0] = polno; 206 216 sel.setPolarizations(id); 207 os_ << "sel=" << sel.print() << LogIO::POST;208 217 209 218 // apply selection to apply tables … … 233 242 ftsys = tsystable_[0]->getBaseFrequency(0); 234 243 interpolatorF_->setX(ftsys.data(), nchanTsys); 235 os_ << "nchanTsys=" << nchanTsys << LogIO::POST;236 244 id[0] = (int)tsysifno; 237 245 sel.setIFs(id); … … 239 247 tsystable_[i]->setSelection(sel); 240 248 nrowTsys += tsystable_[i]->nrow(); 241 os_ << "nrowTsys=" << nrowTsys << LogIO::POST;242 249 } 243 250 } 244 251 245 252 uInt nchanSp = skytable_[skylist[0]]->nchan(ifno); 246 os_ << "nchanSp = " << nchanSp << LogIO::POST;247 253 Vector<Double> timeSky(nrowSky); 248 254 Matrix<Float> spoff(nchanSp, nrowSky); 249 255 Vector<Float> iOff(nchanSp); 250 256 nrowSky = 0; 251 os_ << "spoff.shape()=" << spoff.shape() << LogIO::POST;252 257 for (uInt i = 0 ; i < skylist.nelements(); i++) { 253 258 STCalSkyTable *p = skytable_[skylist[i]]; 254 os_ << "table " << i << ": nrow=" << p->nrow() << LogIO::POST;255 259 Vector<Double> t = p->getTime(); 256 260 Matrix<Float> sp = p->getSpectra(); 257 os_ << "sp.shape()=" << sp.shape() << LogIO::POST;258 os_ << "t.nelements()=" << t.nelements() << LogIO::POST;259 261 for (uInt j = 0; j < t.nelements(); j++) { 260 262 timeSky[nrowSky] = t[j]; 261 os_ << "timeSky[" << nrowSky << "]-timeSky[0]=" << timeSky[nrowSky] - timeSky[0] << LogIO::POST;262 263 spoff.column(nrowSky) = sp.column(j); 263 264 nrowSky++; 264 265 } 265 266 } 266 os_ << "timeSky-timeSky[0]=" << timeSky-timeSky[0] << LogIO::POST;267 267 268 268 Vector<uInt> skyIdx = timeSort(timeSky); 269 os_ << "skyIdx = " << skyIdx << LogIO::POST;270 269 271 270 Double *xa = new Double[skyIdx.nelements()]; … … 276 275 for (uInt i = 0 ; i < skyIdx.nelements(); i++) { 277 276 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 } 281 278 282 279 interpolatorS_->setX(xa, skyIdx.nelements()); 283 280 284 os_ << "doTsys = " << doTsys << LogIO::POST;285 281 Vector<uInt> tsysIdx; 286 282 Vector<Double> timeTsys(nrowTsys); … … 295 291 for (uInt i = 0 ; i < tsystable_.size(); i++) { 296 292 STCalTsysTable *p = tsystable_[i]; 297 os_ << "p->nrow()=" << p->nrow() << LogIO::POST;298 293 Vector<Double> t = p->getTime(); 299 os_ << "t=" << t << LogIO::POST;300 294 Matrix<Float> ts = p->getTsys(); 301 295 for (uInt j = 0; j < t.nelements(); j++) { … … 306 300 } 307 301 tsysIdx = timeSort(timeTsys); 308 os_ << "tsysIdx = " << tsysIdx << LogIO::POST;309 302 310 303 Double *xb = new Double[tsysIdx.nelements()]; … … 315 308 for (uInt i = 0 ; i < tsysIdx.nelements(); i++) { 316 309 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 } 320 311 interpolatorT_->setX(xb, tsysIdx.nelements()); 321 312 } … … 323 314 Table tab = work_->table(); 324 315 ArrayColumn<Float> spCol(tab, "SPECTRA"); 316 ArrayColumn<Float> tsysCol(tab, "TSYS"); 325 317 ScalarColumn<Double> timeCol(tab, "TIME"); 326 318 Vector<Float> on; 327 319 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; 329 321 uInt irow = rows[i]; 330 322 … … 362 354 iTsysT[ichan] = interpolatorT_->interpolate(t0); 363 355 } 364 os_ << "iTsysT=" << iTsysT << LogIO::POST;365 356 if (nchanSp == 1) { 366 357 // take average … … 369 360 else { 370 361 // interpolation on frequency axis 371 os_ << "getBaseFrequency for target" << LogIO::POST;372 362 Vector<Double> fsp = getBaseFrequency(rows[i]); 373 os_ << "fsp = " << fsp << LogIO::POST;374 363 interpolatorF_->setY(yt, nchanTsys); 375 364 for (uInt ichan = 0; ichan < nchanSp; ichan++) { … … 381 370 iTsys = 1.0; 382 371 } 383 os_ << "iTsys=" << iTsys << LogIO::POST;372 //os_ << "iTsys=" << iTsys << LogIO::POST; 384 373 calibrator_->setScaler(iTsys); 385 374 … … 388 377 389 378 // update table 390 os_ << "calibrated=" << calibrator_->getCalibrated() << LogIO::POST;379 //os_ << "calibrated=" << calibrator_->getCalibrated() << LogIO::POST; 391 380 spCol.put(irow, calibrator_->getCalibrated()); 392 381 tsysCol.put(irow, iTsys); 393 382 } 394 383 … … 421 410 i != spwmap_.end(); i++) { 422 411 Vector<uInt> tolist = i->second; 423 os_ << i->first << ": tolist=" << tolist << LogIO::POST;412 os_ << "from=" << i->first << ": tolist=" << tolist << LogIO::POST; 424 413 for (uInt j = 0; j < tolist.nelements(); j++) { 425 414 if (tolist[j] == to) … … 458 447 void STApplyCal::initInterpolator() 459 448 { 460 int ta = (int)STCalEnum::TimeAxis; 461 int fa = (int)STCalEnum::FrequencyAxis; 449 os_.origin(LogOrigin("STApplyCal","initInterpolator",WHERE)); 462 450 int order = (order_ > 0) ? order_ : 1; 463 switch (i nterp_[ta]) {451 switch (iTime_) { 464 452 case STCalEnum::NearestInterpolation: 465 453 { … … 507 495 } 508 496 509 switch (i nterp_[fa]) {497 switch (iFreq_) { 510 498 case STCalEnum::NearestInterpolation: 511 499 { -
trunk/src/STApplyCal.h
r2733 r2735 58 58 59 59 // 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); 61 63 62 64 // set IF (spw) mapping for Tsys transfer … … 69 71 void save(const casa::String &name); 70 72 73 // reset all settings except target scantable 74 void reset(); 75 76 // reset all settings 77 void completeReset(); 78 71 79 private: 72 80 // initialization … … 100 108 101 109 // interpolation method 102 std::vector<STCalEnum::InterpolationType> interp_;103 casa::Bool is2d_;110 STCalEnum::InterpolationType iTime_; 111 STCalEnum::InterpolationType iFreq_; 104 112 casa::Int order_; 105 113 casa::CountedPtr<Interpolator1D<casa::Double, casa::Float> > interpolatorT_;
Note:
See TracChangeset
for help on using the changeset viewer.