[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
861054961a
commit
5465d8cc75
@ -420,7 +420,8 @@ def add_power_capacities_installed_before_baseyear(n, grouping_years, costs, bas
|
||||
|
||||
def get_efficiency(heat_system, carrier, nodes, heating_efficiencies, costs):
|
||||
"""
|
||||
Computes the heating system efficiency based on the sector and carrier type.
|
||||
Computes the heating system efficiency based on the sector and carrier
|
||||
type.
|
||||
|
||||
Parameters:
|
||||
-----------
|
||||
@ -445,7 +446,7 @@ def get_efficiency(heat_system, carrier, nodes, heating_efficiencies, costs):
|
||||
- For residential and services sectors, efficiency is mapped based on the nodes.
|
||||
- For other sectors, the default boiler efficiency is retrieved from the `costs` database.
|
||||
"""
|
||||
|
||||
|
||||
if heat_system.sector.value == "residential":
|
||||
key = f"{carrier} residential space efficiency"
|
||||
efficiency = nodes.str[:2].map(heating_efficiencies[key])
|
||||
@ -458,6 +459,7 @@ def get_efficiency(heat_system, carrier, nodes, heating_efficiencies, costs):
|
||||
|
||||
return efficiency
|
||||
|
||||
|
||||
def add_heating_capacities_installed_before_baseyear(
|
||||
n: pypsa.Network,
|
||||
baseyear: int,
|
||||
@ -586,8 +588,9 @@ def add_heating_capacities_installed_before_baseyear(
|
||||
lifetime=costs.at[heat_system.resistive_heater_costs_name, "lifetime"],
|
||||
)
|
||||
|
||||
efficiency = get_efficiency(heat_system, "gas", nodes,
|
||||
heating_efficiencies, costs)
|
||||
efficiency = get_efficiency(
|
||||
heat_system, "gas", nodes, heating_efficiencies, costs
|
||||
)
|
||||
|
||||
n.madd(
|
||||
"Link",
|
||||
@ -612,8 +615,9 @@ def add_heating_capacities_installed_before_baseyear(
|
||||
lifetime=costs.at[heat_system.gas_boiler_costs_name, "lifetime"],
|
||||
)
|
||||
|
||||
efficiency = get_efficiency(heat_system, "oil", nodes,
|
||||
heating_efficiencies, costs)
|
||||
efficiency = get_efficiency(
|
||||
heat_system, "oil", nodes, heating_efficiencies, costs
|
||||
)
|
||||
|
||||
n.madd(
|
||||
"Link",
|
||||
@ -708,7 +712,7 @@ if __name__ == "__main__":
|
||||
|
||||
# one could use baseyear here instead (but dangerous if no data)
|
||||
heating_efficiencies = (
|
||||
pd.read_csv(snakemake.input.heating_efficiencies, index_col=[1,0])
|
||||
pd.read_csv(snakemake.input.heating_efficiencies, index_col=[1, 0])
|
||||
).loc[int(snakemake.config["energy"]["energy_totals_year"])]
|
||||
|
||||
add_heating_capacities_installed_before_baseyear(
|
||||
|
@ -612,9 +612,11 @@ def build_idees(countries: List[str]) -> pd.DataFrame:
|
||||
# efficiency kgoe/100km -> ktoe/100km so that after conversion TWh/100km
|
||||
totals.loc[:, "passenger car efficiency"] /= 1e6
|
||||
# convert ktoe to TWh
|
||||
exclude = totals.columns.str.fullmatch("passenger cars") \
|
||||
^ totals.columns.str.fullmatch(".*space efficiency") \
|
||||
exclude = (
|
||||
totals.columns.str.fullmatch("passenger cars")
|
||||
^ totals.columns.str.fullmatch(".*space efficiency")
|
||||
^ totals.columns.str.fullmatch(".*water efficiency")
|
||||
)
|
||||
totals = totals.copy()
|
||||
totals.loc[:, ~exclude] *= 11.63 / 1e3
|
||||
|
||||
@ -696,11 +698,11 @@ def build_energy_totals(
|
||||
[countries, eurostat_years], names=["country", "year"]
|
||||
)
|
||||
|
||||
to_drop = idees.columns[idees.columns.str.contains("space efficiency")
|
||||
^ idees.columns.str.contains("water efficiency")]
|
||||
to_drop = to_drop.append(pd.Index(
|
||||
["passenger cars", "passenger car efficiency"]
|
||||
))
|
||||
to_drop = idees.columns[
|
||||
idees.columns.str.contains("space efficiency")
|
||||
^ idees.columns.str.contains("water efficiency")
|
||||
]
|
||||
to_drop = to_drop.append(pd.Index(["passenger cars", "passenger car efficiency"]))
|
||||
|
||||
df = idees.reindex(new_index).drop(to_drop, axis=1)
|
||||
|
||||
@ -1543,6 +1545,7 @@ def build_transformation_output_coke(eurostat, fn):
|
||||
df = eurostat.loc[slicer, :].droplevel(level=[2, 3, 4, 5])
|
||||
df.to_csv(fn)
|
||||
|
||||
|
||||
def build_heating_efficiencies(
|
||||
countries: List[str], idees: pd.DataFrame
|
||||
) -> pd.DataFrame:
|
||||
@ -1569,8 +1572,10 @@ def build_heating_efficiencies(
|
||||
|
||||
years = np.arange(2000, 2022)
|
||||
|
||||
cols = idees.columns[idees.columns.str.contains("space efficiency")
|
||||
^ idees.columns.str.contains("water efficiency")]
|
||||
cols = idees.columns[
|
||||
idees.columns.str.contains("space efficiency")
|
||||
^ idees.columns.str.contains("water efficiency")
|
||||
]
|
||||
|
||||
logger.info(cols)
|
||||
|
||||
@ -1595,6 +1600,7 @@ def build_heating_efficiencies(
|
||||
|
||||
return heating_efficiencies
|
||||
|
||||
|
||||
# %%
|
||||
if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
|
@ -1806,14 +1806,14 @@ def build_heat_demand(n):
|
||||
for sector, use in product(sectors, uses):
|
||||
name = f"{sector} {use}"
|
||||
|
||||
#efficiency for final energy to thermal energy service
|
||||
# efficiency for final energy to thermal energy service
|
||||
eff = pop_weighted_energy_totals.index.str[:2].map(
|
||||
heating_efficiencies[f"total {sector} {use} efficiency"]
|
||||
)
|
||||
)
|
||||
|
||||
heat_demand[name] = (
|
||||
heat_demand_shape[name] / heat_demand_shape[name].sum()
|
||||
).multiply(pop_weighted_energy_totals[f"total {sector} {use}"]*eff) * 1e6
|
||||
).multiply(pop_weighted_energy_totals[f"total {sector} {use}"] * eff) * 1e6
|
||||
electric_heat_supply[name] = (
|
||||
heat_demand_shape[name] / heat_demand_shape[name].sum()
|
||||
).multiply(pop_weighted_energy_totals[f"electricity {sector} {use}"]) * 1e6
|
||||
@ -4288,8 +4288,10 @@ if __name__ == "__main__":
|
||||
pop_weighted_energy_totals.update(pop_weighted_heat_totals)
|
||||
|
||||
heating_efficiencies = (
|
||||
pd.read_csv(snakemake.input.heating_efficiencies, index_col=[0,1])
|
||||
).swaplevel().loc[int(snakemake.config["energy"]["energy_totals_year"])]
|
||||
(pd.read_csv(snakemake.input.heating_efficiencies, index_col=[0, 1]))
|
||||
.swaplevel()
|
||||
.loc[int(snakemake.config["energy"]["energy_totals_year"])]
|
||||
)
|
||||
|
||||
patch_electricity_network(n)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user