MCPcopy Create free account
hub / github.com/comaps/comaps / process_data

Function process_data

tools/python/city_radius.py:86–133  ·  view source on GitHub ↗
(steps_count, base, mult, bestFind = False, dataFlag = 0)

Source from the content-addressed store, hash-verified

84 return (bestBase, bestMult)
85
86def process_data(steps_count, base, mult, bestFind = False, dataFlag = 0):
87 avgData = []
88 maxData = []
89 sqrData = []
90 population = []
91 maxPopulation = 0
92 minPopulation = -1
93 for city in cities:
94 p = city['population']
95 w = city['width']
96 h = city['height']
97 s = city['square']
98 population.append(p)
99 if p > maxPopulation:
100 maxPopulation = p
101 if minPopulation < 0 or p < minPopulation:
102 minPopulation = p
103
104 maxData.append(max([w, h]))
105 avgData.append((w + h) * 0.5)
106 sqrData.append(math.sqrt(s))
107
108
109 bestBase = base
110 bestMult = mult
111 if bestFind:
112 d = maxData
113 if dataFlag == 1:
114 d = avgData
115 elif dataFlag == 2:
116 d = sqrData
117 bestBase, bestMult = findBest(population, d)
118
119 print "Finished\n\nBest mult: %f, Best base: %f" % (bestMult, bestBase)
120
121 approx = []
122 population2 = []
123 v = minPopulation
124 step = (maxPopulation - minPopulation) / float(steps_count)
125 for i in xrange(0, steps_count):
126 approx.append(formula(v, bestBase, bestMult))
127 population2.append(v)
128 v += step
129
130 plt.plot(population, avgData, 'bo', population, maxData, 'ro', population, sqrData, 'go', population2, approx, 'y')
131 plt.axis([minPopulation, maxPopulation, 0, 100])
132 plt.xscale('log')
133 plt.show()
134
135if __name__ == "__main__":
136

Callers 1

city_radius.pyFile · 0.85

Calls 4

findBestFunction · 0.85
formulaFunction · 0.85
appendMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected