style improvement

This commit is contained in:
lisazeyen 2022-03-21 09:14:15 +01:00
parent 71a8bc6c96
commit 03fca360ff
5 changed files with 28 additions and 23 deletions

View File

@ -78,8 +78,14 @@ def add_brownfield(n, n_p, year):
# deal with gas network
pipe_carrier = ['gas pipeline']
to_drop = n.links.carrier.isin(pipe_carrier) & (n.links.build_year!=year)
n.mremove("Link", n.links.loc[to_drop].index)
if snakemake.config["sector"]['H2_retrofit']:
to_drop = n.links.carrier.isin(pipe_carrier) & (n.links.build_year!=year)
n.mremove("Link", n.links.loc[to_drop].index)
else:
new_pipes = n.links.carrier.isin(pipe_carrier) & (n.links.build_year==year)
n.links.loc[new_pipes, "p_nom"] = 0.
n.links.loc[new_pipes, "p_nom_min"] = 0.
#%%
if __name__ == "__main__":

View File

@ -409,12 +409,11 @@ def add_heating_capacities_installed_before_baseyear(n, baseyear, grouping_years
lifetime=costs.at[costs_name, 'lifetime']
)
bus0 = vars(spatial)["gas"].nodes
n.madd("Link",
nodes[name],
suffix= f" {name} gas boiler-{grouping_year}",
bus0=bus0,
bus0=spatial.gas.nodes,
bus1=nodes[name] + " " + name + " heat",
bus2="co2 atmosphere",
carrier=name + " gas boiler",
@ -429,7 +428,7 @@ def add_heating_capacities_installed_before_baseyear(n, baseyear, grouping_years
n.madd("Link",
nodes[name],
suffix=f" {name} oil boiler-{grouping_year}",
bus0="EU oil",
bus0=spatial.oil.nodes,
bus1=nodes[name] + " " + name + " heat",
bus2="co2 atmosphere",
carrier=name + " oil boiler",
@ -458,7 +457,7 @@ if __name__ == "__main__":
clusters="37",
lv=1.0,
opts='',
sector_opts='Co2L0-168H-T-H-B-I-solar+p3-dist1',
sector_opts='168H-T-H-B-I-solar+p3-dist1',
planning_horizons=2020,
)

View File

@ -266,7 +266,7 @@ def plot_h2_map(network):
# make a fake MultiIndex so that area is correct for legend
bus_sizes.rename(index=lambda x: x.replace(" H2", ""), level=0, inplace=True)
# frop all links which are not H2 pipelines
# drop all links which are not H2 pipelines
n.links.drop(n.links.index[~n.links.carrier.str.contains("H2 pipeline")], inplace=True)
h2_new = n.links.loc[n.links.carrier=="H2 pipeline"]

View File

@ -1438,8 +1438,8 @@ def add_land_transport(n, costs):
if "oil" not in n.buses.carrier.unique():
n.madd("Bus",
vars(spatial)["oil"].nodes,
location=vars(spatial)["oil"].locations,
spatial.oil.nodes,
location=spatial.oil.locations,
carrier="oil"
)
@ -1448,7 +1448,7 @@ def add_land_transport(n, costs):
n.madd("Load",
nodes,
suffix=" land transport oil",
bus=vars(spatial)["oil"].nodes,
bus=spatial.oil.nodes,
carrier="land transport oil",
p_set=ice_share / ice_efficiency * transport[nodes]
)
@ -2115,7 +2115,7 @@ def add_industry(n, costs):
n.madd("Load",
nodes,
suffix=" shipping oil",
bus=vars(spatial)["oil"].nodes,
bus=spatial.oil.nodes,
carrier="shipping oil",
p_set=p_set
)
@ -2131,8 +2131,8 @@ def add_industry(n, costs):
if "oil" not in n.buses.carrier.unique():
n.madd("Bus",
vars(spatial)["oil"].nodes,
location=vars(spatial)["oil"].locations,
spatial.oil.nodes,
location=spatial.oil.locations,
carrier="oil"
)
@ -2140,8 +2140,8 @@ def add_industry(n, costs):
#could correct to e.g. 0.001 EUR/kWh * annuity and O&M
n.madd("Store",
[oil_bus + " Store" for oil_bus in vars(spatial)["oil"].nodes],
bus=vars(spatial)["oil"].nodes,
[oil_bus + " Store" for oil_bus in spatial.oil.nodes],
bus=spatial.oil.nodes,
e_nom_extendable=True,
e_cyclic=True,
carrier="oil",
@ -2150,8 +2150,8 @@ def add_industry(n, costs):
if "oil" not in n.generators.carrier.unique():
n.madd("Generator",
vars(spatial)["oil"].nodes,
bus=vars(spatial)["oil"].nodes,
spatial.oil.nodes,
bus=spatial.oil.nodes,
p_nom_extendable=True,
carrier="oil",
marginal_cost=costs.at["oil", 'fuel']
@ -2166,7 +2166,7 @@ def add_industry(n, costs):
n.madd("Link",
nodes_heat[name] + f" {name} oil boiler",
p_nom_extendable=True,
bus0=vars(spatial)["oil"].nodes,
bus0=spatial.oil.nodes,
bus1=nodes_heat[name] + f" {name} heat",
bus2="co2 atmosphere",
carrier=f"{name} oil boiler",
@ -2179,7 +2179,7 @@ def add_industry(n, costs):
n.madd("Link",
nodes + " Fischer-Tropsch",
bus0=nodes + " H2",
bus1=vars(spatial)["oil"].nodes,
bus1=spatial.oil.nodes,
bus2=spatial.co2.nodes,
carrier="Fischer-Tropsch",
efficiency=costs.at["Fischer-Tropsch", 'efficiency'],
@ -2191,7 +2191,7 @@ def add_industry(n, costs):
n.madd("Load",
["naphtha for industry"],
bus=vars(spatial)["oil"].nodes,
bus=spatial.oil.nodes,
carrier="naphtha for industry",
p_set=industrial_demand.loc[nodes, "naphtha"].sum() / 8760
)
@ -2201,7 +2201,7 @@ def add_industry(n, costs):
n.madd("Load",
["kerosene for aviation"],
bus=vars(spatial)["oil"].nodes,
bus=spatial.oil.nodes,
carrier="kerosene for aviation",
p_set=p_set
)
@ -2354,7 +2354,7 @@ def add_agriculture(n, costs):
n.add("Load",
"agriculture machinery oil",
bus=vars(spatial)["oil"].nodes,
bus=spatial.oil.nodes,
carrier="agriculture machinery oil",
p_set=ice_share * machinery_nodal_energy.sum() * 1e6 / 8760
)

View File

@ -282,7 +282,7 @@ if __name__ == "__main__":
if 'snakemake' not in globals():
from helper import mock_snakemake
snakemake = mock_snakemake(
'solve_network_myopic',
'solve_network',
simpl='',
opts="",
clusters="37",