File: scatterplot.py

package info (click to toggle)
infnoise 0.3.1%2Bgit20190812%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 27,296 kB
  • sloc: ansic: 2,176; sh: 251; python: 146; makefile: 65
file content (33 lines) | stat: -rw-r--r-- 621 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python

import matplotlib.pyplot as plt
import numpy as np
import sys

if sys.argv[1]:
        filename=sys.argv[1]
else:
        filename='infnoise.bin'


bp = np.dtype([('byte1',np.uint8),('byte2',np.uint8)]) # 'struct' byte pairs

Z = np.fromfile(filename, dtype=bp, count=2000) # read 2000 byte pairs from binary file

x, y = zip(*Z) # unpack Z pairs into lists

plt.grid(True)

plt.xlim(0, 255)
plt.ylim(0, 255)

plt.xlabel('bytes')
plt.ylabel('bytes')
plt.title('TRNG ' + filename)

plt.scatter(x[:1000],y[:1000])

plt.savefig(filename + '-scatter.png')
plt.show()