build_heat_totals: use more years for regression
This commit is contained in:
parent
cbeb9834ac
commit
8aa4b5b558
@ -15,17 +15,22 @@ idx = pd.IndexSlice
|
|||||||
|
|
||||||
|
|
||||||
def approximate_heat_demand(energy_totals, hdd):
|
def approximate_heat_demand(energy_totals, hdd):
|
||||||
if isinstance(hdd, str):
|
|
||||||
hdd = pd.read_csv(hdd, index_col=0).T
|
countries = hdd.columns
|
||||||
hdd.index = hdd.index.astype(int)
|
|
||||||
|
|
||||||
demands = {}
|
demands = {}
|
||||||
|
|
||||||
for kind, sector in product(["total", "electricity"], ["services", "residential"]):
|
for kind, sector in product(["total", "electricity"], ["services", "residential"]):
|
||||||
row = idx[:, 2007:2015]
|
# reduced number years (2007-2021) for regression because it implicitly
|
||||||
|
# assumes a constant building stock
|
||||||
|
row = idx[:, 2007:2021]
|
||||||
col = f"{kind} {sector} space"
|
col = f"{kind} {sector} space"
|
||||||
demand = energy_totals.loc[row, col].unstack(0)
|
demand = energy_totals.loc[row, col].unstack(0)
|
||||||
|
|
||||||
|
# ffill for GB in 2020- and bfill for CH 2007-2009
|
||||||
|
# compromise to have more years available for the fit
|
||||||
|
demand = demand.ffill(axis=0).bfill(axis=0)
|
||||||
|
|
||||||
demand_approx = {}
|
demand_approx = {}
|
||||||
|
|
||||||
for c in countries:
|
for c in countries:
|
||||||
@ -62,16 +67,15 @@ def approximate_heat_demand(energy_totals, hdd):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if "snakemake" not in globals():
|
if "snakemake" not in globals():
|
||||||
from helper import mock_snakemake
|
from _helpers import mock_snakemake
|
||||||
|
|
||||||
snakemake = mock_snakemake("build_energy_totals")
|
snakemake = mock_snakemake("build_heat_totals")
|
||||||
|
|
||||||
hdd = pd.read_csv(snakemake.input.hdd, index_col=0).T
|
hdd = pd.read_csv(snakemake.input.hdd, index_col=0).T
|
||||||
|
hdd.index = hdd.index.astype(int)
|
||||||
|
|
||||||
energy_totals = pd.read_csv(snakemake.input.energy_totals, index_col=[0, 1])
|
energy_totals = pd.read_csv(snakemake.input.energy_totals, index_col=[0, 1])
|
||||||
|
|
||||||
countries = hdd.columns
|
|
||||||
|
|
||||||
heat_demand = approximate_heat_demand(energy_totals, hdd)
|
heat_demand = approximate_heat_demand(energy_totals, hdd)
|
||||||
|
|
||||||
heat_demand.to_csv(snakemake.output.heat_totals)
|
heat_demand.to_csv(snakemake.output.heat_totals)
|
||||||
|
Loading…
Reference in New Issue
Block a user