This commit is contained in:
Michael Fogleman 2018-01-22 10:56:16 -05:00
parent 456c3dd712
commit 4e7ce86193
1 changed files with 18 additions and 11 deletions

View File

@ -36,31 +36,42 @@ def label():
return d
def main():
# read file
with open(sys.argv[1], 'r') as fp:
data = fp.read()
# strip and split lines
lines = data.split('\n')
lines = [x.strip() for x in lines]
lines = [x.strip(',') for x in lines]
lines = filter(None, lines)
# read values and transpose
data = [map(int, line.split(',')) for line in lines]
data = np.transpose(data)
print len(data)
print '%d series in file' % len(data)
# trim to SECONDS worth of data
n = len(data[0])
m = SECONDS * 60 / 2
a = max(0, int(n // 2 - m))
b = min(n, int(n // 2 + m))
data = [x[a:b] for x in data]
data = [x for x in data if not all(q == x[0] for q in x)]
# remove addresses with too few values
data = [x for x in data if len(set(x)) > 1]
print len(data)
print '%d series that changed' % len(data)
# trim so all rows are full
data = data[:int((len(data) // COLUMNS) * COLUMNS)]
print len(data)
print '%d series after trimming' % len(data)
print '%d data points each' % len(data[0])
# create sparklines in a grid pattern
paths = []
for i, row in enumerate(data):
r = i // COLUMNS
@ -78,12 +89,9 @@ def main():
path.append((x, y))
paths.append(path)
d = axi.Drawing(paths)
print 'transforming paths'
d = d.scale(8.5 / d.width, (12 - 0.5) / d.height)
print 'sorting paths'
d = d.sort_paths()
print 'rendering paths'
# add title and label and fit to page
d = d.scale(8.5 / d.width, (12 - 0.5) / d.height)
d = stack_drawings([d, title()], 0.25)
d = d.rotate(-90)
d = d.center(12, 8.5)
@ -91,12 +99,11 @@ def main():
print d.bounds
# save outputs
d.dump('nes/%d.axi' % NUMBER)
rotated = d.rotate(90).center(8.5, 12)
rotated.render(scale=109 * 1, line_width=0.3/25.4).write_to_png('nes/%d.png' % NUMBER)
rotated.dump_svg('nes/%d.svg' % NUMBER)
# print sum(x.t for x in axi.Device().plan_drawing(d)) / 60
# axi.draw(d)
if __name__ == '__main__':
main()