Mercurial > hg > nsaunier > traffic-intelligence
comparison python/utils.py @ 65:75cf537b8d88
moved and generalized map making functions to the library
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Sun, 07 Nov 2010 01:09:50 -0500 |
| parents | 8aed225f71d8 |
| children | 46ec876ce90e |
comparison
equal
deleted
inserted
replaced
| 64:c75bcdaed00f | 65:75cf537b8d88 |
|---|---|
| 130 | 130 |
| 131 linestyles = PlottingPropertyValues(['-', '--', '-.', ':']) | 131 linestyles = PlottingPropertyValues(['-', '--', '-.', ':']) |
| 132 | 132 |
| 133 colors = PlottingPropertyValues('brgmyck') # 'w' | 133 colors = PlottingPropertyValues('brgmyck') # 'w' |
| 134 | 134 |
| 135 def plotIndicatorMap(indicatorMap, squareSize): | |
| 136 from numpy import array, arange, ones, ma | |
| 137 from matplotlib.pyplot import pcolor | |
| 138 coords = array(indicatorMap.keys()) | |
| 139 minX = min(coords[:,0]) | |
| 140 minY = min(coords[:,1]) | |
| 141 X = arange(minX, max(coords[:,0])+1.1)*squareSize | |
| 142 Y = arange(minY, max(coords[:,1])+1.1)*squareSize | |
| 143 C = -ones((len(Y), len(X))) | |
| 144 for k,v in indicatorMap.iteritems(): | |
| 145 C[k[1]-minY,k[0]-minX] = v | |
| 146 masked = ma.masked_where(C<0,C) | |
| 147 pcolor(X, Y, masked) | |
| 148 | |
| 135 ######################### | 149 ######################### |
| 136 # file I/O section | 150 # file I/O section |
| 137 ######################### | 151 ######################### |
| 138 | 152 |
| 139 def openCheck(filename, option = 'r', quit = False): | 153 def openCheck(filename, option = 'r', quit = False): |
