-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7f91e5
commit 944eaea
Showing
3 changed files
with
135 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import csv | ||
import sys | ||
|
||
import matplotlib.pyplot as plt | ||
|
||
data = {} | ||
max_bars = {} | ||
|
||
file = 1 | ||
try: | ||
while True: | ||
print("{}/heatmap_congestion_by_wiretype_{}.csv".format(sys.argv[1], file)) | ||
with open("{}/heatmap_congestion_by_wiretype_{}.csv".format(sys.argv[1], file)) as f: | ||
reader = csv.reader(f, delimiter=',') | ||
for row in [x for x in reader][1:]: | ||
key = row[0] | ||
values = [float(x) for x in row[1:] if x != ''] | ||
# Ignore wires without overuse | ||
values[0] = 0 | ||
values[1] = 0 | ||
if key not in data: | ||
data[key] = [] | ||
max_bars[key] = 0 | ||
data[key].append(values) | ||
max_bars[key] = max(max_bars[key], len(values)) | ||
file += 1 | ||
except FileNotFoundError: | ||
pass | ||
finally: | ||
file -= 1 | ||
|
||
to_remove = [] | ||
for key in data.keys(): | ||
if sum([sum(values) for values in data[key]]) == 0: | ||
# Prune entries that never have any overuse to attempt to reduce visual clutter | ||
to_remove.append(key) | ||
else: | ||
# Pad entries as needed | ||
for values in data[key]: | ||
while len(values) < max_bars[key]: | ||
values.append(0) | ||
for key in to_remove: | ||
del data[key] | ||
|
||
COLS = 2 | ||
for i in range(file): | ||
plt.suptitle("heatmap for iteration {}".format(i)) | ||
fig, axs = plt.subplots((len(data.keys())+(COLS-1))//COLS, COLS) | ||
for j, key in enumerate(data.keys()): | ||
if sum(data[key][i]) > 0: | ||
axs[j//COLS, j%COLS].bar([x for x in range(len(data[key][i]))], data[key][i]) | ||
axs[j//COLS, j%COLS].set_title(key) | ||
else: | ||
axs[j//COLS, j%COLS].set_axis_off() | ||
plt.savefig("{}/heatmap_congestion_by_wiretype_{:03}.png".format(sys.argv[1], i), dpi=300) | ||
plt.close() |