add_electricity: use conventional_inputs from snakemake.input for attach_conventional_generators
This commit is contained in:
parent
e175d1aa0e
commit
67ac464b6a
@ -229,7 +229,7 @@ rule add_electricity:
|
|||||||
nuts3_shapes='resources/nuts3_shapes.geojson',
|
nuts3_shapes='resources/nuts3_shapes.geojson',
|
||||||
**{f"profile_{tech}": f"resources/profile_{tech}.nc"
|
**{f"profile_{tech}": f"resources/profile_{tech}.nc"
|
||||||
for tech in config['renewable']},
|
for tech in config['renewable']},
|
||||||
**{f"conventional_{carrier}_{attr}": fn for carrier in config.get('conventional', {None: {}}).values() for attr, fn in carrier.items() if str(fn).startswith("data/")},
|
**{f"conventional_{carrier}_{attr}": fn for carrier, d in config.get('conventional', {None: {}}).items() for attr, fn in d.items() if str(fn).startswith("data/")},
|
||||||
output: "networks/elec.nc"
|
output: "networks/elec.nc"
|
||||||
log: "logs/add_electricity.log"
|
log: "logs/add_electricity.log"
|
||||||
benchmark: "benchmarks/add_electricity"
|
benchmark: "benchmarks/add_electricity"
|
||||||
|
@ -302,7 +302,7 @@ def attach_wind_and_solar(n, costs, input_profiles, technologies, extendable_car
|
|||||||
p_max_pu=ds['profile'].transpose('time', 'bus').to_pandas())
|
p_max_pu=ds['profile'].transpose('time', 'bus').to_pandas())
|
||||||
|
|
||||||
|
|
||||||
def attach_conventional_generators(n, costs, ppl, conventional_carriers, extendable_carriers, conventional_config):
|
def attach_conventional_generators(n, costs, ppl, conventional_carriers, extendable_carriers, conventional_config, conventional_inputs):
|
||||||
|
|
||||||
carriers = set(conventional_carriers) | set(extendable_carriers['Generator'])
|
carriers = set(conventional_carriers) | set(extendable_carriers['Generator'])
|
||||||
_add_missing_carriers_from_costs(n, costs, carriers)
|
_add_missing_carriers_from_costs(n, costs, carriers)
|
||||||
@ -332,19 +332,19 @@ def attach_conventional_generators(n, costs, ppl, conventional_carriers, extenda
|
|||||||
# Generators with technology affected
|
# Generators with technology affected
|
||||||
idx = n.generators.query("carrier == @carrier").index
|
idx = n.generators.query("carrier == @carrier").index
|
||||||
|
|
||||||
for key in list(set(conventional_config[carrier]) & set(n.generators)):
|
for attr in list(set(conventional_config[carrier]) & set(n.generators)):
|
||||||
|
|
||||||
values = conventional_config[carrier][key]
|
values = conventional_config[carrier][attr]
|
||||||
|
|
||||||
if isinstance(values, str) and str(values).startswith("data/"):
|
if f"conventional_{carrier}_{attr}" in conventional_inputs:
|
||||||
# Values affecting generators of technology k country-specific
|
# Values affecting generators of technology k country-specific
|
||||||
# First map generator buses to countries; then map countries to p_max_pu
|
# First map generator buses to countries; then map countries to p_max_pu
|
||||||
values = pd.read_csv(values, index_col=0).iloc[:, 0]
|
values = pd.read_csv(values, index_col=0).iloc[:, 0]
|
||||||
bus_values = n.buses.country.map(values)
|
bus_values = n.buses.country.map(values)
|
||||||
n.generators[key].update(n.generators.loc[idx].bus.map(bus_values).dropna())
|
n.generators[attr].update(n.generators.loc[idx].bus.map(bus_values).dropna())
|
||||||
else:
|
else:
|
||||||
# Single value affecting all generators of technology k indiscriminantely of country
|
# Single value affecting all generators of technology k indiscriminantely of country
|
||||||
n.generators.loc[idx, key] = values
|
n.generators.loc[idx, attr] = values
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -603,7 +603,8 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
update_transmission_costs(n, costs, snakemake.config['lines']['length_factor'])
|
update_transmission_costs(n, costs, snakemake.config['lines']['length_factor'])
|
||||||
|
|
||||||
attach_conventional_generators(n, costs, ppl, conventional_carriers, extendable_carriers, snakemake.config.get("conventional", {}))
|
conventional_inputs = {k: v for k, v in snakemake.input.items() if k.startswith("conventional_")}
|
||||||
|
attach_conventional_generators(n, costs, ppl, conventional_carriers, extendable_carriers, snakemake.config.get("conventional", {}), conventional_inputs)
|
||||||
|
|
||||||
attach_wind_and_solar(n, costs, snakemake.input, renewable_carriers, extendable_carriers, snakemake.config['lines']['length_factor'])
|
attach_wind_and_solar(n, costs, snakemake.input, renewable_carriers, extendable_carriers, snakemake.config['lines']['length_factor'])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user