@@ -27,45 +27,57 @@ def _scale_pos_axis1(y_curr, y_orig):
27
27
dy = y_orig [0 , 1 , 0 , 0 ] - y0
28
28
return ((y_curr - y0 ) / dy )
29
29
30
- def approx1 (x_interpolated , x_input , signal_input , method = INTERP .LINEAR , off_grid = 0.0 ):
30
+ def approx1 (signal , x_interpolated , method = INTERP .LINEAR , off_grid = 0.0 , x_input = None ):
31
31
"""
32
32
Interpolate along a single dimension.Interpolation is performed along axis 0
33
33
of the input array.
34
34
35
35
Parameters
36
36
----------
37
37
38
+ signal: af.Array
39
+ Input signal array (signal = f(x))
40
+
38
41
x_interpolated : af.Array
39
42
The x-coordinates of the interpolation points. The interpolation
40
43
function is queried at these set of points.
41
44
42
- x_input : af.Array
43
- The x-coordinates of the input data points
44
-
45
- signal_input: af.Array
46
- Input signal array (signal = f(x))
47
-
48
-
49
45
method: optional: af.INTERP. default: af.INTERP.LINEAR.
50
46
Interpolation method.
51
47
52
48
off_grid: optional: scalar. default: 0.0.
53
49
The value used for positions outside the range.
54
50
51
+ x_input : af.Array
52
+ The x-coordinates of the input data points
53
+
55
54
Returns
56
55
-------
57
56
58
57
output: af.Array
59
58
Values calculated at interpolation points.
59
+
60
+
61
+ Note
62
+ -----
63
+ This holds applicable when x_input isn't provided:
64
+ The initial measurements are assumed to have taken place at equal steps between [0, N - 1],
65
+ where N is the length of the first dimension of `signal`.
60
66
"""
67
+
61
68
output = Array ()
62
- pos0 = _scale_pos_axis0 (x_interpolated , x_input )
63
- safe_call (backend .get ().af_approx1 (c_pointer (output .arr ), signal_input .arr , pos0 .arr ,
69
+
70
+ if (x_input is not None ):
71
+ pos0 = _scale_pos_axis0 (x_interpolated , x_input )
72
+ else :
73
+ pos0 = x_interpolated
74
+
75
+ safe_call (backend .get ().af_approx1 (c_pointer (output .arr ), signal .arr , pos0 .arr ,
64
76
method .value , c_float_t (off_grid )))
65
77
return output
66
78
67
- def approx2 (x_interpolated , x_input , y_interpolated , y_input , signal_input ,
68
- method = INTERP .LINEAR , off_grid = 0.0
79
+ def approx2 (signal , x_interpolated , y_interpolated ,
80
+ method = INTERP .LINEAR , off_grid = 0.0 , x_input = None , y_input = None
69
81
):
70
82
"""
71
83
Interpolate along a two dimension.Interpolation is performed along axes 0 and 1
@@ -74,42 +86,60 @@ def approx2(x_interpolated, x_input, y_interpolated, y_input, signal_input,
74
86
Parameters
75
87
----------
76
88
89
+ signal: af.Array
90
+ Input signal array (signal = f(x, y))
91
+
77
92
x_interpolated : af.Array
78
93
The x-coordinates of the interpolation points. The interpolation
79
94
function is queried at these set of points.
80
95
81
- x_input : af.Array
82
- The x-coordinates of the input data points. The convention followed is that
83
- the x-coordinates vary along axis 0
84
96
85
97
y_interpolated : af.Array
86
98
The y-coordinates of the interpolation points. The interpolation
87
99
function is queried at these set of points.
88
100
89
- y_input : af.Array
90
- The y-coordinates of the input data points. The convention followed is that
91
- the y-coordinates vary along axis 1
92
-
93
- signal_input: af.Array
94
- Input signal array (signal = f(x, y))
95
-
96
101
method: optional: af.INTERP. default: af.INTERP.LINEAR.
97
102
Interpolation method.
98
103
99
104
off_grid: optional: scalar. default: 0.0.
100
105
The value used for positions outside the range.
101
106
107
+ x_input : af.Array
108
+ The x-coordinates of the input data points. The convention followed is that
109
+ the x-coordinates vary along axis 0
110
+
111
+ y_input : af.Array
112
+ The y-coordinates of the input data points. The convention followed is that
113
+ the y-coordinates vary along axis 1
114
+
102
115
Returns
103
116
-------
104
117
105
118
output: af.Array
106
119
Values calculated at interpolation points.
107
120
121
+ Note
122
+ -----
123
+ This holds applicable when x_input/y_input isn't provided:
124
+
125
+ The initial measurements are assumed to have taken place at equal steps between [(0,0) - [M - 1, N - 1]]
126
+ where M is the length of the first dimension of `signal`,
127
+ and N is the length of the second dimension of `signal`.
108
128
"""
129
+
109
130
output = Array ()
110
- pos0 = _scale_pos_axis0 (x_interpolated , x_input )
111
- pos1 = _scale_pos_axis1 (y_interpolated , y_input )
112
- safe_call (backend .get ().af_approx2 (c_pointer (output .arr ), signal_input .arr ,
131
+
132
+ if (x_input is not None ):
133
+ pos0 = _scale_pos_axis0 (x_interpolated , x_input )
134
+ else :
135
+ pos0 = x_interpolated
136
+
137
+ if (y_input is not None ):
138
+ pos1 = _scale_pos_axis1 (y_interpolated , y_input )
139
+ else :
140
+ pos1 = y_interpolated
141
+
142
+ safe_call (backend .get ().af_approx2 (c_pointer (output .arr ), signal .arr ,
113
143
pos0 .arr , pos1 .arr , method .value , c_float_t (off_grid )))
114
144
return output
115
145
0 commit comments