Mercurial > hg > nsaunier > traffic-intelligence
comparison python/utils.py @ 45:74d2de078baf
added colors, linestyles and markers to pick from
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 06 Aug 2010 01:09:44 -0400 |
| parents | 1a2ac2d4f53a |
| children | b5d007612e16 |
comparison
equal
deleted
inserted
replaced
| 44:be3ae926e4e8 | 45:74d2de078baf |
|---|---|
| 6 | 6 |
| 7 import moving | 7 import moving |
| 8 | 8 |
| 9 __metaclass__ = type | 9 __metaclass__ = type |
| 10 | 10 |
| 11 commentChar = '#'; | 11 commentChar = '#' |
| 12 | 12 |
| 13 ######################### | 13 ######################### |
| 14 # simple statistics | 14 # simple statistics |
| 15 ######################### | 15 ######################### |
| 16 | 16 |
| 112 result[:halfWidth] = inputSignal[:halfWidth] | 112 result[:halfWidth] = inputSignal[:halfWidth] |
| 113 result[-halfWidth:] = inputSignal[-halfWidth:] | 113 result[-halfWidth:] = inputSignal[-halfWidth:] |
| 114 return result | 114 return result |
| 115 | 115 |
| 116 ######################### | 116 ######################### |
| 117 # plotting section | |
| 118 ######################### | |
| 119 | |
| 120 class PlottingPropertyValues: | |
| 121 def __init__(self, values): | |
| 122 self.values = values | |
| 123 | |
| 124 def get(self,i): | |
| 125 return self.values[i%len(self.values)] | |
| 126 | |
| 127 markers = PlottingPropertyValues(['+', '*', ',', '.', 'x', 'D', 's', 'o']) | |
| 128 | |
| 129 linestyles = PlottingPropertyValues(['-', '--', '-.', ':']) | |
| 130 | |
| 131 colors = PlottingPropertyValues('brgmyck') # 'w' | |
| 132 | |
| 133 ######################### | |
| 117 # file I/O section | 134 # file I/O section |
| 118 ######################### | 135 ######################### |
| 119 | 136 |
| 120 def openCheck(filename, option = 'r', quit = False): | 137 def openCheck(filename, option = 'r', quit = False): |
| 121 '''Open file filename in read mode by default | 138 '''Open file filename in read mode by default |
