Update home authored by Shaun Mooney's avatar Shaun Mooney
......@@ -51,6 +51,78 @@ All of the tests that have been done for each hardware, along with analysis and
* [[Laptop Tests]]
* [[JETSON TK1]]
# Using Jupyter
A jupyter notebook is a useful, interactive way to present a report from test results. It combines markdown formatted text with live python code, meaning that plotted data can be analysed in more detail and much easier.
### Installation
Various packages will need to be installed to use jupyter:
```
$ sudo apt-get install jupyter-notebook
$ sudo apt-get install python3 pandas
$ sudo apt-get install python3-matplotlib
$ sudo apt-get install python-pip
pip install nbconvert
pip install jupyter_client
```
### Producing a notebook with plots
Notebooks are made of cells, each containing either markdown formatted text or python code.
The first stage is to include the necessary libraries. Matplotlib is a good library for plotting data using python.
```python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
```
Next define a function which takes a data file as an argument, parses the data, and returns a frame containing the data:
```python
def load_datafile(basename):
times = []
values = []
frequency1 = []
frequency2 = []
frequency3 = []
frequency4 = []
with open(basename, "r") as fh:
for line in fh:
line = line.strip()
try:
time, value, f1, f2, f3, f4 = line.split(" ")
times.append(int(time))
values.append(int(value))
frequency1.append(int(f1))
frequency2.append(int(f2))
frequency3.append(int(f3))
frequency4.append(int(f4))
except ValueError:
time = ""
tmpVal = times[0]
times[:] = [x - tmpVal for x in times]
return pd.DataFrame({"Time": times, "Latency": values, "Frequency1": frequency1, "Frequency2": frequency2, "Frequency3": frequency3, "Frequency4": frequency4})
```
Then to plot, simply use the code:
```python
load_datafile(<filename>).plot(title=<title>, x="Time", y="Latency", linewidth=0.5)
```
To add multiple files as subplots, define an array of axes for the plots to use (each subplot is one array element), then in `plot()` add an argument `ax=axes[n]` defining which subplot to use. Note that 2D arrays can be used to plot subplots in grids (i.e. 4 plots in a 2x2 grid).
```python
fig, axes = plt.subplots(nrows=<number of plots>, ncols=1)
load_datafile(<filename1>).plot(title=<title>, x="Time", y="Latency", linewidth=0.5, ax=axes[0])
load_datafile(<filename2>).plot(title=<title>, x="Time", y="Latency", linewidth=0.5, ax=axes[1])
plt.tight_layout()
```
# Notes to consider
[[Kernel tuning notes]]
......
......