Last change
on this file since 2729 was 2727, checked in by Takeshi Nakazato, 12 years ago |
New Development: No
JIRA Issue: Yes CAS-4770, CAS-4774
Ready for Test: Yes
Interface Changes: 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...
Updated STApplyCal to be able to specify interpolation method.
The method can be specified in time and frequency axes independently.
Possible options are nearest, linear (default), (natural) cubic spline,
and polynomial with arbitrary order.
|
File size:
1.1 KB
|
Line | |
---|
1 | //
|
---|
2 | // C++ Implementation: BufferedLinearInterpolator1D
|
---|
3 | //
|
---|
4 | // Description:
|
---|
5 | //
|
---|
6 | //
|
---|
7 | // Author: Takeshi Nakazato <takeshi.nakazato@nao.ac.jp>, (C) 2012
|
---|
8 | //
|
---|
9 | // Copyright: See COPYING file that comes with this distribution
|
---|
10 | //
|
---|
11 | //
|
---|
12 | #include <assert.h>
|
---|
13 |
|
---|
14 | #include "BufferedLinearInterpolator1D.h"
|
---|
15 |
|
---|
16 | namespace asap {
|
---|
17 |
|
---|
18 | BufferedLinearInterpolator1D::BufferedLinearInterpolator1D()
|
---|
19 | : Interpolator1D(),
|
---|
20 | reusable_(false)
|
---|
21 | {}
|
---|
22 |
|
---|
23 | BufferedLinearInterpolator1D::~BufferedLinearInterpolator1D()
|
---|
24 | {}
|
---|
25 |
|
---|
26 | void BufferedLinearInterpolator1D::setX(double *x, unsigned int n)
|
---|
27 | {
|
---|
28 | Interpolator1D::setX(x, n);
|
---|
29 | reusable_ = false;
|
---|
30 | }
|
---|
31 |
|
---|
32 | float BufferedLinearInterpolator1D::interpolate(double x)
|
---|
33 | {
|
---|
34 | assert(isready());
|
---|
35 | if (n_ == 1)
|
---|
36 | return y_[0];
|
---|
37 |
|
---|
38 | unsigned int i;
|
---|
39 | bool b = (reusable_ && x == xold_);
|
---|
40 | if (b) {
|
---|
41 | i = prev_;
|
---|
42 | }
|
---|
43 | else {
|
---|
44 | i = locator_->locate(x);
|
---|
45 | prev_ = i;
|
---|
46 | xold_ = x;
|
---|
47 | }
|
---|
48 |
|
---|
49 | // do not perform extrapolation
|
---|
50 | if (i == 0) {
|
---|
51 | return y_[i];
|
---|
52 | }
|
---|
53 | else if (i == n_) {
|
---|
54 | return y_[i-1];
|
---|
55 | }
|
---|
56 |
|
---|
57 | // linear interpolation
|
---|
58 | if (!b)
|
---|
59 | factor_ = (x - x_[i-1]) / (x_[i] - x_[i-1]);
|
---|
60 | float y = y_[i-1] + (y_[i] - y_[i-1]) * factor_;
|
---|
61 | reusable_ = true;
|
---|
62 | return y;
|
---|
63 | }
|
---|
64 |
|
---|
65 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.