add_load_gen_trafos_to_scigrid.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:PyPSA 作者: PyPSA 项目源码 文件源码
def voronoi_partition(G, outline):
    """                                                                                                                                                   
    For 2D-embedded graph `G`, within the boundary given by the shapely polygon                                                                           
    `outline`, returns `G` with the Voronoi cell region as an additional node                                                                             
    attribute.                                                                                                                                            
    """
    #following line from vresutils.graph caused a bug
    #G = polygon_subgraph(G, outline, copy=False)
    points = list(vresutils.graph.get_node_attributes(G, 'pos').values())
    regions = vresutils.graph.voronoi_partition_pts(points, outline, no_multipolygons=True)
    nx.set_node_attributes(G, 'region', dict(zip(G.nodes(), regions)))

    return G
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号