using python algorithm to edit rules and script
This commit is contained in:
parent
aa50ea44cc
commit
1fc48d8753
@ -19,6 +19,10 @@ if config["enable"].get("prepare_links_p_nom", False):
|
|||||||
|
|
||||||
|
|
||||||
rule build_electricity_demand:
|
rule build_electricity_demand:
|
||||||
|
params:
|
||||||
|
snapshots=config["snapshots"],
|
||||||
|
countries=config["countries"],
|
||||||
|
load=config["load"],
|
||||||
input:
|
input:
|
||||||
ancient("data/load_raw.csv"),
|
ancient("data/load_raw.csv"),
|
||||||
output:
|
output:
|
||||||
@ -34,6 +38,9 @@ rule build_electricity_demand:
|
|||||||
|
|
||||||
|
|
||||||
rule build_powerplants:
|
rule build_powerplants:
|
||||||
|
params:
|
||||||
|
electricity=config["electricity"],
|
||||||
|
countries=config["countries"],
|
||||||
input:
|
input:
|
||||||
base_network=RESOURCES + "networks/base.nc",
|
base_network=RESOURCES + "networks/base.nc",
|
||||||
custom_powerplants="data/custom_powerplants.csv",
|
custom_powerplants="data/custom_powerplants.csv",
|
||||||
@ -79,6 +86,8 @@ rule base_network:
|
|||||||
|
|
||||||
|
|
||||||
rule build_shapes:
|
rule build_shapes:
|
||||||
|
params:
|
||||||
|
countries=config["countries"],
|
||||||
input:
|
input:
|
||||||
naturalearth=ancient("data/bundle/naturalearth/ne_10m_admin_0_countries.shp"),
|
naturalearth=ancient("data/bundle/naturalearth/ne_10m_admin_0_countries.shp"),
|
||||||
eez=ancient("data/bundle/eez/World_EEZ_v8_2014.shp"),
|
eez=ancient("data/bundle/eez/World_EEZ_v8_2014.shp"),
|
||||||
@ -104,6 +113,8 @@ rule build_shapes:
|
|||||||
|
|
||||||
|
|
||||||
rule build_bus_regions:
|
rule build_bus_regions:
|
||||||
|
params:
|
||||||
|
countries=config["countries"],
|
||||||
input:
|
input:
|
||||||
country_shapes=RESOURCES + "country_shapes.geojson",
|
country_shapes=RESOURCES + "country_shapes.geojson",
|
||||||
offshore_shapes=RESOURCES + "offshore_shapes.geojson",
|
offshore_shapes=RESOURCES + "offshore_shapes.geojson",
|
||||||
@ -125,6 +136,9 @@ rule build_bus_regions:
|
|||||||
if config["enable"].get("build_cutout", False):
|
if config["enable"].get("build_cutout", False):
|
||||||
|
|
||||||
rule build_cutout:
|
rule build_cutout:
|
||||||
|
params:
|
||||||
|
snapshots=config["snapshots"],
|
||||||
|
atlite=config["atlite"],
|
||||||
input:
|
input:
|
||||||
regions_onshore=RESOURCES + "regions_onshore.geojson",
|
regions_onshore=RESOURCES + "regions_onshore.geojson",
|
||||||
regions_offshore=RESOURCES + "regions_offshore.geojson",
|
regions_offshore=RESOURCES + "regions_offshore.geojson",
|
||||||
@ -186,6 +200,8 @@ rule build_ship_raster:
|
|||||||
|
|
||||||
|
|
||||||
rule build_renewable_profiles:
|
rule build_renewable_profiles:
|
||||||
|
params:
|
||||||
|
renewable=config["renewable"],
|
||||||
input:
|
input:
|
||||||
base_network=RESOURCES + "networks/base.nc",
|
base_network=RESOURCES + "networks/base.nc",
|
||||||
corine=ancient("data/bundle/corine/g250_clc06_V18_5.tif"),
|
corine=ancient("data/bundle/corine/g250_clc06_V18_5.tif"),
|
||||||
@ -235,6 +251,9 @@ rule build_renewable_profiles:
|
|||||||
|
|
||||||
|
|
||||||
rule build_hydro_profile:
|
rule build_hydro_profile:
|
||||||
|
params:
|
||||||
|
countries=config["countries"],
|
||||||
|
renewable=config["renewable"],
|
||||||
input:
|
input:
|
||||||
country_shapes=RESOURCES + "country_shapes.geojson",
|
country_shapes=RESOURCES + "country_shapes.geojson",
|
||||||
eia_hydro_generation="data/eia_hydro_annual_generation.csv",
|
eia_hydro_generation="data/eia_hydro_annual_generation.csv",
|
||||||
@ -252,6 +271,13 @@ rule build_hydro_profile:
|
|||||||
|
|
||||||
|
|
||||||
rule add_electricity:
|
rule add_electricity:
|
||||||
|
params:
|
||||||
|
lines=config["lines"],
|
||||||
|
load=config["load"],
|
||||||
|
countries=config["countries"],
|
||||||
|
renewable=config["renewable"],
|
||||||
|
electricity=config["electricity"],
|
||||||
|
costs=config["costs"],
|
||||||
input:
|
input:
|
||||||
**{
|
**{
|
||||||
f"profile_{tech}": RESOURCES + f"profile_{tech}.nc"
|
f"profile_{tech}": RESOURCES + f"profile_{tech}.nc"
|
||||||
@ -273,14 +299,6 @@ rule add_electricity:
|
|||||||
nuts3_shapes=RESOURCES + "nuts3_shapes.geojson",
|
nuts3_shapes=RESOURCES + "nuts3_shapes.geojson",
|
||||||
output:
|
output:
|
||||||
RESOURCES + "networks/elec.nc",
|
RESOURCES + "networks/elec.nc",
|
||||||
params:
|
|
||||||
costs=snakemake.config["costs"],
|
|
||||||
electricity=snakemake.config["electricity"],
|
|
||||||
renewable=snakemake.config["renewable"],
|
|
||||||
conventional=snakemake.config.get("conventional", {}),
|
|
||||||
countries=snakemake.config["countries"],
|
|
||||||
scaling_factor=snakemake.config["load"]["scaling_factor"],
|
|
||||||
length_factor=snakemake.config["lines"]["length_factor"],
|
|
||||||
log:
|
log:
|
||||||
LOGS + "add_electricity.log",
|
LOGS + "add_electricity.log",
|
||||||
benchmark:
|
benchmark:
|
||||||
@ -295,6 +313,10 @@ rule add_electricity:
|
|||||||
|
|
||||||
|
|
||||||
rule simplify_network:
|
rule simplify_network:
|
||||||
|
params:
|
||||||
|
clustering=config["clustering"],
|
||||||
|
electricity=config["electricity"],
|
||||||
|
costs=config["costs"],
|
||||||
input:
|
input:
|
||||||
network=RESOURCES + "networks/elec.nc",
|
network=RESOURCES + "networks/elec.nc",
|
||||||
tech_costs=COSTS,
|
tech_costs=COSTS,
|
||||||
@ -320,6 +342,14 @@ rule simplify_network:
|
|||||||
|
|
||||||
|
|
||||||
rule cluster_network:
|
rule cluster_network:
|
||||||
|
params:
|
||||||
|
solving=config["solving"],
|
||||||
|
electricity=config["electricity"],
|
||||||
|
costs=config["costs"],
|
||||||
|
lines=config["lines"],
|
||||||
|
renewable=config["renewable"],
|
||||||
|
clustering=config["clustering"],
|
||||||
|
enable=config["enable"],
|
||||||
input:
|
input:
|
||||||
network=RESOURCES + "networks/elec_s{simpl}.nc",
|
network=RESOURCES + "networks/elec_s{simpl}.nc",
|
||||||
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}.geojson",
|
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}.geojson",
|
||||||
@ -351,6 +381,9 @@ rule cluster_network:
|
|||||||
|
|
||||||
|
|
||||||
rule add_extra_components:
|
rule add_extra_components:
|
||||||
|
params:
|
||||||
|
costs=config["costs"],
|
||||||
|
electricity=config["electricity"],
|
||||||
input:
|
input:
|
||||||
network=RESOURCES + "networks/elec_s{simpl}_{clusters}.nc",
|
network=RESOURCES + "networks/elec_s{simpl}_{clusters}.nc",
|
||||||
tech_costs=COSTS,
|
tech_costs=COSTS,
|
||||||
@ -370,6 +403,12 @@ rule add_extra_components:
|
|||||||
|
|
||||||
|
|
||||||
rule prepare_network:
|
rule prepare_network:
|
||||||
|
params:
|
||||||
|
links=config["links"],
|
||||||
|
solving=config["solving"],
|
||||||
|
lines=config["lines"],
|
||||||
|
electricity=config["electricity"],
|
||||||
|
costs=config["costs"],
|
||||||
input:
|
input:
|
||||||
RESOURCES + "networks/elec_s{simpl}_{clusters}_ec.nc",
|
RESOURCES + "networks/elec_s{simpl}_{clusters}_ec.nc",
|
||||||
tech_costs=COSTS,
|
tech_costs=COSTS,
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
|
|
||||||
rule build_population_layouts:
|
rule build_population_layouts:
|
||||||
|
params:
|
||||||
|
logging=config["logging"],
|
||||||
input:
|
input:
|
||||||
nuts3_shapes=RESOURCES + "nuts3_shapes.geojson",
|
nuts3_shapes=RESOURCES + "nuts3_shapes.geojson",
|
||||||
urban_percent="data/urban_percent.csv",
|
urban_percent="data/urban_percent.csv",
|
||||||
@ -70,6 +72,8 @@ rule build_simplified_population_layouts:
|
|||||||
if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
|
if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
|
||||||
|
|
||||||
rule build_gas_network:
|
rule build_gas_network:
|
||||||
|
params:
|
||||||
|
logging=config["logging"],
|
||||||
input:
|
input:
|
||||||
gas_network="data/gas_network/scigrid-gas/data/IGGIELGN_PipeSegments.geojson",
|
gas_network="data/gas_network/scigrid-gas/data/IGGIELGN_PipeSegments.geojson",
|
||||||
output:
|
output:
|
||||||
@ -84,6 +88,8 @@ if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
|
|||||||
"../scripts/build_gas_network.py"
|
"../scripts/build_gas_network.py"
|
||||||
|
|
||||||
rule build_gas_input_locations:
|
rule build_gas_input_locations:
|
||||||
|
params:
|
||||||
|
logging=config["logging"],
|
||||||
input:
|
input:
|
||||||
lng=HTTP.remote(
|
lng=HTTP.remote(
|
||||||
"https://globalenergymonitor.org/wp-content/uploads/2022/09/Europe-Gas-Tracker-August-2022.xlsx",
|
"https://globalenergymonitor.org/wp-content/uploads/2022/09/Europe-Gas-Tracker-August-2022.xlsx",
|
||||||
@ -110,6 +116,8 @@ if config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]:
|
|||||||
"../scripts/build_gas_input_locations.py"
|
"../scripts/build_gas_input_locations.py"
|
||||||
|
|
||||||
rule cluster_gas_network:
|
rule cluster_gas_network:
|
||||||
|
params:
|
||||||
|
logging=config["logging"],
|
||||||
input:
|
input:
|
||||||
cleaned_gas_network=RESOURCES + "gas_network.csv",
|
cleaned_gas_network=RESOURCES + "gas_network.csv",
|
||||||
regions_onshore=RESOURCES
|
regions_onshore=RESOURCES
|
||||||
@ -140,6 +148,8 @@ if not (config["sector"]["gas_network"] or config["sector"]["H2_retrofit"]):
|
|||||||
|
|
||||||
|
|
||||||
rule build_heat_demands:
|
rule build_heat_demands:
|
||||||
|
params:
|
||||||
|
snapshots=config["snapshots"],
|
||||||
input:
|
input:
|
||||||
pop_layout=RESOURCES + "pop_layout_{scope}.nc",
|
pop_layout=RESOURCES + "pop_layout_{scope}.nc",
|
||||||
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
|
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
|
||||||
@ -160,6 +170,8 @@ rule build_heat_demands:
|
|||||||
|
|
||||||
|
|
||||||
rule build_temperature_profiles:
|
rule build_temperature_profiles:
|
||||||
|
params:
|
||||||
|
snapshots=config["snapshots"],
|
||||||
input:
|
input:
|
||||||
pop_layout=RESOURCES + "pop_layout_{scope}.nc",
|
pop_layout=RESOURCES + "pop_layout_{scope}.nc",
|
||||||
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
|
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
|
||||||
@ -181,6 +193,8 @@ rule build_temperature_profiles:
|
|||||||
|
|
||||||
|
|
||||||
rule build_cop_profiles:
|
rule build_cop_profiles:
|
||||||
|
params:
|
||||||
|
sector=config["sector"],
|
||||||
input:
|
input:
|
||||||
temp_soil_total=RESOURCES + "temp_soil_total_elec_s{simpl}_{clusters}.nc",
|
temp_soil_total=RESOURCES + "temp_soil_total_elec_s{simpl}_{clusters}.nc",
|
||||||
temp_soil_rural=RESOURCES + "temp_soil_rural_elec_s{simpl}_{clusters}.nc",
|
temp_soil_rural=RESOURCES + "temp_soil_rural_elec_s{simpl}_{clusters}.nc",
|
||||||
@ -208,6 +222,9 @@ rule build_cop_profiles:
|
|||||||
|
|
||||||
|
|
||||||
rule build_solar_thermal_profiles:
|
rule build_solar_thermal_profiles:
|
||||||
|
params:
|
||||||
|
snapshots=config["snapshots"],
|
||||||
|
solar_thermal=config["solar_thermal"],
|
||||||
input:
|
input:
|
||||||
pop_layout=RESOURCES + "pop_layout_{scope}.nc",
|
pop_layout=RESOURCES + "pop_layout_{scope}.nc",
|
||||||
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
|
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
|
||||||
@ -228,6 +245,11 @@ rule build_solar_thermal_profiles:
|
|||||||
|
|
||||||
|
|
||||||
rule build_energy_totals:
|
rule build_energy_totals:
|
||||||
|
params:
|
||||||
|
run=config["run"],
|
||||||
|
countries=config["countries"],
|
||||||
|
energy=config["energy"],
|
||||||
|
logging=config["logging"],
|
||||||
input:
|
input:
|
||||||
nuts3_shapes=RESOURCES + "nuts3_shapes.geojson",
|
nuts3_shapes=RESOURCES + "nuts3_shapes.geojson",
|
||||||
co2="data/eea/UNFCCC_v23.csv",
|
co2="data/eea/UNFCCC_v23.csv",
|
||||||
@ -253,6 +275,8 @@ rule build_energy_totals:
|
|||||||
|
|
||||||
|
|
||||||
rule build_biomass_potentials:
|
rule build_biomass_potentials:
|
||||||
|
params:
|
||||||
|
biomass=config["biomass"],
|
||||||
input:
|
input:
|
||||||
enspreso_biomass=HTTP.remote(
|
enspreso_biomass=HTTP.remote(
|
||||||
"https://cidportal.jrc.ec.europa.eu/ftp/jrc-opendata/ENSPRESO/ENSPRESO_BIOMASS.xlsx",
|
"https://cidportal.jrc.ec.europa.eu/ftp/jrc-opendata/ENSPRESO/ENSPRESO_BIOMASS.xlsx",
|
||||||
@ -315,6 +339,8 @@ if not config["sector"]["biomass_transport"]:
|
|||||||
if config["sector"]["regional_co2_sequestration_potential"]["enable"]:
|
if config["sector"]["regional_co2_sequestration_potential"]["enable"]:
|
||||||
|
|
||||||
rule build_sequestration_potentials:
|
rule build_sequestration_potentials:
|
||||||
|
params:
|
||||||
|
sector=config["sector"],
|
||||||
input:
|
input:
|
||||||
sequestration_potential=HTTP.remote(
|
sequestration_potential=HTTP.remote(
|
||||||
"https://raw.githubusercontent.com/ericzhou571/Co2Storage/main/resources/complete_map_2020_unit_Mt.geojson",
|
"https://raw.githubusercontent.com/ericzhou571/Co2Storage/main/resources/complete_map_2020_unit_Mt.geojson",
|
||||||
@ -368,6 +394,8 @@ rule build_salt_cavern_potentials:
|
|||||||
|
|
||||||
|
|
||||||
rule build_ammonia_production:
|
rule build_ammonia_production:
|
||||||
|
params:
|
||||||
|
countries=config["countries"],
|
||||||
input:
|
input:
|
||||||
usgs="data/myb1-2017-nitro.xls",
|
usgs="data/myb1-2017-nitro.xls",
|
||||||
output:
|
output:
|
||||||
@ -386,6 +414,9 @@ rule build_ammonia_production:
|
|||||||
|
|
||||||
|
|
||||||
rule build_industry_sector_ratios:
|
rule build_industry_sector_ratios:
|
||||||
|
params:
|
||||||
|
industry=config["industry"],
|
||||||
|
sector=config["sector"],
|
||||||
input:
|
input:
|
||||||
ammonia_production=RESOURCES + "ammonia_production.csv",
|
ammonia_production=RESOURCES + "ammonia_production.csv",
|
||||||
idees="data/jrc-idees-2015",
|
idees="data/jrc-idees-2015",
|
||||||
@ -405,6 +436,11 @@ rule build_industry_sector_ratios:
|
|||||||
|
|
||||||
|
|
||||||
rule build_industrial_production_per_country:
|
rule build_industrial_production_per_country:
|
||||||
|
params:
|
||||||
|
run=config["run"],
|
||||||
|
industry=config["industry"],
|
||||||
|
countries=config["countries"],
|
||||||
|
logging=config["logging"],
|
||||||
input:
|
input:
|
||||||
ammonia_production=RESOURCES + "ammonia_production.csv",
|
ammonia_production=RESOURCES + "ammonia_production.csv",
|
||||||
jrc="data/jrc-idees-2015",
|
jrc="data/jrc-idees-2015",
|
||||||
@ -426,6 +462,8 @@ rule build_industrial_production_per_country:
|
|||||||
|
|
||||||
|
|
||||||
rule build_industrial_production_per_country_tomorrow:
|
rule build_industrial_production_per_country_tomorrow:
|
||||||
|
params:
|
||||||
|
industry=config["industry"],
|
||||||
input:
|
input:
|
||||||
industrial_production_per_country=RESOURCES
|
industrial_production_per_country=RESOURCES
|
||||||
+ "industrial_production_per_country.csv",
|
+ "industrial_production_per_country.csv",
|
||||||
@ -450,6 +488,10 @@ rule build_industrial_production_per_country_tomorrow:
|
|||||||
|
|
||||||
|
|
||||||
rule build_industrial_distribution_key:
|
rule build_industrial_distribution_key:
|
||||||
|
params:
|
||||||
|
industry=config["industry"],
|
||||||
|
countries=config["countries"],
|
||||||
|
logging=config["logging"],
|
||||||
input:
|
input:
|
||||||
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
|
regions_onshore=RESOURCES + "regions_onshore_elec_s{simpl}_{clusters}.geojson",
|
||||||
clustered_pop_layout=RESOURCES + "pop_layout_elec_s{simpl}_{clusters}.csv",
|
clustered_pop_layout=RESOURCES + "pop_layout_elec_s{simpl}_{clusters}.csv",
|
||||||
@ -524,6 +566,10 @@ rule build_industrial_energy_demand_per_node:
|
|||||||
|
|
||||||
|
|
||||||
rule build_industrial_energy_demand_per_country_today:
|
rule build_industrial_energy_demand_per_country_today:
|
||||||
|
params:
|
||||||
|
run=config["run"],
|
||||||
|
countries=config["countries"],
|
||||||
|
industry=config["industry"],
|
||||||
input:
|
input:
|
||||||
jrc="data/jrc-idees-2015",
|
jrc="data/jrc-idees-2015",
|
||||||
ammonia_production=RESOURCES + "ammonia_production.csv",
|
ammonia_production=RESOURCES + "ammonia_production.csv",
|
||||||
@ -570,6 +616,9 @@ rule build_industrial_energy_demand_per_node_today:
|
|||||||
if config["sector"]["retrofitting"]["retro_endogen"]:
|
if config["sector"]["retrofitting"]["retro_endogen"]:
|
||||||
|
|
||||||
rule build_retro_cost:
|
rule build_retro_cost:
|
||||||
|
params:
|
||||||
|
sector=config["sector"],
|
||||||
|
countries=config["countries"],
|
||||||
input:
|
input:
|
||||||
building_stock="data/retro/data_building_stock.csv",
|
building_stock="data/retro/data_building_stock.csv",
|
||||||
data_tabula="data/retro/tabula-calculator-calcsetbuilding.csv",
|
data_tabula="data/retro/tabula-calculator-calcsetbuilding.csv",
|
||||||
@ -640,6 +689,9 @@ rule build_shipping_demand:
|
|||||||
|
|
||||||
|
|
||||||
rule build_transport_demand:
|
rule build_transport_demand:
|
||||||
|
params:
|
||||||
|
snapshots=config["snapshots"],
|
||||||
|
sector=config["sector"],
|
||||||
input:
|
input:
|
||||||
clustered_pop_layout=RESOURCES + "pop_layout_elec_s{simpl}_{clusters}.csv",
|
clustered_pop_layout=RESOURCES + "pop_layout_elec_s{simpl}_{clusters}.csv",
|
||||||
pop_weighted_energy_totals=RESOURCES
|
pop_weighted_energy_totals=RESOURCES
|
||||||
@ -666,6 +718,19 @@ rule build_transport_demand:
|
|||||||
|
|
||||||
rule prepare_sector_network:
|
rule prepare_sector_network:
|
||||||
params:
|
params:
|
||||||
|
co2_budget=config["co2_budget"],
|
||||||
|
solving=config["solving"],
|
||||||
|
existing_capacities=config["existing_capacities"],
|
||||||
|
foresight=config["foresight"],
|
||||||
|
costs=config["costs"],
|
||||||
|
logging=config["logging"],
|
||||||
|
sector=config["sector"],
|
||||||
|
industry=config["industry"],
|
||||||
|
pypsa_eur=config["pypsa_eur"],
|
||||||
|
lines=config["lines"],
|
||||||
|
scenario=config["scenario"],
|
||||||
|
countries=config["countries"],
|
||||||
|
energy=config["energy"],
|
||||||
RDIR=RDIR,
|
RDIR=RDIR,
|
||||||
input:
|
input:
|
||||||
**build_retro_cost_output,
|
**build_retro_cost_output,
|
||||||
|
@ -9,6 +9,10 @@ localrules:
|
|||||||
|
|
||||||
|
|
||||||
rule plot_network:
|
rule plot_network:
|
||||||
|
params:
|
||||||
|
logging=config["logging"],
|
||||||
|
foresight=config["foresight"],
|
||||||
|
plotting=config["plotting"],
|
||||||
input:
|
input:
|
||||||
overrides="data/override_component_attrs",
|
overrides="data/override_component_attrs",
|
||||||
network=RESULTS
|
network=RESULTS
|
||||||
@ -67,6 +71,11 @@ rule copy_conda_env:
|
|||||||
|
|
||||||
rule make_summary:
|
rule make_summary:
|
||||||
params:
|
params:
|
||||||
|
foresight=config["foresight"],
|
||||||
|
costs=config["costs"],
|
||||||
|
snapshots=config["snapshots"],
|
||||||
|
logging=config["logging"],
|
||||||
|
scenario=config["scenario"],
|
||||||
RDIR=RDIR,
|
RDIR=RDIR,
|
||||||
input:
|
input:
|
||||||
overrides="data/override_component_attrs",
|
overrides="data/override_component_attrs",
|
||||||
@ -114,6 +123,10 @@ rule make_summary:
|
|||||||
|
|
||||||
rule plot_summary:
|
rule plot_summary:
|
||||||
params:
|
params:
|
||||||
|
logging=config["logging"],
|
||||||
|
countries=config["countries"],
|
||||||
|
scenario=config["scenario"],
|
||||||
|
plotting=config["plotting"],
|
||||||
RDIR=RDIR,
|
RDIR=RDIR,
|
||||||
input:
|
input:
|
||||||
costs=RESULTS + "csvs/costs.csv",
|
costs=RESULTS + "csvs/costs.csv",
|
||||||
|
@ -19,6 +19,8 @@ if config["enable"].get("retrieve_databundle", True):
|
|||||||
datafiles.extend(["natura/Natura2000_end2015.shp", "GEBCO_2014_2D.nc"])
|
datafiles.extend(["natura/Natura2000_end2015.shp", "GEBCO_2014_2D.nc"])
|
||||||
|
|
||||||
rule retrieve_databundle:
|
rule retrieve_databundle:
|
||||||
|
params:
|
||||||
|
tutorial=config["tutorial"],
|
||||||
output:
|
output:
|
||||||
expand("data/bundle/{file}", file=datafiles),
|
expand("data/bundle/{file}", file=datafiles),
|
||||||
log:
|
log:
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
|
|
||||||
rule solve_network:
|
rule solve_network:
|
||||||
|
params:
|
||||||
|
solving=config["solving"],
|
||||||
input:
|
input:
|
||||||
network=RESOURCES + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
network=RESOURCES + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
||||||
output:
|
output:
|
||||||
@ -30,6 +32,8 @@ rule solve_network:
|
|||||||
|
|
||||||
|
|
||||||
rule solve_operations_network:
|
rule solve_operations_network:
|
||||||
|
params:
|
||||||
|
solving=config["solving"],
|
||||||
input:
|
input:
|
||||||
network=RESULTS + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
network=RESULTS + "networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc",
|
||||||
output:
|
output:
|
||||||
|
@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
|
|
||||||
rule add_existing_baseyear:
|
rule add_existing_baseyear:
|
||||||
|
params:
|
||||||
|
scenario=config["scenario"],
|
||||||
|
sector=config["sector"],
|
||||||
|
logging=config["logging"],
|
||||||
|
existing_capacities=config["existing_capacities"],
|
||||||
|
costs=config["costs"],
|
||||||
input:
|
input:
|
||||||
overrides="data/override_component_attrs",
|
overrides="data/override_component_attrs",
|
||||||
network=RESULTS
|
network=RESULTS
|
||||||
@ -42,6 +48,10 @@ rule add_existing_baseyear:
|
|||||||
|
|
||||||
|
|
||||||
rule add_brownfield:
|
rule add_brownfield:
|
||||||
|
params:
|
||||||
|
logging=config["logging"],
|
||||||
|
sector=config["sector"],
|
||||||
|
existing_capacities=config["existing_capacities"],
|
||||||
input:
|
input:
|
||||||
overrides="data/override_component_attrs",
|
overrides="data/override_component_attrs",
|
||||||
network=RESULTS
|
network=RESULTS
|
||||||
@ -74,6 +84,8 @@ ruleorder: add_existing_baseyear > add_brownfield
|
|||||||
|
|
||||||
|
|
||||||
rule solve_sector_network_myopic:
|
rule solve_sector_network_myopic:
|
||||||
|
params:
|
||||||
|
solving=config["solving"],
|
||||||
input:
|
input:
|
||||||
overrides="data/override_component_attrs",
|
overrides="data/override_component_attrs",
|
||||||
network=RESULTS
|
network=RESULTS
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
|
|
||||||
rule solve_sector_network:
|
rule solve_sector_network:
|
||||||
|
params:
|
||||||
|
solving=config["solving"],
|
||||||
input:
|
input:
|
||||||
overrides="data/override_component_attrs",
|
overrides="data/override_component_attrs",
|
||||||
network=RESULTS
|
network=RESULTS
|
||||||
|
@ -82,7 +82,7 @@ def load_network(import_name=None, custom_components=None):
|
|||||||
As in pypsa.Network(import_name)
|
As in pypsa.Network(import_name)
|
||||||
custom_components : dict
|
custom_components : dict
|
||||||
Dictionary listing custom components.
|
Dictionary listing custom components.
|
||||||
For using ``snakemake.config['override_components']``
|
For using ``snakemake.params['override_components']``
|
||||||
in ``config/config.yaml`` define:
|
in ``config/config.yaml`` define:
|
||||||
|
|
||||||
.. code:: yaml
|
.. code:: yaml
|
||||||
|
@ -49,7 +49,7 @@ def add_brownfield(n, n_p, year):
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
threshold = snakemake.config["existing_capacities"]["threshold_capacity"]
|
threshold = snakemake.params["existing_capacities"]["threshold_capacity"]
|
||||||
|
|
||||||
if not chp_heat.empty:
|
if not chp_heat.empty:
|
||||||
threshold_chp_heat = (
|
threshold_chp_heat = (
|
||||||
@ -87,7 +87,7 @@ def add_brownfield(n, n_p, year):
|
|||||||
|
|
||||||
# deal with gas network
|
# deal with gas network
|
||||||
pipe_carrier = ["gas pipeline"]
|
pipe_carrier = ["gas pipeline"]
|
||||||
if snakemake.config["sector"]["H2_retrofit"]:
|
if snakemake.params["sector"]["H2_retrofit"]:
|
||||||
# drop capacities of previous year to avoid duplicating
|
# drop capacities of previous year to avoid duplicating
|
||||||
to_drop = n.links.carrier.isin(pipe_carrier) & (n.links.build_year != year)
|
to_drop = n.links.carrier.isin(pipe_carrier) & (n.links.build_year != year)
|
||||||
n.mremove("Link", n.links.loc[to_drop].index)
|
n.mremove("Link", n.links.loc[to_drop].index)
|
||||||
@ -98,7 +98,7 @@ def add_brownfield(n, n_p, year):
|
|||||||
& (n.links.build_year != year)
|
& (n.links.build_year != year)
|
||||||
].index
|
].index
|
||||||
gas_pipes_i = n.links[n.links.carrier.isin(pipe_carrier)].index
|
gas_pipes_i = n.links[n.links.carrier.isin(pipe_carrier)].index
|
||||||
CH4_per_H2 = 1 / snakemake.config["sector"]["H2_retrofit_capacity_per_CH4"]
|
CH4_per_H2 = 1 / snakemake.params["sector"]["H2_retrofit_capacity_per_CH4"]
|
||||||
fr = "H2 pipeline retrofitted"
|
fr = "H2 pipeline retrofitted"
|
||||||
to = "gas pipeline"
|
to = "gas pipeline"
|
||||||
# today's pipe capacity
|
# today's pipe capacity
|
||||||
@ -139,7 +139,7 @@ if __name__ == "__main__":
|
|||||||
planning_horizons=2030,
|
planning_horizons=2030,
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
logging.basicConfig(level=snakemake.params["logging"]["level"])
|
||||||
|
|
||||||
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
||||||
|
|
||||||
|
@ -686,15 +686,15 @@ def estimate_renewable_capacities(n, config):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def add_nice_carrier_names(n, plotting):
|
def add_nice_carrier_names(n, config):
|
||||||
carrier_i = n.carriers.index
|
carrier_i = n.carriers.index
|
||||||
nice_names = (
|
nice_names = (
|
||||||
pd.Series(plotting["nice_names"])
|
pd.Series(config["plotting"]["nice_names"])
|
||||||
.reindex(carrier_i)
|
.reindex(carrier_i)
|
||||||
.fillna(carrier_i.to_series().str.title())
|
.fillna(carrier_i.to_series().str.title())
|
||||||
)
|
)
|
||||||
n.carriers["nice_name"] = nice_names
|
n.carriers["nice_name"] = nice_names
|
||||||
colors = pd.Series(plotting["tech_colors"]).reindex(carrier_i)
|
colors = pd.Series(config["plotting"]["tech_colors"]).reindex(carrier_i)
|
||||||
if colors.isna().any():
|
if colors.isna().any():
|
||||||
missing_i = list(colors.index[colors.isna()])
|
missing_i = list(colors.index[colors.isna()])
|
||||||
logger.warning(f"tech_colors for carriers {missing_i} not defined in config.")
|
logger.warning(f"tech_colors for carriers {missing_i} not defined in config.")
|
||||||
@ -713,23 +713,23 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
costs = load_costs(
|
costs = load_costs(
|
||||||
snakemake.input.tech_costs,
|
snakemake.input.tech_costs,
|
||||||
snakemake.param["costs"],
|
snakemake.params["costs"],
|
||||||
snakemake.param["electricity"],
|
snakemake.params["electricity"],
|
||||||
Nyears,
|
Nyears,
|
||||||
)
|
)
|
||||||
ppl = load_powerplants(snakemake.input.powerplants)
|
ppl = load_powerplants(snakemake.input.powerplants)
|
||||||
|
|
||||||
if "renewable_carriers" in snakemake.param["electricity"]:
|
if "renewable_carriers" in snakemake.params["electricity"]:
|
||||||
renewable_carriers = set(snakemake.param["electricity"]["renewable_carriers"])
|
renewable_carriers = set(snakemake.params["electricity"]["renewable_carriers"])
|
||||||
else:
|
else:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Missing key `renewable_carriers` under config entry `electricity`. "
|
"Missing key `renewable_carriers` under config entry `electricity`. "
|
||||||
"In future versions, this will raise an error. "
|
"In future versions, this will raise an error. "
|
||||||
"Falling back to carriers listed under `renewable`."
|
"Falling back to carriers listed under `renewable`."
|
||||||
)
|
)
|
||||||
renewable_carriers = snakemake.param["renewable"]
|
renewable_carriers = snakemake.params["renewable"]
|
||||||
|
|
||||||
extendable_carriers = snakemake.param["electricity"]["extendable_carriers"]
|
extendable_carriers = snakemake.params["electricity"]["extendable_carriers"]
|
||||||
if not (set(renewable_carriers) & set(extendable_carriers["Generator"])):
|
if not (set(renewable_carriers) & set(extendable_carriers["Generator"])):
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"No renewables found in config entry `extendable_carriers`. "
|
"No renewables found in config entry `extendable_carriers`. "
|
||||||
@ -737,18 +737,18 @@ if __name__ == "__main__":
|
|||||||
"Falling back to all renewables."
|
"Falling back to all renewables."
|
||||||
)
|
)
|
||||||
|
|
||||||
conventional_carriers = snakemake.param["electricity"]["conventional_carriers"]
|
conventional_carriers = snakemake.params["electricity"]["conventional_carriers"]
|
||||||
|
|
||||||
attach_load(
|
attach_load(
|
||||||
n,
|
n,
|
||||||
snakemake.input.regions,
|
snakemake.input.regions,
|
||||||
snakemake.input.load,
|
snakemake.input.load,
|
||||||
snakemake.input.nuts3_shapes,
|
snakemake.input.nuts3_shapes,
|
||||||
snakemake.param["countries"],
|
snakemake.params["countries"],
|
||||||
snakemake.param["load"]["scaling_factor"],
|
snakemake.params["load"]["scaling_factor"],
|
||||||
)
|
)
|
||||||
|
|
||||||
update_transmission_costs(n, costs, snakemake.param["lines"]["length_factor"])
|
update_transmission_costs(n, costs, snakemake.params["lines"]["length_factor"])
|
||||||
|
|
||||||
conventional_inputs = {
|
conventional_inputs = {
|
||||||
k: v for k, v in snakemake.input.items() if k.startswith("conventional_")
|
k: v for k, v in snakemake.input.items() if k.startswith("conventional_")
|
||||||
@ -759,7 +759,7 @@ if __name__ == "__main__":
|
|||||||
ppl,
|
ppl,
|
||||||
conventional_carriers,
|
conventional_carriers,
|
||||||
extendable_carriers,
|
extendable_carriers,
|
||||||
snakemake.param.get("conventional", {}),
|
snakemake.config.get("conventional", {}),
|
||||||
conventional_inputs,
|
conventional_inputs,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -769,11 +769,11 @@ if __name__ == "__main__":
|
|||||||
snakemake.input,
|
snakemake.input,
|
||||||
renewable_carriers,
|
renewable_carriers,
|
||||||
extendable_carriers,
|
extendable_carriers,
|
||||||
snakemake.param["lines"]["length_factor"],
|
snakemake.params["lines"]["length_factor"],
|
||||||
)
|
)
|
||||||
|
|
||||||
if "hydro" in renewable_carriers:
|
if "hydro" in renewable_carriers:
|
||||||
conf = snakemake.param["renewable"]["hydro"]
|
conf = snakemake.params["renewable"]["hydro"]
|
||||||
attach_hydro(
|
attach_hydro(
|
||||||
n,
|
n,
|
||||||
costs,
|
costs,
|
||||||
@ -784,7 +784,7 @@ if __name__ == "__main__":
|
|||||||
**conf,
|
**conf,
|
||||||
)
|
)
|
||||||
|
|
||||||
if "estimate_renewable_capacities" not in snakemake.param["electricity"]:
|
if "estimate_renewable_capacities" not in snakemake.params["electricity"]:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Missing key `estimate_renewable_capacities` under config entry `electricity`. "
|
"Missing key `estimate_renewable_capacities` under config entry `electricity`. "
|
||||||
"In future versions, this will raise an error. "
|
"In future versions, this will raise an error. "
|
||||||
@ -792,18 +792,18 @@ if __name__ == "__main__":
|
|||||||
)
|
)
|
||||||
if (
|
if (
|
||||||
"estimate_renewable_capacities_from_capacity_stats"
|
"estimate_renewable_capacities_from_capacity_stats"
|
||||||
in snakemake.param["electricity"]
|
in snakemake.params["electricity"]
|
||||||
):
|
):
|
||||||
estimate_renewable_caps = {
|
estimate_renewable_caps = {
|
||||||
"enable": True,
|
"enable": True,
|
||||||
**snakemake.param["electricity"][
|
**snakemake.params["electricity"][
|
||||||
"estimate_renewable_capacities_from_capacity_stats"
|
"estimate_renewable_capacities_from_capacity_stats"
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
estimate_renewable_caps = {"enable": False}
|
estimate_renewable_caps = {"enable": False}
|
||||||
else:
|
else:
|
||||||
estimate_renewable_caps = snakemake.param["electricity"][
|
estimate_renewable_caps = snakemake.params["electricity"][
|
||||||
"estimate_renewable_capacities"
|
"estimate_renewable_capacities"
|
||||||
]
|
]
|
||||||
if "enable" not in estimate_renewable_caps:
|
if "enable" not in estimate_renewable_caps:
|
||||||
@ -819,21 +819,21 @@ if __name__ == "__main__":
|
|||||||
"Falling back to whether `renewable_capacities_from_opsd` is non-empty."
|
"Falling back to whether `renewable_capacities_from_opsd` is non-empty."
|
||||||
)
|
)
|
||||||
from_opsd = bool(
|
from_opsd = bool(
|
||||||
snakemake.param["electricity"].get("renewable_capacities_from_opsd", False)
|
snakemake.params["electricity"].get("renewable_capacities_from_opsd", False)
|
||||||
)
|
)
|
||||||
estimate_renewable_caps["from_opsd"] = from_opsd
|
estimate_renewable_caps["from_opsd"] = from_opsd
|
||||||
|
|
||||||
if estimate_renewable_caps["enable"]:
|
if estimate_renewable_caps["enable"]:
|
||||||
if estimate_renewable_caps["from_opsd"]:
|
if estimate_renewable_caps["from_opsd"]:
|
||||||
tech_map = snakemake.param["electricity"]["estimate_renewable_capacities"][
|
tech_map = snakemake.params["electricity"]["estimate_renewable_capacities"][
|
||||||
"technology_mapping"
|
"technology_mapping"
|
||||||
]
|
]
|
||||||
attach_OPSD_renewables(n, tech_map)
|
attach_OPSD_renewables(n, tech_map)
|
||||||
estimate_renewable_capacities(n, snakemake.param)
|
estimate_renewable_capacities(n, snakemake.config)
|
||||||
|
|
||||||
update_p_nom_max(n)
|
update_p_nom_max(n)
|
||||||
|
|
||||||
add_nice_carrier_names(n, snakemake.param["plotting"])
|
add_nice_carrier_names(n, snakemake.config)
|
||||||
|
|
||||||
n.meta = snakemake.param
|
n.meta = snakemake.config
|
||||||
n.export_to_netcdf(snakemake.output[0])
|
n.export_to_netcdf(snakemake.output[0])
|
||||||
|
@ -157,7 +157,7 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
|
|||||||
# Fill missing DateOut
|
# Fill missing DateOut
|
||||||
dateout = (
|
dateout = (
|
||||||
df_agg.loc[biomass_i, "DateIn"]
|
df_agg.loc[biomass_i, "DateIn"]
|
||||||
+ snakemake.config["costs"]["fill_values"]["lifetime"]
|
+ snakemake.params["costs"]["fill_values"]["lifetime"]
|
||||||
)
|
)
|
||||||
df_agg.loc[biomass_i, "DateOut"] = df_agg.loc[biomass_i, "DateOut"].fillna(dateout)
|
df_agg.loc[biomass_i, "DateOut"] = df_agg.loc[biomass_i, "DateOut"].fillna(dateout)
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
|
|||||||
capacity = df.loc[grouping_year, generator]
|
capacity = df.loc[grouping_year, generator]
|
||||||
capacity = capacity[~capacity.isna()]
|
capacity = capacity[~capacity.isna()]
|
||||||
capacity = capacity[
|
capacity = capacity[
|
||||||
capacity > snakemake.config["existing_capacities"]["threshold_capacity"]
|
capacity > snakemake.params["existing_capacities"]["threshold_capacity"]
|
||||||
]
|
]
|
||||||
suffix = "-ac" if generator == "offwind" else ""
|
suffix = "-ac" if generator == "offwind" else ""
|
||||||
name_suffix = f" {generator}{suffix}-{grouping_year}"
|
name_suffix = f" {generator}{suffix}-{grouping_year}"
|
||||||
@ -582,7 +582,7 @@ def add_heating_capacities_installed_before_baseyear(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# delete links with capacities below threshold
|
# delete links with capacities below threshold
|
||||||
threshold = snakemake.config["existing_capacities"]["threshold_capacity"]
|
threshold = snakemake.params["existing_capacities"]["threshold_capacity"]
|
||||||
n.mremove(
|
n.mremove(
|
||||||
"Link",
|
"Link",
|
||||||
[
|
[
|
||||||
@ -608,14 +608,14 @@ if __name__ == "__main__":
|
|||||||
planning_horizons=2020,
|
planning_horizons=2020,
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
logging.basicConfig(level=snakemake.params["logging"]["level"])
|
||||||
|
|
||||||
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
||||||
|
|
||||||
options = snakemake.config["sector"]
|
options = snakemake.params["sector"]
|
||||||
opts = snakemake.wildcards.sector_opts.split("-")
|
opts = snakemake.wildcards.sector_opts.split("-")
|
||||||
|
|
||||||
baseyear = snakemake.config["scenario"]["planning_horizons"][0]
|
baseyear = snakemake.params["scenario"]["planning_horizons"][0]
|
||||||
|
|
||||||
overrides = override_component_attrs(snakemake.input.overrides)
|
overrides = override_component_attrs(snakemake.input.overrides)
|
||||||
n = pypsa.Network(snakemake.input.network, override_component_attrs=overrides)
|
n = pypsa.Network(snakemake.input.network, override_component_attrs=overrides)
|
||||||
@ -626,14 +626,14 @@ if __name__ == "__main__":
|
|||||||
Nyears = n.snapshot_weightings.generators.sum() / 8760.0
|
Nyears = n.snapshot_weightings.generators.sum() / 8760.0
|
||||||
costs = prepare_costs(
|
costs = prepare_costs(
|
||||||
snakemake.input.costs,
|
snakemake.input.costs,
|
||||||
snakemake.config["costs"],
|
snakemake.params["costs"],
|
||||||
Nyears,
|
Nyears,
|
||||||
)
|
)
|
||||||
|
|
||||||
grouping_years_power = snakemake.config["existing_capacities"][
|
grouping_years_power = snakemake.params["existing_capacities"][
|
||||||
"grouping_years_power"
|
"grouping_years_power"
|
||||||
]
|
]
|
||||||
grouping_years_heat = snakemake.config["existing_capacities"]["grouping_years_heat"]
|
grouping_years_heat = snakemake.params["existing_capacities"]["grouping_years_heat"]
|
||||||
add_power_capacities_installed_before_baseyear(
|
add_power_capacities_installed_before_baseyear(
|
||||||
n, grouping_years_power, costs, baseyear
|
n, grouping_years_power, costs, baseyear
|
||||||
)
|
)
|
||||||
@ -650,7 +650,7 @@ if __name__ == "__main__":
|
|||||||
.to_pandas()
|
.to_pandas()
|
||||||
.reindex(index=n.snapshots)
|
.reindex(index=n.snapshots)
|
||||||
)
|
)
|
||||||
default_lifetime = snakemake.config["costs"]["fill_values"]["lifetime"]
|
default_lifetime = snakemake.params["costs"]["fill_values"]["lifetime"]
|
||||||
add_heating_capacities_installed_before_baseyear(
|
add_heating_capacities_installed_before_baseyear(
|
||||||
n,
|
n,
|
||||||
baseyear,
|
baseyear,
|
||||||
|
@ -235,11 +235,11 @@ if __name__ == "__main__":
|
|||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
|
|
||||||
n = pypsa.Network(snakemake.input.network)
|
n = pypsa.Network(snakemake.input.network)
|
||||||
elec_config = snakemake.config["electricity"]
|
elec_config = snakemake.params["electricity"]
|
||||||
|
|
||||||
Nyears = n.snapshot_weightings.objective.sum() / 8760.0
|
Nyears = n.snapshot_weightings.objective.sum() / 8760.0
|
||||||
costs = load_costs(
|
costs = load_costs(
|
||||||
snakemake.input.tech_costs, snakemake.config["costs"], elec_config, Nyears
|
snakemake.input.tech_costs, snakemake.params["costs"], elec_config, Nyears
|
||||||
)
|
)
|
||||||
|
|
||||||
attach_storageunits(n, costs, elec_config)
|
attach_storageunits(n, costs, elec_config)
|
||||||
|
@ -30,7 +30,7 @@ if __name__ == "__main__":
|
|||||||
ammonia.index = cc.convert(ammonia.index, to="iso2")
|
ammonia.index = cc.convert(ammonia.index, to="iso2")
|
||||||
|
|
||||||
years = [str(i) for i in range(2013, 2018)]
|
years = [str(i) for i in range(2013, 2018)]
|
||||||
countries = ammonia.index.intersection(snakemake.config["countries"])
|
countries = ammonia.index.intersection(snakemake.params["countries"])
|
||||||
ammonia = ammonia.loc[countries, years].astype(float)
|
ammonia = ammonia.loc[countries, years].astype(float)
|
||||||
|
|
||||||
# convert from ktonN to ktonNH3
|
# convert from ktonN to ktonNH3
|
||||||
|
@ -210,7 +210,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
snakemake = mock_snakemake("build_biomass_potentials", simpl="", clusters="5")
|
snakemake = mock_snakemake("build_biomass_potentials", simpl="", clusters="5")
|
||||||
|
|
||||||
config = snakemake.config["biomass"]
|
config = snakemake.params["biomass"]
|
||||||
year = config["year"]
|
year = config["year"]
|
||||||
scenario = config["scenario"]
|
scenario = config["scenario"]
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ if __name__ == "__main__":
|
|||||||
snakemake = mock_snakemake("build_bus_regions")
|
snakemake = mock_snakemake("build_bus_regions")
|
||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
|
|
||||||
countries = snakemake.config["countries"]
|
countries = snakemake.params["countries"]
|
||||||
|
|
||||||
n = pypsa.Network(snakemake.input.base_network)
|
n = pypsa.Network(snakemake.input.base_network)
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ if __name__ == "__main__":
|
|||||||
for source in ["air", "soil"]:
|
for source in ["air", "soil"]:
|
||||||
source_T = xr.open_dataarray(snakemake.input[f"temp_{source}_{area}"])
|
source_T = xr.open_dataarray(snakemake.input[f"temp_{source}_{area}"])
|
||||||
|
|
||||||
delta_T = snakemake.config["sector"]["heat_pump_sink_T"] - source_T
|
delta_T = snakemake.params["sector"]["heat_pump_sink_T"] - source_T
|
||||||
|
|
||||||
cop = coefficient_of_performance(delta_T, source)
|
cop = coefficient_of_performance(delta_T, source)
|
||||||
|
|
||||||
|
@ -106,9 +106,9 @@ if __name__ == "__main__":
|
|||||||
snakemake = mock_snakemake("build_cutout", cutout="europe-2013-era5")
|
snakemake = mock_snakemake("build_cutout", cutout="europe-2013-era5")
|
||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
|
|
||||||
cutout_params = snakemake.config["atlite"]["cutouts"][snakemake.wildcards.cutout]
|
cutout_params = snakemake.params["atlite"]["cutouts"][snakemake.wildcards.cutout]
|
||||||
|
|
||||||
snapshots = pd.date_range(freq="h", **snakemake.config["snapshots"])
|
snapshots = pd.date_range(freq="h", **snakemake.params["snapshots"])
|
||||||
time = [snapshots[0], snapshots[-1]]
|
time = [snapshots[0], snapshots[-1]]
|
||||||
cutout_params["time"] = slice(*cutout_params.get("time", time))
|
cutout_params["time"] = slice(*cutout_params.get("time", time))
|
||||||
|
|
||||||
|
@ -279,16 +279,16 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
|
|
||||||
powerstatistics = snakemake.config["load"]["power_statistics"]
|
powerstatistics = snakemake.params["load"]["power_statistics"]
|
||||||
interpolate_limit = snakemake.config["load"]["interpolate_limit"]
|
interpolate_limit = snakemake.params["load"]["interpolate_limit"]
|
||||||
countries = snakemake.config["countries"]
|
countries = snakemake.params["countries"]
|
||||||
snapshots = pd.date_range(freq="h", **snakemake.config["snapshots"])
|
snapshots = pd.date_range(freq="h", **snakemake.params["snapshots"])
|
||||||
years = slice(snapshots[0], snapshots[-1])
|
years = slice(snapshots[0], snapshots[-1])
|
||||||
time_shift = snakemake.config["load"]["time_shift_for_large_gaps"]
|
time_shift = snakemake.params["load"]["time_shift_for_large_gaps"]
|
||||||
|
|
||||||
load = load_timeseries(snakemake.input[0], years, countries, powerstatistics)
|
load = load_timeseries(snakemake.input[0], years, countries, powerstatistics)
|
||||||
|
|
||||||
if snakemake.config["load"]["manual_adjustments"]:
|
if snakemake.params["load"]["manual_adjustments"]:
|
||||||
load = manual_adjustment(load, snakemake.input[0], powerstatistics)
|
load = manual_adjustment(load, snakemake.input[0], powerstatistics)
|
||||||
|
|
||||||
logger.info(f"Linearly interpolate gaps of size {interpolate_limit} and less.")
|
logger.info(f"Linearly interpolate gaps of size {interpolate_limit} and less.")
|
||||||
|
@ -373,7 +373,7 @@ def idees_per_country(ct, year, base_dir):
|
|||||||
|
|
||||||
def build_idees(countries, year):
|
def build_idees(countries, year):
|
||||||
nprocesses = snakemake.threads
|
nprocesses = snakemake.threads
|
||||||
disable_progress = snakemake.config["run"].get("disable_progressbar", False)
|
disable_progress = snakemake.params["run"].get("disable_progressbar", False)
|
||||||
|
|
||||||
func = partial(idees_per_country, year=year, base_dir=snakemake.input.idees)
|
func = partial(idees_per_country, year=year, base_dir=snakemake.input.idees)
|
||||||
tqdm_kwargs = dict(
|
tqdm_kwargs = dict(
|
||||||
@ -735,18 +735,18 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
snakemake = mock_snakemake("build_energy_totals")
|
snakemake = mock_snakemake("build_energy_totals")
|
||||||
|
|
||||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
logging.basicConfig(level=snakemake.params["logging"]["level"])
|
||||||
|
|
||||||
config = snakemake.config["energy"]
|
config = snakemake.params["energy"]
|
||||||
|
|
||||||
nuts3 = gpd.read_file(snakemake.input.nuts3_shapes).set_index("index")
|
nuts3 = gpd.read_file(snakemake.input.nuts3_shapes).set_index("index")
|
||||||
population = nuts3["pop"].groupby(nuts3.country).sum()
|
population = nuts3["pop"].groupby(nuts3.country).sum()
|
||||||
|
|
||||||
countries = snakemake.config["countries"]
|
countries = snakemake.params["countries"]
|
||||||
idees_countries = pd.Index(countries).intersection(eu28)
|
idees_countries = pd.Index(countries).intersection(eu28)
|
||||||
|
|
||||||
data_year = config["energy_totals_year"]
|
data_year = config["energy_totals_year"]
|
||||||
report_year = snakemake.config["energy"]["eurostat_report_year"]
|
report_year = snakemake.params["energy"]["eurostat_report_year"]
|
||||||
input_eurostat = snakemake.input.eurostat
|
input_eurostat = snakemake.input.eurostat
|
||||||
eurostat = build_eurostat(input_eurostat, countries, report_year, data_year)
|
eurostat = build_eurostat(input_eurostat, countries, report_year, data_year)
|
||||||
swiss = build_swiss(data_year)
|
swiss = build_swiss(data_year)
|
||||||
@ -756,7 +756,7 @@ if __name__ == "__main__":
|
|||||||
energy.to_csv(snakemake.output.energy_name)
|
energy.to_csv(snakemake.output.energy_name)
|
||||||
|
|
||||||
base_year_emissions = config["base_emissions_year"]
|
base_year_emissions = config["base_emissions_year"]
|
||||||
emissions_scope = snakemake.config["energy"]["emissions"]
|
emissions_scope = snakemake.params["energy"]["emissions"]
|
||||||
eea_co2 = build_eea_co2(snakemake.input.co2, base_year_emissions, emissions_scope)
|
eea_co2 = build_eea_co2(snakemake.input.co2, base_year_emissions, emissions_scope)
|
||||||
eurostat_co2 = build_eurostat_co2(
|
eurostat_co2 = build_eurostat_co2(
|
||||||
input_eurostat, countries, report_year, base_year_emissions
|
input_eurostat, countries, report_year, base_year_emissions
|
||||||
|
@ -86,7 +86,7 @@ if __name__ == "__main__":
|
|||||||
clusters="37",
|
clusters="37",
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
logging.basicConfig(level=snakemake.params["logging"]["level"])
|
||||||
|
|
||||||
regions = load_bus_regions(
|
regions = load_bus_regions(
|
||||||
snakemake.input.regions_onshore, snakemake.input.regions_offshore
|
snakemake.input.regions_onshore, snakemake.input.regions_offshore
|
||||||
|
@ -147,7 +147,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
snakemake = mock_snakemake("build_gas_network")
|
snakemake = mock_snakemake("build_gas_network")
|
||||||
|
|
||||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
logging.basicConfig(level=snakemake.params["logging"]["level"])
|
||||||
|
|
||||||
gas_network = load_dataset(snakemake.input.gas_network)
|
gas_network = load_dataset(snakemake.input.gas_network)
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ if __name__ == "__main__":
|
|||||||
cluster = LocalCluster(n_workers=nprocesses, threads_per_worker=1)
|
cluster = LocalCluster(n_workers=nprocesses, threads_per_worker=1)
|
||||||
client = Client(cluster, asynchronous=True)
|
client = Client(cluster, asynchronous=True)
|
||||||
|
|
||||||
time = pd.date_range(freq="h", **snakemake.config["snapshots"])
|
time = pd.date_range(freq="h", **snakemake.params["snapshots"])
|
||||||
cutout = atlite.Cutout(snakemake.input.cutout).sel(time=time)
|
cutout = atlite.Cutout(snakemake.input.cutout).sel(time=time)
|
||||||
|
|
||||||
clustered_regions = (
|
clustered_regions = (
|
||||||
|
@ -130,10 +130,10 @@ if __name__ == "__main__":
|
|||||||
snakemake = mock_snakemake("build_hydro_profile")
|
snakemake = mock_snakemake("build_hydro_profile")
|
||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
|
|
||||||
config_hydro = snakemake.config["renewable"]["hydro"]
|
config_hydro = snakemake.params["renewable"]["hydro"]
|
||||||
cutout = atlite.Cutout(snakemake.input.cutout)
|
cutout = atlite.Cutout(snakemake.input.cutout)
|
||||||
|
|
||||||
countries = snakemake.config["countries"]
|
countries = snakemake.params["countries"]
|
||||||
country_shapes = (
|
country_shapes = (
|
||||||
gpd.read_file(snakemake.input.country_shapes)
|
gpd.read_file(snakemake.input.country_shapes)
|
||||||
.set_index("name")["geometry"]
|
.set_index("name")["geometry"]
|
||||||
|
@ -73,7 +73,7 @@ def prepare_hotmaps_database(regions):
|
|||||||
|
|
||||||
df[["srid", "coordinates"]] = df.geom.str.split(";", expand=True)
|
df[["srid", "coordinates"]] = df.geom.str.split(";", expand=True)
|
||||||
|
|
||||||
if snakemake.config["industry"].get("hotmaps_locate_missing", False):
|
if snakemake.params["industry"].get("hotmaps_locate_missing", False):
|
||||||
df = locate_missing_industrial_sites(df)
|
df = locate_missing_industrial_sites(df)
|
||||||
|
|
||||||
# remove those sites without valid locations
|
# remove those sites without valid locations
|
||||||
@ -141,9 +141,9 @@ if __name__ == "__main__":
|
|||||||
clusters=48,
|
clusters=48,
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
logging.basicConfig(level=snakemake.params["logging"]["level"])
|
||||||
|
|
||||||
countries = snakemake.config["countries"]
|
countries = snakemake.params["countries"]
|
||||||
|
|
||||||
regions = gpd.read_file(snakemake.input.regions_onshore).set_index("name")
|
regions = gpd.read_file(snakemake.input.regions_onshore).set_index("name")
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ def add_non_eu28_industrial_energy_demand(countries, demand):
|
|||||||
|
|
||||||
def industrial_energy_demand(countries, year):
|
def industrial_energy_demand(countries, year):
|
||||||
nprocesses = snakemake.threads
|
nprocesses = snakemake.threads
|
||||||
disable_progress = snakemake.config["run"].get("disable_progressbar", False)
|
disable_progress = snakemake.params["run"].get("disable_progressbar", False)
|
||||||
func = partial(
|
func = partial(
|
||||||
industrial_energy_demand_per_country, year=year, jrc_dir=snakemake.input.jrc
|
industrial_energy_demand_per_country, year=year, jrc_dir=snakemake.input.jrc
|
||||||
)
|
)
|
||||||
@ -178,9 +178,9 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
snakemake = mock_snakemake("build_industrial_energy_demand_per_country_today")
|
snakemake = mock_snakemake("build_industrial_energy_demand_per_country_today")
|
||||||
|
|
||||||
config = snakemake.config["industry"]
|
config = snakemake.params["industry"]
|
||||||
year = config.get("reference_year", 2015)
|
year = config.get("reference_year", 2015)
|
||||||
countries = pd.Index(snakemake.config["countries"])
|
countries = pd.Index(snakemake.params["countries"])
|
||||||
|
|
||||||
demand = industrial_energy_demand(countries.intersection(eu28), year)
|
demand = industrial_energy_demand(countries.intersection(eu28), year)
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ def industry_production_per_country(country, year, eurostat_dir, jrc_dir):
|
|||||||
|
|
||||||
def industry_production(countries, year, eurostat_dir, jrc_dir):
|
def industry_production(countries, year, eurostat_dir, jrc_dir):
|
||||||
nprocesses = snakemake.threads
|
nprocesses = snakemake.threads
|
||||||
disable_progress = snakemake.config["run"].get("disable_progressbar", False)
|
disable_progress = snakemake.params["run"].get("disable_progressbar", False)
|
||||||
|
|
||||||
func = partial(
|
func = partial(
|
||||||
industry_production_per_country,
|
industry_production_per_country,
|
||||||
@ -277,13 +277,13 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
snakemake = mock_snakemake("build_industrial_production_per_country")
|
snakemake = mock_snakemake("build_industrial_production_per_country")
|
||||||
|
|
||||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
logging.basicConfig(level=snakemake.params["logging"]["level"])
|
||||||
|
|
||||||
countries = snakemake.config["countries"]
|
countries = snakemake.params["countries"]
|
||||||
|
|
||||||
year = snakemake.config["industry"]["reference_year"]
|
year = snakemake.params["industry"]["reference_year"]
|
||||||
|
|
||||||
config = snakemake.config["industry"]
|
config = snakemake.params["industry"]
|
||||||
|
|
||||||
jrc_dir = snakemake.input.jrc
|
jrc_dir = snakemake.input.jrc
|
||||||
eurostat_dir = snakemake.input.eurostat
|
eurostat_dir = snakemake.input.eurostat
|
||||||
|
@ -15,7 +15,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
snakemake = mock_snakemake("build_industrial_production_per_country_tomorrow")
|
snakemake = mock_snakemake("build_industrial_production_per_country_tomorrow")
|
||||||
|
|
||||||
config = snakemake.config["industry"]
|
config = snakemake.params["industry"]
|
||||||
|
|
||||||
investment_year = int(snakemake.wildcards.planning_horizons)
|
investment_year = int(snakemake.wildcards.planning_horizons)
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ def chemicals_industry():
|
|||||||
|
|
||||||
sector = "Ammonia"
|
sector = "Ammonia"
|
||||||
df[sector] = 0.0
|
df[sector] = 0.0
|
||||||
if snakemake.config["sector"].get("ammonia", False):
|
if snakemake.params["sector"].get("ammonia", False):
|
||||||
df.loc["ammonia", sector] = config["MWh_NH3_per_tNH3"]
|
df.loc["ammonia", sector] = config["MWh_NH3_per_tNH3"]
|
||||||
else:
|
else:
|
||||||
df.loc["hydrogen", sector] = config["MWh_H2_per_tNH3_electrolysis"]
|
df.loc["hydrogen", sector] = config["MWh_H2_per_tNH3_electrolysis"]
|
||||||
@ -1468,7 +1468,7 @@ if __name__ == "__main__":
|
|||||||
# TODO make config option
|
# TODO make config option
|
||||||
year = 2015
|
year = 2015
|
||||||
|
|
||||||
config = snakemake.config["industry"]
|
config = snakemake.params["industry"]
|
||||||
|
|
||||||
df = pd.concat(
|
df = pd.concat(
|
||||||
[
|
[
|
||||||
|
@ -23,7 +23,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
snakemake = mock_snakemake("build_population_layouts")
|
snakemake = mock_snakemake("build_population_layouts")
|
||||||
|
|
||||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
logging.basicConfig(level=snakemake.params["logging"]["level"])
|
||||||
|
|
||||||
cutout = atlite.Cutout(snakemake.input.cutout)
|
cutout = atlite.Cutout(snakemake.input.cutout)
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ if __name__ == "__main__":
|
|||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
|
|
||||||
n = pypsa.Network(snakemake.input.base_network)
|
n = pypsa.Network(snakemake.input.base_network)
|
||||||
countries = snakemake.config["countries"]
|
countries = snakemake.params["countries"]
|
||||||
|
|
||||||
ppl = (
|
ppl = (
|
||||||
pm.powerplants(from_url=True)
|
pm.powerplants(from_url=True)
|
||||||
@ -134,12 +134,12 @@ if __name__ == "__main__":
|
|||||||
ppl = ppl.query('not (Country in @available_countries and Fueltype == "Bioenergy")')
|
ppl = ppl.query('not (Country in @available_countries and Fueltype == "Bioenergy")')
|
||||||
ppl = pd.concat([ppl, opsd])
|
ppl = pd.concat([ppl, opsd])
|
||||||
|
|
||||||
ppl_query = snakemake.config["electricity"]["powerplants_filter"]
|
ppl_query = snakemake.params["electricity"]["powerplants_filter"]
|
||||||
if isinstance(ppl_query, str):
|
if isinstance(ppl_query, str):
|
||||||
ppl.query(ppl_query, inplace=True)
|
ppl.query(ppl_query, inplace=True)
|
||||||
|
|
||||||
# add carriers from own powerplant files:
|
# add carriers from own powerplant files:
|
||||||
custom_ppl_query = snakemake.config["electricity"]["custom_powerplants"]
|
custom_ppl_query = snakemake.params["electricity"]["custom_powerplants"]
|
||||||
ppl = add_custom_powerplants(
|
ppl = add_custom_powerplants(
|
||||||
ppl, snakemake.input.custom_powerplants, custom_ppl_query
|
ppl, snakemake.input.custom_powerplants, custom_ppl_query
|
||||||
)
|
)
|
||||||
|
@ -203,8 +203,8 @@ if __name__ == "__main__":
|
|||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
|
|
||||||
nprocesses = int(snakemake.threads)
|
nprocesses = int(snakemake.threads)
|
||||||
noprogress = snakemake.config["run"].get("disable_progressbar", True)
|
noprogress = snakemake.params["run"].get("disable_progressbar", True)
|
||||||
config = snakemake.config["renewable"][snakemake.wildcards.technology]
|
config = snakemake.params["renewable"][snakemake.wildcards.technology]
|
||||||
resource = config["resource"] # pv panel config / wind turbine config
|
resource = config["resource"] # pv panel config / wind turbine config
|
||||||
correction_factor = config.get("correction_factor", 1.0)
|
correction_factor = config.get("correction_factor", 1.0)
|
||||||
capacity_per_sqkm = config["capacity_per_sqkm"]
|
capacity_per_sqkm = config["capacity_per_sqkm"]
|
||||||
|
@ -305,7 +305,7 @@ def prepare_building_stock_data():
|
|||||||
u_values.set_index(["country_code", "subsector", "bage", "type"], inplace=True)
|
u_values.set_index(["country_code", "subsector", "bage", "type"], inplace=True)
|
||||||
|
|
||||||
# only take in config.yaml specified countries into account
|
# only take in config.yaml specified countries into account
|
||||||
countries = snakemake.config["countries"]
|
countries = snakemake.params["countries"]
|
||||||
area_tot = area_tot.loc[countries]
|
area_tot = area_tot.loc[countries]
|
||||||
|
|
||||||
return u_values, country_iso_dic, countries, area_tot, area
|
return u_values, country_iso_dic, countries, area_tot, area
|
||||||
@ -1040,7 +1040,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# ******** config *********************************************************
|
# ******** config *********************************************************
|
||||||
|
|
||||||
retro_opts = snakemake.config["sector"]["retrofitting"]
|
retro_opts = snakemake.params["sector"]["retrofitting"]
|
||||||
interest_rate = retro_opts["interest_rate"]
|
interest_rate = retro_opts["interest_rate"]
|
||||||
annualise_cost = retro_opts["annualise_cost"] # annualise the investment costs
|
annualise_cost = retro_opts["annualise_cost"] # annualise the investment costs
|
||||||
tax_weighting = retro_opts[
|
tax_weighting = retro_opts[
|
||||||
|
@ -41,7 +41,7 @@ if __name__ == "__main__":
|
|||||||
"build_sequestration_potentials", simpl="", clusters="181"
|
"build_sequestration_potentials", simpl="", clusters="181"
|
||||||
)
|
)
|
||||||
|
|
||||||
cf = snakemake.config["sector"]["regional_co2_sequestration_potential"]
|
cf = snakemake.params["sector"]["regional_co2_sequestration_potential"]
|
||||||
|
|
||||||
gdf = gpd.read_file(snakemake.input.sequestration_potential[0])
|
gdf = gpd.read_file(snakemake.input.sequestration_potential[0])
|
||||||
|
|
||||||
|
@ -255,12 +255,12 @@ if __name__ == "__main__":
|
|||||||
configure_logging(snakemake)
|
configure_logging(snakemake)
|
||||||
|
|
||||||
country_shapes = countries(
|
country_shapes = countries(
|
||||||
snakemake.input.naturalearth, snakemake.config["countries"]
|
snakemake.input.naturalearth, snakemake.params["countries"]
|
||||||
)
|
)
|
||||||
country_shapes.reset_index().to_file(snakemake.output.country_shapes)
|
country_shapes.reset_index().to_file(snakemake.output.country_shapes)
|
||||||
|
|
||||||
offshore_shapes = eez(
|
offshore_shapes = eez(
|
||||||
country_shapes, snakemake.input.eez, snakemake.config["countries"]
|
country_shapes, snakemake.input.eez, snakemake.params["countries"]
|
||||||
)
|
)
|
||||||
offshore_shapes.reset_index().to_file(snakemake.output.offshore_shapes)
|
offshore_shapes.reset_index().to_file(snakemake.output.offshore_shapes)
|
||||||
|
|
||||||
|
@ -27,9 +27,9 @@ if __name__ == "__main__":
|
|||||||
cluster = LocalCluster(n_workers=nprocesses, threads_per_worker=1)
|
cluster = LocalCluster(n_workers=nprocesses, threads_per_worker=1)
|
||||||
client = Client(cluster, asynchronous=True)
|
client = Client(cluster, asynchronous=True)
|
||||||
|
|
||||||
config = snakemake.config["solar_thermal"]
|
config = snakemake.params["solar_thermal"]
|
||||||
|
|
||||||
time = pd.date_range(freq="h", **snakemake.config["snapshots"])
|
time = pd.date_range(freq="h", **snakemake.params["snapshots"])
|
||||||
cutout = atlite.Cutout(snakemake.input.cutout).sel(time=time)
|
cutout = atlite.Cutout(snakemake.input.cutout).sel(time=time)
|
||||||
|
|
||||||
clustered_regions = (
|
clustered_regions = (
|
||||||
|
@ -27,7 +27,7 @@ if __name__ == "__main__":
|
|||||||
cluster = LocalCluster(n_workers=nprocesses, threads_per_worker=1)
|
cluster = LocalCluster(n_workers=nprocesses, threads_per_worker=1)
|
||||||
client = Client(cluster, asynchronous=True)
|
client = Client(cluster, asynchronous=True)
|
||||||
|
|
||||||
time = pd.date_range(freq="h", **snakemake.config["snapshots"])
|
time = pd.date_range(freq="h", **snakemake.params["snapshots"])
|
||||||
cutout = atlite.Cutout(snakemake.input.cutout).sel(time=time)
|
cutout = atlite.Cutout(snakemake.input.cutout).sel(time=time)
|
||||||
|
|
||||||
clustered_regions = (
|
clustered_regions = (
|
||||||
|
@ -175,9 +175,9 @@ if __name__ == "__main__":
|
|||||||
snakemake.input.pop_weighted_energy_totals, index_col=0
|
snakemake.input.pop_weighted_energy_totals, index_col=0
|
||||||
)
|
)
|
||||||
|
|
||||||
options = snakemake.config["sector"]
|
options = snakemake.params["sector"]
|
||||||
|
|
||||||
snapshots = pd.date_range(freq="h", **snakemake.config["snapshots"], tz="UTC")
|
snapshots = pd.date_range(freq="h", **snakemake.params["snapshots"], tz="UTC")
|
||||||
|
|
||||||
nyears = len(snapshots) / 8760
|
nyears = len(snapshots) / 8760
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
snakemake = mock_snakemake("cluster_gas_network", simpl="", clusters="37")
|
snakemake = mock_snakemake("cluster_gas_network", simpl="", clusters="37")
|
||||||
|
|
||||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
logging.basicConfig(level=snakemake.params["logging"]["level"])
|
||||||
|
|
||||||
fn = snakemake.input.cleaned_gas_network
|
fn = snakemake.input.cleaned_gas_network
|
||||||
df = pd.read_csv(fn, index_col=0)
|
df = pd.read_csv(fn, index_col=0)
|
||||||
|
@ -468,18 +468,18 @@ if __name__ == "__main__":
|
|||||||
[
|
[
|
||||||
tech
|
tech
|
||||||
for tech in n.generators.carrier.unique()
|
for tech in n.generators.carrier.unique()
|
||||||
if tech in snakemake.config["renewable"]
|
if tech in snakemake.params["renewable"]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
exclude_carriers = snakemake.config["clustering"]["cluster_network"].get(
|
exclude_carriers = snakemake.params["clustering"]["cluster_network"].get(
|
||||||
"exclude_carriers", []
|
"exclude_carriers", []
|
||||||
)
|
)
|
||||||
aggregate_carriers = set(n.generators.carrier) - set(exclude_carriers)
|
aggregate_carriers = set(n.generators.carrier) - set(exclude_carriers)
|
||||||
if snakemake.wildcards.clusters.endswith("m"):
|
if snakemake.wildcards.clusters.endswith("m"):
|
||||||
n_clusters = int(snakemake.wildcards.clusters[:-1])
|
n_clusters = int(snakemake.wildcards.clusters[:-1])
|
||||||
conventional = set(
|
conventional = set(
|
||||||
snakemake.config["electricity"].get("conventional_carriers", [])
|
snakemake.params["electricity"].get("conventional_carriers", [])
|
||||||
)
|
)
|
||||||
aggregate_carriers = conventional.intersection(aggregate_carriers)
|
aggregate_carriers = conventional.intersection(aggregate_carriers)
|
||||||
elif snakemake.wildcards.clusters == "all":
|
elif snakemake.wildcards.clusters == "all":
|
||||||
@ -495,13 +495,13 @@ if __name__ == "__main__":
|
|||||||
n, busmap, linemap, linemap, pd.Series(dtype="O")
|
n, busmap, linemap, linemap, pd.Series(dtype="O")
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
line_length_factor = snakemake.config["lines"]["length_factor"]
|
line_length_factor = snakemake.params["lines"]["length_factor"]
|
||||||
Nyears = n.snapshot_weightings.objective.sum() / 8760
|
Nyears = n.snapshot_weightings.objective.sum() / 8760
|
||||||
|
|
||||||
hvac_overhead_cost = load_costs(
|
hvac_overhead_cost = load_costs(
|
||||||
snakemake.input.tech_costs,
|
snakemake.input.tech_costs,
|
||||||
snakemake.config["costs"],
|
snakemake.params["costs"],
|
||||||
snakemake.config["electricity"],
|
snakemake.params["electricity"],
|
||||||
Nyears,
|
Nyears,
|
||||||
).at["HVAC overhead", "capital_cost"]
|
).at["HVAC overhead", "capital_cost"]
|
||||||
|
|
||||||
@ -512,7 +512,7 @@ if __name__ == "__main__":
|
|||||||
).all() or x.isnull().all(), "The `potential` configuration option must agree for all renewable carriers, for now!"
|
).all() or x.isnull().all(), "The `potential` configuration option must agree for all renewable carriers, for now!"
|
||||||
return v
|
return v
|
||||||
|
|
||||||
aggregation_strategies = snakemake.config["clustering"].get(
|
aggregation_strategies = snakemake.params["clustering"].get(
|
||||||
"aggregation_strategies", {}
|
"aggregation_strategies", {}
|
||||||
)
|
)
|
||||||
# translate str entries of aggregation_strategies to pd.Series functions:
|
# translate str entries of aggregation_strategies to pd.Series functions:
|
||||||
@ -521,7 +521,7 @@ if __name__ == "__main__":
|
|||||||
for p in aggregation_strategies.keys()
|
for p in aggregation_strategies.keys()
|
||||||
}
|
}
|
||||||
|
|
||||||
custom_busmap = snakemake.config["enable"].get("custom_busmap", False)
|
custom_busmap = snakemake.params["enable"].get("custom_busmap", False)
|
||||||
if custom_busmap:
|
if custom_busmap:
|
||||||
custom_busmap = pd.read_csv(
|
custom_busmap = pd.read_csv(
|
||||||
snakemake.input.custom_busmap, index_col=0, squeeze=True
|
snakemake.input.custom_busmap, index_col=0, squeeze=True
|
||||||
@ -539,7 +539,7 @@ if __name__ == "__main__":
|
|||||||
aggregate_carriers,
|
aggregate_carriers,
|
||||||
line_length_factor,
|
line_length_factor,
|
||||||
aggregation_strategies,
|
aggregation_strategies,
|
||||||
snakemake.config["solving"]["solver"]["name"],
|
snakemake.params["solving"]["solver"]["name"],
|
||||||
cluster_config.get("algorithm", "hac"),
|
cluster_config.get("algorithm", "hac"),
|
||||||
cluster_config.get("feature", "solar+onwind-time"),
|
cluster_config.get("feature", "solar+onwind-time"),
|
||||||
hvac_overhead_cost,
|
hvac_overhead_cost,
|
||||||
|
@ -198,7 +198,7 @@ def calculate_costs(n, label, costs):
|
|||||||
|
|
||||||
|
|
||||||
def calculate_cumulative_cost():
|
def calculate_cumulative_cost():
|
||||||
planning_horizons = snakemake.config["scenario"]["planning_horizons"]
|
planning_horizons = snakemake.params["scenario"]["planning_horizons"]
|
||||||
|
|
||||||
cumulative_cost = pd.DataFrame(
|
cumulative_cost = pd.DataFrame(
|
||||||
index=df["costs"].sum().index,
|
index=df["costs"].sum().index,
|
||||||
@ -682,25 +682,25 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
snakemake = mock_snakemake("make_summary")
|
snakemake = mock_snakemake("make_summary")
|
||||||
|
|
||||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
logging.basicConfig(level=snakemake.params["logging"]["level"])
|
||||||
|
|
||||||
networks_dict = {
|
networks_dict = {
|
||||||
(cluster, ll, opt + sector_opt, planning_horizon): "results/"
|
(cluster, ll, opt + sector_opt, planning_horizon): "results/"
|
||||||
+ snakemake.params.RDIR
|
+ snakemake.params.RDIR
|
||||||
+ f"/postnetworks/elec_s{simpl}_{cluster}_l{ll}_{opt}_{sector_opt}_{planning_horizon}.nc"
|
+ f"/postnetworks/elec_s{simpl}_{cluster}_l{ll}_{opt}_{sector_opt}_{planning_horizon}.nc"
|
||||||
for simpl in snakemake.config["scenario"]["simpl"]
|
for simpl in snakemake.params["scenario"]["simpl"]
|
||||||
for cluster in snakemake.config["scenario"]["clusters"]
|
for cluster in snakemake.params["scenario"]["clusters"]
|
||||||
for opt in snakemake.config["scenario"]["opts"]
|
for opt in snakemake.params["scenario"]["opts"]
|
||||||
for sector_opt in snakemake.config["scenario"]["sector_opts"]
|
for sector_opt in snakemake.params["scenario"]["sector_opts"]
|
||||||
for ll in snakemake.config["scenario"]["ll"]
|
for ll in snakemake.params["scenario"]["ll"]
|
||||||
for planning_horizon in snakemake.config["scenario"]["planning_horizons"]
|
for planning_horizon in snakemake.params["scenario"]["planning_horizons"]
|
||||||
}
|
}
|
||||||
|
|
||||||
Nyears = len(pd.date_range(freq="h", **snakemake.config["snapshots"])) / 8760
|
Nyears = len(pd.date_range(freq="h", **snakemake.params["snapshots"])) / 8760
|
||||||
|
|
||||||
costs_db = prepare_costs(
|
costs_db = prepare_costs(
|
||||||
snakemake.input.costs,
|
snakemake.input.costs,
|
||||||
snakemake.config["costs"],
|
snakemake.params["costs"],
|
||||||
Nyears,
|
Nyears,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -710,7 +710,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
to_csv(df)
|
to_csv(df)
|
||||||
|
|
||||||
if snakemake.config["foresight"] == "myopic":
|
if snakemake.params["foresight"] == "myopic":
|
||||||
cumulative_cost = calculate_cumulative_cost()
|
cumulative_cost = calculate_cumulative_cost()
|
||||||
cumulative_cost.to_csv(
|
cumulative_cost.to_csv(
|
||||||
"results/" + snakemake.params.RDIR + "/csvs/cumulative_cost.csv"
|
"results/" + snakemake.params.RDIR + "/csvs/cumulative_cost.csv"
|
||||||
|
@ -70,7 +70,7 @@ def plot_map(
|
|||||||
transmission=False,
|
transmission=False,
|
||||||
with_legend=True,
|
with_legend=True,
|
||||||
):
|
):
|
||||||
tech_colors = snakemake.config["plotting"]["tech_colors"]
|
tech_colors = snakemake.params["plotting"]["tech_colors"]
|
||||||
|
|
||||||
n = network.copy()
|
n = network.copy()
|
||||||
assign_location(n)
|
assign_location(n)
|
||||||
@ -116,7 +116,7 @@ def plot_map(
|
|||||||
costs = costs.stack() # .sort_index()
|
costs = costs.stack() # .sort_index()
|
||||||
|
|
||||||
# hack because impossible to drop buses...
|
# hack because impossible to drop buses...
|
||||||
eu_location = snakemake.config["plotting"].get(
|
eu_location = snakemake.params["plotting"].get(
|
||||||
"eu_node_location", dict(x=-5.5, y=46)
|
"eu_node_location", dict(x=-5.5, y=46)
|
||||||
)
|
)
|
||||||
n.buses.loc["EU gas", "x"] = eu_location["x"]
|
n.buses.loc["EU gas", "x"] = eu_location["x"]
|
||||||
@ -315,7 +315,7 @@ def plot_h2_map(network, regions):
|
|||||||
h2_new = n.links[n.links.carrier == "H2 pipeline"]
|
h2_new = n.links[n.links.carrier == "H2 pipeline"]
|
||||||
h2_retro = n.links[n.links.carrier == "H2 pipeline retrofitted"]
|
h2_retro = n.links[n.links.carrier == "H2 pipeline retrofitted"]
|
||||||
|
|
||||||
if snakemake.config["foresight"] == "myopic":
|
if snakemake.params["foresight"] == "myopic":
|
||||||
# sum capacitiy for pipelines from different investment periods
|
# sum capacitiy for pipelines from different investment periods
|
||||||
h2_new = group_pipes(h2_new)
|
h2_new = group_pipes(h2_new)
|
||||||
|
|
||||||
@ -558,7 +558,7 @@ def plot_ch4_map(network):
|
|||||||
link_widths_used = max_usage / linewidth_factor
|
link_widths_used = max_usage / linewidth_factor
|
||||||
link_widths_used[max_usage < line_lower_threshold] = 0.0
|
link_widths_used[max_usage < line_lower_threshold] = 0.0
|
||||||
|
|
||||||
tech_colors = snakemake.config["plotting"]["tech_colors"]
|
tech_colors = snakemake.params["plotting"]["tech_colors"]
|
||||||
|
|
||||||
pipe_colors = {
|
pipe_colors = {
|
||||||
"gas pipeline": "#f08080",
|
"gas pipeline": "#f08080",
|
||||||
@ -700,7 +700,7 @@ def plot_map_without(network):
|
|||||||
|
|
||||||
# hack because impossible to drop buses...
|
# hack because impossible to drop buses...
|
||||||
if "EU gas" in n.buses.index:
|
if "EU gas" in n.buses.index:
|
||||||
eu_location = snakemake.config["plotting"].get(
|
eu_location = snakemake.params["plotting"].get(
|
||||||
"eu_node_location", dict(x=-5.5, y=46)
|
"eu_node_location", dict(x=-5.5, y=46)
|
||||||
)
|
)
|
||||||
n.buses.loc["EU gas", "x"] = eu_location["x"]
|
n.buses.loc["EU gas", "x"] = eu_location["x"]
|
||||||
@ -876,7 +876,7 @@ def plot_series(network, carrier="AC", name="test"):
|
|||||||
stacked=True,
|
stacked=True,
|
||||||
linewidth=0.0,
|
linewidth=0.0,
|
||||||
color=[
|
color=[
|
||||||
snakemake.config["plotting"]["tech_colors"][i.replace(suffix, "")]
|
snakemake.params["plotting"]["tech_colors"][i.replace(suffix, "")]
|
||||||
for i in new_columns
|
for i in new_columns
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -930,14 +930,14 @@ if __name__ == "__main__":
|
|||||||
planning_horizons="2030",
|
planning_horizons="2030",
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
logging.basicConfig(level=snakemake.params["logging"]["level"])
|
||||||
|
|
||||||
overrides = override_component_attrs(snakemake.input.overrides)
|
overrides = override_component_attrs(snakemake.input.overrides)
|
||||||
n = pypsa.Network(snakemake.input.network, override_component_attrs=overrides)
|
n = pypsa.Network(snakemake.input.network, override_component_attrs=overrides)
|
||||||
|
|
||||||
regions = gpd.read_file(snakemake.input.regions).set_index("name")
|
regions = gpd.read_file(snakemake.input.regions).set_index("name")
|
||||||
|
|
||||||
map_opts = snakemake.config["plotting"]["map"]
|
map_opts = snakemake.params["plotting"]["map"]
|
||||||
|
|
||||||
if map_opts["boundaries"] is None:
|
if map_opts["boundaries"] is None:
|
||||||
map_opts["boundaries"] = regions.total_bounds[[0, 2, 1, 3]] + [-1, 1, -1, 1]
|
map_opts["boundaries"] = regions.total_bounds[[0, 2, 1, 3]] + [-1, 1, -1, 1]
|
||||||
|
@ -142,10 +142,10 @@ def plot_costs():
|
|||||||
|
|
||||||
df = df.groupby(df.index.map(rename_techs)).sum()
|
df = df.groupby(df.index.map(rename_techs)).sum()
|
||||||
|
|
||||||
to_drop = df.index[df.max(axis=1) < snakemake.config["plotting"]["costs_threshold"]]
|
to_drop = df.index[df.max(axis=1) < snakemake.params["plotting"]["costs_threshold"]]
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Dropping technology with costs below {snakemake.config['plotting']['costs_threshold']} EUR billion per year"
|
f"Dropping technology with costs below {snakemake.params['plotting']['costs_threshold']} EUR billion per year"
|
||||||
)
|
)
|
||||||
logger.debug(df.loc[to_drop])
|
logger.debug(df.loc[to_drop])
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ def plot_costs():
|
|||||||
kind="bar",
|
kind="bar",
|
||||||
ax=ax,
|
ax=ax,
|
||||||
stacked=True,
|
stacked=True,
|
||||||
color=[snakemake.config["plotting"]["tech_colors"][i] for i in new_index],
|
color=[snakemake.params["plotting"]["tech_colors"][i] for i in new_index],
|
||||||
)
|
)
|
||||||
|
|
||||||
handles, labels = ax.get_legend_handles_labels()
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
@ -173,7 +173,7 @@ def plot_costs():
|
|||||||
handles.reverse()
|
handles.reverse()
|
||||||
labels.reverse()
|
labels.reverse()
|
||||||
|
|
||||||
ax.set_ylim([0, snakemake.config["plotting"]["costs_max"]])
|
ax.set_ylim([0, snakemake.params["plotting"]["costs_max"]])
|
||||||
|
|
||||||
ax.set_ylabel("System Cost [EUR billion per year]")
|
ax.set_ylabel("System Cost [EUR billion per year]")
|
||||||
|
|
||||||
@ -201,11 +201,11 @@ def plot_energy():
|
|||||||
df = df.groupby(df.index.map(rename_techs)).sum()
|
df = df.groupby(df.index.map(rename_techs)).sum()
|
||||||
|
|
||||||
to_drop = df.index[
|
to_drop = df.index[
|
||||||
df.abs().max(axis=1) < snakemake.config["plotting"]["energy_threshold"]
|
df.abs().max(axis=1) < snakemake.params["plotting"]["energy_threshold"]
|
||||||
]
|
]
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
f"Dropping all technology with energy consumption or production below {snakemake.config['plotting']['energy_threshold']} TWh/a"
|
f"Dropping all technology with energy consumption or production below {snakemake.params['plotting']['energy_threshold']} TWh/a"
|
||||||
)
|
)
|
||||||
logger.debug(df.loc[to_drop])
|
logger.debug(df.loc[to_drop])
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ def plot_energy():
|
|||||||
kind="bar",
|
kind="bar",
|
||||||
ax=ax,
|
ax=ax,
|
||||||
stacked=True,
|
stacked=True,
|
||||||
color=[snakemake.config["plotting"]["tech_colors"][i] for i in new_index],
|
color=[snakemake.params["plotting"]["tech_colors"][i] for i in new_index],
|
||||||
)
|
)
|
||||||
|
|
||||||
handles, labels = ax.get_legend_handles_labels()
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
@ -237,8 +237,8 @@ def plot_energy():
|
|||||||
|
|
||||||
ax.set_ylim(
|
ax.set_ylim(
|
||||||
[
|
[
|
||||||
snakemake.config["plotting"]["energy_min"],
|
snakemake.params["plotting"]["energy_min"],
|
||||||
snakemake.config["plotting"]["energy_max"],
|
snakemake.params["plotting"]["energy_max"],
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ def plot_balances():
|
|||||||
df = df.groupby(df.index.map(rename_techs)).sum()
|
df = df.groupby(df.index.map(rename_techs)).sum()
|
||||||
|
|
||||||
to_drop = df.index[
|
to_drop = df.index[
|
||||||
df.abs().max(axis=1) < snakemake.config["plotting"]["energy_threshold"] / 10
|
df.abs().max(axis=1) < snakemake.params["plotting"]["energy_threshold"] / 10
|
||||||
]
|
]
|
||||||
|
|
||||||
if v[0] in co2_carriers:
|
if v[0] in co2_carriers:
|
||||||
@ -296,7 +296,7 @@ def plot_balances():
|
|||||||
units = "TWh/a"
|
units = "TWh/a"
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"Dropping technology energy balance smaller than {snakemake.config['plotting']['energy_threshold']/10} {units}"
|
f"Dropping technology energy balance smaller than {snakemake.params['plotting']['energy_threshold']/10} {units}"
|
||||||
)
|
)
|
||||||
logger.debug(df.loc[to_drop])
|
logger.debug(df.loc[to_drop])
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ def plot_balances():
|
|||||||
kind="bar",
|
kind="bar",
|
||||||
ax=ax,
|
ax=ax,
|
||||||
stacked=True,
|
stacked=True,
|
||||||
color=[snakemake.config["plotting"]["tech_colors"][i] for i in new_index],
|
color=[snakemake.params["plotting"]["tech_colors"][i] for i in new_index],
|
||||||
)
|
)
|
||||||
|
|
||||||
handles, labels = ax.get_legend_handles_labels()
|
handles, labels = ax.get_legend_handles_labels()
|
||||||
@ -455,10 +455,10 @@ def plot_carbon_budget_distribution(input_eurostat):
|
|||||||
ax1 = plt.subplot(gs1[0, 0])
|
ax1 = plt.subplot(gs1[0, 0])
|
||||||
ax1.set_ylabel("CO$_2$ emissions (Gt per year)", fontsize=22)
|
ax1.set_ylabel("CO$_2$ emissions (Gt per year)", fontsize=22)
|
||||||
ax1.set_ylim([0, 5])
|
ax1.set_ylim([0, 5])
|
||||||
ax1.set_xlim([1990, snakemake.config["scenario"]["planning_horizons"][-1] + 1])
|
ax1.set_xlim([1990, snakemake.params["scenario"]["planning_horizons"][-1] + 1])
|
||||||
|
|
||||||
path_cb = "results/" + snakemake.params.RDIR + "/csvs/"
|
path_cb = "results/" + snakemake.params.RDIR + "/csvs/"
|
||||||
countries = snakemake.config["countries"]
|
countries = snakemake.params["countries"]
|
||||||
e_1990 = co2_emissions_year(countries, input_eurostat, opts, year=1990)
|
e_1990 = co2_emissions_year(countries, input_eurostat, opts, year=1990)
|
||||||
CO2_CAP = pd.read_csv(path_cb + "carbon_budget_distribution.csv", index_col=0)
|
CO2_CAP = pd.read_csv(path_cb + "carbon_budget_distribution.csv", index_col=0)
|
||||||
|
|
||||||
@ -545,7 +545,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
snakemake = mock_snakemake("plot_summary")
|
snakemake = mock_snakemake("plot_summary")
|
||||||
|
|
||||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
logging.basicConfig(level=snakemake.params["logging"]["level"])
|
||||||
|
|
||||||
n_header = 4
|
n_header = 4
|
||||||
|
|
||||||
@ -555,7 +555,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
plot_balances()
|
plot_balances()
|
||||||
|
|
||||||
for sector_opts in snakemake.config["scenario"]["sector_opts"]:
|
for sector_opts in snakemake.params["scenario"]["sector_opts"]:
|
||||||
opts = sector_opts.split("-")
|
opts = sector_opts.split("-")
|
||||||
for o in opts:
|
for o in opts:
|
||||||
if "cb" in o:
|
if "cb" in o:
|
||||||
|
@ -253,12 +253,12 @@ if __name__ == "__main__":
|
|||||||
Nyears = n.snapshot_weightings.objective.sum() / 8760.0
|
Nyears = n.snapshot_weightings.objective.sum() / 8760.0
|
||||||
costs = load_costs(
|
costs = load_costs(
|
||||||
snakemake.input.tech_costs,
|
snakemake.input.tech_costs,
|
||||||
snakemake.config["costs"],
|
snakemake.params["costs"],
|
||||||
snakemake.config["electricity"],
|
snakemake.params["electricity"],
|
||||||
Nyears,
|
Nyears,
|
||||||
)
|
)
|
||||||
|
|
||||||
set_line_s_max_pu(n, snakemake.config["lines"]["s_max_pu"])
|
set_line_s_max_pu(n, snakemake.params["lines"]["s_max_pu"])
|
||||||
|
|
||||||
for o in opts:
|
for o in opts:
|
||||||
m = re.match(r"^\d+h$", o, re.IGNORECASE)
|
m = re.match(r"^\d+h$", o, re.IGNORECASE)
|
||||||
@ -269,7 +269,7 @@ if __name__ == "__main__":
|
|||||||
for o in opts:
|
for o in opts:
|
||||||
m = re.match(r"^\d+seg$", o, re.IGNORECASE)
|
m = re.match(r"^\d+seg$", o, re.IGNORECASE)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
solver_name = snakemake.config["solving"]["solver"]["name"]
|
solver_name = snakemake.params["solving"]["solver"]["name"]
|
||||||
n = apply_time_segmentation(n, m.group(0)[:-3], solver_name)
|
n = apply_time_segmentation(n, m.group(0)[:-3], solver_name)
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -277,11 +277,11 @@ if __name__ == "__main__":
|
|||||||
if "Co2L" in o:
|
if "Co2L" in o:
|
||||||
m = re.findall("[0-9]*\.?[0-9]+$", o)
|
m = re.findall("[0-9]*\.?[0-9]+$", o)
|
||||||
if len(m) > 0:
|
if len(m) > 0:
|
||||||
co2limit = float(m[0]) * snakemake.config["electricity"]["co2base"]
|
co2limit = float(m[0]) * snakemake.params["electricity"]["co2base"]
|
||||||
add_co2limit(n, co2limit, Nyears)
|
add_co2limit(n, co2limit, Nyears)
|
||||||
logger.info("Setting CO2 limit according to wildcard value.")
|
logger.info("Setting CO2 limit according to wildcard value.")
|
||||||
else:
|
else:
|
||||||
add_co2limit(n, snakemake.config["electricity"]["co2limit"], Nyears)
|
add_co2limit(n, snakemake.params["electricity"]["co2limit"], Nyears)
|
||||||
logger.info("Setting CO2 limit according to config value.")
|
logger.info("Setting CO2 limit according to config value.")
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ if __name__ == "__main__":
|
|||||||
add_gaslimit(n, limit, Nyears)
|
add_gaslimit(n, limit, Nyears)
|
||||||
logger.info("Setting gas usage limit according to wildcard value.")
|
logger.info("Setting gas usage limit according to wildcard value.")
|
||||||
else:
|
else:
|
||||||
add_gaslimit(n, snakemake.config["electricity"].get("gaslimit"), Nyears)
|
add_gaslimit(n, snakemake.params["electricity"].get("gaslimit"), Nyears)
|
||||||
logger.info("Setting gas usage limit according to config value.")
|
logger.info("Setting gas usage limit according to config value.")
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ if __name__ == "__main__":
|
|||||||
add_emission_prices(n, dict(co2=float(m[0])))
|
add_emission_prices(n, dict(co2=float(m[0])))
|
||||||
else:
|
else:
|
||||||
logger.info("Setting emission prices according to config value.")
|
logger.info("Setting emission prices according to config value.")
|
||||||
add_emission_prices(n, snakemake.config["costs"]["emission_prices"])
|
add_emission_prices(n, snakemake.params["costs"]["emission_prices"])
|
||||||
break
|
break
|
||||||
|
|
||||||
ll_type, factor = snakemake.wildcards.ll[0], snakemake.wildcards.ll[1:]
|
ll_type, factor = snakemake.wildcards.ll[0], snakemake.wildcards.ll[1:]
|
||||||
@ -330,8 +330,8 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
set_line_nom_max(
|
set_line_nom_max(
|
||||||
n,
|
n,
|
||||||
s_nom_max_set=snakemake.config["lines"].get("s_nom_max,", np.inf),
|
s_nom_max_set=snakemake.params["lines"].get("s_nom_max,", np.inf),
|
||||||
p_nom_max_set=snakemake.config["links"].get("p_nom_max,", np.inf),
|
p_nom_max_set=snakemake.params["links"].get("p_nom_max,", np.inf),
|
||||||
)
|
)
|
||||||
|
|
||||||
if "ATK" in opts:
|
if "ATK" in opts:
|
||||||
|
@ -200,12 +200,12 @@ def co2_emissions_year(
|
|||||||
"""
|
"""
|
||||||
Calculate CO2 emissions in one specific year (e.g. 1990 or 2018).
|
Calculate CO2 emissions in one specific year (e.g. 1990 or 2018).
|
||||||
"""
|
"""
|
||||||
emissions_scope = snakemake.config["energy"]["emissions"]
|
emissions_scope = snakemake.params["energy"]["emissions"]
|
||||||
eea_co2 = build_eea_co2(snakemake.input.co2, year, emissions_scope)
|
eea_co2 = build_eea_co2(snakemake.input.co2, year, emissions_scope)
|
||||||
|
|
||||||
# TODO: read Eurostat data from year > 2014
|
# TODO: read Eurostat data from year > 2014
|
||||||
# this only affects the estimation of CO2 emissions for BA, RS, AL, ME, MK
|
# this only affects the estimation of CO2 emissions for BA, RS, AL, ME, MK
|
||||||
report_year = snakemake.config["energy"]["eurostat_report_year"]
|
report_year = snakemake.params["energy"]["eurostat_report_year"]
|
||||||
if year > 2014:
|
if year > 2014:
|
||||||
eurostat_co2 = build_eurostat_co2(
|
eurostat_co2 = build_eurostat_co2(
|
||||||
input_eurostat, countries, report_year, year=2014
|
input_eurostat, countries, report_year, year=2014
|
||||||
@ -241,7 +241,7 @@ def build_carbon_budget(o, input_eurostat, fn, emissions_scope, report_year):
|
|||||||
carbon_budget = float(o[o.find("cb") + 2 : o.find("ex")])
|
carbon_budget = float(o[o.find("cb") + 2 : o.find("ex")])
|
||||||
r = float(o[o.find("ex") + 2 :])
|
r = float(o[o.find("ex") + 2 :])
|
||||||
|
|
||||||
countries = snakemake.config["countries"]
|
countries = snakemake.params["countries"]
|
||||||
|
|
||||||
e_1990 = co2_emissions_year(
|
e_1990 = co2_emissions_year(
|
||||||
countries, input_eurostat, opts, emissions_scope, report_year, year=1990
|
countries, input_eurostat, opts, emissions_scope, report_year, year=1990
|
||||||
@ -252,7 +252,7 @@ def build_carbon_budget(o, input_eurostat, fn, emissions_scope, report_year):
|
|||||||
countries, input_eurostat, opts, emissions_scope, report_year, year=2018
|
countries, input_eurostat, opts, emissions_scope, report_year, year=2018
|
||||||
)
|
)
|
||||||
|
|
||||||
planning_horizons = snakemake.config["scenario"]["planning_horizons"]
|
planning_horizons = snakemake.params["scenario"]["planning_horizons"]
|
||||||
t_0 = planning_horizons[0]
|
t_0 = planning_horizons[0]
|
||||||
|
|
||||||
if "be" in o:
|
if "be" in o:
|
||||||
@ -391,7 +391,7 @@ def update_wind_solar_costs(n, costs):
|
|||||||
with xr.open_dataset(profile) as ds:
|
with xr.open_dataset(profile) as ds:
|
||||||
underwater_fraction = ds["underwater_fraction"].to_pandas()
|
underwater_fraction = ds["underwater_fraction"].to_pandas()
|
||||||
connection_cost = (
|
connection_cost = (
|
||||||
snakemake.config["lines"]["length_factor"]
|
snakemake.params["lines"]["length_factor"]
|
||||||
* ds["average_distance"].to_pandas()
|
* ds["average_distance"].to_pandas()
|
||||||
* (
|
* (
|
||||||
underwater_fraction
|
underwater_fraction
|
||||||
@ -483,8 +483,8 @@ def remove_elec_base_techs(n):
|
|||||||
batteries and H2) from base electricity-only network, since they're added
|
batteries and H2) from base electricity-only network, since they're added
|
||||||
here differently using links.
|
here differently using links.
|
||||||
"""
|
"""
|
||||||
for c in n.iterate_components(snakemake.config["pypsa_eur"]):
|
for c in n.iterate_components(snakemake.params["pypsa_eur"]):
|
||||||
to_keep = snakemake.config["pypsa_eur"][c.name]
|
to_keep = snakemake.params["pypsa_eur"][c.name]
|
||||||
to_remove = pd.Index(c.df.carrier.unique()).symmetric_difference(to_keep)
|
to_remove = pd.Index(c.df.carrier.unique()).symmetric_difference(to_keep)
|
||||||
if to_remove.empty:
|
if to_remove.empty:
|
||||||
continue
|
continue
|
||||||
@ -674,7 +674,7 @@ def add_dac(n, costs):
|
|||||||
def add_co2limit(n, nyears=1.0, limit=0.0):
|
def add_co2limit(n, nyears=1.0, limit=0.0):
|
||||||
logger.info(f"Adding CO2 budget limit as per unit of 1990 levels of {limit}")
|
logger.info(f"Adding CO2 budget limit as per unit of 1990 levels of {limit}")
|
||||||
|
|
||||||
countries = snakemake.config["countries"]
|
countries = snakemake.params["countries"]
|
||||||
|
|
||||||
sectors = emission_sectors_from_opts(opts)
|
sectors = emission_sectors_from_opts(opts)
|
||||||
|
|
||||||
@ -787,7 +787,7 @@ def add_ammonia(n, costs):
|
|||||||
|
|
||||||
nodes = pop_layout.index
|
nodes = pop_layout.index
|
||||||
|
|
||||||
cf_industry = snakemake.config["industry"]
|
cf_industry = snakemake.params["industry"]
|
||||||
|
|
||||||
n.add("Carrier", "NH3")
|
n.add("Carrier", "NH3")
|
||||||
|
|
||||||
@ -1102,7 +1102,7 @@ def add_storage_and_grids(n, costs):
|
|||||||
lifetime=costs.at["OCGT", "lifetime"],
|
lifetime=costs.at["OCGT", "lifetime"],
|
||||||
)
|
)
|
||||||
|
|
||||||
cavern_types = snakemake.config["sector"]["hydrogen_underground_storage_locations"]
|
cavern_types = snakemake.params["sector"]["hydrogen_underground_storage_locations"]
|
||||||
h2_caverns = pd.read_csv(snakemake.input.h2_cavern, index_col=0)
|
h2_caverns = pd.read_csv(snakemake.input.h2_cavern, index_col=0)
|
||||||
|
|
||||||
if not h2_caverns.empty and options["hydrogen_underground_storage"]:
|
if not h2_caverns.empty and options["hydrogen_underground_storage"]:
|
||||||
@ -3266,11 +3266,11 @@ if __name__ == "__main__":
|
|||||||
planning_horizons="2030",
|
planning_horizons="2030",
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
logging.basicConfig(level=snakemake.params["logging"]["level"])
|
||||||
|
|
||||||
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
||||||
|
|
||||||
options = snakemake.config["sector"]
|
options = snakemake.params["sector"]
|
||||||
|
|
||||||
opts = snakemake.wildcards.sector_opts.split("-")
|
opts = snakemake.wildcards.sector_opts.split("-")
|
||||||
|
|
||||||
@ -3285,7 +3285,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
costs = prepare_costs(
|
costs = prepare_costs(
|
||||||
snakemake.input.costs,
|
snakemake.input.costs,
|
||||||
snakemake.config["costs"],
|
snakemake.params["costs"],
|
||||||
nyears,
|
nyears,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -3297,10 +3297,10 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
spatial = define_spatial(pop_layout.index, options)
|
spatial = define_spatial(pop_layout.index, options)
|
||||||
|
|
||||||
if snakemake.config["foresight"] == "myopic":
|
if snakemake.params["foresight"] == "myopic":
|
||||||
add_lifetime_wind_solar(n, costs)
|
add_lifetime_wind_solar(n, costs)
|
||||||
|
|
||||||
conventional = snakemake.config["existing_capacities"]["conventional_carriers"]
|
conventional = snakemake.params["existing_capacities"]["conventional_carriers"]
|
||||||
for carrier in conventional:
|
for carrier in conventional:
|
||||||
add_carrier_buses(n, carrier)
|
add_carrier_buses(n, carrier)
|
||||||
|
|
||||||
@ -3365,19 +3365,19 @@ if __name__ == "__main__":
|
|||||||
if options["allam_cycle"]:
|
if options["allam_cycle"]:
|
||||||
add_allam(n, costs)
|
add_allam(n, costs)
|
||||||
|
|
||||||
solver_name = snakemake.config["solving"]["solver"]["name"]
|
solver_name = snakemake.params["solving"]["solver"]["name"]
|
||||||
n = set_temporal_aggregation(n, opts, solver_name)
|
n = set_temporal_aggregation(n, opts, solver_name)
|
||||||
|
|
||||||
limit_type = "config"
|
limit_type = "config"
|
||||||
limit = get(snakemake.config["co2_budget"], investment_year)
|
limit = get(snakemake.params["co2_budget"], investment_year)
|
||||||
for o in opts:
|
for o in opts:
|
||||||
if "cb" not in o:
|
if "cb" not in o:
|
||||||
continue
|
continue
|
||||||
limit_type = "carbon budget"
|
limit_type = "carbon budget"
|
||||||
fn = "results/" + snakemake.params.RDIR + "/csvs/carbon_budget_distribution.csv"
|
fn = "results/" + snakemake.params.RDIR + "/csvs/carbon_budget_distribution.csv"
|
||||||
if not os.path.exists(fn):
|
if not os.path.exists(fn):
|
||||||
emissions_scope = snakemake.config["energy"]["emissions"]
|
emissions_scope = snakemake.params["energy"]["emissions"]
|
||||||
report_year = snakemake.config["energy"]["eurostat_report_year"]
|
report_year = snakemake.params["energy"]["eurostat_report_year"]
|
||||||
build_carbon_budget(
|
build_carbon_budget(
|
||||||
o, snakemake.input.eurostat, fn, emissions_scope, report_year
|
o, snakemake.input.eurostat, fn, emissions_scope, report_year
|
||||||
)
|
)
|
||||||
@ -3412,8 +3412,8 @@ if __name__ == "__main__":
|
|||||||
if options["electricity_grid_connection"]:
|
if options["electricity_grid_connection"]:
|
||||||
add_electricity_grid_connection(n, costs)
|
add_electricity_grid_connection(n, costs)
|
||||||
|
|
||||||
first_year_myopic = (snakemake.config["foresight"] == "myopic") and (
|
first_year_myopic = (snakemake.params["foresight"] == "myopic") and (
|
||||||
snakemake.config["scenario"]["planning_horizons"][0] == investment_year
|
snakemake.params["scenario"]["planning_horizons"][0] == investment_year
|
||||||
)
|
)
|
||||||
|
|
||||||
if options.get("cluster_heat_buses", False) and not first_year_myopic:
|
if options.get("cluster_heat_buses", False) and not first_year_myopic:
|
||||||
|
@ -53,7 +53,7 @@ if __name__ == "__main__":
|
|||||||
snakemake
|
snakemake
|
||||||
) # TODO Make logging compatible with progressbar (see PR #102)
|
) # TODO Make logging compatible with progressbar (see PR #102)
|
||||||
|
|
||||||
if snakemake.config["tutorial"]:
|
if snakemake.params["tutorial"]:
|
||||||
url = "https://zenodo.org/record/3517921/files/pypsa-eur-tutorial-data-bundle.tar.xz"
|
url = "https://zenodo.org/record/3517921/files/pypsa-eur-tutorial-data-bundle.tar.xz"
|
||||||
else:
|
else:
|
||||||
url = "https://zenodo.org/record/3517935/files/pypsa-eur-data-bundle.tar.xz"
|
url = "https://zenodo.org/record/3517935/files/pypsa-eur-data-bundle.tar.xz"
|
||||||
@ -63,7 +63,7 @@ if __name__ == "__main__":
|
|||||||
to_fn = Path(f"{rootpath}/data")
|
to_fn = Path(f"{rootpath}/data")
|
||||||
|
|
||||||
logger.info(f"Downloading databundle from '{url}'.")
|
logger.info(f"Downloading databundle from '{url}'.")
|
||||||
disable_progress = snakemake.config["run"].get("disable_progressbar", False)
|
disable_progress = snakemake.params["run"].get("disable_progressbar", False)
|
||||||
progress_retrieve(url, tarball_fn, disable=disable_progress)
|
progress_retrieve(url, tarball_fn, disable=disable_progress)
|
||||||
|
|
||||||
logger.info("Extracting databundle.")
|
logger.info("Extracting databundle.")
|
||||||
|
@ -510,7 +510,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
n = pypsa.Network(snakemake.input.network)
|
n = pypsa.Network(snakemake.input.network)
|
||||||
|
|
||||||
aggregation_strategies = snakemake.config["clustering"].get(
|
aggregation_strategies = snakemake.params["clustering"].get(
|
||||||
"aggregation_strategies", {}
|
"aggregation_strategies", {}
|
||||||
)
|
)
|
||||||
# translate str entries of aggregation_strategies to pd.Series functions:
|
# translate str entries of aggregation_strategies to pd.Series functions:
|
||||||
@ -525,8 +525,8 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
technology_costs = load_costs(
|
technology_costs = load_costs(
|
||||||
snakemake.input.tech_costs,
|
snakemake.input.tech_costs,
|
||||||
snakemake.config["costs"],
|
snakemake.params["costs"],
|
||||||
snakemake.config["electricity"],
|
snakemake.params["electricity"],
|
||||||
Nyears,
|
Nyears,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -536,7 +536,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
busmaps = [trafo_map, simplify_links_map]
|
busmaps = [trafo_map, simplify_links_map]
|
||||||
|
|
||||||
cluster_config = snakemake.config["clustering"]["simplify_network"]
|
cluster_config = snakemake.params["clustering"]["simplify_network"]
|
||||||
if cluster_config.get("remove_stubs", True):
|
if cluster_config.get("remove_stubs", True):
|
||||||
n, stub_map = remove_stubs(
|
n, stub_map = remove_stubs(
|
||||||
n,
|
n,
|
||||||
|
@ -663,7 +663,7 @@ if __name__ == "__main__":
|
|||||||
if "sector_opts" in snakemake.wildcards.keys():
|
if "sector_opts" in snakemake.wildcards.keys():
|
||||||
opts += "-" + snakemake.wildcards.sector_opts
|
opts += "-" + snakemake.wildcards.sector_opts
|
||||||
opts = [o for o in opts.split("-") if o != ""]
|
opts = [o for o in opts.split("-") if o != ""]
|
||||||
solve_opts = snakemake.config["solving"]["options"]
|
solve_opts = snakemake.params["solving"]["options"]
|
||||||
|
|
||||||
np.random.seed(solve_opts.get("seed", 123))
|
np.random.seed(solve_opts.get("seed", 123))
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
opts = (snakemake.wildcards.opts + "-" + snakemake.wildcards.sector_opts).split("-")
|
opts = (snakemake.wildcards.opts + "-" + snakemake.wildcards.sector_opts).split("-")
|
||||||
opts = [o for o in opts if o != ""]
|
opts = [o for o in opts if o != ""]
|
||||||
solve_opts = snakemake.config["solving"]["options"]
|
solve_opts = snakemake.params["solving"]["options"]
|
||||||
|
|
||||||
np.random.seed(solve_opts.get("seed", 123))
|
np.random.seed(solve_opts.get("seed", 123))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user