tools/draw-diagram/draw.py
author Aravindakshan Babu <akshan@stanford.edu>
Tue, 17 Aug 2010 22:19:19 -0700
branchdev
changeset 219 5311343eb2f5
parent 171 a172b960aaaa
child 243 c9b8c98187a8
permissions -rwxr-xr-x
Added documentation for the python classes Point and PersistenceDiagram. Removed the __sub__ method for PersistenceDiagram. Minor renaming. Renamed BottleneckDistance to bottleneck_distance. Renamed intervals iterator for PersistenceDiagram to points. Seems in better conformance with usage.

#!/usr/bin/env python

import  pd
from    sys         import argv, exit

if len(argv) < 2:
    print "Usage: %s FILENAME [MULTIPLIER=1] [NOISE=0] [RADIUS=.15] [DIMENSIONS=XMIN,YMIN,XMAX,YMAX]" % argv[0]
    print "  MULTIPLIER -   multiply coordinates of each point by this quantity"
    print "  NOISE -        filter out points below this persistence"
    print "  RADIUS -       radius of a point in the persistence diagram"
    print "  DIMENSIONS -   dimensions of the persistence diagram"
    print 
    print "  Example: %s torus.dgm 1 0 .05 -1,-1,10,10" % argv[0]
    exit()

multiplier =    float(argv[2])                  if len(argv) > 2    else 1
noise =         float(argv[3])                  if len(argv) > 3    else 0
R =             float(argv[4])                  if len(argv) > 4    else .15
dimensions =    map(float, argv[5].split(','))  if len(argv) > 5    else None

noise_filter =   pd.noise_filter(noise)
amplify_filter = pd.amplify_filter(multiplier)

dgm = pd.PersistenceDiagram(argv[1], lambda x,y: noise_filter(x,y) and amplify_filter(x,y))
dgm.savePDF(argv[1] + '.', radius = R, dimensions = dimensions)