Permalink
Browse files

plot_gso_dump now undersands json.

  • Loading branch information...
lgremy committed Jul 31, 2017
1 parent 9900eac commit 161f1bc13510bad09266a8cf8cfd8369c97c179f
Showing with 15 additions and 5 deletions.
  1. +15 −5 tools/plot_gso_dump.py
View
@@ -1,16 +1,25 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from optparse import OptionParser
import json
def do_plot(filename):
import matplotlib.pyplot as plt
x1,x2,y1,y2 = None,None,None,None
for i,line in enumerate(open(filename).readlines()):
i = 0
filer = open(filename, "r")
data_json = json.load(filer)
filer.close()
for d in data_json:
plt.clf()
line = line.strip()
name, data = line.split(":")
data = [d for d in data.split(" ") if d]
name = d.get("step")
if int(d.get("loop")) != -1:
name += " {0}".format(d.get("loop"))
if d.get("step") != "Input":
name += " ({0} s)".format(d.get("time"))
data = d.get("norms")
data = map(float, data)
plt.plot(range(len(data)), data)
@@ -25,6 +34,7 @@ def do_plot(filename):
from os.path import basename
name = basename(filename)
plt.savefig("%s-%04d.png"%(name,i))
i += 1
def main():
parser = OptionParser(usage="""\
@@ -40,4 +50,4 @@ def main():
do_plot(filename)
if __name__ == '__main__':
main()
main()

0 comments on commit 161f1bc

Please sign in to comment.