simplify: drop incorrect cols if they exist (avoid error) (#272)

This commit is contained in:
Martha Frysztacki 2021-09-07 16:28:01 +02:00 committed by GitHub
parent 4117e19897
commit 8bec0cc423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -407,8 +407,11 @@ if __name__ == "__main__":
if snakemake.wildcards.simpl: if snakemake.wildcards.simpl:
n, cluster_map = cluster(n, int(snakemake.wildcards.simpl)) n, cluster_map = cluster(n, int(snakemake.wildcards.simpl))
busmaps.append(cluster_map) busmaps.append(cluster_map)
else:
n.buses = n.buses.drop(['symbol', 'tags', 'under_construction', 'substation_lv', 'substation_off'], axis=1) # some entries in n.buses are not updated in previous functions, therefore can be wrong. as they are not needed
# and are lost when clustering (for example with the simpl wildcard), we remove them for consistency:
buses_c = {'symbol', 'tags', 'under_construction', 'substation_lv', 'substation_off'}.intersection(n.buses.columns)
n.buses = n.buses.drop(buses_c, axis=1)
update_p_nom_max(n) update_p_nom_max(n)