Changeset 2928
- Timestamp:
- 04/16/14 12:19:06 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STApplyCal.cpp
r2925 r2928 206 206 207 207 // list of apply tables for sky calibration 208 Vector<uInt> skycalList ;208 Vector<uInt> skycalList(skytable_.size()); 209 209 uInt numSkyCal = 0; 210 uInt nrowSky = 0;211 210 212 211 // list of apply tables for Tsys calibration … … 214 213 STCalEnum::CalType caltype = STApplyTable::getCalType(skytable_[i]); 215 214 if (caltype == caltype_) { 216 skycalList.resize(numSkyCal+1, True);217 215 skycalList[numSkyCal] = i; 218 216 numSkyCal++; 219 nrowSky += skytable_[i]->nrow();220 221 }217 } 218 } 219 skycalList.resize(numSkyCal, True); 222 220 223 221 … … 303 301 304 302 uInt nchanSp = skytable_[skylist[0]]->nchan(ifno); 305 Vector<Double> timeSky(nrowSky); 306 Matrix<Float> spoff(nrowSky, nchanSp); 307 Vector<Float> iOff(nchanSp); 308 nrowSky = 0; 309 for (uInt i = 0 ; i < skylist.nelements(); i++) { 310 STCalSkyTable *p = skytable_[skylist[i]]; 311 Vector<Double> t = p->getTime(); 312 Matrix<Float> sp = p->getSpectra(); 313 for (uInt j = 0; j < t.nelements(); j++) { 314 timeSky[nrowSky] = t[j]; 315 spoff.row(nrowSky) = sp.column(j); 316 nrowSky++; 317 } 318 } 319 320 Vector<uInt> skyIdx = timeSort(timeSky); 321 322 Double *xa = new Double[skyIdx.nelements()]; 323 Float *ya = new Float[skyIdx.nelements()]; 324 IPosition ipos(1, skyIdx.nelements()); 325 Vector<Double> timeSkySorted(ipos, xa, TAKE_OVER); 326 Vector<Float> tmpOff(ipos, ya, TAKE_OVER); 327 for (uInt i = 0 ; i < skyIdx.nelements(); i++) { 328 timeSkySorted[i] = timeSky[skyIdx[i]]; 329 } 330 331 interpolatorS_->setX(xa, skyIdx.nelements()); 332 333 Vector<uInt> tsysIdx; 334 Vector<Double> timeTsys(nrowTsys); 335 Matrix<Float> tsys; 303 uInt nrowSkySorted = nrowSky; 304 Vector<Double> timeSkySorted; 305 Matrix<Float> spoffSorted; 306 { 307 Vector<Double> timeSky(nrowSky); 308 Matrix<Float> spoff(nrowSky, nchanSp); 309 nrowSky = 0; 310 for (uInt i = 0 ; i < skylist.nelements(); i++) { 311 STCalSkyTable *p = skytable_[skylist[i]]; 312 Vector<Double> t = p->getTime(); 313 Matrix<Float> sp = p->getSpectra(); 314 for (uInt j = 0; j < t.nelements(); j++) { 315 timeSky[nrowSky] = t[j]; 316 spoff.row(nrowSky) = sp.column(j); 317 nrowSky++; 318 } 319 } 320 321 Vector<uInt> skyIdx = timeSort(timeSky); 322 nrowSkySorted = skyIdx.nelements(); 323 324 timeSkySorted.takeStorage(IPosition(1, nrowSkySorted), 325 new Double[nrowSkySorted], 326 TAKE_OVER); 327 for (uInt i = 0 ; i < nrowSkySorted; i++) { 328 timeSkySorted[i] = timeSky[skyIdx[i]]; 329 } 330 interpolatorS_->setX(timeSkySorted.data(), nrowSkySorted); 331 332 spoffSorted.takeStorage(IPosition(2, nrowSky, nchanSp), 333 new Float[nrowSky * nchanSp], 334 TAKE_OVER); 335 for (uInt i = 0 ; i < nrowSky; i++) { 336 spoffSorted.row(i) = spoff.row(skyIdx[i]); 337 } 338 } 339 340 uInt nrowTsysSorted = nrowTsys; 341 Matrix<Float> tsysSorted; 336 342 Vector<Double> timeTsysSorted; 337 Vector<Float> tmpTsys;338 343 if (doTsys) { 339 344 //os_ << "doTsys" << LogIO::POST; 340 timeTsys.resize(nrowTsys); 341 tsys.resize(nrowTsys, nchanTsys); 345 Vector<Double> timeTsys(nrowTsys); 346 Matrix<Float> tsys(nrowTsys, nchanTsys); 347 tsysSorted.takeStorage(IPosition(2, nrowTsys, nchanTsys), 348 new Float[nrowTsys * nchanTsys], 349 TAKE_OVER); 342 350 nrowTsys = 0; 343 351 for (uInt i = 0 ; i < tsystable_.size(); i++) { … … 351 359 } 352 360 } 353 tsysIdx = timeSort(timeTsys); 354 355 Double *xb = new Double[tsysIdx.nelements()]; 356 Float *yb = new Float[tsysIdx.nelements()]; 357 IPosition ipos(1, tsysIdx.nelements()); 358 timeTsysSorted.takeStorage(ipos, xb, TAKE_OVER); 359 tmpTsys.takeStorage(ipos, yb, TAKE_OVER); 360 for (uInt i = 0 ; i < tsysIdx.nelements(); i++) { 361 Vector<uInt> tsysIdx = timeSort(timeTsys); 362 nrowTsysSorted = tsysIdx.nelements(); 363 364 timeTsysSorted.takeStorage(IPosition(1, nrowTsysSorted), 365 new Double[nrowTsysSorted], 366 TAKE_OVER); 367 for (uInt i = 0 ; i < nrowTsysSorted; i++) { 361 368 timeTsysSorted[i] = timeTsys[tsysIdx[i]]; 362 369 } 363 interpolatorT_->setX(xb, tsysIdx.nelements()); 370 interpolatorT_->setX(timeTsysSorted.data(), nrowTsysSorted); 371 372 for (uInt i = 0; i < nrowTsys; ++i) { 373 tsysSorted.row(i) = tsys.row(tsysIdx[i]); 374 } 364 375 } 365 376 … … 371 382 372 383 // Array for scaling factor (aka Tsys) 373 Vector<Float> iTsys(IPosition(1,nchanSp), new Float[nchanSp], TAKE_OVER); 384 Vector<Float> iTsys(IPosition(1, nchanSp), new Float[nchanSp], TAKE_OVER); 385 // Array for Tsys interpolation 386 // This is empty array and is never referenced if doTsys == false 387 // (i.e. nchanTsys == 0) 388 Vector<Float> iTsysT(IPosition(1, nchanTsys), new Float[nchanTsys], TAKE_OVER); 389 390 // Array for interpolated off spectrum 391 Vector<Float> iOff(IPosition(1, nchanSp), new Float[nchanSp], TAKE_OVER); 374 392 375 393 for (uInt i = 0; i < rows.nelements(); i++) { … … 385 403 Double t0 = timeCol(irow); 386 404 for (uInt ichan = 0; ichan < nchanSp; ichan++) { 387 for (uInt j = 0; j < skyIdx.nelements(); j++) { 388 tmpOff[j] = spoff(skyIdx[j], ichan); 389 } 390 interpolatorS_->setY(ya, skyIdx.nelements()); 405 Float *tmpY = &(spoffSorted.data()[ichan * nrowSkySorted]); 406 interpolatorS_->setY(tmpY, nrowSkySorted); 391 407 iOff[ichan] = interpolatorS_->interpolate(t0); 392 408 } … … 396 412 if (doTsys) { 397 413 // Tsys correction 398 Float *yt = new Float[nchanTsys]; 399 Vector<Float> iTsysT(IPosition(1,nchanTsys), yt, TAKE_OVER); 400 Float *yb = tmpTsys.data(); 414 Float *yt = iTsysT.data(); 401 415 for (uInt ichan = 0; ichan < nchanTsys; ichan++) { 402 for (uInt j = 0; j < tsysIdx.nelements(); j++) { 403 tmpTsys[j] = tsys(tsysIdx[j], ichan); 404 } 405 interpolatorT_->setY(yb, tsysIdx.nelements()); 416 Float *tmpY = &(tsysSorted.data()[ichan * nrowTsysSorted]); 417 interpolatorT_->setY(tmpY, nrowTsysSorted); 406 418 iTsysT[ichan] = interpolatorT_->interpolate(t0); 407 419 }
Note:
See TracChangeset
for help on using the changeset viewer.