oml-plot-tools 0.8.0__tar.gz → 0.9.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oml_plot_tools-0.9.1/.github/workflows/continuous-integration.yml +65 -0
- oml_plot_tools-0.9.1/.gitignore +65 -0
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/PKG-INFO +14 -13
- oml_plot_tools-0.9.1/codecov.yml +1 -0
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/oml_plot_tools/__init__.py +2 -2
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/oml_plot_tools/common.py +49 -42
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/oml_plot_tools/consum.py +80 -54
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/oml_plot_tools/main.py +6 -7
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/oml_plot_tools/radio.py +61 -47
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/oml_plot_tools/tests/__init__.py +1 -1
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/oml_plot_tools/tests/common.py +34 -38
- oml_plot_tools-0.9.1/oml_plot_tools/tests/common_test.py +133 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/consum_test.py +201 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/consumption.oml +4179 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/consumption_all.png +0 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/consumption_clock.png +0 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/consumption_current.png +0 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/consumption_only_one.oml +10 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/grenoble-iotlab.png +0 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/radio.oml +2009 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/radio_clock.png +0 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/radio_separated_last.png +0 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/radio_single.png +0 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/robot.oml +1447 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/trajectory_all.png +0 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/trajectory_angle.png +0 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/trajectory_circuit.png +0 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/trajectory_clock.png +0 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/examples/trajectory_only.png +0 -0
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/oml_plot_tools/tests/main_parser_test.py +23 -9
- oml_plot_tools-0.9.1/oml_plot_tools/tests/radio_test.py +173 -0
- oml_plot_tools-0.9.1/oml_plot_tools/tests/traj_test.py +223 -0
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/oml_plot_tools/traj.py +113 -96
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/plot_oml_consum +1 -0
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/plot_oml_radio +1 -0
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/plot_oml_traj +1 -0
- oml_plot_tools-0.9.1/pyproject.toml +72 -0
- oml_plot_tools-0.9.1/requirements.txt +2 -0
- oml_plot_tools-0.9.1/tests_utils/COPYING_HEADER +18 -0
- oml_plot_tools-0.9.1/tests_utils/check_license.sh +73 -0
- oml_plot_tools-0.9.1/tests_utils/matplotlib/.gitignore +2 -0
- oml_plot_tools-0.9.1/tests_utils/matplotlib/matplotlibrc +2 -0
- oml_plot_tools-0.9.1/tests_utils/test-requirements.txt +6 -0
- oml_plot_tools-0.9.1/tox.ini +62 -0
- oml_plot_tools-0.8.0/oml_plot_tools/tests/common_test.py +0 -104
- oml_plot_tools-0.8.0/oml_plot_tools/tests/consum_test.py +0 -128
- oml_plot_tools-0.8.0/oml_plot_tools/tests/radio_test.py +0 -99
- oml_plot_tools-0.8.0/oml_plot_tools/tests/traj_test.py +0 -176
- oml_plot_tools-0.8.0/oml_plot_tools.egg-info/PKG-INFO +0 -34
- oml_plot_tools-0.8.0/oml_plot_tools.egg-info/SOURCES.txt +0 -27
- oml_plot_tools-0.8.0/oml_plot_tools.egg-info/dependency_links.txt +0 -1
- oml_plot_tools-0.8.0/oml_plot_tools.egg-info/requires.txt +0 -5
- oml_plot_tools-0.8.0/oml_plot_tools.egg-info/top_level.txt +0 -1
- oml_plot_tools-0.8.0/setup.cfg +0 -23
- oml_plot_tools-0.8.0/setup.py +0 -81
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/AUTHORS +0 -0
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/COPYING +0 -0
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/README.rst +0 -0
- {oml_plot_tools-0.8.0 → oml_plot_tools-0.9.1}/iotlab-plot +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
tags:
|
|
8
|
+
- '*'
|
|
9
|
+
pull_request:
|
|
10
|
+
branches:
|
|
11
|
+
- master
|
|
12
|
+
schedule:
|
|
13
|
+
- cron: '30 7 * * *'
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
build:
|
|
17
|
+
runs-on: ${{ matrix.os }}
|
|
18
|
+
strategy:
|
|
19
|
+
max-parallel: 3
|
|
20
|
+
fail-fast: false
|
|
21
|
+
matrix:
|
|
22
|
+
os: [ubuntu-latest]
|
|
23
|
+
python-version: ['3.10', '3.13', '3.14']
|
|
24
|
+
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
28
|
+
uses: actions/setup-python@v5
|
|
29
|
+
with:
|
|
30
|
+
python-version: ${{ matrix.python-version }}
|
|
31
|
+
allow-prereleases: true
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: |
|
|
34
|
+
python -m pip install --upgrade pip
|
|
35
|
+
python -m pip install tox tox-gh-actions
|
|
36
|
+
- name: Test with tox
|
|
37
|
+
run: |
|
|
38
|
+
tox -e py$(echo ${{ matrix.python-version }} | tr -d .)-tests
|
|
39
|
+
- name: Test cli
|
|
40
|
+
run: |
|
|
41
|
+
tox -e py$(echo ${{ matrix.python-version }} | tr -d .)-cli
|
|
42
|
+
- name: Check style
|
|
43
|
+
if: ${{ matrix.python-version == '3.13' }}
|
|
44
|
+
run: |
|
|
45
|
+
tox -e py$(echo ${{ matrix.python-version }} | tr -d .)-lint
|
|
46
|
+
tox -e copying
|
|
47
|
+
- name: Upload coverage to Codecov
|
|
48
|
+
if: ${{ matrix.python-version == '3.13' }}
|
|
49
|
+
uses: codecov/codecov-action@v4
|
|
50
|
+
with:
|
|
51
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
52
|
+
fail_ci_if_error: true
|
|
53
|
+
- name: Build distribution
|
|
54
|
+
if: matrix.python-version == '3.13'
|
|
55
|
+
run: |
|
|
56
|
+
pip install build
|
|
57
|
+
python -m build
|
|
58
|
+
- name: Publish package to PyPI
|
|
59
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
60
|
+
if: >-
|
|
61
|
+
matrix.python-version == '3.13' &&
|
|
62
|
+
github.event_name == 'push' &&
|
|
63
|
+
startsWith(github.event.ref, 'refs/tags')
|
|
64
|
+
with:
|
|
65
|
+
password: ${{ secrets.pypi_password }}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
|
|
5
|
+
# C extensions
|
|
6
|
+
*.so
|
|
7
|
+
|
|
8
|
+
# Distribution / packaging
|
|
9
|
+
.Python
|
|
10
|
+
env/
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
*.egg-info/
|
|
23
|
+
.installed.cfg
|
|
24
|
+
*.egg
|
|
25
|
+
|
|
26
|
+
# PyInstaller
|
|
27
|
+
# Usually these files are written by a python script from a template
|
|
28
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
29
|
+
*.manifest
|
|
30
|
+
*.spec
|
|
31
|
+
|
|
32
|
+
# Installer logs
|
|
33
|
+
pip-log.txt
|
|
34
|
+
pip-delete-this-directory.txt
|
|
35
|
+
|
|
36
|
+
# Unit test / coverage reports
|
|
37
|
+
htmlcov/
|
|
38
|
+
.tox/
|
|
39
|
+
.coverage
|
|
40
|
+
.coverage.*
|
|
41
|
+
.cache
|
|
42
|
+
nosetests.xml
|
|
43
|
+
coverage.xml
|
|
44
|
+
*,cover
|
|
45
|
+
|
|
46
|
+
# Translations
|
|
47
|
+
*.mo
|
|
48
|
+
*.pot
|
|
49
|
+
|
|
50
|
+
# Django stuff:
|
|
51
|
+
*.log
|
|
52
|
+
|
|
53
|
+
# Sphinx documentation
|
|
54
|
+
docs/_build/
|
|
55
|
+
|
|
56
|
+
# PyBuilder
|
|
57
|
+
target/
|
|
58
|
+
|
|
59
|
+
*.swp
|
|
60
|
+
cover/
|
|
61
|
+
|
|
62
|
+
# Generated json files
|
|
63
|
+
*.json
|
|
64
|
+
|
|
65
|
+
\.idea/
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: oml_plot_tools
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9.1
|
|
4
4
|
Summary: IoT-LAB OML plot tools
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Author-email: admin@iot-lab.info
|
|
5
|
+
Project-URL: Homepage, http://www.iot-lab.info
|
|
6
|
+
Project-URL: Download URL, http://github.com/iot-lab/oml-plot-tools/
|
|
7
|
+
Author-email: IoT-LAB Team <admin@iot-lab.info>
|
|
8
8
|
License: CeCILL v2.1
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
License-File: AUTHORS
|
|
10
|
+
License-File: COPYING
|
|
11
11
|
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
12
14
|
Classifier: Programming Language :: Python
|
|
13
15
|
Classifier: Programming Language :: Python :: 3
|
|
14
|
-
Classifier: Intended Audience :: End Users/Desktop
|
|
15
|
-
Classifier: Environment :: Console
|
|
16
16
|
Classifier: Topic :: Utilities
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: iotlabcli>=3.3.0
|
|
19
|
+
Requires-Dist: matplotlib
|
|
20
|
+
Requires-Dist: numpy
|
|
21
|
+
Requires-Dist: pillow
|
|
17
22
|
Description-Content-Type: text/x-rst
|
|
18
|
-
License-File: COPYING
|
|
19
|
-
License-File: AUTHORS
|
|
20
23
|
|
|
21
24
|
OML Plot Tools
|
|
22
25
|
==============
|
|
@@ -30,5 +33,3 @@ OML Plot Tools
|
|
|
30
33
|
.. |Codecov| image:: https://codecov.io/gh/iot-lab/oml-plot-tools/branch/master/graph/badge.svg
|
|
31
34
|
:target: https://codecov.io/gh/iot-lab/oml-plot-tools/branch/master
|
|
32
35
|
:alt: Codecov coverage status
|
|
33
|
-
|
|
34
|
-
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
comment: false
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
# The fact that you are presently reading this means that you have had
|
|
20
20
|
# knowledge of the CeCILL license and that you accept its terms.
|
|
21
21
|
|
|
22
|
-
"""
|
|
22
|
+
"""List of tools to display iot-lab oml generated files"""
|
|
23
23
|
|
|
24
|
-
__version__ =
|
|
24
|
+
__version__ = "0.9.1"
|
|
@@ -20,48 +20,48 @@
|
|
|
20
20
|
# The fact that you are presently reading this means that you have had
|
|
21
21
|
# knowledge of the CeCILL license and that you accept its terms.
|
|
22
22
|
|
|
23
|
-
"""
|
|
23
|
+
"""Common functions for all oml types"""
|
|
24
24
|
|
|
25
25
|
# Issues with numpy
|
|
26
26
|
# pylint:disable=no-member
|
|
27
27
|
|
|
28
|
-
from collections import
|
|
28
|
+
from collections import OrderedDict, namedtuple
|
|
29
29
|
|
|
30
|
-
import numpy
|
|
31
30
|
import matplotlib.pyplot as plt
|
|
31
|
+
import numpy
|
|
32
32
|
|
|
33
33
|
OML_HEADER_LEN = 9
|
|
34
34
|
|
|
35
35
|
OML_TYPES = {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
"consumption": 1,
|
|
37
|
+
"radio": 2,
|
|
38
|
+
"event": 3,
|
|
39
|
+
"sniffer": 4,
|
|
40
|
+
"robot_pose": 10,
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
TIMESTAMP_LABEL =
|
|
43
|
+
TIMESTAMP_LABEL = "Sample Time (sec)"
|
|
44
44
|
OML_FIELDS = [
|
|
45
|
-
(
|
|
46
|
-
(
|
|
47
|
-
(
|
|
48
|
-
(
|
|
49
|
-
(
|
|
45
|
+
("timestamp", float),
|
|
46
|
+
("type", numpy.str_, 16),
|
|
47
|
+
("num", int),
|
|
48
|
+
("t_s", int),
|
|
49
|
+
("t_us", int),
|
|
50
50
|
]
|
|
51
51
|
|
|
52
|
-
MeasureTuple = namedtuple(
|
|
52
|
+
MeasureTuple = namedtuple("MeasureTuple", ["name", "type", "label"])
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
def measures_dict(*measures_tuples):
|
|
56
|
-
"""
|
|
56
|
+
"""Create a dict of 'MeasuresTuple' with given measures"""
|
|
57
57
|
measures_list = [(m[0], MeasureTuple(*m)) for m in measures_tuples]
|
|
58
58
|
return OrderedDict(measures_list)
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
def oml_load(filename, meas_type, measures):
|
|
62
|
-
"""
|
|
62
|
+
"""Load oml file
|
|
63
63
|
:returns: numpy array
|
|
64
|
-
:measures: list of MeasureTuple
|
|
64
|
+
:measures: list of MeasureTuple"""
|
|
65
65
|
|
|
66
66
|
meas_dtypes = [(m.name, m.type) for m in measures]
|
|
67
67
|
|
|
@@ -85,21 +85,21 @@ def oml_load(filename, meas_type, measures):
|
|
|
85
85
|
return data
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
def oml_plot_clock(data, title=
|
|
89
|
-
"""
|
|
88
|
+
def oml_plot_clock(data, title="Clock time verification"):
|
|
89
|
+
"""Print clock diff between measures
|
|
90
90
|
:params data: oml_load returned array
|
|
91
91
|
"""
|
|
92
|
-
time = data[
|
|
92
|
+
time = data["timestamp"]
|
|
93
93
|
clock_diff = numpy.diff(time) * 1000
|
|
94
94
|
|
|
95
|
-
print(f
|
|
96
|
-
print(
|
|
97
|
-
print(
|
|
98
|
-
print(
|
|
99
|
-
print(
|
|
100
|
-
print(
|
|
101
|
-
print(
|
|
102
|
-
print(
|
|
95
|
+
print(f"Time from {time[0]:f} to {time[-1]:f}")
|
|
96
|
+
print("NB Points =", len(time))
|
|
97
|
+
print("Duration (s)=", time[-1] - time[0])
|
|
98
|
+
print("Steptime (ms)=", 1000 * (time[-1] - time[0]) / len(time))
|
|
99
|
+
print("Clock mean (ms)=", numpy.mean(clock_diff))
|
|
100
|
+
print("Clock std (ms)=", numpy.std(clock_diff))
|
|
101
|
+
print("Clock max (ms)=", numpy.max(clock_diff))
|
|
102
|
+
print("Clock min (ms)=", numpy.min(clock_diff))
|
|
103
103
|
|
|
104
104
|
plt.figure()
|
|
105
105
|
plt.title(title)
|
|
@@ -110,12 +110,12 @@ def oml_plot_clock(data, title='Clock time verification'):
|
|
|
110
110
|
|
|
111
111
|
|
|
112
112
|
def plot(data, title, field, ylabel, xlabel=TIMESTAMP_LABEL):
|
|
113
|
-
"""
|
|
113
|
+
"""Plot data"""
|
|
114
114
|
plt.title(title)
|
|
115
115
|
plt.grid()
|
|
116
116
|
plt.xlabel(xlabel)
|
|
117
117
|
plt.ylabel(ylabel)
|
|
118
|
-
plt.plot(data[
|
|
118
|
+
plt.plot(data["timestamp"], data[field])
|
|
119
119
|
|
|
120
120
|
|
|
121
121
|
def plot_show():
|
|
@@ -128,35 +128,42 @@ def plot_show():
|
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
def _oml_read(filename, meas_type, fields_dtypes=()):
|
|
131
|
-
"""
|
|
132
|
-
:measures: list of MeasureTuple
|
|
131
|
+
"""Read oml file
|
|
132
|
+
:measures: list of MeasureTuple"""
|
|
133
133
|
|
|
134
134
|
# Select values
|
|
135
135
|
dtypes = OML_FIELDS + list(fields_dtypes)
|
|
136
136
|
names = [entry[0] for entry in dtypes]
|
|
137
137
|
|
|
138
138
|
# Read values from file
|
|
139
|
-
c_meas_type = {names.index(
|
|
140
|
-
data = numpy.genfromtxt(
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
c_meas_type = {names.index("type"): _valid_oml_f(meas_type)}
|
|
140
|
+
data = numpy.genfromtxt(
|
|
141
|
+
filename,
|
|
142
|
+
skip_header=OML_HEADER_LEN,
|
|
143
|
+
names=names,
|
|
144
|
+
dtype=dtypes,
|
|
145
|
+
converters=c_meas_type,
|
|
146
|
+
invalid_raise=False,
|
|
147
|
+
)
|
|
143
148
|
|
|
144
149
|
# Update 'timestamp' field with the cn calculated timestamp
|
|
145
|
-
for row in numpy.nditer(data, op_flags=[
|
|
146
|
-
timestamp = row[
|
|
147
|
-
row[
|
|
150
|
+
for row in numpy.nditer(data, op_flags=["readwrite"]):
|
|
151
|
+
timestamp = row["t_s"] + row["t_us"] / 1e6
|
|
152
|
+
row["timestamp"] = timestamp
|
|
148
153
|
|
|
149
154
|
return data
|
|
150
155
|
|
|
151
156
|
|
|
152
157
|
def _valid_oml_f(meas_type):
|
|
153
|
-
"""
|
|
158
|
+
"""Return a function that validates oml type"""
|
|
159
|
+
|
|
154
160
|
def _validate(value):
|
|
155
|
-
"""
|
|
161
|
+
"""Check that 'meas_type' column matchs requested"""
|
|
156
162
|
value = int(value)
|
|
157
163
|
if int(value) == OML_TYPES[meas_type]:
|
|
158
164
|
return meas_type
|
|
159
165
|
raise TypeError(f"OML file is not: {meas_type}")
|
|
166
|
+
|
|
160
167
|
return _validate
|
|
161
168
|
|
|
162
169
|
|
|
@@ -27,81 +27,107 @@ usage: plot_oml_consum [-h] -i DATA [-l TITLE] [-b BEGIN] [-e END] [-a] [-p]
|
|
|
27
27
|
|
|
28
28
|
Plot iot-lab consumption OML files
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
-h, --help
|
|
32
|
-
-i
|
|
33
|
-
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
-b BEGIN, --begin BEGIN
|
|
37
|
-
Sample start
|
|
38
|
-
-e END, --end END Sample end
|
|
30
|
+
options:
|
|
31
|
+
-h, --help show this help message and exit
|
|
32
|
+
-i, --input DATA Node consumption values
|
|
33
|
+
-l, --label TITLE Graph title
|
|
34
|
+
-b, --begin BEGIN Sample start
|
|
35
|
+
-e, --end END Sample end
|
|
39
36
|
|
|
40
37
|
plot:
|
|
41
38
|
Plot selection
|
|
42
39
|
|
|
43
|
-
-a, --all
|
|
44
|
-
-p, --power
|
|
45
|
-
-v, --voltage
|
|
46
|
-
-c, --current
|
|
47
|
-
-t, --time
|
|
48
|
-
"""
|
|
49
|
-
|
|
40
|
+
-a, --all Plot power/voltage/current on one figure (default)
|
|
41
|
+
-p, --power Plot power
|
|
42
|
+
-v, --voltage Plot voltage
|
|
43
|
+
-c, --current Plot current
|
|
44
|
+
-t, --time Plot time verification
|
|
45
|
+
""" # noqa: E501
|
|
50
46
|
|
|
51
47
|
import argparse
|
|
52
48
|
import sys
|
|
53
49
|
|
|
54
50
|
import matplotlib.pyplot as plt
|
|
55
|
-
from . import common
|
|
56
51
|
|
|
52
|
+
from . import common
|
|
57
53
|
|
|
58
54
|
# Selection variables
|
|
59
|
-
_POWER =
|
|
60
|
-
_VOLTAGE =
|
|
61
|
-
_CURRENT =
|
|
62
|
-
_ALL =
|
|
63
|
-
_TIME =
|
|
64
|
-
_TITLE =
|
|
55
|
+
_POWER = "power"
|
|
56
|
+
_VOLTAGE = "voltage"
|
|
57
|
+
_CURRENT = "current"
|
|
58
|
+
_ALL = "all"
|
|
59
|
+
_TIME = "time"
|
|
60
|
+
_TITLE = "Node"
|
|
65
61
|
|
|
66
62
|
|
|
67
63
|
MEASURES_D = common.measures_dict(
|
|
68
|
-
(_POWER, float,
|
|
69
|
-
(_VOLTAGE, float,
|
|
70
|
-
(_CURRENT, float,
|
|
64
|
+
(_POWER, float, "Power (W)"),
|
|
65
|
+
(_VOLTAGE, float, "Voltage (V)"),
|
|
66
|
+
(_CURRENT, float, "Current (A)"),
|
|
71
67
|
)
|
|
72
68
|
|
|
73
69
|
|
|
74
70
|
def oml_load(filename):
|
|
75
|
-
"""
|
|
76
|
-
data = common.oml_load(filename,
|
|
71
|
+
"""Load consumption oml file"""
|
|
72
|
+
data = common.oml_load(filename, "consumption", MEASURES_D.values())
|
|
77
73
|
return data
|
|
78
74
|
|
|
79
75
|
|
|
80
76
|
PARSER = argparse.ArgumentParser(
|
|
81
|
-
prog=
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
_PLOT.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
77
|
+
prog="plot_oml_consum", description="Plot iot-lab consumption OML files"
|
|
78
|
+
)
|
|
79
|
+
PARSER.add_argument(
|
|
80
|
+
"-i",
|
|
81
|
+
"--input",
|
|
82
|
+
dest="data",
|
|
83
|
+
type=oml_load,
|
|
84
|
+
required=True,
|
|
85
|
+
help="Node consumption values",
|
|
86
|
+
)
|
|
87
|
+
PARSER.add_argument("-l", "--label", dest="title", default=_TITLE, help="Graph title")
|
|
88
|
+
PARSER.add_argument("-b", "--begin", default=0, type=int, help="Sample start")
|
|
89
|
+
PARSER.add_argument("-e", "--end", default=-1, type=int, help="Sample end")
|
|
90
|
+
|
|
91
|
+
_PLOT = PARSER.add_argument_group("plot", "Plot selection")
|
|
92
|
+
_PLOT.add_argument(
|
|
93
|
+
"-a",
|
|
94
|
+
"--all",
|
|
95
|
+
dest="plot",
|
|
96
|
+
const=_ALL,
|
|
97
|
+
action="append_const",
|
|
98
|
+
help="Plot power/voltage/current on one figure (default)",
|
|
99
|
+
)
|
|
100
|
+
_PLOT.add_argument(
|
|
101
|
+
"-p", "--power", dest="plot", const=_POWER, action="append_const", help="Plot power"
|
|
102
|
+
)
|
|
103
|
+
_PLOT.add_argument(
|
|
104
|
+
"-v",
|
|
105
|
+
"--voltage",
|
|
106
|
+
dest="plot",
|
|
107
|
+
const=_VOLTAGE,
|
|
108
|
+
action="append_const",
|
|
109
|
+
help="Plot voltage",
|
|
110
|
+
)
|
|
111
|
+
_PLOT.add_argument(
|
|
112
|
+
"-c",
|
|
113
|
+
"--current",
|
|
114
|
+
dest="plot",
|
|
115
|
+
const=_CURRENT,
|
|
116
|
+
action="append_const",
|
|
117
|
+
help="Plot current",
|
|
118
|
+
)
|
|
119
|
+
_PLOT.add_argument(
|
|
120
|
+
"-t",
|
|
121
|
+
"--time",
|
|
122
|
+
dest="plot",
|
|
123
|
+
const=_TIME,
|
|
124
|
+
action="append_const",
|
|
125
|
+
help="Plot time verification",
|
|
126
|
+
)
|
|
101
127
|
|
|
102
128
|
|
|
103
129
|
def consumption_plot(data, title, selection):
|
|
104
|
-
"""
|
|
130
|
+
"""Plot consumption values according to selection
|
|
105
131
|
|
|
106
132
|
:param data: numpy array returned by oml_read
|
|
107
133
|
:param title: Subplots title base
|
|
@@ -121,14 +147,14 @@ def consumption_plot(data, title, selection):
|
|
|
121
147
|
oml_plot(data, title, MEASURES_D.values())
|
|
122
148
|
|
|
123
149
|
# Clock verification
|
|
124
|
-
if
|
|
150
|
+
if "time" in selection:
|
|
125
151
|
common.oml_plot_clock(data)
|
|
126
152
|
|
|
127
153
|
common.plot_show()
|
|
128
154
|
|
|
129
155
|
|
|
130
156
|
def oml_plot(data, title, meas_tuples):
|
|
131
|
-
"""
|
|
157
|
+
"""Plot consumption value for 'meas_tuples'
|
|
132
158
|
|
|
133
159
|
:param data: numpy array returned by oml_read
|
|
134
160
|
:param title: Subplots title base
|
|
@@ -141,19 +167,19 @@ def oml_plot(data, title, meas_tuples):
|
|
|
141
167
|
for num, meas in enumerate(meas_tuples, start=1):
|
|
142
168
|
plt.subplot(nbplots, 1, num)
|
|
143
169
|
|
|
144
|
-
_title = f
|
|
170
|
+
_title = f"{title} {meas.name}"
|
|
145
171
|
common.plot(data, _title, meas.name, meas.label)
|
|
146
172
|
|
|
147
173
|
|
|
148
174
|
def main(args=None):
|
|
149
|
-
"""
|
|
175
|
+
"""iotlab-plot consum command"""
|
|
150
176
|
args = args or sys.argv[1:]
|
|
151
177
|
|
|
152
178
|
opts = PARSER.parse_args(args)
|
|
153
179
|
# default to plot all
|
|
154
180
|
selection = opts.plot or (_ALL)
|
|
155
181
|
# select samples
|
|
156
|
-
data = opts.data[opts.begin:opts.end]
|
|
182
|
+
data = opts.data[opts.begin : opts.end]
|
|
157
183
|
consumption_plot(data, opts.title, selection)
|
|
158
184
|
|
|
159
185
|
|
|
@@ -34,16 +34,15 @@ def main(args=None):
|
|
|
34
34
|
args = args or sys.argv[1:]
|
|
35
35
|
|
|
36
36
|
commands = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
"consum": oml_plot_tools.consum.main,
|
|
38
|
+
"radio": oml_plot_tools.radio.main,
|
|
39
|
+
"traj": oml_plot_tools.traj.main,
|
|
40
|
+
"help": None,
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
parser = ArgumentParser()
|
|
44
|
-
parser.add_argument(
|
|
45
|
-
|
|
46
|
-
commands['help'] = lambda args: parser.print_help()
|
|
44
|
+
parser.add_argument("command", nargs="?", choices=commands.keys(), default="help")
|
|
45
|
+
commands["help"] = lambda args: parser.print_help()
|
|
47
46
|
|
|
48
47
|
opts, args = parser.parse_known_args(args)
|
|
49
48
|
|