review params implementation; reproduce objective values in CI
This commit is contained in:
parent
45cac01ea3
commit
1d10073514
@ -31,6 +31,14 @@ snapshots:
|
||||
end: "2013-03-08"
|
||||
|
||||
electricity:
|
||||
co2limit: 100.e+6
|
||||
|
||||
extendable_carriers:
|
||||
Generator: [OCGT]
|
||||
StorageUnit: [battery]
|
||||
Store: [H2]
|
||||
Link: [H2 pipeline]
|
||||
|
||||
renewable_carriers: [solar, onwind, offwind-ac, offwind-dc]
|
||||
|
||||
atlite:
|
||||
|
@ -28,6 +28,14 @@ snapshots:
|
||||
end: "2013-03-08"
|
||||
|
||||
electricity:
|
||||
co2limit: 100.e+6
|
||||
|
||||
extendable_carriers:
|
||||
Generator: [OCGT]
|
||||
StorageUnit: [battery]
|
||||
Store: [H2]
|
||||
Link: [H2 pipeline]
|
||||
|
||||
renewable_carriers: [solar, onwind, offwind-ac, offwind-dc]
|
||||
|
||||
atlite:
|
||||
|
@ -394,7 +394,7 @@ rule cluster_network:
|
||||
rule add_extra_components:
|
||||
params:
|
||||
costs=config["costs"],
|
||||
ext_carriers=config["electricity"]["extendable_carriers"],
|
||||
extendable_carriers=config["electricity"]["extendable_carriers"],
|
||||
max_hours=config["electricity"]["max_hours"],
|
||||
input:
|
||||
network=RESOURCES + "networks/elec_s{simpl}_{clusters}.nc",
|
||||
|
@ -406,7 +406,7 @@ rule build_ammonia_production:
|
||||
rule build_industry_sector_ratios:
|
||||
params:
|
||||
industry=config["industry"],
|
||||
sector_amonia=config["sector"].get("ammonia", False),
|
||||
ammonia=config["sector"].get("ammonia", False),
|
||||
input:
|
||||
ammonia_production=RESOURCES + "ammonia_production.csv",
|
||||
idees="data/jrc-idees-2015",
|
||||
|
@ -49,7 +49,7 @@ def add_brownfield(n, n_p, year):
|
||||
)
|
||||
]
|
||||
|
||||
threshold = snakemake.params["threshold_capacity"]
|
||||
threshold = snakemake.params.threshold_capacity
|
||||
|
||||
if not chp_heat.empty:
|
||||
threshold_chp_heat = (
|
||||
@ -87,7 +87,7 @@ def add_brownfield(n, n_p, year):
|
||||
|
||||
# deal with gas network
|
||||
pipe_carrier = ["gas pipeline"]
|
||||
if snakemake.params["H2_retrofit"]:
|
||||
if snakemake.params.H2_retrofit:
|
||||
# drop capacities of previous year to avoid duplicating
|
||||
to_drop = n.links.carrier.isin(pipe_carrier) & (n.links.build_year != year)
|
||||
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)
|
||||
].index
|
||||
gas_pipes_i = n.links[n.links.carrier.isin(pipe_carrier)].index
|
||||
CH4_per_H2 = 1 / snakemake.params["H2_retrofit_capacity_per_CH4"]
|
||||
CH4_per_H2 = 1 / snakemake.params.H2_retrofit_capacity_per_CH4
|
||||
fr = "H2 pipeline retrofitted"
|
||||
to = "gas pipeline"
|
||||
# today's pipe capacity
|
||||
|
@ -652,13 +652,7 @@ def attach_OPSD_renewables(n, tech_map):
|
||||
n.generators.p_nom_min.update(gens.bus.map(caps).dropna())
|
||||
|
||||
|
||||
def estimate_renewable_capacities(n, electricity_params, countries):
|
||||
year = electricity_params["estimate_renewable_capacities"]["year"]
|
||||
tech_map = electricity_params["estimate_renewable_capacities"]["technology_mapping"]
|
||||
expansion_limit = electricity_params["estimate_renewable_capacities"][
|
||||
"expansion_limit"
|
||||
]
|
||||
|
||||
def estimate_renewable_capacities(n, year, tech_map, expansion_limit, countries):
|
||||
if not len(countries) or not len(tech_map):
|
||||
return
|
||||
|
||||
@ -721,48 +715,42 @@ if __name__ == "__main__":
|
||||
snakemake = mock_snakemake("add_electricity")
|
||||
configure_logging(snakemake)
|
||||
|
||||
params = snakemake.params
|
||||
|
||||
n = pypsa.Network(snakemake.input.base_network)
|
||||
Nyears = n.snapshot_weightings.objective.sum() / 8760.0
|
||||
|
||||
costs = load_costs(
|
||||
snakemake.input.tech_costs,
|
||||
snakemake.params.costs,
|
||||
snakemake.params.electricity["max_hours"],
|
||||
params.costs,
|
||||
params.electricity["max_hours"],
|
||||
Nyears,
|
||||
)
|
||||
ppl = load_powerplants(snakemake.input.powerplants)
|
||||
|
||||
if "renewable_carriers" in snakemake.params.electricity:
|
||||
renewable_carriers = set(snakemake.params.electricity["renewable_carriers"])
|
||||
if "renewable_carriers" in params.electricity:
|
||||
renewable_carriers = set(params.electricity["renewable_carriers"])
|
||||
else:
|
||||
logger.warning(
|
||||
"Missing key `renewable_carriers` under config entry `electricity`. "
|
||||
"In future versions, this will raise an error. "
|
||||
"Falling back to carriers listed under `renewable`."
|
||||
)
|
||||
renewable_carriers = snakemake.params.renewable
|
||||
|
||||
extendable_carriers = snakemake.params.electricity["extendable_carriers"]
|
||||
if not (set(renewable_carriers) & set(extendable_carriers["Generator"])):
|
||||
logger.warning(
|
||||
"No renewables found in config entry `extendable_carriers`. "
|
||||
"In future versions, these have to be explicitly listed. "
|
||||
"Falling back to all renewables."
|
||||
)
|
||||
|
||||
conventional_carriers = snakemake.params.electricity["conventional_carriers"]
|
||||
renewable_carriers = params.renewable
|
||||
|
||||
attach_load(
|
||||
n,
|
||||
snakemake.input.regions,
|
||||
snakemake.input.load,
|
||||
snakemake.input.nuts3_shapes,
|
||||
snakemake.params.countries,
|
||||
snakemake.params.scaling_factor,
|
||||
params.countries,
|
||||
params.scaling_factor,
|
||||
)
|
||||
|
||||
update_transmission_costs(n, costs, snakemake.params.length_factor)
|
||||
update_transmission_costs(n, costs, params.length_factor)
|
||||
|
||||
extendable_carriers = params.electricity["extendable_carriers"]
|
||||
conventional_carriers = params.electricity["conventional_carriers"]
|
||||
conventional_inputs = {
|
||||
k: v for k, v in snakemake.input.items() if k.startswith("conventional_")
|
||||
}
|
||||
@ -772,7 +760,7 @@ if __name__ == "__main__":
|
||||
ppl,
|
||||
conventional_carriers,
|
||||
extendable_carriers,
|
||||
snakemake.params.conventional,
|
||||
params.conventional,
|
||||
conventional_inputs,
|
||||
)
|
||||
|
||||
@ -782,11 +770,11 @@ if __name__ == "__main__":
|
||||
snakemake.input,
|
||||
renewable_carriers,
|
||||
extendable_carriers,
|
||||
snakemake.params.length_factor,
|
||||
params.length_factor,
|
||||
)
|
||||
|
||||
if "hydro" in renewable_carriers:
|
||||
para = snakemake.params.renewable["hydro"]
|
||||
para = params.renewable["hydro"]
|
||||
attach_hydro(
|
||||
n,
|
||||
costs,
|
||||
@ -797,53 +785,16 @@ if __name__ == "__main__":
|
||||
**para,
|
||||
)
|
||||
|
||||
if "estimate_renewable_capacities" not in snakemake.params.electricity:
|
||||
logger.warning(
|
||||
"Missing key `estimate_renewable_capacities` under config entry `electricity`. "
|
||||
"In future versions, this will raise an error. "
|
||||
"Falling back to whether ``estimate_renewable_capacities_from_capacity_stats`` is in the config."
|
||||
)
|
||||
if (
|
||||
"estimate_renewable_capacities_from_capacity_stats"
|
||||
in snakemake.params.electricity
|
||||
):
|
||||
estimate_renewable_caps = {
|
||||
"enable": True,
|
||||
**snakemake.params.electricity[
|
||||
"estimate_renewable_capacities_from_capacity_stats"
|
||||
],
|
||||
}
|
||||
else:
|
||||
estimate_renewable_caps = {"enable": False}
|
||||
else:
|
||||
estimate_renewable_caps = snakemake.params.electricity[
|
||||
"estimate_renewable_capacities"
|
||||
]
|
||||
if "enable" not in estimate_renewable_caps:
|
||||
logger.warning(
|
||||
"Missing key `enable` under config entry `estimate_renewable_capacities`. "
|
||||
"In future versions, this will raise an error. Falling back to False."
|
||||
)
|
||||
estimate_renewable_caps = {"enable": False}
|
||||
if "from_opsd" not in estimate_renewable_caps:
|
||||
logger.warning(
|
||||
"Missing key `from_opsd` under config entry `estimate_renewable_capacities`. "
|
||||
"In future versions, this will raise an error. "
|
||||
"Falling back to whether `renewable_capacities_from_opsd` is non-empty."
|
||||
)
|
||||
from_opsd = bool(
|
||||
snakemake.params.electricity.get("renewable_capacities_from_opsd", False)
|
||||
)
|
||||
estimate_renewable_caps["from_opsd"] = from_opsd
|
||||
|
||||
estimate_renewable_caps = params.electricity["estimate_renewable_capacities"]
|
||||
if estimate_renewable_caps["enable"]:
|
||||
tech_map = estimate_renewable_caps["technology_mapping"]
|
||||
expansion_limit = estimate_renewable_caps["expansion_limit"]
|
||||
year = estimate_renewable_caps["year"]
|
||||
|
||||
if estimate_renewable_caps["from_opsd"]:
|
||||
tech_map = snakemake.params.electricity["estimate_renewable_capacities"][
|
||||
"technology_mapping"
|
||||
]
|
||||
attach_OPSD_renewables(n, tech_map)
|
||||
estimate_renewable_capacities(
|
||||
n, snakemake.params.electricity, snakemake.params.countries
|
||||
n, year, tech_map, expansion_limit, params.countries
|
||||
)
|
||||
|
||||
update_p_nom_max(n)
|
||||
|
@ -157,7 +157,7 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
|
||||
# Fill missing DateOut
|
||||
dateout = (
|
||||
df_agg.loc[biomass_i, "DateIn"]
|
||||
+ snakemake.params["costs"]["fill_values"]["lifetime"]
|
||||
+ snakemake.params.costs["fill_values"]["lifetime"]
|
||||
)
|
||||
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 = capacity[~capacity.isna()]
|
||||
capacity = capacity[
|
||||
capacity > snakemake.params["existing_capacities"]["threshold_capacity"]
|
||||
capacity > snakemake.params.existing_capacities["threshold_capacity"]
|
||||
]
|
||||
suffix = "-ac" if generator == "offwind" else ""
|
||||
name_suffix = f" {generator}{suffix}-{grouping_year}"
|
||||
@ -582,7 +582,7 @@ def add_heating_capacities_installed_before_baseyear(
|
||||
)
|
||||
|
||||
# delete links with capacities below threshold
|
||||
threshold = snakemake.params["existing_capacities"]["threshold_capacity"]
|
||||
threshold = snakemake.params.existing_capacities["threshold_capacity"]
|
||||
n.mremove(
|
||||
"Link",
|
||||
[
|
||||
@ -612,10 +612,10 @@ if __name__ == "__main__":
|
||||
|
||||
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
||||
|
||||
options = snakemake.params["sector"]
|
||||
options = snakemake.params.sector
|
||||
opts = snakemake.wildcards.sector_opts.split("-")
|
||||
|
||||
baseyear = snakemake.params["baseyear"]
|
||||
baseyear = snakemake.params.baseyear
|
||||
|
||||
overrides = override_component_attrs(snakemake.input.overrides)
|
||||
n = pypsa.Network(snakemake.input.network, override_component_attrs=overrides)
|
||||
@ -626,14 +626,12 @@ if __name__ == "__main__":
|
||||
Nyears = n.snapshot_weightings.generators.sum() / 8760.0
|
||||
costs = prepare_costs(
|
||||
snakemake.input.costs,
|
||||
snakemake.params["costs"],
|
||||
snakemake.params.costs,
|
||||
Nyears,
|
||||
)
|
||||
|
||||
grouping_years_power = snakemake.params["existing_capacities"][
|
||||
"grouping_years_power"
|
||||
]
|
||||
grouping_years_heat = snakemake.params["existing_capacities"]["grouping_years_heat"]
|
||||
grouping_years_power = snakemake.params.existing_capacities["grouping_years_power"]
|
||||
grouping_years_heat = snakemake.params.existing_capacities["grouping_years_heat"]
|
||||
add_power_capacities_installed_before_baseyear(
|
||||
n, grouping_years_power, costs, baseyear
|
||||
)
|
||||
@ -650,7 +648,7 @@ if __name__ == "__main__":
|
||||
.to_pandas()
|
||||
.reindex(index=n.snapshots)
|
||||
)
|
||||
default_lifetime = snakemake.params["costs"]["fill_values"]["lifetime"]
|
||||
default_lifetime = snakemake.params.costs["fill_values"]["lifetime"]
|
||||
add_heating_capacities_installed_before_baseyear(
|
||||
n,
|
||||
baseyear,
|
||||
|
@ -67,8 +67,8 @@ idx = pd.IndexSlice
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def attach_storageunits(n, costs, ext_carriers, max_hours):
|
||||
carriers = ext_carriers["StorageUnit"]
|
||||
def attach_storageunits(n, costs, extendable_carriers, max_hours):
|
||||
carriers = extendable_carriers["StorageUnit"]
|
||||
|
||||
_add_missing_carriers_from_costs(n, costs, carriers)
|
||||
|
||||
@ -98,8 +98,8 @@ def attach_storageunits(n, costs, ext_carriers, max_hours):
|
||||
)
|
||||
|
||||
|
||||
def attach_stores(n, costs, ext_carriers):
|
||||
carriers = ext_carriers["Store"]
|
||||
def attach_stores(n, costs, extendable_carriers):
|
||||
carriers = extendable_carriers["Store"]
|
||||
|
||||
_add_missing_carriers_from_costs(n, costs, carriers)
|
||||
|
||||
@ -186,10 +186,10 @@ def attach_stores(n, costs, ext_carriers):
|
||||
)
|
||||
|
||||
|
||||
def attach_hydrogen_pipelines(n, costs, ext_carriers):
|
||||
as_stores = ext_carriers.get("Store", [])
|
||||
def attach_hydrogen_pipelines(n, costs, extendable_carriers):
|
||||
as_stores = extendable_carriers.get("Store", [])
|
||||
|
||||
if "H2 pipeline" not in ext_carriers.get("Link", []):
|
||||
if "H2 pipeline" not in extendable_carriers.get("Link", []):
|
||||
return
|
||||
|
||||
assert "H2" in as_stores, (
|
||||
@ -233,17 +233,17 @@ if __name__ == "__main__":
|
||||
configure_logging(snakemake)
|
||||
|
||||
n = pypsa.Network(snakemake.input.network)
|
||||
ext_carriers = snakemake.params["ext_carriers"]
|
||||
max_hours = snakemake.params["max_hours"]
|
||||
extendable_carriers = snakemake.params.extendable_carriers
|
||||
max_hours = snakemake.params.max_hours
|
||||
|
||||
Nyears = n.snapshot_weightings.objective.sum() / 8760.0
|
||||
costs = load_costs(
|
||||
snakemake.input.tech_costs, snakemake.params["costs"], max_hours, Nyears
|
||||
snakemake.input.tech_costs, snakemake.params.costs, max_hours, Nyears
|
||||
)
|
||||
|
||||
attach_storageunits(n, costs, ext_carriers, max_hours)
|
||||
attach_stores(n, costs, ext_carriers)
|
||||
attach_hydrogen_pipelines(n, costs, ext_carriers)
|
||||
attach_storageunits(n, costs, extendable_carriers, max_hours)
|
||||
attach_stores(n, costs, extendable_carriers)
|
||||
attach_hydrogen_pipelines(n, costs, extendable_carriers)
|
||||
|
||||
add_nice_carrier_names(n, snakemake.config)
|
||||
|
||||
|
@ -30,7 +30,7 @@ if __name__ == "__main__":
|
||||
ammonia.index = cc.convert(ammonia.index, to="iso2")
|
||||
|
||||
years = [str(i) for i in range(2013, 2018)]
|
||||
countries = ammonia.index.intersection(snakemake.params["countries"])
|
||||
countries = ammonia.index.intersection(snakemake.params.countries)
|
||||
ammonia = ammonia.loc[countries, years].astype(float)
|
||||
|
||||
# convert from ktonN to ktonNH3
|
||||
|
@ -210,7 +210,7 @@ if __name__ == "__main__":
|
||||
|
||||
snakemake = mock_snakemake("build_biomass_potentials", simpl="", clusters="5")
|
||||
|
||||
params = snakemake.params["biomass"]
|
||||
params = snakemake.params.biomass
|
||||
year = params["year"]
|
||||
scenario = params["scenario"]
|
||||
|
||||
|
@ -116,7 +116,7 @@ if __name__ == "__main__":
|
||||
snakemake = mock_snakemake("build_bus_regions")
|
||||
configure_logging(snakemake)
|
||||
|
||||
countries = snakemake.params["countries"]
|
||||
countries = snakemake.params.countries
|
||||
|
||||
n = pypsa.Network(snakemake.input.base_network)
|
||||
|
||||
|
@ -39,7 +39,7 @@ if __name__ == "__main__":
|
||||
for source in ["air", "soil"]:
|
||||
source_T = xr.open_dataarray(snakemake.input[f"temp_{source}_{area}"])
|
||||
|
||||
delta_T = snakemake.params["heat_pump_sink_T"] - source_T
|
||||
delta_T = snakemake.params.heat_pump_sink_T - source_T
|
||||
|
||||
cop = coefficient_of_performance(delta_T, source)
|
||||
|
||||
|
@ -106,9 +106,9 @@ if __name__ == "__main__":
|
||||
snakemake = mock_snakemake("build_cutout", cutout="europe-2013-era5")
|
||||
configure_logging(snakemake)
|
||||
|
||||
cutout_params = snakemake.params["cutouts"][snakemake.wildcards.cutout]
|
||||
cutout_params = snakemake.params.cutouts[snakemake.wildcards.cutout]
|
||||
|
||||
snapshots = pd.date_range(freq="h", **snakemake.params["snapshots"])
|
||||
snapshots = pd.date_range(freq="h", **snakemake.params.snapshots)
|
||||
time = [snapshots[0], snapshots[-1]]
|
||||
cutout_params["time"] = slice(*cutout_params.get("time", time))
|
||||
|
||||
|
@ -279,16 +279,16 @@ if __name__ == "__main__":
|
||||
|
||||
configure_logging(snakemake)
|
||||
|
||||
powerstatistics = snakemake.params["load"]["power_statistics"]
|
||||
interpolate_limit = snakemake.params["load"]["interpolate_limit"]
|
||||
countries = snakemake.params["countries"]
|
||||
snapshots = pd.date_range(freq="h", **snakemake.params["snapshots"])
|
||||
powerstatistics = snakemake.params.load["power_statistics"]
|
||||
interpolate_limit = snakemake.params.load["interpolate_limit"]
|
||||
countries = snakemake.params.countries
|
||||
snapshots = pd.date_range(freq="h", **snakemake.params.snapshots)
|
||||
years = slice(snapshots[0], snapshots[-1])
|
||||
time_shift = snakemake.params["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)
|
||||
|
||||
if snakemake.params["load"]["manual_adjustments"]:
|
||||
if snakemake.params.load["manual_adjustments"]:
|
||||
load = manual_adjustment(load, snakemake.input[0], powerstatistics)
|
||||
|
||||
logger.info(f"Linearly interpolate gaps of size {interpolate_limit} and less.")
|
||||
|
@ -737,16 +737,16 @@ if __name__ == "__main__":
|
||||
|
||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
||||
|
||||
params = snakemake.params["energy"]
|
||||
params = snakemake.params.energy
|
||||
|
||||
nuts3 = gpd.read_file(snakemake.input.nuts3_shapes).set_index("index")
|
||||
population = nuts3["pop"].groupby(nuts3.country).sum()
|
||||
|
||||
countries = snakemake.params["countries"]
|
||||
countries = snakemake.params.countries
|
||||
idees_countries = pd.Index(countries).intersection(eu28)
|
||||
|
||||
data_year = params["energy_totals_year"]
|
||||
report_year = snakemake.params["energy"]["eurostat_report_year"]
|
||||
report_year = snakemake.params.energy["eurostat_report_year"]
|
||||
input_eurostat = snakemake.input.eurostat
|
||||
eurostat = build_eurostat(input_eurostat, countries, report_year, data_year)
|
||||
swiss = build_swiss(data_year)
|
||||
@ -756,7 +756,7 @@ if __name__ == "__main__":
|
||||
energy.to_csv(snakemake.output.energy_name)
|
||||
|
||||
base_year_emissions = params["base_emissions_year"]
|
||||
emissions_scope = snakemake.params["energy"]["emissions"]
|
||||
emissions_scope = snakemake.params.energy["emissions"]
|
||||
eea_co2 = build_eea_co2(snakemake.input.co2, base_year_emissions, emissions_scope)
|
||||
eurostat_co2 = build_eurostat_co2(
|
||||
input_eurostat, countries, report_year, base_year_emissions
|
||||
|
@ -27,7 +27,7 @@ if __name__ == "__main__":
|
||||
cluster = LocalCluster(n_workers=nprocesses, threads_per_worker=1)
|
||||
client = Client(cluster, asynchronous=True)
|
||||
|
||||
time = pd.date_range(freq="h", **snakemake.params["snapshots"])
|
||||
time = pd.date_range(freq="h", **snakemake.params.snapshots)
|
||||
cutout = atlite.Cutout(snakemake.input.cutout).sel(time=time)
|
||||
|
||||
clustered_regions = (
|
||||
|
@ -130,10 +130,10 @@ if __name__ == "__main__":
|
||||
snakemake = mock_snakemake("build_hydro_profile")
|
||||
configure_logging(snakemake)
|
||||
|
||||
params_hydro = snakemake.params["hydro"]
|
||||
params_hydro = snakemake.params.hydro
|
||||
cutout = atlite.Cutout(snakemake.input.cutout)
|
||||
|
||||
countries = snakemake.params["countries"]
|
||||
countries = snakemake.params.countries
|
||||
country_shapes = (
|
||||
gpd.read_file(snakemake.input.country_shapes)
|
||||
.set_index("name")["geometry"]
|
||||
|
@ -73,7 +73,7 @@ def prepare_hotmaps_database(regions):
|
||||
|
||||
df[["srid", "coordinates"]] = df.geom.str.split(";", expand=True)
|
||||
|
||||
if snakemake.params["hotmaps_locate_missing"]:
|
||||
if snakemake.params.hotmaps_locate_missing:
|
||||
df = locate_missing_industrial_sites(df)
|
||||
|
||||
# remove those sites without valid locations
|
||||
@ -143,7 +143,7 @@ if __name__ == "__main__":
|
||||
|
||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
||||
|
||||
countries = snakemake.params["countries"]
|
||||
countries = snakemake.params.countries
|
||||
|
||||
regions = gpd.read_file(snakemake.input.regions_onshore).set_index("name")
|
||||
|
||||
|
@ -178,9 +178,9 @@ if __name__ == "__main__":
|
||||
|
||||
snakemake = mock_snakemake("build_industrial_energy_demand_per_country_today")
|
||||
|
||||
params = snakemake.params["industry"]
|
||||
params = snakemake.params.industry
|
||||
year = params.get("reference_year", 2015)
|
||||
countries = pd.Index(snakemake.params["countries"])
|
||||
countries = pd.Index(snakemake.params.countries)
|
||||
|
||||
demand = industrial_energy_demand(countries.intersection(eu28), year)
|
||||
|
||||
|
@ -279,11 +279,11 @@ if __name__ == "__main__":
|
||||
|
||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
||||
|
||||
countries = snakemake.params["countries"]
|
||||
countries = snakemake.params.countries
|
||||
|
||||
year = snakemake.params["industry"]["reference_year"]
|
||||
year = snakemake.params.industry["reference_year"]
|
||||
|
||||
params = snakemake.params["industry"]
|
||||
params = snakemake.params.industry
|
||||
|
||||
jrc_dir = snakemake.input.jrc
|
||||
eurostat_dir = snakemake.input.eurostat
|
||||
|
@ -15,7 +15,7 @@ if __name__ == "__main__":
|
||||
|
||||
snakemake = mock_snakemake("build_industrial_production_per_country_tomorrow")
|
||||
|
||||
params = snakemake.params["industry"]
|
||||
params = snakemake.params.industry
|
||||
|
||||
investment_year = int(snakemake.wildcards.planning_horizons)
|
||||
|
||||
|
@ -439,7 +439,7 @@ def chemicals_industry():
|
||||
|
||||
sector = "Ammonia"
|
||||
df[sector] = 0.0
|
||||
if snakemake.params["sector_amonia"]:
|
||||
if snakemake.params.ammonia:
|
||||
df.loc["ammonia", sector] = params["MWh_NH3_per_tNH3"]
|
||||
else:
|
||||
df.loc["hydrogen", sector] = params["MWh_H2_per_tNH3_electrolysis"]
|
||||
@ -1468,7 +1468,7 @@ if __name__ == "__main__":
|
||||
# TODO make params option
|
||||
year = 2015
|
||||
|
||||
params = snakemake.params["industry"]
|
||||
params = snakemake.params.industry
|
||||
|
||||
df = pd.concat(
|
||||
[
|
||||
|
@ -115,7 +115,7 @@ if __name__ == "__main__":
|
||||
configure_logging(snakemake)
|
||||
|
||||
n = pypsa.Network(snakemake.input.base_network)
|
||||
countries = snakemake.params["countries"]
|
||||
countries = snakemake.params.countries
|
||||
|
||||
ppl = (
|
||||
pm.powerplants(from_url=True)
|
||||
@ -134,12 +134,12 @@ if __name__ == "__main__":
|
||||
ppl = ppl.query('not (Country in @available_countries and Fueltype == "Bioenergy")')
|
||||
ppl = pd.concat([ppl, opsd])
|
||||
|
||||
ppl_query = snakemake.params["powerplants_filter"]
|
||||
ppl_query = snakemake.params.powerplants_filter
|
||||
if isinstance(ppl_query, str):
|
||||
ppl.query(ppl_query, inplace=True)
|
||||
|
||||
# add carriers from own powerplant files:
|
||||
custom_ppl_query = snakemake.params["custom_powerplants"]
|
||||
custom_ppl_query = snakemake.params.custom_powerplants
|
||||
ppl = add_custom_powerplants(
|
||||
ppl, snakemake.input.custom_powerplants, custom_ppl_query
|
||||
)
|
||||
|
@ -204,7 +204,7 @@ if __name__ == "__main__":
|
||||
|
||||
nprocesses = int(snakemake.threads)
|
||||
noprogress = snakemake.config["run"].get("disable_progressbar", True)
|
||||
params = snakemake.params["renewable"][snakemake.wildcards.technology]
|
||||
params = snakemake.params.renewable[snakemake.wildcards.technology]
|
||||
resource = params["resource"] # pv panel params / wind turbine params
|
||||
correction_factor = params.get("correction_factor", 1.0)
|
||||
capacity_per_sqkm = params["capacity_per_sqkm"]
|
||||
|
@ -305,7 +305,7 @@ def prepare_building_stock_data():
|
||||
u_values.set_index(["country_code", "subsector", "bage", "type"], inplace=True)
|
||||
|
||||
# only take in config.yaml specified countries into account
|
||||
countries = snakemake.params["countries"]
|
||||
countries = snakemake.params.countries
|
||||
area_tot = area_tot.loc[countries]
|
||||
|
||||
return u_values, country_iso_dic, countries, area_tot, area
|
||||
@ -1040,7 +1040,7 @@ if __name__ == "__main__":
|
||||
|
||||
# ******** config *********************************************************
|
||||
|
||||
retro_opts = snakemake.params["retrofitting"]
|
||||
retro_opts = snakemake.params.retrofitting
|
||||
interest_rate = retro_opts["interest_rate"]
|
||||
annualise_cost = retro_opts["annualise_cost"] # annualise the investment costs
|
||||
tax_weighting = retro_opts[
|
||||
|
@ -41,7 +41,7 @@ if __name__ == "__main__":
|
||||
"build_sequestration_potentials", simpl="", clusters="181"
|
||||
)
|
||||
|
||||
cf = snakemake.params["co2seq_potential"]
|
||||
cf = snakemake.params.co2seq_potential
|
||||
|
||||
gdf = gpd.read_file(snakemake.input.sequestration_potential[0])
|
||||
|
||||
|
@ -255,13 +255,11 @@ if __name__ == "__main__":
|
||||
snakemake = mock_snakemake("build_shapes")
|
||||
configure_logging(snakemake)
|
||||
|
||||
country_shapes = countries(
|
||||
snakemake.input.naturalearth, snakemake.params["countries"]
|
||||
)
|
||||
country_shapes = countries(snakemake.input.naturalearth, snakemake.params.countries)
|
||||
country_shapes.reset_index().to_file(snakemake.output.country_shapes)
|
||||
|
||||
offshore_shapes = eez(
|
||||
country_shapes, snakemake.input.eez, snakemake.params["countries"]
|
||||
country_shapes, snakemake.input.eez, snakemake.params.countries
|
||||
)
|
||||
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)
|
||||
client = Client(cluster, asynchronous=True)
|
||||
|
||||
config = snakemake.params["solar_thermal"]
|
||||
config = snakemake.params.solar_thermal
|
||||
|
||||
time = pd.date_range(freq="h", **snakemake.params["snapshots"])
|
||||
time = pd.date_range(freq="h", **snakemake.params.snapshots)
|
||||
cutout = atlite.Cutout(snakemake.input.cutout).sel(time=time)
|
||||
|
||||
clustered_regions = (
|
||||
|
@ -27,7 +27,7 @@ if __name__ == "__main__":
|
||||
cluster = LocalCluster(n_workers=nprocesses, threads_per_worker=1)
|
||||
client = Client(cluster, asynchronous=True)
|
||||
|
||||
time = pd.date_range(freq="h", **snakemake.params["snapshots"])
|
||||
time = pd.date_range(freq="h", **snakemake.params.snapshots)
|
||||
cutout = atlite.Cutout(snakemake.input.cutout).sel(time=time)
|
||||
|
||||
clustered_regions = (
|
||||
|
@ -175,9 +175,9 @@ if __name__ == "__main__":
|
||||
snakemake.input.pop_weighted_energy_totals, index_col=0
|
||||
)
|
||||
|
||||
options = snakemake.params["sector"]
|
||||
options = snakemake.params.sector
|
||||
|
||||
snapshots = pd.date_range(freq="h", **snakemake.params["snapshots"], tz="UTC")
|
||||
snapshots = pd.date_range(freq="h", **snakemake.params.snapshots, tz="UTC")
|
||||
|
||||
nyears = len(snapshots) / 8760
|
||||
|
||||
|
@ -198,7 +198,7 @@ def calculate_costs(n, label, costs):
|
||||
|
||||
|
||||
def calculate_cumulative_cost():
|
||||
planning_horizons = snakemake.params["scenario"]["planning_horizons"]
|
||||
planning_horizons = snakemake.params.scenario["planning_horizons"]
|
||||
|
||||
cumulative_cost = pd.DataFrame(
|
||||
index=df["costs"].sum().index,
|
||||
@ -688,19 +688,19 @@ if __name__ == "__main__":
|
||||
(cluster, ll, opt + sector_opt, planning_horizon): "results/"
|
||||
+ snakemake.params.RDIR
|
||||
+ f"/postnetworks/elec_s{simpl}_{cluster}_l{ll}_{opt}_{sector_opt}_{planning_horizon}.nc"
|
||||
for simpl in snakemake.params["scenario"]["simpl"]
|
||||
for cluster in snakemake.params["scenario"]["clusters"]
|
||||
for opt in snakemake.params["scenario"]["opts"]
|
||||
for sector_opt in snakemake.params["scenario"]["sector_opts"]
|
||||
for ll in snakemake.params["scenario"]["ll"]
|
||||
for planning_horizon in snakemake.params["scenario"]["planning_horizons"]
|
||||
for simpl in snakemake.params.scenario["simpl"]
|
||||
for cluster in snakemake.params.scenario["clusters"]
|
||||
for opt in snakemake.params.scenario["opts"]
|
||||
for sector_opt in snakemake.params.scenario["sector_opts"]
|
||||
for ll in snakemake.params.scenario["ll"]
|
||||
for planning_horizon in snakemake.params.scenario["planning_horizons"]
|
||||
}
|
||||
|
||||
Nyears = len(pd.date_range(freq="h", **snakemake.params["snapshots"])) / 8760
|
||||
Nyears = len(pd.date_range(freq="h", **snakemake.params.snapshots)) / 8760
|
||||
|
||||
costs_db = prepare_costs(
|
||||
snakemake.input.costs,
|
||||
snakemake.params["costs"],
|
||||
snakemake.params.costs,
|
||||
Nyears,
|
||||
)
|
||||
|
||||
@ -710,7 +710,7 @@ if __name__ == "__main__":
|
||||
|
||||
to_csv(df)
|
||||
|
||||
if snakemake.params["foresight"] == "myopic":
|
||||
if snakemake.params.foresight == "myopic":
|
||||
cumulative_cost = calculate_cumulative_cost()
|
||||
cumulative_cost.to_csv(
|
||||
"results/" + snakemake.params.RDIR + "/csvs/cumulative_cost.csv"
|
||||
|
@ -70,7 +70,7 @@ def plot_map(
|
||||
transmission=False,
|
||||
with_legend=True,
|
||||
):
|
||||
tech_colors = snakemake.params["plotting"]["tech_colors"]
|
||||
tech_colors = snakemake.params.plotting["tech_colors"]
|
||||
|
||||
n = network.copy()
|
||||
assign_location(n)
|
||||
@ -116,9 +116,7 @@ def plot_map(
|
||||
costs = costs.stack() # .sort_index()
|
||||
|
||||
# hack because impossible to drop buses...
|
||||
eu_location = snakemake.params["plotting"].get(
|
||||
"eu_node_location", dict(x=-5.5, y=46)
|
||||
)
|
||||
eu_location = snakemake.params.plotting.get("eu_node_location", dict(x=-5.5, y=46))
|
||||
n.buses.loc["EU gas", "x"] = eu_location["x"]
|
||||
n.buses.loc["EU gas", "y"] = eu_location["y"]
|
||||
|
||||
@ -315,7 +313,7 @@ def plot_h2_map(network, regions):
|
||||
h2_new = n.links[n.links.carrier == "H2 pipeline"]
|
||||
h2_retro = n.links[n.links.carrier == "H2 pipeline retrofitted"]
|
||||
|
||||
if snakemake.params["foresight"] == "myopic":
|
||||
if snakemake.params.foresight == "myopic":
|
||||
# sum capacitiy for pipelines from different investment periods
|
||||
h2_new = group_pipes(h2_new)
|
||||
|
||||
@ -558,7 +556,7 @@ def plot_ch4_map(network):
|
||||
link_widths_used = max_usage / linewidth_factor
|
||||
link_widths_used[max_usage < line_lower_threshold] = 0.0
|
||||
|
||||
tech_colors = snakemake.params["plotting"]["tech_colors"]
|
||||
tech_colors = snakemake.params.plotting["tech_colors"]
|
||||
|
||||
pipe_colors = {
|
||||
"gas pipeline": "#f08080",
|
||||
@ -700,7 +698,7 @@ def plot_map_without(network):
|
||||
|
||||
# hack because impossible to drop buses...
|
||||
if "EU gas" in n.buses.index:
|
||||
eu_location = snakemake.params["plotting"].get(
|
||||
eu_location = snakemake.params.plotting.get(
|
||||
"eu_node_location", dict(x=-5.5, y=46)
|
||||
)
|
||||
n.buses.loc["EU gas", "x"] = eu_location["x"]
|
||||
@ -876,7 +874,7 @@ def plot_series(network, carrier="AC", name="test"):
|
||||
stacked=True,
|
||||
linewidth=0.0,
|
||||
color=[
|
||||
snakemake.params["plotting"]["tech_colors"][i.replace(suffix, "")]
|
||||
snakemake.params.plotting["tech_colors"][i.replace(suffix, "")]
|
||||
for i in new_columns
|
||||
],
|
||||
)
|
||||
@ -937,7 +935,7 @@ if __name__ == "__main__":
|
||||
|
||||
regions = gpd.read_file(snakemake.input.regions).set_index("name")
|
||||
|
||||
map_opts = snakemake.params["plotting"]["map"]
|
||||
map_opts = snakemake.params.plotting["map"]
|
||||
|
||||
if map_opts["boundaries"] is None:
|
||||
map_opts["boundaries"] = regions.total_bounds[[0, 2, 1, 3]] + [-1, 1, -1, 1]
|
||||
|
@ -142,7 +142,7 @@ def plot_costs():
|
||||
|
||||
df = df.groupby(df.index.map(rename_techs)).sum()
|
||||
|
||||
to_drop = df.index[df.max(axis=1) < snakemake.params["plotting"]["costs_threshold"]]
|
||||
to_drop = df.index[df.max(axis=1) < snakemake.params.plotting["costs_threshold"]]
|
||||
|
||||
logger.info(
|
||||
f"Dropping technology with costs below {snakemake.params['plotting']['costs_threshold']} EUR billion per year"
|
||||
@ -165,7 +165,7 @@ def plot_costs():
|
||||
kind="bar",
|
||||
ax=ax,
|
||||
stacked=True,
|
||||
color=[snakemake.params["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()
|
||||
@ -173,7 +173,7 @@ def plot_costs():
|
||||
handles.reverse()
|
||||
labels.reverse()
|
||||
|
||||
ax.set_ylim([0, snakemake.params["plotting"]["costs_max"]])
|
||||
ax.set_ylim([0, snakemake.params.plotting["costs_max"]])
|
||||
|
||||
ax.set_ylabel("System Cost [EUR billion per year]")
|
||||
|
||||
@ -201,7 +201,7 @@ def plot_energy():
|
||||
df = df.groupby(df.index.map(rename_techs)).sum()
|
||||
|
||||
to_drop = df.index[
|
||||
df.abs().max(axis=1) < snakemake.params["plotting"]["energy_threshold"]
|
||||
df.abs().max(axis=1) < snakemake.params.plotting["energy_threshold"]
|
||||
]
|
||||
|
||||
logger.info(
|
||||
@ -227,7 +227,7 @@ def plot_energy():
|
||||
kind="bar",
|
||||
ax=ax,
|
||||
stacked=True,
|
||||
color=[snakemake.params["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()
|
||||
@ -237,8 +237,8 @@ def plot_energy():
|
||||
|
||||
ax.set_ylim(
|
||||
[
|
||||
snakemake.params["plotting"]["energy_min"],
|
||||
snakemake.params["plotting"]["energy_max"],
|
||||
snakemake.params.plotting["energy_min"],
|
||||
snakemake.params.plotting["energy_max"],
|
||||
]
|
||||
)
|
||||
|
||||
@ -287,7 +287,7 @@ def plot_balances():
|
||||
df = df.groupby(df.index.map(rename_techs)).sum()
|
||||
|
||||
to_drop = df.index[
|
||||
df.abs().max(axis=1) < snakemake.params["plotting"]["energy_threshold"] / 10
|
||||
df.abs().max(axis=1) < snakemake.params.plotting["energy_threshold"] / 10
|
||||
]
|
||||
|
||||
if v[0] in co2_carriers:
|
||||
@ -317,7 +317,7 @@ def plot_balances():
|
||||
kind="bar",
|
||||
ax=ax,
|
||||
stacked=True,
|
||||
color=[snakemake.params["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()
|
||||
@ -455,10 +455,10 @@ def plot_carbon_budget_distribution(input_eurostat):
|
||||
ax1 = plt.subplot(gs1[0, 0])
|
||||
ax1.set_ylabel("CO$_2$ emissions (Gt per year)", fontsize=22)
|
||||
ax1.set_ylim([0, 5])
|
||||
ax1.set_xlim([1990, snakemake.params["planning_horizons"][-1] + 1])
|
||||
ax1.set_xlim([1990, snakemake.params.planning_horizons[-1] + 1])
|
||||
|
||||
path_cb = "results/" + snakemake.params.RDIR + "/csvs/"
|
||||
countries = snakemake.params["countries"]
|
||||
countries = snakemake.params.countries
|
||||
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)
|
||||
|
||||
@ -555,7 +555,7 @@ if __name__ == "__main__":
|
||||
|
||||
plot_balances()
|
||||
|
||||
for sector_opts in snakemake.params["sector_opts"]:
|
||||
for sector_opts in snakemake.params.sector_opts:
|
||||
opts = sector_opts.split("-")
|
||||
for o in opts:
|
||||
if "cb" in o:
|
||||
|
@ -253,12 +253,12 @@ if __name__ == "__main__":
|
||||
Nyears = n.snapshot_weightings.objective.sum() / 8760.0
|
||||
costs = load_costs(
|
||||
snakemake.input.tech_costs,
|
||||
snakemake.params["costs"],
|
||||
snakemake.params["max_hours"],
|
||||
snakemake.params.costs,
|
||||
snakemake.params.max_hours,
|
||||
Nyears,
|
||||
)
|
||||
|
||||
set_line_s_max_pu(n, snakemake.params["lines"]["s_max_pu"])
|
||||
set_line_s_max_pu(n, snakemake.params.lines["s_max_pu"])
|
||||
|
||||
for o in opts:
|
||||
m = re.match(r"^\d+h$", o, re.IGNORECASE)
|
||||
@ -269,7 +269,7 @@ if __name__ == "__main__":
|
||||
for o in opts:
|
||||
m = re.match(r"^\d+seg$", o, re.IGNORECASE)
|
||||
if m is not None:
|
||||
solver_name = snakemake.params["solver_name"]
|
||||
solver_name = snakemake.params.solver_name
|
||||
n = apply_time_segmentation(n, m.group(0)[:-3], solver_name)
|
||||
break
|
||||
|
||||
@ -277,11 +277,11 @@ if __name__ == "__main__":
|
||||
if "Co2L" in o:
|
||||
m = re.findall("[0-9]*\.?[0-9]+$", o)
|
||||
if len(m) > 0:
|
||||
co2limit = float(m[0]) * snakemake.params["co2base"]
|
||||
co2limit = float(m[0]) * snakemake.params.co2base
|
||||
add_co2limit(n, co2limit, Nyears)
|
||||
logger.info("Setting CO2 limit according to wildcard value.")
|
||||
else:
|
||||
add_co2limit(n, snakemake.params["co2limit"], Nyears)
|
||||
add_co2limit(n, snakemake.params.co2limit, Nyears)
|
||||
logger.info("Setting CO2 limit according to config value.")
|
||||
break
|
||||
|
||||
@ -293,7 +293,7 @@ if __name__ == "__main__":
|
||||
add_gaslimit(n, limit, Nyears)
|
||||
logger.info("Setting gas usage limit according to wildcard value.")
|
||||
else:
|
||||
add_gaslimit(n, snakemake.params["gaslimit"], Nyears)
|
||||
add_gaslimit(n, snakemake.params.gaslimit, Nyears)
|
||||
logger.info("Setting gas usage limit according to config value.")
|
||||
break
|
||||
|
||||
@ -322,7 +322,7 @@ if __name__ == "__main__":
|
||||
add_emission_prices(n, dict(co2=float(m[0])))
|
||||
else:
|
||||
logger.info("Setting emission prices according to config value.")
|
||||
add_emission_prices(n, snakemake.params["costs"]["emission_prices"])
|
||||
add_emission_prices(n, snakemake.params.costs["emission_prices"])
|
||||
break
|
||||
|
||||
ll_type, factor = snakemake.wildcards.ll[0], snakemake.wildcards.ll[1:]
|
||||
@ -330,8 +330,8 @@ if __name__ == "__main__":
|
||||
|
||||
set_line_nom_max(
|
||||
n,
|
||||
s_nom_max_set=snakemake.params["lines"].get("s_nom_max,", np.inf),
|
||||
p_nom_max_set=snakemake.params["links"].get("p_nom_max,", np.inf),
|
||||
s_nom_max_set=snakemake.params.lines.get("s_nom_max,", np.inf),
|
||||
p_nom_max_set=snakemake.params.links.get("p_nom_max,", np.inf),
|
||||
)
|
||||
|
||||
if "ATK" in opts:
|
||||
|
@ -200,12 +200,12 @@ def co2_emissions_year(
|
||||
"""
|
||||
Calculate CO2 emissions in one specific year (e.g. 1990 or 2018).
|
||||
"""
|
||||
emissions_scope = snakemake.params["energy"]["emissions"]
|
||||
emissions_scope = snakemake.params.energy["emissions"]
|
||||
eea_co2 = build_eea_co2(snakemake.input.co2, year, emissions_scope)
|
||||
|
||||
# TODO: read Eurostat data from year > 2014
|
||||
# this only affects the estimation of CO2 emissions for BA, RS, AL, ME, MK
|
||||
report_year = snakemake.params["energy"]["eurostat_report_year"]
|
||||
report_year = snakemake.params.energy["eurostat_report_year"]
|
||||
if year > 2014:
|
||||
eurostat_co2 = build_eurostat_co2(
|
||||
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")])
|
||||
r = float(o[o.find("ex") + 2 :])
|
||||
|
||||
countries = snakemake.params["countries"]
|
||||
countries = snakemake.params.countries
|
||||
|
||||
e_1990 = co2_emissions_year(
|
||||
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
|
||||
)
|
||||
|
||||
planning_horizons = snakemake.params["planning_horizons"]
|
||||
planning_horizons = snakemake.params.planning_horizons
|
||||
t_0 = planning_horizons[0]
|
||||
|
||||
if "be" in o:
|
||||
@ -391,7 +391,7 @@ def update_wind_solar_costs(n, costs):
|
||||
with xr.open_dataset(profile) as ds:
|
||||
underwater_fraction = ds["underwater_fraction"].to_pandas()
|
||||
connection_cost = (
|
||||
snakemake.params["length_factor"]
|
||||
snakemake.params.length_factor
|
||||
* ds["average_distance"].to_pandas()
|
||||
* (
|
||||
underwater_fraction
|
||||
@ -483,8 +483,8 @@ def remove_elec_base_techs(n):
|
||||
batteries and H2) from base electricity-only network, since they're added
|
||||
here differently using links.
|
||||
"""
|
||||
for c in n.iterate_components(snakemake.params["pypsa_eur"]):
|
||||
to_keep = snakemake.params["pypsa_eur"][c.name]
|
||||
for c in n.iterate_components(snakemake.params.pypsa_eur):
|
||||
to_keep = snakemake.params.pypsa_eur[c.name]
|
||||
to_remove = pd.Index(c.df.carrier.unique()).symmetric_difference(to_keep)
|
||||
if to_remove.empty:
|
||||
continue
|
||||
@ -674,7 +674,7 @@ def add_dac(n, costs):
|
||||
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}")
|
||||
|
||||
countries = snakemake.params["countries"]
|
||||
countries = snakemake.params.countries
|
||||
|
||||
sectors = emission_sectors_from_opts(opts)
|
||||
|
||||
@ -787,7 +787,7 @@ def add_ammonia(n, costs):
|
||||
|
||||
nodes = pop_layout.index
|
||||
|
||||
cf_industry = snakemake.params["industry"]
|
||||
cf_industry = snakemake.params.industry
|
||||
|
||||
n.add("Carrier", "NH3")
|
||||
|
||||
@ -1102,7 +1102,7 @@ def add_storage_and_grids(n, costs):
|
||||
lifetime=costs.at["OCGT", "lifetime"],
|
||||
)
|
||||
|
||||
cavern_types = snakemake.params["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)
|
||||
|
||||
if (
|
||||
@ -3274,7 +3274,7 @@ if __name__ == "__main__":
|
||||
|
||||
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
||||
|
||||
options = snakemake.params["sector"]
|
||||
options = snakemake.params.sector
|
||||
|
||||
opts = snakemake.wildcards.sector_opts.split("-")
|
||||
|
||||
@ -3289,7 +3289,7 @@ if __name__ == "__main__":
|
||||
|
||||
costs = prepare_costs(
|
||||
snakemake.input.costs,
|
||||
snakemake.params["costs"],
|
||||
snakemake.params.costs,
|
||||
nyears,
|
||||
)
|
||||
|
||||
@ -3301,10 +3301,10 @@ if __name__ == "__main__":
|
||||
|
||||
spatial = define_spatial(pop_layout.index, options)
|
||||
|
||||
if snakemake.params["foresight"] == "myopic":
|
||||
if snakemake.params.foresight == "myopic":
|
||||
add_lifetime_wind_solar(n, costs)
|
||||
|
||||
conventional = snakemake.params["conventional_carriers"]
|
||||
conventional = snakemake.params.conventional_carriers
|
||||
for carrier in conventional:
|
||||
add_carrier_buses(n, carrier)
|
||||
|
||||
@ -3369,19 +3369,19 @@ if __name__ == "__main__":
|
||||
if options["allam_cycle"]:
|
||||
add_allam(n, costs)
|
||||
|
||||
solver_name = snakemake.params["solver_name"]
|
||||
solver_name = snakemake.params.solver_name
|
||||
n = set_temporal_aggregation(n, opts, solver_name)
|
||||
|
||||
limit_type = "config"
|
||||
limit = get(snakemake.params["co2_budget"], investment_year)
|
||||
limit = get(snakemake.params.co2_budget, investment_year)
|
||||
for o in opts:
|
||||
if "cb" not in o:
|
||||
continue
|
||||
limit_type = "carbon budget"
|
||||
fn = "results/" + snakemake.params.RDIR + "/csvs/carbon_budget_distribution.csv"
|
||||
if not os.path.exists(fn):
|
||||
emissions_scope = snakemake.params["emissions_scope"]
|
||||
report_year = snakemake.params["report_year"]
|
||||
emissions_scope = snakemake.params.emissions_scope
|
||||
report_year = snakemake.params.report_year
|
||||
build_carbon_budget(
|
||||
o, snakemake.input.eurostat, fn, emissions_scope, report_year
|
||||
)
|
||||
@ -3416,8 +3416,8 @@ if __name__ == "__main__":
|
||||
if options["electricity_grid_connection"]:
|
||||
add_electricity_grid_connection(n, costs)
|
||||
|
||||
first_year_myopic = (snakemake.params["foresight"] == "myopic") and (
|
||||
snakemake.params["planning_horizons"][0] == investment_year
|
||||
first_year_myopic = (snakemake.params.foresight == "myopic") and (
|
||||
snakemake.params.planning_horizons[0] == investment_year
|
||||
)
|
||||
|
||||
if options.get("cluster_heat_buses", False) and not first_year_myopic:
|
||||
|
@ -53,7 +53,7 @@ if __name__ == "__main__":
|
||||
snakemake
|
||||
) # TODO Make logging compatible with progressbar (see PR #102)
|
||||
|
||||
if snakemake.params["tutorial"]:
|
||||
if snakemake.params.tutorial:
|
||||
url = "https://zenodo.org/record/3517921/files/pypsa-eur-tutorial-data-bundle.tar.xz"
|
||||
else:
|
||||
url = "https://zenodo.org/record/3517935/files/pypsa-eur-data-bundle.tar.xz"
|
||||
|
@ -44,9 +44,9 @@ pypsa.pf.logger.setLevel(logging.WARNING)
|
||||
from pypsa.descriptors import get_switchable_as_dense as get_as_dense
|
||||
|
||||
|
||||
def add_land_use_constraint(n, planning_horizons_param, config):
|
||||
def add_land_use_constraint(n, planning_horizons, config):
|
||||
if "m" in snakemake.wildcards.clusters:
|
||||
_add_land_use_constraint_m(n, planning_horizons_param, config)
|
||||
_add_land_use_constraint_m(n, planning_horizons, config)
|
||||
else:
|
||||
_add_land_use_constraint(n)
|
||||
|
||||
@ -80,7 +80,7 @@ def _add_land_use_constraint(n):
|
||||
n.generators.p_nom_max.clip(lower=0, inplace=True)
|
||||
|
||||
|
||||
def _add_land_use_constraint_m(n, planning_horizons_param, config):
|
||||
def _add_land_use_constraint_m(n, planning_horizons, config):
|
||||
# if generators clustering is lower than network clustering, land_use accounting is at generators clusters
|
||||
|
||||
planning_horizons = param["planning_horizons"]
|
||||
@ -145,9 +145,9 @@ def prepare_network(
|
||||
n,
|
||||
solve_opts=None,
|
||||
config=None,
|
||||
foresight_param=None,
|
||||
planning_horizons_param=None,
|
||||
co2_sequestration_potential_param=None,
|
||||
foresight=None,
|
||||
planning_horizons=None,
|
||||
co2_sequestration_potential=None,
|
||||
):
|
||||
if "clip_p_max_pu" in solve_opts:
|
||||
for df in (
|
||||
@ -198,11 +198,11 @@ def prepare_network(
|
||||
n.set_snapshots(n.snapshots[:nhours])
|
||||
n.snapshot_weightings[:] = 8760.0 / nhours
|
||||
|
||||
if foresight_param == "myopic":
|
||||
add_land_use_constraint(n, planning_horizons_param, config)
|
||||
if foresight == "myopic":
|
||||
add_land_use_constraint(n, planning_horizons, config)
|
||||
|
||||
if n.stores.carrier.eq("co2 stored").any():
|
||||
limit = co2_sequestration_potential_param
|
||||
limit = co2_sequestration_potential
|
||||
add_co2_sequestration_limit(n, limit=limit)
|
||||
|
||||
return n
|
||||
@ -597,13 +597,11 @@ def extra_functionality(n, snapshots):
|
||||
add_pipe_retrofit_constraint(n)
|
||||
|
||||
|
||||
def solve_network(n, config, solving_param, opts="", **kwargs):
|
||||
set_of_options = solving_param["solver"]["options"]
|
||||
solver_options = (
|
||||
solving_param["solver_options"][set_of_options] if set_of_options else {}
|
||||
)
|
||||
solver_name = solving_param["solver"]["name"]
|
||||
cf_solving = solving_param["options"]
|
||||
def solve_network(n, config, solving, opts="", **kwargs):
|
||||
set_of_options = solving["solver"]["options"]
|
||||
solver_options = solving["solver_options"][set_of_options] if set_of_options else {}
|
||||
solver_name = solving["solver"]["name"]
|
||||
cf_solving = solving["options"]
|
||||
track_iterations = cf_solving.get("track_iterations", False)
|
||||
min_iterations = cf_solving.get("min_iterations", 4)
|
||||
max_iterations = cf_solving.get("max_iterations", 6)
|
||||
@ -672,7 +670,7 @@ if __name__ == "__main__":
|
||||
if "sector_opts" in snakemake.wildcards.keys():
|
||||
opts += "-" + snakemake.wildcards.sector_opts
|
||||
opts = [o for o in opts.split("-") if o != ""]
|
||||
solve_opts = snakemake.params["solving"]["options"]
|
||||
solve_opts = snakemake.params.solving["options"]
|
||||
|
||||
np.random.seed(solve_opts.get("seed", 123))
|
||||
|
||||
@ -686,17 +684,15 @@ if __name__ == "__main__":
|
||||
n,
|
||||
solve_opts,
|
||||
config=snakemake.config,
|
||||
foresight_param=snakemake.params["foresight"],
|
||||
planning_horizons_param=snakemake.params["planning_horizons"],
|
||||
co2_sequestration_potential_param=snakemake.params[
|
||||
"co2_sequestration_potential"
|
||||
],
|
||||
foresight=snakemake.params.foresight,
|
||||
planning_horizons=snakemake.params.planning_horizons,
|
||||
co2_sequestration_potential=snakemake.params["co2_sequestration_potential"],
|
||||
)
|
||||
|
||||
n = solve_network(
|
||||
n,
|
||||
config=snakemake.config,
|
||||
solving_param=snakemake.params["solving"],
|
||||
solving=snakemake.params.solving,
|
||||
opts=opts,
|
||||
log_fn=snakemake.log.solver,
|
||||
)
|
||||
|
@ -41,7 +41,7 @@ if __name__ == "__main__":
|
||||
|
||||
opts = (snakemake.wildcards.opts + "-" + snakemake.wildcards.sector_opts).split("-")
|
||||
opts = [o for o in opts if o != ""]
|
||||
solve_opts = snakemake.params["options"]
|
||||
solve_opts = snakemake.params.options
|
||||
|
||||
np.random.seed(solve_opts.get("seed", 123))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user