Changeset 2727
- Timestamp:
- 01/11/13 18:48:37 (12 years ago)
- Location:
- trunk/src
- Files:
-
- 12 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/BisectionLocator.cpp
r2720 r2727 12 12 #include <assert.h> 13 13 14 #include <casa/Arrays/Vector.h>15 #include <casa/Arrays/ArrayIO.h>16 #include <casa/Exceptions/Error.h>17 18 14 #include "BisectionLocator.h" 19 20 using namespace casa;21 15 22 16 namespace asap { … … 39 33 else if (x > x_[n_-1]) 40 34 return n_; 35 36 unsigned int jl = 0; 37 unsigned int ju = n_; 38 unsigned int jm; 39 while (ju - jl > 1) { 40 jm = (ju + jl) >> 1; 41 if (x > x_[jm]) 42 jl = jm; 43 else 44 ju = jm; 45 } 46 return ju; 41 47 } 42 48 else { 43 if (x > x_[0])49 if (x >= x_[0]) 44 50 return 0; 45 else if (x < =x_[n_-1])51 else if (x < x_[n_-1]) 46 52 return n_; 53 54 unsigned int jl = 0; 55 unsigned int ju = n_; 56 unsigned int jm; 57 while (ju - jl > 1) { 58 jm = (ju + jl) >> 1; 59 if (x < x_[jm]) 60 jl = jm; 61 else 62 ju = jm; 63 } 64 return ju; 47 65 } 48 unsigned int jl = 0;49 unsigned int ju = n_;50 unsigned int jm;51 52 while (ju - jl > 1) {53 jm = (ju + jl) >> 1;54 if ((x >= x_[jm]) == ascending)55 jl = jm;56 else57 ju = jm;58 }59 return ju;60 66 } 61 67 -
trunk/src/BisectionLocator.h
r2720 r2727 12 12 #ifndef ASAP_BISECTION_LOCATOR_H 13 13 #define ASAP_BISECTION_LOCATOR_H 14 15 #include <memory>16 #include <vector>17 18 #include <casa/aips.h>19 #include <casa/Arrays/Vector.h>20 #include <casa/Arrays/Matrix.h>21 #include <casa/BasicSL/String.h>22 #include <casa/Utilities/CountedPtr.h>23 14 24 15 #include "Locator.h" -
trunk/src/CMakeLists.txt
r2720 r2727 82 82 ${SRCDIR}/Locator.cpp 83 83 ${SRCDIR}/BisectionLocator.cpp 84 ${SRCDIR}/HuntLocator.cpp 85 ${SRCDIR}/BufferedBisectionLocator.cpp 84 86 ${SRCDIR}/Interpolator1D.cpp 85 ${SRCDIR}/NearestInterpolator1D.cpp ) 87 ${SRCDIR}/NearestInterpolator1D.cpp 88 ${SRCDIR}/LinearInterpolator1D.cpp 89 ${SRCDIR}/BufferedLinearInterpolator1D.cpp 90 ${SRCDIR}/CubicSplineInterpolator1D.cpp 91 ${SRCDIR}/PolynomialInterpolator1D.cpp ) 86 92 87 93 set( ASAP_PYSRCS -
trunk/src/Interpolator1D.cpp
r2720 r2727 17 17 #include "Interpolator1D.h" 18 18 #include "BisectionLocator.h" 19 #include "HuntLocator.h" 19 20 20 21 using namespace casa; … … 23 24 24 25 Interpolator1D::Interpolator1D() 25 : order_( 0),26 : order_(1), 26 27 n_(0), 27 28 x_(0), 28 y_(0) 29 y_(0), 30 locator_(0) 29 31 { 30 locator_ = new BisectionLocator();31 32 } 32 33 … … 42 43 y_ = y; 43 44 n_ = n; 45 createLocator(); 44 46 locator_->set(x, n); 45 47 } … … 50 52 x_ = x; 51 53 n_ = n; 54 createLocator(); 52 55 locator_->set(x, n); 53 56 } … … 65 68 x_ = 0; 66 69 y_ = 0; 70 if (locator_) { 71 delete locator_; 72 locator_ = 0; 73 } 67 74 } 68 75 … … 77 84 } 78 85 86 void Interpolator1D::createLocator() 87 { 88 if (!locator_) { 89 if (n_ > 1000) 90 locator_ = new HuntLocator(); 91 else 92 locator_ = new BisectionLocator(); 93 } 79 94 } 95 96 } -
trunk/src/Interpolator1D.h
r2720 r2727 12 12 #ifndef ASAP_INTERPOLATOR_1D_H 13 13 #define ASAP_INTERPOLATOR_1D_H 14 15 #include <memory>16 #include <vector>17 18 #include <casa/aips.h>19 #include <casa/Containers/Block.h>20 #include <casa/Arrays/Vector.h>21 #include <casa/Arrays/Matrix.h>22 #include <casa/BasicSL/String.h>23 #include <casa/Utilities/CountedPtr.h>24 14 25 15 #include "Locator.h" … … 41 31 void setY(float *y, unsigned int n); 42 32 void reset(); 33 34 // currently only effective for polynomial interpolation 43 35 void setOrder(unsigned int order) {order_ = order;} 44 36 … … 48 40 int locate(double x); 49 41 bool isready(); 42 void createLocator(); 50 43 51 44 unsigned int order_; -
trunk/src/Locator.cpp
r2720 r2727 12 12 #include <assert.h> 13 13 14 #include <casa/Arrays/Vector.h>15 #include <casa/Exceptions/Error.h>16 17 14 #include "Locator.h" 18 19 using namespace casa;20 15 21 16 namespace asap { -
trunk/src/Locator.h
r2720 r2727 12 12 #ifndef ASAP_LOCATOR_H 13 13 #define ASAP_LOCATOR_H 14 15 #include <memory>16 #include <vector>17 18 #include <casa/aips.h>19 #include <casa/Arrays/Vector.h>20 #include <casa/Arrays/Matrix.h>21 #include <casa/BasicSL/String.h>22 #include <casa/Utilities/CountedPtr.h>23 14 24 15 namespace asap { -
trunk/src/STApplyCal.cpp
r2722 r2727 34 34 #include "PSAlmaCalibrator.h" 35 35 #include "NearestInterpolator1D.h" 36 #include "BufferedLinearInterpolator1D.h" 37 #include "PolynomialInterpolator1D.h" 38 #include "CubicSplineInterpolator1D.h" 36 39 #include <atnf/PKSIO/SrcType.h> 37 40 … … 62 65 doTsys_ = False; 63 66 interp_.resize((int)STCalEnum::NumAxis); 67 // default is linear interpolation 68 for (unsigned int i = 0; i < interp_.size(); i++) { 69 interp_[i] = STCalEnum::LinearInterpolation; 70 } 64 71 } 65 72 … … 125 132 126 133 // interpolator 127 interpolatorS_ = new NearestInterpolator1D(); 128 interpolatorT_ = new NearestInterpolator1D(); 129 interpolatorF_ = new NearestInterpolator1D(); 134 initInterpolator(); 130 135 131 136 // select data … … 450 455 } 451 456 452 } 457 void STApplyCal::initInterpolator() 458 { 459 int ta = (int)STCalEnum::TimeAxis; 460 int fa = (int)STCalEnum::FrequencyAxis; 461 int order = (order_ > 0) ? order_ : 1; 462 switch (interp_[ta]) { 463 case STCalEnum::NearestInterpolation: 464 { 465 os_ << "use NearestInterpolator in time axis" << LogIO::POST; 466 interpolatorS_ = new NearestInterpolator1D(); 467 interpolatorT_ = new NearestInterpolator1D(); 468 break; 469 } 470 case STCalEnum::LinearInterpolation: 471 { 472 os_ << "use BufferedLinearInterpolator in time axis" << LogIO::POST; 473 interpolatorS_ = new BufferedLinearInterpolator1D(); 474 interpolatorT_ = new BufferedLinearInterpolator1D(); 475 break; 476 } 477 case STCalEnum::CubicSplineInterpolation: 478 { 479 os_ << "use CubicSplineInterpolator in time axis" << LogIO::POST; 480 interpolatorS_ = new CubicSplineInterpolator1D(); 481 interpolatorT_ = new CubicSplineInterpolator1D(); 482 break; 483 } 484 case STCalEnum::PolynomialInterpolation: 485 { 486 os_ << "use PolynomialInterpolator in time axis" << LogIO::POST; 487 if (order == 0) { 488 interpolatorS_ = new NearestInterpolator1D(); 489 interpolatorT_ = new NearestInterpolator1D(); 490 } 491 else { 492 interpolatorS_ = new PolynomialInterpolator1D(); 493 interpolatorT_ = new PolynomialInterpolator1D(); 494 interpolatorS_->setOrder(order); 495 interpolatorT_->setOrder(order); 496 } 497 break; 498 } 499 default: 500 { 501 os_ << "use BufferedLinearInterpolator in time axis" << LogIO::POST; 502 interpolatorS_ = new BufferedLinearInterpolator1D(); 503 interpolatorT_ = new BufferedLinearInterpolator1D(); 504 break; 505 } 506 } 507 508 switch (interp_[fa]) { 509 case STCalEnum::NearestInterpolation: 510 { 511 os_ << "use NearestInterpolator in frequency axis" << LogIO::POST; 512 interpolatorF_ = new NearestInterpolator1D(); 513 break; 514 } 515 case STCalEnum::LinearInterpolation: 516 { 517 os_ << "use BufferedLinearInterpolator in frequency axis" << LogIO::POST; 518 interpolatorF_ = new BufferedLinearInterpolator1D(); 519 break; 520 } 521 case STCalEnum::CubicSplineInterpolation: 522 { 523 os_ << "use CubicSplineInterpolator in frequency axis" << LogIO::POST; 524 interpolatorF_ = new CubicSplineInterpolator1D(); 525 break; 526 } 527 case STCalEnum::PolynomialInterpolation: 528 { 529 os_ << "use PolynomialInterpolator in frequency axis" << LogIO::POST; 530 if (order == 0) { 531 interpolatorF_ = new NearestInterpolator1D(); 532 } 533 else { 534 interpolatorF_ = new PolynomialInterpolator1D(); 535 interpolatorF_->setOrder(order); 536 } 537 break; 538 } 539 default: 540 { 541 os_ << "use LinearInterpolator in frequency axis" << LogIO::POST; 542 interpolatorF_ = new BufferedLinearInterpolator1D(); 543 break; 544 } 545 } 546 } 547 } -
trunk/src/STApplyCal.h
r2720 r2727 73 73 void init(); 74 74 75 // setup interpolator 76 void initInterpolator(); 77 75 78 // single loop element in apply() 76 79 void doapply(casa::uInt beamno, casa::uInt ifno, casa::uInt polno, -
trunk/src/STCalEnum.h
r2721 r2727 33 33 LinearInterpolation, 34 34 PolynomialInterpolation, 35 C SplineInterpolation};35 CubicSplineInterpolation}; 36 36 enum InterpolationAxis {TimeAxis = 0, 37 37 FrequencyAxis, -
trunk/src/STCalSkyTable.cpp
r2720 r2727 10 10 // 11 11 // 12 #include <assert.h> 13 12 14 #include <casa/Exceptions/Error.h> 13 15 #include <casa/Logging/LogIO.h>
Note:
See TracChangeset
for help on using the changeset viewer.