replace the word "config" to "params" in functions
This commit is contained in:
parent
8208ac033b
commit
8af1fe5649
@ -277,6 +277,7 @@ rule add_electricity:
|
||||
countries=config["countries"],
|
||||
renewable=config["renewable"],
|
||||
electricity=config["electricity"],
|
||||
conventional=config.get("conventional", {})
|
||||
costs=config["costs"],
|
||||
input:
|
||||
**{
|
||||
|
@ -135,7 +135,7 @@ def _add_missing_carriers_from_costs(n, costs, carriers):
|
||||
n.import_components_from_dataframe(emissions, "Carrier")
|
||||
|
||||
|
||||
def load_costs(tech_costs, config, elec_config, Nyears=1.0):
|
||||
def load_costs(tech_costs, params, elec_params, Nyears=1.0):
|
||||
# set all asset costs and other parameters
|
||||
costs = pd.read_csv(tech_costs, index_col=[0, 1]).sort_index()
|
||||
|
||||
@ -143,7 +143,7 @@ def load_costs(tech_costs, config, elec_config, Nyears=1.0):
|
||||
costs.loc[costs.unit.str.contains("/kW"), "value"] *= 1e3
|
||||
costs.unit = costs.unit.str.replace("/kW", "/MW")
|
||||
|
||||
fill_values = config["fill_values"]
|
||||
fill_values = params["fill_values"]
|
||||
costs = costs.value.unstack().fillna(fill_values)
|
||||
|
||||
costs["capital_cost"] = (
|
||||
@ -166,8 +166,8 @@ def load_costs(tech_costs, config, elec_config, Nyears=1.0):
|
||||
costs.at["CCGT", "co2_emissions"] = costs.at["gas", "co2_emissions"]
|
||||
|
||||
costs.at["solar", "capital_cost"] = (
|
||||
config["rooftop_share"] * costs.at["solar-rooftop", "capital_cost"]
|
||||
+ (1 - config["rooftop_share"]) * costs.at["solar-utility", "capital_cost"]
|
||||
params["rooftop_share"] * costs.at["solar-rooftop", "capital_cost"]
|
||||
+ (1 - params["rooftop_share"]) * costs.at["solar-utility", "capital_cost"]
|
||||
)
|
||||
|
||||
def costs_for_storage(store, link1, link2=None, max_hours=1.0):
|
||||
@ -178,7 +178,7 @@ def load_costs(tech_costs, config, elec_config, Nyears=1.0):
|
||||
dict(capital_cost=capital_cost, marginal_cost=0.0, co2_emissions=0.0)
|
||||
)
|
||||
|
||||
max_hours = elec_config["max_hours"]
|
||||
max_hours = elec_params["max_hours"]
|
||||
costs.loc["battery"] = costs_for_storage(
|
||||
costs.loc["battery storage"],
|
||||
costs.loc["battery inverter"],
|
||||
@ -192,7 +192,7 @@ def load_costs(tech_costs, config, elec_config, Nyears=1.0):
|
||||
)
|
||||
|
||||
for attr in ("marginal_cost", "capital_cost"):
|
||||
overwrites = config.get(attr)
|
||||
overwrites = params.get(attr)
|
||||
if overwrites is not None:
|
||||
overwrites = pd.Series(overwrites)
|
||||
costs.loc[overwrites.index, attr] = overwrites
|
||||
@ -356,7 +356,7 @@ def attach_conventional_generators(
|
||||
ppl,
|
||||
conventional_carriers,
|
||||
extendable_carriers,
|
||||
conventional_config,
|
||||
conventional_params,
|
||||
conventional_inputs,
|
||||
):
|
||||
carriers = set(conventional_carriers) | set(extendable_carriers["Generator"])
|
||||
@ -393,12 +393,12 @@ def attach_conventional_generators(
|
||||
lifetime=(ppl.dateout - ppl.datein).fillna(np.inf),
|
||||
)
|
||||
|
||||
for carrier in conventional_config:
|
||||
for carrier in conventional_params:
|
||||
# Generators with technology affected
|
||||
idx = n.generators.query("carrier == @carrier").index
|
||||
|
||||
for attr in list(set(conventional_config[carrier]) & set(n.generators)):
|
||||
values = conventional_config[carrier][attr]
|
||||
for attr in list(set(conventional_params[carrier]) & set(n.generators)):
|
||||
values = conventional_params[carrier][attr]
|
||||
|
||||
if f"conventional_{carrier}_{attr}" in conventional_inputs:
|
||||
# Values affecting generators of technology k country-specific
|
||||
@ -413,7 +413,7 @@ def attach_conventional_generators(
|
||||
n.generators.loc[idx, attr] = values
|
||||
|
||||
|
||||
def attach_hydro(n, costs, ppl, profile_hydro, hydro_capacities, carriers, **config):
|
||||
def attach_hydro(n, costs, ppl, profile_hydro, hydro_capacities, carriers, **params):
|
||||
_add_missing_carriers_from_costs(n, costs, carriers)
|
||||
|
||||
ppl = (
|
||||
@ -468,9 +468,9 @@ def attach_hydro(n, costs, ppl, profile_hydro, hydro_capacities, carriers, **con
|
||||
)
|
||||
|
||||
if "PHS" in carriers and not phs.empty:
|
||||
# fill missing max hours to config value and
|
||||
# fill missing max hours to params value and
|
||||
# assume no natural inflow due to lack of data
|
||||
max_hours = config.get("PHS_max_hours", 6)
|
||||
max_hours = params.get("PHS_max_hours", 6)
|
||||
phs = phs.replace({"max_hours": {0: max_hours}})
|
||||
n.madd(
|
||||
"StorageUnit",
|
||||
@ -486,7 +486,7 @@ def attach_hydro(n, costs, ppl, profile_hydro, hydro_capacities, carriers, **con
|
||||
)
|
||||
|
||||
if "hydro" in carriers and not hydro.empty:
|
||||
hydro_max_hours = config.get("hydro_max_hours")
|
||||
hydro_max_hours = params.get("hydro_max_hours")
|
||||
|
||||
assert hydro_max_hours is not None, "No path for hydro capacities given."
|
||||
|
||||
@ -636,13 +636,12 @@ def attach_OPSD_renewables(n, tech_map):
|
||||
n.generators.p_nom_min.update(gens.bus.map(caps).dropna())
|
||||
|
||||
|
||||
def estimate_renewable_capacities(n, config):
|
||||
year = config["electricity"]["estimate_renewable_capacities"]["year"]
|
||||
tech_map = config["electricity"]["estimate_renewable_capacities"][
|
||||
def estimate_renewable_capacities(n, electricity_params, countries):
|
||||
year = electricity_params["estimate_renewable_capacities"]["year"]
|
||||
tech_map = electricity_params["estimate_renewable_capacities"][
|
||||
"technology_mapping"
|
||||
]
|
||||
countries = config["countries"]
|
||||
expansion_limit = config["electricity"]["estimate_renewable_capacities"][
|
||||
expansion_limit = electricity_params["estimate_renewable_capacities"][
|
||||
"expansion_limit"
|
||||
]
|
||||
|
||||
@ -759,7 +758,7 @@ if __name__ == "__main__":
|
||||
ppl,
|
||||
conventional_carriers,
|
||||
extendable_carriers,
|
||||
snakemake.config.get("conventional", {}),
|
||||
snakemake.params.get("conventional", {}),
|
||||
conventional_inputs,
|
||||
)
|
||||
|
||||
@ -773,15 +772,15 @@ if __name__ == "__main__":
|
||||
)
|
||||
|
||||
if "hydro" in renewable_carriers:
|
||||
conf = snakemake.params["renewable"]["hydro"]
|
||||
para = snakemake.params["renewable"]["hydro"]
|
||||
attach_hydro(
|
||||
n,
|
||||
costs,
|
||||
ppl,
|
||||
snakemake.input.profile_hydro,
|
||||
snakemake.input.hydro_capacities,
|
||||
conf.pop("carriers", []),
|
||||
**conf,
|
||||
para.pop("carriers", []),
|
||||
**para,
|
||||
)
|
||||
|
||||
if "estimate_renewable_capacities" not in snakemake.params["electricity"]:
|
||||
@ -829,7 +828,7 @@ if __name__ == "__main__":
|
||||
"technology_mapping"
|
||||
]
|
||||
attach_OPSD_renewables(n, tech_map)
|
||||
estimate_renewable_capacities(n, snakemake.config)
|
||||
estimate_renewable_capacities(n, snakemake.params["electricity"],snakemake.params["countries"])
|
||||
|
||||
update_p_nom_max(n)
|
||||
|
||||
|
@ -210,9 +210,9 @@ if __name__ == "__main__":
|
||||
|
||||
snakemake = mock_snakemake("build_biomass_potentials", simpl="", clusters="5")
|
||||
|
||||
config = snakemake.params["biomass"]
|
||||
year = config["year"]
|
||||
scenario = config["scenario"]
|
||||
params = snakemake.params["biomass"]
|
||||
year = params["year"]
|
||||
scenario = params["scenario"]
|
||||
|
||||
enspreso = enspreso_biomass_potentials(year, scenario)
|
||||
|
||||
@ -228,7 +228,7 @@ if __name__ == "__main__":
|
||||
|
||||
df.to_csv(snakemake.output.biomass_potentials_all)
|
||||
|
||||
grouper = {v: k for k, vv in config["classes"].items() for v in vv}
|
||||
grouper = {v: k for k, vv in params["classes"].items() for v in vv}
|
||||
df = df.groupby(grouper, axis=1).sum()
|
||||
|
||||
df *= 1e6 # TWh/a to MWh/a
|
||||
|
@ -737,7 +737,7 @@ if __name__ == "__main__":
|
||||
|
||||
logging.basicConfig(level=snakemake.config["logging"]["level"])
|
||||
|
||||
config = 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()
|
||||
@ -745,7 +745,7 @@ if __name__ == "__main__":
|
||||
countries = snakemake.params["countries"]
|
||||
idees_countries = pd.Index(countries).intersection(eu28)
|
||||
|
||||
data_year = config["energy_totals_year"]
|
||||
data_year = params["energy_totals_year"]
|
||||
report_year = snakemake.params["energy"]["eurostat_report_year"]
|
||||
input_eurostat = snakemake.input.eurostat
|
||||
eurostat = build_eurostat(input_eurostat, countries, report_year, data_year)
|
||||
@ -755,7 +755,7 @@ if __name__ == "__main__":
|
||||
energy = build_energy_totals(countries, eurostat, swiss, idees)
|
||||
energy.to_csv(snakemake.output.energy_name)
|
||||
|
||||
base_year_emissions = config["base_emissions_year"]
|
||||
base_year_emissions = params["base_emissions_year"]
|
||||
emissions_scope = snakemake.params["energy"]["emissions"]
|
||||
eea_co2 = build_eea_co2(snakemake.input.co2, base_year_emissions, emissions_scope)
|
||||
eurostat_co2 = build_eurostat_co2(
|
||||
|
@ -130,7 +130,7 @@ if __name__ == "__main__":
|
||||
snakemake = mock_snakemake("build_hydro_profile")
|
||||
configure_logging(snakemake)
|
||||
|
||||
config_hydro = snakemake.params["renewable"]["hydro"]
|
||||
params_hydro = snakemake.params["renewable"]["hydro"]
|
||||
cutout = atlite.Cutout(snakemake.input.cutout)
|
||||
|
||||
countries = snakemake.params["countries"]
|
||||
@ -151,7 +151,7 @@ if __name__ == "__main__":
|
||||
normalize_using_yearly=eia_stats,
|
||||
)
|
||||
|
||||
if "clip_min_inflow" in config_hydro:
|
||||
inflow = inflow.where(inflow > config_hydro["clip_min_inflow"], 0)
|
||||
if "clip_min_inflow" in params_hydro:
|
||||
inflow = inflow.where(inflow > params_hydro["clip_min_inflow"], 0)
|
||||
|
||||
inflow.to_netcdf(snakemake.output[0])
|
||||
|
@ -101,8 +101,8 @@ def add_ammonia_energy_demand(demand):
|
||||
|
||||
def get_ammonia_by_fuel(x):
|
||||
fuels = {
|
||||
"gas": config["MWh_CH4_per_tNH3_SMR"],
|
||||
"electricity": config["MWh_elec_per_tNH3_SMR"],
|
||||
"gas": params["MWh_CH4_per_tNH3_SMR"],
|
||||
"electricity": params["MWh_elec_per_tNH3_SMR"],
|
||||
}
|
||||
|
||||
return pd.Series({k: x * v for k, v in fuels.items()})
|
||||
@ -112,7 +112,7 @@ def add_ammonia_energy_demand(demand):
|
||||
index=demand.index, fill_value=0.0
|
||||
)
|
||||
|
||||
ammonia = pd.DataFrame({"ammonia": ammonia * config["MWh_NH3_per_tNH3"]}).T
|
||||
ammonia = pd.DataFrame({"ammonia": ammonia * params["MWh_NH3_per_tNH3"]}).T
|
||||
|
||||
demand["Ammonia"] = ammonia.unstack().reindex(index=demand.index, fill_value=0.0)
|
||||
|
||||
@ -178,8 +178,8 @@ if __name__ == "__main__":
|
||||
|
||||
snakemake = mock_snakemake("build_industrial_energy_demand_per_country_today")
|
||||
|
||||
config = snakemake.params["industry"]
|
||||
year = config.get("reference_year", 2015)
|
||||
params = snakemake.params["industry"]
|
||||
year = params.get("reference_year", 2015)
|
||||
countries = pd.Index(snakemake.params["countries"])
|
||||
|
||||
demand = industrial_energy_demand(countries.intersection(eu28), year)
|
||||
|
@ -264,9 +264,9 @@ def separate_basic_chemicals(demand, year):
|
||||
|
||||
# assume HVC, methanol, chlorine production proportional to non-ammonia basic chemicals
|
||||
distribution_key = demand["Basic chemicals"] / demand["Basic chemicals"].sum()
|
||||
demand["HVC"] = config["HVC_production_today"] * 1e3 * distribution_key
|
||||
demand["Chlorine"] = config["chlorine_production_today"] * 1e3 * distribution_key
|
||||
demand["Methanol"] = config["methanol_production_today"] * 1e3 * distribution_key
|
||||
demand["HVC"] = params["HVC_production_today"] * 1e3 * distribution_key
|
||||
demand["Chlorine"] = params["chlorine_production_today"] * 1e3 * distribution_key
|
||||
demand["Methanol"] = params["methanol_production_today"] * 1e3 * distribution_key
|
||||
|
||||
demand.drop(columns=["Basic chemicals"], inplace=True)
|
||||
|
||||
@ -283,7 +283,7 @@ if __name__ == "__main__":
|
||||
|
||||
year = snakemake.params["industry"]["reference_year"]
|
||||
|
||||
config = 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")
|
||||
|
||||
config = snakemake.params["industry"]
|
||||
params = snakemake.params["industry"]
|
||||
|
||||
investment_year = int(snakemake.wildcards.planning_horizons)
|
||||
|
||||
@ -25,8 +25,8 @@ if __name__ == "__main__":
|
||||
keys = ["Integrated steelworks", "Electric arc"]
|
||||
total_steel = production[keys].sum(axis=1)
|
||||
|
||||
st_primary_fraction = get(config["St_primary_fraction"], investment_year)
|
||||
dri_fraction = get(config["DRI_fraction"], investment_year)
|
||||
st_primary_fraction = get(params["St_primary_fraction"], investment_year)
|
||||
dri_fraction = get(params["DRI_fraction"], investment_year)
|
||||
int_steel = production["Integrated steelworks"].sum()
|
||||
fraction_persistent_primary = st_primary_fraction * total_steel.sum() / int_steel
|
||||
|
||||
@ -51,7 +51,7 @@ if __name__ == "__main__":
|
||||
key_pri = "Aluminium - primary production"
|
||||
key_sec = "Aluminium - secondary production"
|
||||
|
||||
al_primary_fraction = get(config["Al_primary_fraction"], investment_year)
|
||||
al_primary_fraction = get(params["Al_primary_fraction"], investment_year)
|
||||
fraction_persistent_primary = (
|
||||
al_primary_fraction * total_aluminium.sum() / production[key_pri].sum()
|
||||
)
|
||||
@ -60,15 +60,15 @@ if __name__ == "__main__":
|
||||
production[key_sec] = total_aluminium - production[key_pri]
|
||||
|
||||
production["HVC (mechanical recycling)"] = (
|
||||
get(config["HVC_mechanical_recycling_fraction"], investment_year)
|
||||
get(params["HVC_mechanical_recycling_fraction"], investment_year)
|
||||
* production["HVC"]
|
||||
)
|
||||
production["HVC (chemical recycling)"] = (
|
||||
get(config["HVC_chemical_recycling_fraction"], investment_year)
|
||||
get(params["HVC_chemical_recycling_fraction"], investment_year)
|
||||
* production["HVC"]
|
||||
)
|
||||
|
||||
production["HVC"] *= get(config["HVC_primary_fraction"], investment_year)
|
||||
production["HVC"] *= get(params["HVC_primary_fraction"], investment_year)
|
||||
|
||||
fn = snakemake.output.industrial_production_per_country_tomorrow
|
||||
production.to_csv(fn, float_format="%.2f")
|
||||
|
@ -185,10 +185,10 @@ def iron_and_steel():
|
||||
df[sector] = df["Electric arc"]
|
||||
|
||||
# add H2 consumption for DRI at 1.7 MWh H2 /ton steel
|
||||
df.at["hydrogen", sector] = config["H2_DRI"]
|
||||
df.at["hydrogen", sector] = params["H2_DRI"]
|
||||
|
||||
# add electricity consumption in DRI shaft (0.322 MWh/tSl)
|
||||
df.at["elec", sector] += config["elec_DRI"]
|
||||
df.at["elec", sector] += params["elec_DRI"]
|
||||
|
||||
## Integrated steelworks
|
||||
# could be used in combination with CCS)
|
||||
@ -383,19 +383,19 @@ def chemicals_industry():
|
||||
assert s_emi.index[0] == sector
|
||||
|
||||
# convert from MtHVC/a to ktHVC/a
|
||||
s_out = config["HVC_production_today"] * 1e3
|
||||
s_out = params["HVC_production_today"] * 1e3
|
||||
|
||||
# tCO2/t material
|
||||
df.loc["process emission", sector] += (
|
||||
s_emi["Process emissions"]
|
||||
- config["petrochemical_process_emissions"] * 1e3
|
||||
- config["NH3_process_emissions"] * 1e3
|
||||
- params["petrochemical_process_emissions"] * 1e3
|
||||
- params["NH3_process_emissions"] * 1e3
|
||||
) / s_out
|
||||
|
||||
# emissions originating from feedstock, could be non-fossil origin
|
||||
# tCO2/t material
|
||||
df.loc["process emission from feedstock", sector] += (
|
||||
config["petrochemical_process_emissions"] * 1e3
|
||||
params["petrochemical_process_emissions"] * 1e3
|
||||
) / s_out
|
||||
|
||||
# convert from ktoe/a to GWh/a
|
||||
@ -405,18 +405,18 @@ def chemicals_industry():
|
||||
# subtract ammonia energy demand (in ktNH3/a)
|
||||
ammonia = pd.read_csv(snakemake.input.ammonia_production, index_col=0)
|
||||
ammonia_total = ammonia.loc[ammonia.index.intersection(eu28), str(year)].sum()
|
||||
df.loc["methane", sector] -= ammonia_total * config["MWh_CH4_per_tNH3_SMR"]
|
||||
df.loc["elec", sector] -= ammonia_total * config["MWh_elec_per_tNH3_SMR"]
|
||||
df.loc["methane", sector] -= ammonia_total * params["MWh_CH4_per_tNH3_SMR"]
|
||||
df.loc["elec", sector] -= ammonia_total * params["MWh_elec_per_tNH3_SMR"]
|
||||
|
||||
# subtract chlorine demand
|
||||
chlorine_total = config["chlorine_production_today"]
|
||||
df.loc["hydrogen", sector] -= chlorine_total * config["MWh_H2_per_tCl"]
|
||||
df.loc["elec", sector] -= chlorine_total * config["MWh_elec_per_tCl"]
|
||||
chlorine_total = params["chlorine_production_today"]
|
||||
df.loc["hydrogen", sector] -= chlorine_total * params["MWh_H2_per_tCl"]
|
||||
df.loc["elec", sector] -= chlorine_total * params["MWh_elec_per_tCl"]
|
||||
|
||||
# subtract methanol demand
|
||||
methanol_total = config["methanol_production_today"]
|
||||
df.loc["methane", sector] -= methanol_total * config["MWh_CH4_per_tMeOH"]
|
||||
df.loc["elec", sector] -= methanol_total * config["MWh_elec_per_tMeOH"]
|
||||
methanol_total = params["methanol_production_today"]
|
||||
df.loc["methane", sector] -= methanol_total * params["MWh_CH4_per_tMeOH"]
|
||||
df.loc["elec", sector] -= methanol_total * params["MWh_elec_per_tMeOH"]
|
||||
|
||||
# MWh/t material
|
||||
df.loc[sources, sector] = df.loc[sources, sector] / s_out
|
||||
@ -427,37 +427,37 @@ def chemicals_industry():
|
||||
|
||||
sector = "HVC (mechanical recycling)"
|
||||
df[sector] = 0.0
|
||||
df.loc["elec", sector] = config["MWh_elec_per_tHVC_mechanical_recycling"]
|
||||
df.loc["elec", sector] = params["MWh_elec_per_tHVC_mechanical_recycling"]
|
||||
|
||||
# HVC chemical recycling
|
||||
|
||||
sector = "HVC (chemical recycling)"
|
||||
df[sector] = 0.0
|
||||
df.loc["elec", sector] = config["MWh_elec_per_tHVC_chemical_recycling"]
|
||||
df.loc["elec", sector] = params["MWh_elec_per_tHVC_chemical_recycling"]
|
||||
|
||||
# Ammonia
|
||||
|
||||
sector = "Ammonia"
|
||||
df[sector] = 0.0
|
||||
if snakemake.params["sector"].get("ammonia", False):
|
||||
df.loc["ammonia", sector] = config["MWh_NH3_per_tNH3"]
|
||||
df.loc["ammonia", sector] = params["MWh_NH3_per_tNH3"]
|
||||
else:
|
||||
df.loc["hydrogen", sector] = config["MWh_H2_per_tNH3_electrolysis"]
|
||||
df.loc["elec", sector] = config["MWh_elec_per_tNH3_electrolysis"]
|
||||
df.loc["hydrogen", sector] = params["MWh_H2_per_tNH3_electrolysis"]
|
||||
df.loc["elec", sector] = params["MWh_elec_per_tNH3_electrolysis"]
|
||||
|
||||
# Chlorine
|
||||
|
||||
sector = "Chlorine"
|
||||
df[sector] = 0.0
|
||||
df.loc["hydrogen", sector] = config["MWh_H2_per_tCl"]
|
||||
df.loc["elec", sector] = config["MWh_elec_per_tCl"]
|
||||
df.loc["hydrogen", sector] = params["MWh_H2_per_tCl"]
|
||||
df.loc["elec", sector] = params["MWh_elec_per_tCl"]
|
||||
|
||||
# Methanol
|
||||
|
||||
sector = "Methanol"
|
||||
df[sector] = 0.0
|
||||
df.loc["methane", sector] = config["MWh_CH4_per_tMeOH"]
|
||||
df.loc["elec", sector] = config["MWh_elec_per_tMeOH"]
|
||||
df.loc["methane", sector] = params["MWh_CH4_per_tMeOH"]
|
||||
df.loc["elec", sector] = params["MWh_elec_per_tMeOH"]
|
||||
|
||||
# Other chemicals
|
||||
|
||||
@ -1465,10 +1465,10 @@ if __name__ == "__main__":
|
||||
|
||||
snakemake = mock_snakemake("build_industry_sector_ratios")
|
||||
|
||||
# TODO make config option
|
||||
# TODO make params option
|
||||
year = 2015
|
||||
|
||||
config = snakemake.params["industry"]
|
||||
params = snakemake.params["industry"]
|
||||
|
||||
df = pd.concat(
|
||||
[
|
||||
|
@ -64,7 +64,7 @@ Inputs
|
||||
- ``resources/offshore_shapes.geojson``: confer :ref:`shapes`
|
||||
- ``resources/regions_onshore.geojson``: (if not offshore wind), confer :ref:`busregions`
|
||||
- ``resources/regions_offshore.geojson``: (if offshore wind), :ref:`busregions`
|
||||
- ``"cutouts/" + config["renewable"][{technology}]['cutout']``: :ref:`cutout`
|
||||
- ``"cutouts/" + params["renewable"][{technology}]['cutout']``: :ref:`cutout`
|
||||
- ``networks/base.nc``: :ref:`base`
|
||||
|
||||
Outputs
|
||||
@ -204,14 +204,14 @@ if __name__ == "__main__":
|
||||
|
||||
nprocesses = int(snakemake.threads)
|
||||
noprogress = snakemake.config["run"].get("disable_progressbar", True)
|
||||
config = snakemake.params["renewable"][snakemake.wildcards.technology]
|
||||
resource = config["resource"] # pv panel config / wind turbine config
|
||||
correction_factor = config.get("correction_factor", 1.0)
|
||||
capacity_per_sqkm = config["capacity_per_sqkm"]
|
||||
p_nom_max_meth = config.get("potential", "conservative")
|
||||
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"]
|
||||
p_nom_max_meth = params.get("potential", "conservative")
|
||||
|
||||
if isinstance(config.get("corine", {}), list):
|
||||
config["corine"] = {"grid_codes": config["corine"]}
|
||||
if isinstance(params.get("corine", {}), list):
|
||||
params["corine"] = {"grid_codes": params["corine"]}
|
||||
|
||||
if correction_factor != 1.0:
|
||||
logger.info(f"correction_factor is set as {correction_factor}")
|
||||
@ -229,13 +229,13 @@ if __name__ == "__main__":
|
||||
regions = regions.set_index("name").rename_axis("bus")
|
||||
buses = regions.index
|
||||
|
||||
res = config.get("excluder_resolution", 100)
|
||||
res = params.get("excluder_resolution", 100)
|
||||
excluder = atlite.ExclusionContainer(crs=3035, res=res)
|
||||
|
||||
if config["natura"]:
|
||||
if params["natura"]:
|
||||
excluder.add_raster(snakemake.input.natura, nodata=0, allow_no_overlap=True)
|
||||
|
||||
corine = config.get("corine", {})
|
||||
corine = params.get("corine", {})
|
||||
if "grid_codes" in corine:
|
||||
codes = corine["grid_codes"]
|
||||
excluder.add_raster(snakemake.input.corine, codes=codes, invert=True, crs=3035)
|
||||
@ -246,28 +246,28 @@ if __name__ == "__main__":
|
||||
snakemake.input.corine, codes=codes, buffer=buffer, crs=3035
|
||||
)
|
||||
|
||||
if "ship_threshold" in config:
|
||||
if "ship_threshold" in params:
|
||||
shipping_threshold = (
|
||||
config["ship_threshold"] * 8760 * 6
|
||||
params["ship_threshold"] * 8760 * 6
|
||||
) # approximation because 6 years of data which is hourly collected
|
||||
func = functools.partial(np.less, shipping_threshold)
|
||||
excluder.add_raster(
|
||||
snakemake.input.ship_density, codes=func, crs=4326, allow_no_overlap=True
|
||||
)
|
||||
|
||||
if config.get("max_depth"):
|
||||
if params.get("max_depth"):
|
||||
# lambda not supported for atlite + multiprocessing
|
||||
# use named function np.greater with partially frozen argument instead
|
||||
# and exclude areas where: -max_depth > grid cell depth
|
||||
func = functools.partial(np.greater, -config["max_depth"])
|
||||
func = functools.partial(np.greater, -params["max_depth"])
|
||||
excluder.add_raster(snakemake.input.gebco, codes=func, crs=4326, nodata=-1000)
|
||||
|
||||
if "min_shore_distance" in config:
|
||||
buffer = config["min_shore_distance"]
|
||||
if "min_shore_distance" in params:
|
||||
buffer = params["min_shore_distance"]
|
||||
excluder.add_geometry(snakemake.input.country_shapes, buffer=buffer)
|
||||
|
||||
if "max_shore_distance" in config:
|
||||
buffer = config["max_shore_distance"]
|
||||
if "max_shore_distance" in params:
|
||||
buffer = params["max_shore_distance"]
|
||||
excluder.add_geometry(
|
||||
snakemake.input.country_shapes, buffer=buffer, invert=True
|
||||
)
|
||||
@ -309,7 +309,7 @@ if __name__ == "__main__":
|
||||
p_nom_max = capacities / max_cap_factor
|
||||
else:
|
||||
raise AssertionError(
|
||||
'Config key `potential` should be one of "simple" '
|
||||
'params key `potential` should be one of "simple" '
|
||||
f'(default) or "conservative", not "{p_nom_max_meth}"'
|
||||
)
|
||||
|
||||
@ -358,13 +358,13 @@ if __name__ == "__main__":
|
||||
# select only buses with some capacity and minimal capacity factor
|
||||
ds = ds.sel(
|
||||
bus=(
|
||||
(ds["profile"].mean("time") > config.get("min_p_max_pu", 0.0))
|
||||
& (ds["p_nom_max"] > config.get("min_p_nom_max", 0.0))
|
||||
(ds["profile"].mean("time") > params.get("min_p_max_pu", 0.0))
|
||||
& (ds["p_nom_max"] > params.get("min_p_nom_max", 0.0))
|
||||
)
|
||||
)
|
||||
|
||||
if "clip_p_max_pu" in config:
|
||||
min_p_max_pu = config["clip_p_max_pu"]
|
||||
if "clip_p_max_pu" in params:
|
||||
min_p_max_pu = params["clip_p_max_pu"]
|
||||
ds["profile"] = ds["profile"].where(ds["profile"] >= min_p_max_pu, 0)
|
||||
|
||||
ds.to_netcdf(snakemake.output.profile)
|
||||
|
@ -727,7 +727,7 @@ def cycling_shift(df, steps=1):
|
||||
return df
|
||||
|
||||
|
||||
def prepare_costs(cost_file, config, nyears):
|
||||
def prepare_costs(cost_file, params, nyears):
|
||||
# set all asset costs and other parameters
|
||||
costs = pd.read_csv(cost_file, index_col=[0, 1]).sort_index()
|
||||
|
||||
@ -739,7 +739,7 @@ def prepare_costs(cost_file, config, nyears):
|
||||
costs.loc[:, "value"].unstack(level=1).groupby("technology").sum(min_count=1)
|
||||
)
|
||||
|
||||
costs = costs.fillna(config["fill_values"])
|
||||
costs = costs.fillna(params["fill_values"])
|
||||
|
||||
def annuity_factor(v):
|
||||
return annuity(v["lifetime"], v["discount rate"]) + v["FOM"] / 100
|
||||
|
Loading…
Reference in New Issue
Block a user