File: plot_congestion_by_coordinate.py

package info (click to toggle)
nextpnr 0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 40,064 kB
  • sloc: cpp: 176,747; python: 18,011; ansic: 10,558; pascal: 1,367; sh: 383; makefile: 223; vhdl: 44; objc: 42; tcl: 41
file content (27 lines) | stat: -rw-r--r-- 825 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
import csv
import sys

import matplotlib.pyplot as plt

data = []

file = 1
try:
    while True:
        print("{}/heatmap_congestion_by_coordinate_{}.csv".format(sys.argv[1], file))
        with open("{}/heatmap_congestion_by_coordinate_{}.csv".format(sys.argv[1], file)) as f:
            file_data = []
            reader = csv.reader(f, delimiter=',')
            for row in reader:
                file_data.append([float(x) for x in row if x != ''])
            data.append(file_data)
        file += 1
except FileNotFoundError:
    pass

for i, file_data in enumerate(data):
    plt.imshow(file_data, cmap="gray", aspect="equal")
    plt.title("heatmap for iteration {}".format(i+1))
    plt.tight_layout()
    plt.savefig("{}/heatmap_congestion_by_coordinate_{:03}.png".format(sys.argv[1], i), dpi=300)
    plt.clf()