Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
ors-utils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ors-utils
Commits
d4f11b41
Commit
d4f11b41
authored
Jul 12, 2023
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ors-tx-interpolation script
parent
81eb8423
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
0 deletions
+120
-0
ors-tx-interpolation/interpolate.py
ors-tx-interpolation/interpolate.py
+120
-0
No files found.
ors-tx-interpolation/interpolate.py
0 → 100644
View file @
d4f11b41
import
scipy.interpolate
import
numpy
as
np
from
matplotlib
import
pyplot
as
plt
def
fit_data
(
data
,
d
,
s
):
xs
=
[
x
[
0
]
for
x
in
data
]
dbm_ys
=
[
x
[
1
]
for
x
in
data
]
fit_xs_ys
(
xs
,
dbm_ys
,
s
+
" (dBM)"
,
d
)
def
fit_xs_ys
(
xs
,
ys
,
s
,
d
):
p
=
np
.
poly1d
(
np
.
polyfit
(
xs
,
ys
,
deg
=
d
))
max_error
=
0
for
i
in
range
(
len
(
ys
)):
py
=
p
(
xs
[
i
])
y
=
ys
[
i
]
error
=
abs
(
py
-
y
)
max_error
=
error
if
error
>
max_error
else
max_error
f
=
"lambda x: ({}) * x**2 + ({}) * x + ({})"
.
format
(
*
p
.
coefficients
)
print
(
"{} max error is {}"
.
format
(
s
,
max_error
))
print
(
f
)
#x = np.linspace(30, 90, 100)
#plt.plot(x, p(x))
#plt.show()
def
fit_xs_ys_spline
(
xs
,
ys
,
s
):
p
=
scipy
.
interpolate
.
CubicSpline
(
xs
,
ys
)
max_error
=
0
for
i
in
range
(
len
(
ys
)):
py
=
p
(
xs
[
i
])
y
=
ys
[
i
]
d
=
abs
(
py
-
y
)
error
=
(
100
*
d
)
/
y
max_error
=
error
if
error
>
max_error
else
max_error
print
(
"{}: {} (max error: {}%)"
.
format
(
s
,
p
,
max_error
))
x
=
np
.
linspace
(
30
,
90
,
100
)
plt
.
plot
(
x
,
p
(
x
))
plt
.
show
()
b42_1w_data
=
[
(
60
,
3.2
,
1.92
),
(
70
,
13.7
,
2.03
),
(
75
,
18.9
,
2.21
),
(
80
,
24.8
,
2.44
),
(
81
,
26.3
,
2.96
),
(
82
,
27.6
,
3.85
),
(
83
,
28.3
,
4.70
),
(
84
,
29.3
,
7.30
),
]
b43_1w_data
=
[
(
60
,
3
,
1.9
),
(
70
,
13
,
1.4
),
(
80
,
23
,
2.6
),
(
81
,
24
,
3.2
),
(
83
,
26
,
6.0
),
(
85
,
27
,
9.5
),
]
b39_1w_data
=
[
(
60
,
1.3
,
1.53
),
(
70
,
11.3
,
1.07
),
(
80
,
20.4
,
1.42
),
(
81
,
21.2
,
1.45
),
(
82
,
22.1
,
1.46
),
(
83
,
23.0
,
1.45
),
(
84
,
24.0
,
1.45
),
(
85
,
24.9
,
1.53
),
(
86
,
25.9
,
1.82
),
(
87
,
26.7
,
2.39
),
(
88
,
27.5
,
3.13
),
(
89
,
28.4
,
4.45
),
]
b38_1w_data
=
[
(
60
,
0
,
1.81
),
(
65
,
5.0
,
1.37
),
(
70
,
10.5
,
1.30
),
(
73
,
13.5
,
1.27
),
(
76
,
16.1
,
1.30
),
(
78
,
18.2
,
1.34
),
(
80
,
20.2
,
1.38
),
(
81
,
21.1
,
1.42
),
(
82
,
21.9
,
1.42
),
(
83
,
22.6
,
1.44
),
(
84
,
23.3
,
1.45
),
(
85
,
24.2
,
1.50
),
(
86
,
25.3
,
1.48
),
(
87
,
26.2
,
1.59
),
(
88
,
27.0
,
1.89
),
(
89
,
28.1
,
3.00
),
]
b43_500mw_data
=
[
(
60
,
2.5
,
1.77
),
(
70
,
13.7
,
1.82
),
(
73
,
16.6
,
1.97
),
(
74
,
17.6
,
2.07
),
(
75
,
18.5
,
2.51
),
(
76
,
19.4
,
3.77
),
(
77
,
20.2
,
6.17
),
(
78
,
20.9
,
8.81
),
(
79
,
21.4
,
10.6
),
]
b38_500mw_data
=
[
(
60
,
6.3
,
1.29
),
(
65
,
11.6
,
1.18
),
(
70
,
16.6
,
1.23
),
(
73
,
19.6
,
1.21
),
(
75
,
21.6
,
1.23
),
(
76
,
22.5
,
1.40
),
(
77
,
23.4
,
1.97
),
(
78
,
24.3
,
3.21
),
(
79
,
25.0
,
5.16
),
(
80
,
25.7
,
7.87
),
(
81
,
26.2
,
9.58
),
]
fit_data
(
b42_1w_data
,
2
,
"B42 2x1W"
)
fit_data
(
b43_1w_data
,
2
,
"B43 2x1W"
)
fit_data
(
b39_1w_data
,
2
,
"B39 2x1W"
)
fit_data
(
b38_1w_data
,
2
,
"B38 2x1W"
)
fit_data
(
b43_500mw_data
,
2
,
"B43 2x0.5W"
)
fit_data
(
b38_500mw_data
,
2
,
"B38 2x0.5W"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment