Changeset 2733
- Timestamp:
- 01/16/13 20:00:01 (12 years ago)
- Location:
- trunk/src
- Files:
-
- 6 added
- 6 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/BufferedLinearInterpolator1D.h
r2730 r2733 21 21 * @author TakeshiNakazato 22 22 */ 23 class BufferedLinearInterpolator1D : public Interpolator1D { 23 template <class T, class U> 24 class BufferedLinearInterpolator1D : public Interpolator1D<T, U> { 24 25 public: 25 26 // Default constructor. … … 34 35 // @param[in] n number of data. 35 36 // @see Interpolator1D::setData() 36 void setData( double *x, float*y, unsigned int n);37 void setData(T *x, U *y, unsigned int n); 37 38 38 39 // Set horizontal data (x). … … 40 41 // @param[in] n number of data. 41 42 // @see Interpolator1D::setX() 42 void setX( double*x, unsigned int n);43 void setX(T *x, unsigned int n); 43 44 44 45 // Perform interpolation. … … 47 48 // @return interpolated value at x. 48 49 // @see Interpolator1D::interpolate() 49 float interpolate(doublex);50 U interpolate(T x); 50 51 51 52 private: 52 53 // Numerical factor for linear interpolation. 53 doublefactor_;54 T factor_; 54 55 55 56 // Previous location. 56 doublexold_;57 T xold_; 57 58 58 59 // Previous location as an index … … 64 65 65 66 } 67 68 #include "BufferedLinearInterpolator1D.tcc" 69 66 70 #endif -
trunk/src/CMakeLists.txt
r2731 r2733 80 80 ${SRCDIR}/Calibrator.cpp 81 81 ${SRCDIR}/PSAlmaCalibrator.cpp 82 ${SRCDIR}/Interpolator1D.cpp83 ${SRCDIR}/NearestInterpolator1D.cpp84 ${SRCDIR}/LinearInterpolator1D.cpp85 ${SRCDIR}/BufferedLinearInterpolator1D.cpp86 ${SRCDIR}/CubicSplineInterpolator1D.cpp87 ${SRCDIR}/PolynomialInterpolator1D.cpp88 82 ${SRCDIR}/STBaselineParamTable.cpp ) 89 83 -
trunk/src/CubicSplineInterpolator1D.h
r2730 r2733 21 21 * @author TakeshiNakazato 22 22 */ 23 class CubicSplineInterpolator1D : public Interpolator1D { 23 template <class T, class U> 24 class CubicSplineInterpolator1D : public Interpolator1D<T, U> { 24 25 public: 25 26 // Default constructor. … … 31 32 // Override Interpolator1D::setData. 32 33 // @see Interpolator1D::setData 33 void setData( double *x, float*y, unsigned int n);34 void setData(T *x, U *y, unsigned int n); 34 35 35 36 // Override Interpolator1D::setY. 36 37 // @see Interpolator1D::setY() 37 void setY( float*y, unsigned int n);38 void setY(U *y, unsigned int n); 38 39 39 40 // Perform interpolation. … … 41 42 // by interpolation. 42 43 // @return interpolated value at x. 43 float interpolate(doublex);44 U interpolate(T x); 44 45 private: 45 46 // Determine second derivatives of each point based on … … 53 54 // @param[in] i location index for x. 54 55 // @return interpolated value at x. 55 float dospline(doublex, unsigned int i);56 U dospline(T x, unsigned int i); 56 57 57 58 // Array to store second derivatives on the data points. 58 float*y2_;59 U *y2_; 59 60 60 61 // number of data points for second derivatives … … 66 67 67 68 } 69 70 #include "CubicSplineInterpolator1D.tcc" 71 68 72 #endif -
trunk/src/Interpolator1D.h
r2731 r2733 21 21 * @author TakeshiNakazato 22 22 */ 23 class Interpolator1D {23 template <class T, class U> class Interpolator1D { 24 24 public: 25 25 // Default constructor. … … 33 33 // @param[in] y pointer to vertical data. 34 34 // @param[in] n number of data. 35 void setData( double *x, float*y, unsigned int n);35 void setData(T *x, U *y, unsigned int n); 36 36 37 37 // Set horizontal data (x). 38 38 // @param[in] x pointer to horizontal data. 39 39 // @param[in] n number of data. 40 void setX( double*x, unsigned int n);40 void setX(T *x, unsigned int n); 41 41 42 42 // Set vertical data (y). 43 43 // @param[in] y pointer to vertical data. 44 44 // @param[in] n number of data. 45 void setY( float*y, unsigned int n);45 void setY(U *y, unsigned int n); 46 46 47 47 // Reset object. … … 58 58 // by interpolation. 59 59 // @return interpolated value at x. 60 virtual float interpolate(doublex) = 0;60 virtual U interpolate(T x) = 0; 61 61 62 62 protected: … … 65 65 // @return location as an index. 66 66 // @see Locator::locate() 67 unsigned int locate( doublex);67 unsigned int locate(T x); 68 68 69 69 // Query function whether the object is ready to interpolate. … … 81 81 82 82 // Horizontal data. 83 double*x_;83 T *x_; 84 84 85 85 // Vertical data. 86 float*y_;86 U *y_; 87 87 88 88 // Pointer to the Locator object. 89 Locator< double> *locator_;89 Locator<T> *locator_; 90 90 }; 91 91 92 92 } 93 94 #include "Interpolator1D.tcc" 95 93 96 #endif -
trunk/src/LinearInterpolator1D.h
r2730 r2733 21 21 * @author TakeshiNakazato 22 22 */ 23 class LinearInterpolator1D : public Interpolator1D { 23 template <class T, class U> 24 class LinearInterpolator1D : public Interpolator1D<T, U> { 24 25 public: 25 26 // Default constructor. … … 34 35 // @return interpolated value at x. 35 36 // @see Interpolator1D::interpolate() 36 float interpolate(doublex);37 U interpolate(T x); 37 38 }; 38 39 39 40 } 41 42 #include "LinearInterpolator1D.tcc" 43 40 44 #endif -
trunk/src/NearestInterpolator1D.h
r2730 r2733 31 31 * @author TakeshiNakazato 32 32 */ 33 class NearestInterpolator1D : public Interpolator1D { 33 template <class T, class U> 34 class NearestInterpolator1D : public Interpolator1D<T, U> { 34 35 public: 35 36 // Default constructor. … … 44 45 // @return interpolated value at x. 45 46 // @see Interpolator1D::interpolate() 46 float interpolate(doublex);47 U interpolate(T x); 47 48 }; 48 49 49 50 } 51 52 #include "NearestInterpolator1D.tcc" 53 50 54 #endif -
trunk/src/PolynomialInterpolator1D.h
r2730 r2733 21 21 * @author TakeshiNakazato 22 22 */ 23 class PolynomialInterpolator1D : public Interpolator1D { 23 template <class T, class U> 24 class PolynomialInterpolator1D : public Interpolator1D<T, U> { 24 25 public: 25 26 // Default constructor. … … 33 34 // by interpolation. 34 35 // @return interpolated value at x. 35 float interpolate(doublex);36 U interpolate(T x); 36 37 private: 37 38 // Perform polynomial interpolation. … … 44 45 // @param[in] n number of data points of sub-region. 45 46 // @return interpolated value at x. 46 float dopoly(doublex, unsigned int left, unsigned int n);47 U dopoly(T x, unsigned int left, unsigned int n); 47 48 }; 48 49 49 50 } 51 52 #include "PolynomialInterpolator1D.tcc" 53 50 54 #endif -
trunk/src/STApplyCal.cpp
r2727 r2733 33 33 #include "Calibrator.h" 34 34 #include "PSAlmaCalibrator.h" 35 #include "Interpolator1D.h" 35 36 #include "NearestInterpolator1D.h" 36 37 #include "BufferedLinearInterpolator1D.h" … … 268 269 os_ << "skyIdx = " << skyIdx << LogIO::POST; 269 270 270 double *xa = new double[skyIdx.nelements()];271 float *ya = new float[skyIdx.nelements()];271 Double *xa = new Double[skyIdx.nelements()]; 272 Float *ya = new Float[skyIdx.nelements()]; 272 273 IPosition ipos(1, skyIdx.nelements()); 273 Vector< double> timeSkySorted(ipos, xa, TAKE_OVER);274 Vector<Double> timeSkySorted(ipos, xa, TAKE_OVER); 274 275 Vector<Float> tmpOff(ipos, ya, TAKE_OVER); 275 276 for (uInt i = 0 ; i < skyIdx.nelements(); i++) { 276 timeSkySorted[i] = (double)timeSky[skyIdx[i]];277 timeSkySorted[i] = timeSky[skyIdx[i]]; 277 278 os_ << "timeSkySorted[" << i << "]-timeSkySorted[0]=" << timeSkySorted[i] - timeSkySorted[0] << LogIO::POST; 278 279 } … … 285 286 Vector<Double> timeTsys(nrowTsys); 286 287 Matrix<Float> tsys; 287 Vector< double> timeTsysSorted;288 Vector<Double> timeTsysSorted; 288 289 Vector<Float> tmpTsys; 289 290 if (doTsys) { … … 307 308 os_ << "tsysIdx = " << tsysIdx << LogIO::POST; 308 309 309 double *xb = new double[tsysIdx.nelements()];310 float *yb = new float[tsysIdx.nelements()];310 Double *xb = new Double[tsysIdx.nelements()]; 311 Float *yb = new Float[tsysIdx.nelements()]; 311 312 IPosition ipos(1, tsysIdx.nelements()); 312 313 timeTsysSorted.takeStorage(ipos, xb, TAKE_OVER); 313 314 tmpTsys.takeStorage(ipos, yb, TAKE_OVER); 314 315 for (uInt i = 0 ; i < tsysIdx.nelements(); i++) { 315 timeTsysSorted[i] = (double)timeTsys[tsysIdx[i]];316 timeTsysSorted[i] = timeTsys[tsysIdx[i]]; 316 317 os_ << "timeTsysSorted[" << i << "]-timeTsysSorted[0]=" << timeTsysSorted[i] - timeTsysSorted[0] << LogIO::POST; 317 318 } … … 333 334 334 335 // interpolation 335 double t0 = (double)timeCol(irow);336 Double t0 = timeCol(irow); 336 337 for (uInt ichan = 0; ichan < nchanSp; ichan++) { 337 338 Vector<Float> spOffSlice = spoff.row(ichan); 338 339 //os_ << "spOffSlice = " << spOffSlice << LogIO::POST; 339 340 for (uInt j = 0; j < skyIdx.nelements(); j++) { 340 tmpOff[j] = (float)spOffSlice[skyIdx[j]];341 tmpOff[j] = spOffSlice[skyIdx[j]]; 341 342 } 342 343 interpolatorS_->setY(ya, skyIdx.nelements()); … … 350 351 if (doTsys) { 351 352 // Tsys correction 352 float *yt = new float[nchanTsys];353 Float *yt = new Float[nchanTsys]; 353 354 Vector<Float> iTsysT(IPosition(1,nchanTsys), yt, TAKE_OVER); 354 float *yb = tmpTsys.data();355 Float *yb = tmpTsys.data(); 355 356 for (uInt ichan = 0; ichan < nchanTsys; ichan++) { 356 357 Vector<Float> tsysSlice = tsys.row(ichan); 357 358 for (uInt j = 0; j < tsysIdx.nelements(); j++) { 358 tmpTsys[j] = (float)tsysSlice[tsysIdx[j]];359 tmpTsys[j] = tsysSlice[tsysIdx[j]]; 359 360 } 360 361 interpolatorT_->setY(yb, tsysIdx.nelements()); … … 373 374 interpolatorF_->setY(yt, nchanTsys); 374 375 for (uInt ichan = 0; ichan < nchanSp; ichan++) { 375 iTsys[ichan] = (Float)interpolatorF_->interpolate(fsp[ichan]);376 iTsys[ichan] = interpolatorF_->interpolate(fsp[ichan]); 376 377 } 377 378 } … … 464 465 { 465 466 os_ << "use NearestInterpolator in time axis" << LogIO::POST; 466 interpolatorS_ = new NearestInterpolator1D ();467 interpolatorT_ = new NearestInterpolator1D ();467 interpolatorS_ = new NearestInterpolator1D<Double, Float>(); 468 interpolatorT_ = new NearestInterpolator1D<Double, Float>(); 468 469 break; 469 470 } … … 471 472 { 472 473 os_ << "use BufferedLinearInterpolator in time axis" << LogIO::POST; 473 interpolatorS_ = new BufferedLinearInterpolator1D ();474 interpolatorT_ = new BufferedLinearInterpolator1D ();474 interpolatorS_ = new BufferedLinearInterpolator1D<Double, Float>(); 475 interpolatorT_ = new BufferedLinearInterpolator1D<Double, Float>(); 475 476 break; 476 477 } … … 478 479 { 479 480 os_ << "use CubicSplineInterpolator in time axis" << LogIO::POST; 480 interpolatorS_ = new CubicSplineInterpolator1D ();481 interpolatorT_ = new CubicSplineInterpolator1D ();481 interpolatorS_ = new CubicSplineInterpolator1D<Double, Float>(); 482 interpolatorT_ = new CubicSplineInterpolator1D<Double, Float>(); 482 483 break; 483 484 } … … 486 487 os_ << "use PolynomialInterpolator in time axis" << LogIO::POST; 487 488 if (order == 0) { 488 interpolatorS_ = new NearestInterpolator1D ();489 interpolatorT_ = new NearestInterpolator1D ();489 interpolatorS_ = new NearestInterpolator1D<Double, Float>(); 490 interpolatorT_ = new NearestInterpolator1D<Double, Float>(); 490 491 } 491 492 else { 492 interpolatorS_ = new PolynomialInterpolator1D ();493 interpolatorT_ = new PolynomialInterpolator1D ();493 interpolatorS_ = new PolynomialInterpolator1D<Double, Float>(); 494 interpolatorT_ = new PolynomialInterpolator1D<Double, Float>(); 494 495 interpolatorS_->setOrder(order); 495 496 interpolatorT_->setOrder(order); … … 500 501 { 501 502 os_ << "use BufferedLinearInterpolator in time axis" << LogIO::POST; 502 interpolatorS_ = new BufferedLinearInterpolator1D ();503 interpolatorT_ = new BufferedLinearInterpolator1D ();503 interpolatorS_ = new BufferedLinearInterpolator1D<Double, Float>(); 504 interpolatorT_ = new BufferedLinearInterpolator1D<Double, Float>(); 504 505 break; 505 506 } … … 510 511 { 511 512 os_ << "use NearestInterpolator in frequency axis" << LogIO::POST; 512 interpolatorF_ = new NearestInterpolator1D ();513 interpolatorF_ = new NearestInterpolator1D<Double, Float>(); 513 514 break; 514 515 } … … 516 517 { 517 518 os_ << "use BufferedLinearInterpolator in frequency axis" << LogIO::POST; 518 interpolatorF_ = new BufferedLinearInterpolator1D ();519 interpolatorF_ = new BufferedLinearInterpolator1D<Double, Float>(); 519 520 break; 520 521 } … … 522 523 { 523 524 os_ << "use CubicSplineInterpolator in frequency axis" << LogIO::POST; 524 interpolatorF_ = new CubicSplineInterpolator1D ();525 interpolatorF_ = new CubicSplineInterpolator1D<Double, Float>(); 525 526 break; 526 527 } … … 529 530 os_ << "use PolynomialInterpolator in frequency axis" << LogIO::POST; 530 531 if (order == 0) { 531 interpolatorF_ = new NearestInterpolator1D ();532 interpolatorF_ = new NearestInterpolator1D<Double, Float>(); 532 533 } 533 534 else { 534 interpolatorF_ = new PolynomialInterpolator1D ();535 interpolatorF_ = new PolynomialInterpolator1D<Double, Float>(); 535 536 interpolatorF_->setOrder(order); 536 537 } … … 540 541 { 541 542 os_ << "use LinearInterpolator in frequency axis" << LogIO::POST; 542 interpolatorF_ = new BufferedLinearInterpolator1D ();543 interpolatorF_ = new BufferedLinearInterpolator1D<Double, Float>(); 543 544 break; 544 545 } -
trunk/src/STApplyCal.h
r2727 r2733 103 103 casa::Bool is2d_; 104 104 casa::Int order_; 105 casa::CountedPtr<Interpolator1D > interpolatorT_;106 casa::CountedPtr<Interpolator1D > interpolatorF_;107 casa::CountedPtr<Interpolator1D > interpolatorS_;105 casa::CountedPtr<Interpolator1D<casa::Double, casa::Float> > interpolatorT_; 106 casa::CountedPtr<Interpolator1D<casa::Double, casa::Float> > interpolatorF_; 107 casa::CountedPtr<Interpolator1D<casa::Double, casa::Float> > interpolatorS_; 108 108 109 109 // IF (spw) mapping for Tsys transfer
Note:
See TracChangeset
for help on using the changeset viewer.