File: colormap.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 (32 lines) | stat: -rw-r--r-- 706 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
#!/usr/bin/env python

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

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

nx = 1000
ny = 1000

data = np.fromfile(open(filename,'rb'), dtype=np.uint8, count=nx*nx)
data.resize(nx,ny)

plt.xlim(0, nx)
plt.ylim(0, ny)

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

#cax = plt.imshow(data, interpolation='nearest', cmap=cm.coolwarm)
cax = plt.imshow(data, interpolation='nearest', cmap=cm.afmhot)
cbar = plt.colorbar(cax, ticks=[255, 127, 0])
cbar.ax.set_yticklabels(['255', '127', '0'])

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