Skip to content

Commit

Permalink
Merge pull request #447 from rl-institut/release/v0.17.0
Browse files Browse the repository at this point in the history
Release v0.17.0
  • Loading branch information
henhuy authored Jul 17, 2020
2 parents c3c148b + 2120e57 commit 67d9c81
Show file tree
Hide file tree
Showing 117 changed files with 2,905 additions and 2,697 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project tries to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.17.0] - 2020-07-17
### Changed
- bus fleet distance is calculated dynamically from project start

## [0.16.0] - 2020-07-15
### Added
- answered questions of finished category can be re-seen
Expand Down
2 changes: 1 addition & 1 deletion e_metrobus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.16.0"
__version__ = "0.17.0"
__version_info__ = tuple(
[
int(num) if num.isdigit() else num
Expand Down
18 changes: 12 additions & 6 deletions e_metrobus/navigation/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,21 @@ def get_sizes(max_value):
return Sizes(*map(lambda x: x / 50 * max_value, [MARGIN, OFFSET, SIZE, TEXTSIZE]))


def get_mobility_figure(values, title):
def get_mobility_figure(values, title, e_asterisk=False):
rounding = get_rounding(max(values))
if rounding == 0:
rounded_values = [int(v) for v in values]
else:
rounded_values = [round(v, rounding) for v in values]
separated_values = [set_separators(v) for v in rounded_values]
# add asterisk to E-Pkw and E-bus for information
if e_asterisk:
separated_values[1] = separated_values[1] + "<sup>*</sup>"
separated_values[2] = separated_values[2] + "<sup>*</sup>"
scaled_values = [
(v + min(rounded_values)) / max(rounded_values) * 100 for v in rounded_values
]

colors = [DEFAULT_COLOR] * 5
colors[1] = E_BUS_COLOR
mobiles = [
Expand All @@ -59,17 +68,14 @@ def get_mobility_figure(values, title):
_("Dieselbus"),
_("Pkw (Diesel)"),
]
scaled_values = [
(v + min(rounded_values)) / max(rounded_values) * 100 for v in rounded_values
]
max_value = max(scaled_values)
sizes = get_sizes(max_value)

bar = go.Bar(
x=mobiles,
y=scaled_values,
marker_color=colors,
text=[set_separators(v) for v in rounded_values],
text=separated_values,
textposition="outside",
width=0.6,
)
Expand Down Expand Up @@ -137,7 +143,7 @@ def get_mobility_figure(values, title):

def get_co2_figure(values):
title = _("CO<sub>2</sub> Emissionen [in g]<br>nach Verkehrsmittel")
return get_mobility_figure(values, title)
return get_mobility_figure(values, title, e_asterisk=True)


def get_nitrogen_figure(values):
Expand Down
20 changes: 14 additions & 6 deletions e_metrobus/navigation/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import math
import datetime as dt
from collections import namedtuple
from dataclasses import dataclass, fields

Expand All @@ -12,9 +13,14 @@
"Consumption", ["distance", "co2", "nitrogen", "fine_dust"]
)

FLEET_CONSUMPTION = Consumption(
distance=3000, co2=300000, nitrogen=20000, fine_dust=10000
)
FLEET_START_DATE = dt.date(2020, 8, 12)
FLEET_DISTANCE_PER_DAY = 2800


def get_fleet_distance():
days = (dt.date.today() - FLEET_START_DATE).days + 1
distance = FLEET_DISTANCE_PER_DAY * days
return max(distance, FLEET_DISTANCE_PER_DAY)


class Ellipse:
Expand Down Expand Up @@ -64,12 +70,12 @@ class Vehicle:
Vehicle(
name="car",
label=_("PKW (Diesel)"),
data=DataPerKilometer(co2=147, nitrogen=0.43, fine_dust=0.004),
data=DataPerKilometer(co2=147, nitrogen=0.43, fine_dust=0.007),
),
Vehicle(
name="bus",
label=_("Dieselbus"),
data=DataPerKilometer(co2=80, nitrogen=0.32, fine_dust=0.003),
data=DataPerKilometer(co2=80, nitrogen=0.32, fine_dust=0.005),
),
Vehicle(name="e-pkw", label=_("Elektro-PKW"), data=DataPerKilometer(53, 0, 0),),
Vehicle(name="e-bus", label=_("Elektrobus"), data=DataPerKilometer(42, 0, 0),),
Expand All @@ -78,8 +84,10 @@ class Vehicle:
]

