regions to n.shapes: smooth out remaining issues
This commit is contained in:
parent
9686407756
commit
47134a88d8
@ -705,7 +705,7 @@ def _set_shapes(n, country_shapes, offshore_shapes):
|
||||
offshore_shapes = gpd.read_file(offshore_shapes).rename(columns={"name": "idx"})
|
||||
offshore_shapes["type"] = "offshore"
|
||||
all_shapes = pd.concat([country_shapes, offshore_shapes])
|
||||
n.shapes = pd.concat([n.shapes, all_shapes])
|
||||
n.shapes = pd.concat([n.shapes, all_shapes], ignore_index=True)
|
||||
|
||||
|
||||
def base_network(
|
||||
|
@ -176,7 +176,8 @@ if __name__ == "__main__":
|
||||
gdf = pd.concat(onshore_regions, ignore_index=True)
|
||||
gdf.to_file(snakemake.output.regions_onshore)
|
||||
|
||||
index = gdf.index.astype(int) + n.shapes.index.astype(int).max() + 1
|
||||
offset = n.shapes.index.astype(int).max() + 1 if not n.shapes.empty else 0
|
||||
index = gdf.index.astype(int) + offset
|
||||
n.madd(
|
||||
"Shape",
|
||||
index,
|
||||
@ -185,11 +186,13 @@ if __name__ == "__main__":
|
||||
component="Bus",
|
||||
type="onshore",
|
||||
)
|
||||
|
||||
if offshore_regions:
|
||||
gdf = pd.concat(offshore_regions, ignore_index=True)
|
||||
gdf.to_file(snakemake.output.regions_offshore)
|
||||
|
||||
index = gdf.index.astype(int) + n.shapes.index.astype(int).max() + 1
|
||||
offset = n.shapes.index.astype(int).max() + 1 if not n.shapes.empty else 0
|
||||
index = gdf.index.astype(int) + offset
|
||||
n.madd(
|
||||
"Shape",
|
||||
index,
|
||||
|
@ -443,7 +443,8 @@ def cluster_regions(busmaps, which, input=None, output=None):
|
||||
n.mremove("Shape", remove)
|
||||
|
||||
# add new clustered regions
|
||||
index = regions_c.index.astype(int) + n.shapes.index.astype(int).max() + 1
|
||||
offset = n.shapes.index.astype(int).max() + 1 if not n.shapes.empty else 0
|
||||
index = regions_c.index.astype(int) + offset
|
||||
type = which.split("_")[1]
|
||||
n.madd(
|
||||
"Shape",
|
||||
|
@ -629,4 +629,5 @@ if __name__ == "__main__":
|
||||
busmap_s = reduce(lambda x, y: x.map(y), busmaps[1:], busmaps[0])
|
||||
busmap_s.to_csv(snakemake.output.busmap)
|
||||
|
||||
cluster_regions(busmaps, snakemake.input, snakemake.output)
|
||||
for which in ["regions_onshore", "regions_offshore"]:
|
||||
cluster_regions(busmaps, which, snakemake.input, snakemake.output)
|
||||
|
Loading…
Reference in New Issue
Block a user