Rips pairwise cohomology produces output necessary for 1-cocycle parametrization
3 from pylab import scatter, show, cm, colorbar, savefig, axis, \
4 figure, xlim, axes, hsv, subplots_adjust as adjust
5 from itertools import izip
6 from sys import argv, exit
10 def plot(val_fn, pts_fn, output_fn):
12 with open(pts_fn) as fp:
13 for line in fp.xreadlines():
14 points.append(map(float, line.split()))
17 with open(val_fn) as fp:
18 for line in fp.xreadlines():
19 values.append(float(line.split()[1]))
21 xx = [pt[0] for pt in points]
22 yy = [pt[1] for pt in points]
23 print "X:", min(xx), max(xx)
24 print "Y:", min(yy), max(yy)
27 values = [(v-m) % 1. for v in values]
28 print "V:", min(values), max(values)
30 aspect = (max(yy) - min(yy))/(max(xx) - min(xx)) + .1
34 # fig = figure(figsize = (3,3*aspect))
35 # ax = fig.add_axes([-.05,-.1,1.1,1.1])
38 ax.set_aspect('equal', 'box') 39 ax.scatter(xx,yy,s=10,c=values)
42 fig.savefig(output_fn)
44 if __name__ == '__main__':
46 print "Usage: %s VALUES POINTS" % argv[0]
51 output_fn, ext = osp.splitext(val_fn)
53 plot(val_fn, pts_fn, output_fn)