本文整理匯總了Python中Plotter.Plotter.plot_topology方法的典型用法代碼示例。如果您正苦於以下問題:Python Plotter.plot_topology方法的具體用法?Python Plotter.plot_topology怎麽用?Python Plotter.plot_topology使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Plotter.Plotter
的用法示例。
在下文中一共展示了Plotter.plot_topology方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: modeling
# 需要導入模塊: from Plotter import Plotter [as 別名]
# 或者: from Plotter.Plotter import plot_topology [as 別名]
def modeling(self, country_name):
# create dest dir
if not exists(self.destdir):
makedirs(self.destdir)
root.info('Infer for %s', country_name)
time = datetime.now()
# build location where clause for succeeding queries
boundary = None
if self.poly:
boundary = PolyParser.poly_to_polygon(self.poly)
where_clause = "st_intersects(l.way, st_transform(st_geomfromtext('" + boundary.wkt + "',4269),3857))"
elif self.bpoly:
boundary = wkt.loads(self.bpoly)
where_clause = "st_intersects(l.way, st_transform(st_geomfromtext('" + boundary.wkt + "',4269),3857))"
else:
where_clause = "st_distance(l.way, (select way from planet_osm_polygon where osm_id = " + str(
self.ssid) + ")) <= 300000"
# do inference for each voltage level
all_circuits = []
all_substations = dict()
all_generators = dict()
equipment_points = []
length_found_lines = 0
for voltage_level in self.voltage_levels.split('|'):
(length_found_lines, equipment_points, generators, substations, circuits) = self.inference_for_voltage(
voltage_level, where_clause, length_found_lines, equipment_points,
all_substations, all_generators, boundary)
all_generators.update(generators)
all_substations.update(substations)
all_circuits.extend(circuits)
root.info('Total length of all found lines is %s meters', str(length_found_lines))
equipments_multipoint = MultiPoint(equipment_points)
map_centroid = equipments_multipoint.centroid
logging.debug('Centroid lat:%lf, lon:%lf', map_centroid.x, map_centroid.y)
all_circuits = Transnet.remove_duplicates(all_circuits)
root.info('Inference took %s millies', str(datetime.now() - time))
transnet_instance.export_to_json(all_circuits)
partition_by_station_dict = None
population_by_station_dict = None
cities = None
if self.load_estimation:
root.info('Start partitioning into Voronoi-portions')
load_estimator = LoadEstimator(all_substations, boundary)
partition_by_station_dict, population_by_station_dict = load_estimator.partition()
cities = load_estimator.cities
if self.topology:
root.info('Plot inferred transmission system topology')
plotter = Plotter(self.voltage_levels)
plotter.plot_topology(all_circuits, equipments_multipoint, partition_by_station_dict, cities, self.destdir)
root.info('CSV generation started ...')
csv_writer = CSVWriter(all_circuits)
csv_writer.publish(self.destdir + '/csv')
root.info('CIM model generation started ...')
cim_writer = CimWriter(all_circuits, map_centroid, population_by_station_dict, self.voltage_levels)
cim_writer.publish(self.destdir + '/cim')
# for circuit in all_circuits:
# for line in circuit.members[1:-1]:
# if line.id not in self.all_lines:
# self.length_all += line.length
# self.all_lines[line.id] = line.id
#
# root.info('All lines length without duplicates %s', str(self.length_all / 1000))
#
# self.length_all = 0
# for circuit in all_circuits:
# for line in circuit.members[1:-1]:
# self.length_all += line.length
#
# root.info('All lines length with duplicates %s', str(self.length_all / 1000))
#
# for circuit in all_circuits:
# sts = [circuit.members[0], circuit.members[-1]]
# for st in sts:
# if st.id not in self.all_stations:
# self.all_stations[st.id] = 1
# else:
# self.all_stations[st.id] += 1
#
# root.info('All Stations %s', str(self.all_stations))
if validate:
validator = InferenceValidator(self.cur)
if boundary:
all_stations = all_substations.copy()
all_stations.update(all_generators)
validator.validate2(all_circuits, all_stations, boundary, self.voltage_levels)
else:
#.........這裏部分代碼省略.........
示例2: population_of_region
# 需要導入模塊: from Plotter import Plotter [as 別名]
# 或者: from Plotter.Plotter import plot_topology [as 別名]
cnx.close()
return _cities
def population_of_region(self, region_polygon):
population = 100 # offset
for city in self.cities:
if city.geom.within(region_polygon):
population += city.population
return population
@staticmethod
def estimate_load(population):
# German per head power consumption in kWh according to statista (for the year 2015)
per_head_power_consumption = 7.381
load_per_head = (per_head_power_consumption * 1000) / (365 * 24)
total_load = population * load_per_head
return total_load
if __name__ == "__main__":
bpoly = "POLYGON((7.5117 49.7913, 10.4956 49.7913, 10.4956 47.5325, 7.5117 47.5325, 7.5117 49.7913))"
# bpoly = "POLYGON((5.87 55.1, 15.04 55.1, 15.04 47.27, 5.87 47.27, 5.87 55.1))"
bayern_bounding_polygon = wkt.loads(bpoly)
load_estimator = LoadEstimator(dict(), bayern_bounding_polygon)
cities = load_estimator.cities
interpolation_fct = load_estimator.interpolation_fct
root = logging.getLogger()
root.info('Plot inferred transmission system topology')
plotter = Plotter('')
plotter.plot_topology([], bayern_bounding_polygon, None, cities, interpolation_fct)