Skip to content

Commit

Permalink
Merge pull request #101 from empowerplan/feature/result_charts1
Browse files Browse the repository at this point in the history
Pre-result charts for PV and wind
  • Loading branch information
nesnoj authored May 2, 2024
2 parents 0e4fc9a + ff800bd commit 89df9c5
Show file tree
Hide file tree
Showing 20 changed files with 735 additions and 1,275 deletions.
28 changes: 0 additions & 28 deletions digiplan/map/calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,34 +304,6 @@ def heat_demand_per_municipality_2045(user_settings: dict) -> pd.DataFrame:
return demand.iloc[:] * shares


def ghg_reduction(simulation_id: int) -> pd.Series:
"""
Calculate data for GHG reduction chart from simulation ID.
Parameters
----------
simulation_id: int
Simulation ID to calculate results from
Returns
-------
pandas.Series
holding data for GHG reduction chart
"""
renewables = renewable_electricity_production(simulation_id).sum()

results = get_results(
simulation_id,
{
"electricity_production": electricity_production,
},
)
electricity_import = results["electricity_production"].loc[["ABW-electricity-import"]]
electricity_import.index = electricity_import.index.get_level_values(0)
electricity_import["ABW-renewables"] = renewables
return electricity_import * 1e-3


def electricity_from_from_biomass(simulation_id: int) -> pd.Series:
"""
Calculate electricity from biomass.
Expand Down
36 changes: 0 additions & 36 deletions digiplan/map/charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,6 @@ def render(self) -> dict: # noqa: D102
return self.chart_options


class GHGReductionChart(SimulationChart):
"""GHG Reduction Chart. Shows greenhouse gas emissions."""

lookup = "ghg_reduction"

def get_chart_data(self): # noqa: D102, ANN201
return calculations.get_reduction(simulation_id=self.simulation_id)

def render(self) -> dict: # noqa: D102
# Enter import and energy from renewables
for i, item in enumerate(self.chart_options["series"][7:9]):
item["data"][1] = self.chart_data[i]
# Calculate emission offset
summed_emissions_2019 = sum(item["data"][0] for item in self.chart_options["series"][:7])
self.chart_options["series"][0]["data"][1] = summed_emissions_2019 - sum(self.chart_data)
return self.chart_options


class ElectricityOverviewChart(SimulationChart):
"""Chart for electricity overview."""

Expand Down Expand Up @@ -285,23 +267,6 @@ def get_chart_data(self): # noqa: D102, ANN201
return calculations.heat_overview(simulation_id=self.simulation_id, distribution="decentral")


class GhgHistoryChart(SimulationChart):
"""GHG history chart."""

lookup = "ghg_history"

def get_chart_data(self): # noqa: D102, ANN201
# TODO(Hendrik): Get static data from digipipe datapackage # noqa: TD003
return pd.DataFrame()

def render(self) -> dict: # noqa: D102
for item in self.chart_options["series"]:
profile = config.SIMULATION_NAME_MAPPING[item["name"]]
item["data"][1] = self.chart_data[profile]

return self.chart_options


class PopulationRegionChart(Chart):
"""Chart for regional population."""

Expand Down Expand Up @@ -976,7 +941,6 @@ def get_chart_options(self) -> dict:

CHARTS: dict[str, Union[type[PreResultsChart], type[SimulationChart]]] = {
"detailed_overview": DetailedOverviewChart,
"ghg_reduction": GHGReductionChart,
"electricity_overview": ElectricityOverviewChart,
"electricity_autarky": ElectricityAutarkyChart,
"heat_decentralized": HeatStructureDecentralChart,
Expand Down
6 changes: 1 addition & 5 deletions digiplan/map/charts/electricity_autarky.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
{
"brush": {
"toolbox": ["rect", "polygon", "lineX", "lineY", "keep", "clear"],
"xAxisIndex": 0
},
"grid": {
"bottom": "25%"
},
Expand All @@ -20,7 +16,7 @@
},
"yAxis": {
"type": "category",
"data": ["Dein Szenario", "2022"],
"data": ["Dein Szenario", "2023"],
"axisTick": {
"show": false
}
Expand Down
35 changes: 11 additions & 24 deletions digiplan/map/charts/electricity_overview.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
{
"brush": {
"toolbox": ["rect", "polygon", "lineX", "lineY", "keep", "clear"],
"xAxisIndex": 0
},
"toolbox": {
"feature": {
"magicType": {
"type": ["stack"]
},
"dataView": {}
}
},
"tooltip": {},
"grid": {
"top": "10%",
"left": "3%",
Expand All @@ -20,7 +7,7 @@
"containLabel": true
},
"yAxis": {
"data": ["Ziel 2045", "Dein Szenario", "2022"],
"data": ["Ziel Brandenburg 2040", "Ziel Brandenburg 2030", "Dein Szenario", "2023"],
"axisLine": { "onZero": true },
"splitLine": { "show": false },
"splitArea": { "show": false }
Expand Down Expand Up @@ -49,7 +36,7 @@
"shadowColor": "rgba(0,0,0,0.3)"
}
},
"data": [0, 0, 0]
"data": [0, 0, 0, 0]
},
{
"name": "Freiflächen-PV",
Expand All @@ -62,7 +49,7 @@
"shadowColor": "rgba(0,0,0,0.3)"
}
},
"data": [0, 0, 0]
"data": [0, 0, 0, 0]
},
{
"name": "Aufdach-PV",
Expand All @@ -75,7 +62,7 @@
"shadowColor": "rgba(0,0,0,0.3)"
}
},
"data": [0, 0, 0]
"data": [0, 0, 0, 0]
},
{
"name": "Bioenergie",
Expand All @@ -88,7 +75,7 @@
"shadowColor": "rgba(0,0,0,0.3)"
}
},
"data": [0, 0, 0]
"data": [0, 0, 0, 0]
},
{
"name": "Wasserkraft",
Expand All @@ -102,7 +89,7 @@
"shadowColor": "rgba(0,0,0,0.3)"
}
},
"data": [0, 0, 0]
"data": [0, 0, 0, 0]
},
{
"name": "Verbrauch Haushalte",
Expand All @@ -116,7 +103,7 @@
"shadowColor": "rgba(0,0,0,0.3)"
}
},
"data": [0, 0, 0]
"data": [0, 0, 0, 0]
},
{
"name": "Verbrauch GHD",
Expand All @@ -129,7 +116,7 @@
"shadowColor": "rgba(0,0,0,0.3)"
}
},
"data": [0, 0, 0]
"data": [0, 0, 0, 0]
},
{
"name": "Verbrauch Industrie",
Expand All @@ -143,7 +130,7 @@
"shadowColor": "rgba(0,0,0,0.3)"
}
},
"data": [0, 0, 0]
"data": [0, 0, 0, 0]
},
{
"name": "Import*",
Expand All @@ -157,7 +144,7 @@
"shadowColor": "rgba(0,0,0,0.3)"
}
},
"data": [0, 0, 0]
"data": [0, 0, 0, 0]
},
{
"name": "Export*",
Expand All @@ -171,7 +158,7 @@
"shadowColor": "rgba(0,0,0,0.3)"
}
},
"data": [0, 0, 0]
"data": [0, 0, 0, 0]
}
]
}
Loading

0 comments on commit 89df9c5

Please sign in to comment.