Commits

Anonymous committed 10bfb58

seperated demo script (first_time.py) from code.

Comments (0)

Files changed (2)

                 if err:
                     print """\nYou should run 'patch_data' on data/%s.csv'. You must respecify the address.""" %(name,) 
 
-if __name__ == '__main__':
-
-    #gen a map of travel times for source. 
-    #area analyzed is defined by global variables at top of file
-    #This is a demonstration of how to use the program.
-
-    #run this once per area you are analyzing.  You can add to this data set whenever
-    #generate grid of lats and longs for the working area
-    #gen_grid_file(ll,ur,divisions=40)
-
-    #generate traveling times* (time intensive)
-
-    #  *for one address only:
-    '''
-    source = 'bennu coffee, Austin Tx 78702'
-    results = time_map_from_address(source, filename='data/001.csv')
-    print 'time map results: %s, errors: %s' % tuple(results)    
-    '''
-    #  *for addresses defined in ./data/_address_list.csv
-    #if user was already processed, they wont be processed again when this is run
-    address_file = 'data/_address_list.csv'
-    process_users(address_file, output_path ="data/")
-    
-    #calculate total driving time of all users to each point on grid
-    #a different function could weight users differently in making this map
-    sum_files(source_path="data/",save_file='_sumfile.csv')
-
-    #calculate contour data from csv file
-    levels,colors,legend = get_contour_paths('data/_sumfile.csv',n=20)
-    
-    #set up map
-    mymap = pygmaps.maps(center[0], center[1], 10)
-
-    #display bounding box
-    x1,y1 = ll
-    x2,y2 = ur
-    path = [(x1,y1), (x1,y2),(x2,y2),(x2,y1),(x1,y1)]
-    mymap.addpath(path,color="#0000FF",fillcolor = "#000000", opacity=.2)
-
-    #plot the acceptable area for final presentation
-    acceptable_level = int(1)   #index to the contour level that is acceptable
-    color = '#5555ee'
-    print 'Highlighted area is under %s minutes.' % (legend[acceptable_level]/60.)
-    for i,path in enumerate(levels[acceptable_level]):
-            p =  map(tuple,path)   #contour includes full 
-            mymap.addpath(p,color=color,fillcolor=color,opacity=.5)
-
-    #plot the other contour levels
-    #select approriate lines to plot from 'levels' using slices
-    for i,paths in enumerate(levels[::3][:3]):
-        #colors slowly turns from blue to red, slice it differently to get faster change in color
-        color='#%0.2x%0.2x%0.2x' % tuple([q*255 for q in colors[i*4][0][:-1]])
-        for i,path in enumerate(paths):
-            p =  map(tuple,path)    
-            mymap.addpath(p,color=color,fillcolor=color,opacity=0)
-
-    print "contour values: %s" % (legend,) 
-    mymap.draw('./html/mymap.html')
+
+if __name__ == '__main__':
+
+    #gen a map of travel times for source. 
+    #area analyzed is defined by global variables at top of file
+    #This is a demonstration of how to use the program.
+
+    #run this once per area you are analyzing.  You can add to this data set whenever
+    #generate grid of lats and longs for the working area
+    gen_grid_file(ll,ur,divisions=40)
+
+    #generate traveling times* (time intensive)
+
+    #  *for one address only:
+    '''
+    source = 'bennu coffee, Austin Tx 78702'
+    results = time_map_from_address(source, filename='data/001.csv')
+    print 'time map results: %s, errors: %s' % tuple(results)    
+    '''
+    #  *for addresses defined in ./data/_address_list.csv
+    #if user was already processed, they wont be processed again when this is run
+    address_file = 'data/_address_list.csv'
+    process_users(address_file, output_path ="data/")
+    
+    #calculate total driving time of all users to each point on grid
+    #a different function could weight users differently in making this map
+    sum_files(source_path="data/",save_file='_TKandL.csv')
+    
+    #calculate contour data from csv file
+    levels,colors,legend = get_contour_paths('data/_TKandL.csv',n=20)
+    
+    #set up map
+    mymap = pygmaps.maps(center[0], center[1], 10)
+
+    #display bounding box
+    x1,y1 = ll
+    x2,y2 = ur
+    path = [(x1,y1), (x1,y2),(x2,y2),(x2,y1),(x1,y1)]
+    mymap.addpath(path,color="#0000FF",fillcolor = "#000000", opacity=.2)
+
+    #plot the acceptable area for final presentation
+    acceptable_level = int(1)   #index to the contour level that is acceptable
+    color = '#5555ee'
+    print 'Highlighted area is under %s minutes.' % (legend[acceptable_level]/60.)
+    for i,path in enumerate(levels[acceptable_level]):
+            p =  map(tuple,path)   #contour includes full 
+            mymap.addpath(p,color=color,fillcolor=color,opacity=.5)
+
+    #plot the other contour levels
+    #select approriate lines to plot from 'levels' using slices
+    for i,paths in enumerate(levels[::3][:3]):
+        #colors slowly turns from blue to red, slice it differently to get faster change in color
+        color='#%0.2x%0.2x%0.2x' % tuple([q*255 for q in colors[i*4][0][:-1]])
+        for i,path in enumerate(paths):
+            p =  map(tuple,path)    
+            mymap.addpath(p,color=color,fillcolor=color,opacity=0)
+
+    print "contour values: %s" % (legend,) 
+    mymap.draw('./html/mymap.html')