From e8761c9e24fc34583e9a53bb0b7f9b8484d70121 Mon Sep 17 00:00:00 2001 From: toniseibold Date: Mon, 25 Mar 2024 15:03:23 +0100 Subject: [PATCH 1/4] overwriting agriculture and transport totals --- scripts/build_energy_totals.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/build_energy_totals.py b/scripts/build_energy_totals.py index b56d3294..fcba5b4d 100644 --- a/scripts/build_energy_totals.py +++ b/scripts/build_energy_totals.py @@ -842,7 +842,7 @@ def rescale_idees_from_eurostat( "total": [ "total agriculture heat", "total agriculture machinery", - "total agriculture", + "total agriculture", # = sum of all other agriculture categories ], "elec": [ "total agriculture electricity", @@ -850,7 +850,7 @@ def rescale_idees_from_eurostat( }, "Road": { "total": [ - "total road", + "total road", # = sum of all other road categories "total passenger cars", "total other road passenger", "total light duty road freight", @@ -891,6 +891,7 @@ def rescale_idees_from_eurostat( navigation = [ "total domestic navigation", ] + # international navigation is already read in from the eurostat data directly for country in idees_countries: filling_years = [(2015, slice(2016, 2021)), (2000, slice(1990, 1999))] @@ -940,6 +941,17 @@ def rescale_idees_from_eurostat( energy.loc[slicer_source, navigation].squeeze(axis=0), ).values + # set the total of agriculture/road to the sum of all agriculture/road categories (corresponding to the IDEES data) + energy.loc[country, "total agriculture"] = energy.loc[country, ["total agriculture electricity", "total agriculture heat", "total agriculture machinery"]].sum(axis=1) + + energy.loc[country, :]["total road"] = energy[["total passenger cars", + "total other road passenger", + "total light duty road freight", + "electricity road", + "electricity passenger cars", + "electricity other road passenger", + "electricity light duty road freight"]].loc[country, :].sum(axis=1) + return energy From dda0c98b2833adb21424cdfd57d9af81774eadf4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:05:17 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/build_energy_totals.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/scripts/build_energy_totals.py b/scripts/build_energy_totals.py index fcba5b4d..5bcd2695 100644 --- a/scripts/build_energy_totals.py +++ b/scripts/build_energy_totals.py @@ -842,7 +842,7 @@ def rescale_idees_from_eurostat( "total": [ "total agriculture heat", "total agriculture machinery", - "total agriculture", # = sum of all other agriculture categories + "total agriculture", # = sum of all other agriculture categories ], "elec": [ "total agriculture electricity", @@ -850,7 +850,7 @@ def rescale_idees_from_eurostat( }, "Road": { "total": [ - "total road", # = sum of all other road categories + "total road", # = sum of all other road categories "total passenger cars", "total other road passenger", "total light duty road freight", @@ -942,15 +942,30 @@ def rescale_idees_from_eurostat( ).values # set the total of agriculture/road to the sum of all agriculture/road categories (corresponding to the IDEES data) - energy.loc[country, "total agriculture"] = energy.loc[country, ["total agriculture electricity", "total agriculture heat", "total agriculture machinery"]].sum(axis=1) + energy.loc[country, "total agriculture"] = energy.loc[ + country, + [ + "total agriculture electricity", + "total agriculture heat", + "total agriculture machinery", + ], + ].sum(axis=1) - energy.loc[country, :]["total road"] = energy[["total passenger cars", + energy.loc[country, :]["total road"] = ( + energy[ + [ + "total passenger cars", "total other road passenger", "total light duty road freight", "electricity road", "electricity passenger cars", "electricity other road passenger", - "electricity light duty road freight"]].loc[country, :].sum(axis=1) + "electricity light duty road freight", + ] + ] + .loc[country, :] + .sum(axis=1) + ) return energy From d09df8a4733de899de6de7b361b0ebcec9b0c1a8 Mon Sep 17 00:00:00 2001 From: toniseibold Date: Tue, 26 Mar 2024 20:56:11 +0100 Subject: [PATCH 3/4] bug fix --- scripts/build_energy_totals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build_energy_totals.py b/scripts/build_energy_totals.py index 5bcd2695..2f4f29b6 100644 --- a/scripts/build_energy_totals.py +++ b/scripts/build_energy_totals.py @@ -951,7 +951,7 @@ def rescale_idees_from_eurostat( ], ].sum(axis=1) - energy.loc[country, :]["total road"] = ( + energy.loc[country, "total road"] = ( energy[ [ "total passenger cars", From f25c594a07d21ea207421dd35b168707b7342433 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Mon, 20 May 2024 15:37:54 +0200 Subject: [PATCH 4/4] bugfix: include total heavy-duty road freight; do not treat total transport as other but including electricity --- scripts/build_energy_totals.py | 37 +++++++++++++--------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/scripts/build_energy_totals.py b/scripts/build_energy_totals.py index 2f4f29b6..f40d7e1a 100644 --- a/scripts/build_energy_totals.py +++ b/scripts/build_energy_totals.py @@ -842,7 +842,7 @@ def rescale_idees_from_eurostat( "total": [ "total agriculture heat", "total agriculture machinery", - "total agriculture", # = sum of all other agriculture categories + "total agriculture", ], "elec": [ "total agriculture electricity", @@ -850,10 +850,11 @@ def rescale_idees_from_eurostat( }, "Road": { "total": [ - "total road", # = sum of all other road categories + "total road", "total passenger cars", "total other road passenger", "total light duty road freight", + "total heavy duty road freight", ], "elec": [ "electricity road", @@ -941,31 +942,21 @@ def rescale_idees_from_eurostat( energy.loc[slicer_source, navigation].squeeze(axis=0), ).values - # set the total of agriculture/road to the sum of all agriculture/road categories (corresponding to the IDEES data) - energy.loc[country, "total agriculture"] = energy.loc[ - country, - [ + # set the total of agriculture/road to the sum of all agriculture/road categories (corresponding to the IDEES data) + sel = [ "total agriculture electricity", "total agriculture heat", "total agriculture machinery", - ], - ].sum(axis=1) - - energy.loc[country, "total road"] = ( - energy[ - [ - "total passenger cars", - "total other road passenger", - "total light duty road freight", - "electricity road", - "electricity passenger cars", - "electricity other road passenger", - "electricity light duty road freight", - ] ] - .loc[country, :] - .sum(axis=1) - ) + energy.loc[country, "total agriculture"] = energy.loc[country, sel].sum(axis=1) + + sel = [ + "total passenger cars", + "total other road passenger", + "total light duty road freight", + "total heavy duty road freight", + ] + energy.loc[country, "total road"] = energy.loc[country, sel].sum(axis=1) return energy