DATA_SOURCES = [
'Umweltbundesamt, "Vergleich der durchschnittlichen Emissionen einzelner Verkehrsmittel im Personenverkehr in Deutschland - Bezugsjahr 2018", 01/2020',
'Umweltbundesamt, "Vergleich der durchschnittlichen Emissionen einzelner Verkehrsmittel im Personenverkehr in Deutschland - Bezugsjahr 2018", 01/2020, TREMOD 6.03',
'Umweltbundesamt, "Entwicklung der spezifischen Kohlendioxid-Emissionen des deutschen Strommix in den Jahren 1990 - 2019", 13/2020',
_("Annahmen zum Energieverbrauch der E-PKWs und E-Busse: Reiner Lemoine Institut"),
_("Annahmen zur Personenzahl eines Linienbusses: BVG")
]

POSTHOG_EVENTS = ("shared", "sources", "english")
Expand Down
2 changes: 1 addition & 1 deletion e_metrobus/navigation/questions.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
label = "Vorteile"
question = "Was sind Vorteile einer elektrifizierten Buslinie?"
answers = "Weniger CO<sub>2</sub>-Belastung", "Weniger Lärmbelastung", "Kürzere Fahrzeiten", "Günstigere Fahrkarten", "Keine Belastung durch Stickoxide und Feinstaub"
correct = 0, 1
correct = 0, 1, 4
short_answer = "Elektrobusse tragen zu einer lebenswerteren Stadt bei, weil sie lokal emissionsfrei sind und somit keine Stickoxide oder Feinstaub durch den Kraftstoffeinsatz ausstoßen. Auch verursachen Elektrobusse weniger CO<sub>2</sub>-Emissionen im Vergleich zu Dieselbussen. "
[[[footprint]]]
label = "Wahl des Verkehrsmittels"
Expand Down
4 changes: 2 additions & 2 deletions e_metrobus/navigation/stations.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas
from django.conf import settings

from e_metrobus.navigation.constants import DataPerKilometer, VEHICLES, FLEET_CONSUMPTION
from e_metrobus.navigation.constants import DataPerKilometer, VEHICLES, get_fleet_distance

STATIONS_FILE = os.path.join(settings.APPS_DIR, "navigation", "stations.csv")

Expand Down Expand Up @@ -42,7 +42,7 @@ def get_route_data(
}

def get_fleet_data(self):
distance = FLEET_CONSUMPTION.distance
distance = get_fleet_distance()
return {
vehicle.name: self.__calc_route_data(distance, vehicle)
for vehicle in VEHICLES
Expand Down
5 changes: 4 additions & 1 deletion e_metrobus/navigation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ def posthog_event(request, event=None):
data["session_id"] = request.session.session_key
data["version"] = __version__
if event is None:
event = request.path
event = request.get_host() + request.path
else:
if event not in constants.POSTHOG_EVENTS:
raise ValueError("Not a valid posthog event!")
else:
event = f"{request.get_host()}/{event}/"
data["event"] = event
posthog.capture(
request.session.session_key, event, properties=data,
)
Expand Down
3 changes: 2 additions & 1 deletion e_metrobus/navigation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def get_context_data(self, **kwargs):
for emission in ("co2", "nitrogen", "fine_dust")
]
context["route_distance"] = stations.STATIONS.get_distance(*current_stations)
context["fleet_distance"] = constants.FLEET_CONSUMPTION.distance
context["fleet_distance"] = utils.set_separators(constants.get_fleet_distance())
context["fleet_start"] = constants.FLEET_START_DATE
return context


Expand Down
Binary file removed e_metrobus/static/images/Emetrobus_LP_img.png
Binary file not shown.
Binary file removed e_metrobus/static/images/HP_hero_device.png
Binary file not shown.
Binary file removed e_metrobus/static/images/LP_Device_v2.png
Binary file not shown.
Binary file removed e_metrobus/static/images/RLi_logo.png
Binary file not shown.
125 changes: 124 additions & 1 deletion e_metrobus/static/images/Route_dotted_line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 67d9c81

Please sign in to comment.