tools/draw-diagram/draw.py
author Dmitriy Morozov <dmitriy@mrzv.org>
Thu Sep 07 17:35:28 2017 -0700 (2 months ago)
changeset 290 21b56c6c9512
parent 243 c9b8c98187a8
permissions -rwxr-xr-x
Add Vanessa Robins' periodic alpha shapes code
     1 #!/usr/bin/env python2
     2 
     3 import  pd
     4 from    sys         import argv, exit
     5 
     6 if len(argv) < 2:
     7     print "Usage: %s FILENAME [MULTIPLIER=1] [NOISE=0] [RADIUS=.15] [DIMENSIONS=XMIN,YMIN,XMAX,YMAX]" % argv[0]
     8     print "  MULTIPLIER -   multiply coordinates of each point by this quantity"
     9     print "  NOISE -        filter out points below this persistence"
    10     print "  RADIUS -       radius of a point in the persistence diagram"
    11     print "  DIMENSIONS -   dimensions of the persistence diagram"
    12     print 
    13     print "  Example: %s torus.dgm 1 0 .05 -1,-1,10,10" % argv[0]
    14     exit()
    15 
    16 multiplier =    float(argv[2])                  if len(argv) > 2    else 1
    17 noise =         float(argv[3])                  if len(argv) > 3    else 0
    18 R =             float(argv[4])                  if len(argv) > 4    else .15
    19 dimensions =    map(float, argv[5].split(','))  if len(argv) > 5    else None
    20 
    21 noise_filter =   pd.noise_filter(noise)
    22 amplify_filter = pd.amplify_filter(multiplier)
    23 
    24 dgm = pd.PersistenceDiagram(argv[1], lambda x,y: noise_filter(x,y) and amplify_filter(x,y))
    25 dgm.savePDF(argv[1] + '.', radius = R, dimensions = dimensions)