eflips-depot 4.15.0__py3-none-any.whl → 4.15.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- eflips/depot/api/private/consumption.py +46 -23
- eflips/depot/api/private/util.py +18 -6
- {eflips_depot-4.15.0.dist-info → eflips_depot-4.15.1.dist-info}/METADATA +1 -1
- {eflips_depot-4.15.0.dist-info → eflips_depot-4.15.1.dist-info}/RECORD +6 -6
- {eflips_depot-4.15.0.dist-info → eflips_depot-4.15.1.dist-info}/WHEEL +0 -0
- {eflips_depot-4.15.0.dist-info → eflips_depot-4.15.1.dist-info}/licenses/LICENSE.md +0 -0
|
@@ -286,20 +286,6 @@ def extract_trip_information(
|
|
|
286
286
|
)
|
|
287
287
|
.one()
|
|
288
288
|
)
|
|
289
|
-
# Check exactly one of the vehicle classes has a consumption LUT
|
|
290
|
-
all_consumption_luts = [
|
|
291
|
-
vehicle_class.consumption_lut
|
|
292
|
-
for vehicle_class in trip.rotation.vehicle_type.vehicle_classes
|
|
293
|
-
]
|
|
294
|
-
all_consumption_luts = [x for x in all_consumption_luts if x is not None]
|
|
295
|
-
if len(all_consumption_luts) != 1:
|
|
296
|
-
raise ValueError(
|
|
297
|
-
f"Expected exactly one consumption LUT, got {len(all_consumption_luts)}"
|
|
298
|
-
)
|
|
299
|
-
consumption_lut = all_consumption_luts[0]
|
|
300
|
-
# Disconnect the consumption LUT from the session to avoid loading the whole table
|
|
301
|
-
|
|
302
|
-
del all_consumption_luts
|
|
303
289
|
|
|
304
290
|
total_distance = trip.route.distance / 1000 # km
|
|
305
291
|
total_duration = (
|
|
@@ -307,6 +293,13 @@ def extract_trip_information(
|
|
|
307
293
|
).total_seconds() / 3600
|
|
308
294
|
average_speed = total_distance / total_duration # km/h
|
|
309
295
|
|
|
296
|
+
# Check exactly one of the vehicle classes has a consumption LUT
|
|
297
|
+
all_consumption_luts = [
|
|
298
|
+
vehicle_class.consumption_lut
|
|
299
|
+
for vehicle_class in trip.rotation.vehicle_type.vehicle_classes
|
|
300
|
+
]
|
|
301
|
+
all_consumption_luts = [x for x in all_consumption_luts if x is not None]
|
|
302
|
+
|
|
310
303
|
temperature = temperature_for_trip(trip_id, session)
|
|
311
304
|
|
|
312
305
|
payload_mass = passenger_mass * passenger_count
|
|
@@ -324,16 +317,46 @@ def extract_trip_information(
|
|
|
324
317
|
)
|
|
325
318
|
level_of_loading = payload_mass / full_payload
|
|
326
319
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
320
|
+
if len(all_consumption_luts) == 1:
|
|
321
|
+
consumption_lut = all_consumption_luts[0]
|
|
322
|
+
# Disconnect the consumption LUT from the session to avoid loading the whole table
|
|
323
|
+
|
|
324
|
+
del all_consumption_luts
|
|
325
|
+
|
|
326
|
+
info = ConsumptionInformation(
|
|
327
|
+
trip_id=trip.id,
|
|
328
|
+
consumption_lut=consumption_lut,
|
|
329
|
+
average_speed=average_speed,
|
|
330
|
+
distance=total_distance,
|
|
331
|
+
temperature=temperature,
|
|
332
|
+
level_of_loading=level_of_loading,
|
|
333
|
+
)
|
|
334
|
+
info.calculate()
|
|
335
|
+
elif len(all_consumption_luts) == 0:
|
|
336
|
+
warnings.warn(
|
|
337
|
+
f"No consumption LUT found for vehicle type {trip.rotation.vehicle_type}.",
|
|
338
|
+
ConsistencyWarning,
|
|
339
|
+
)
|
|
340
|
+
# Here, we fill out the condumption information without the LUT and LUT data, but with `consumption_per_km`
|
|
341
|
+
# set to the vehicle's `consumption` value.
|
|
342
|
+
assert (
|
|
343
|
+
VehicleType.consumption is not None
|
|
344
|
+
), f"Vehicle type {trip.rotation.vehicle_type} must have a consumption value set if no consumption LUT is available."
|
|
345
|
+
info = ConsumptionInformation(
|
|
346
|
+
trip_id=trip.id,
|
|
347
|
+
average_speed=average_speed,
|
|
348
|
+
distance=total_distance,
|
|
349
|
+
consumption_per_km=trip.rotation.vehicle_type.consumption,
|
|
350
|
+
consumption=trip.rotation.vehicle_type.consumption * total_distance,
|
|
351
|
+
consumption_lut=None,
|
|
352
|
+
temperature=temperature,
|
|
353
|
+
level_of_loading=level_of_loading,
|
|
354
|
+
)
|
|
355
|
+
else:
|
|
356
|
+
raise ValueError(
|
|
357
|
+
f"Expected exactly one consumption LUT, got {len(all_consumption_luts)}"
|
|
358
|
+
)
|
|
335
359
|
|
|
336
|
-
info.calculate()
|
|
337
360
|
return info
|
|
338
361
|
|
|
339
362
|
|
eflips/depot/api/private/util.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""This module contains miscellaneous utility functions for the eflips-depot API."""
|
|
2
2
|
import logging
|
|
3
3
|
import os
|
|
4
|
+
import warnings
|
|
4
5
|
from contextlib import contextmanager
|
|
5
6
|
from dataclasses import dataclass
|
|
6
7
|
from datetime import timedelta, datetime
|
|
@@ -17,9 +18,11 @@ from eflips.model import (
|
|
|
17
18
|
Trip,
|
|
18
19
|
Depot,
|
|
19
20
|
Temperatures,
|
|
21
|
+
ConsistencyWarning,
|
|
20
22
|
)
|
|
21
23
|
from eflips.model import create_engine
|
|
22
24
|
from sqlalchemy import inspect
|
|
25
|
+
from sqlalchemy.exc import NoResultFound
|
|
23
26
|
from sqlalchemy.orm import Session
|
|
24
27
|
|
|
25
28
|
from eflips.depot import SimpleTrip, Timetable as EflipsTimeTable
|
|
@@ -204,7 +207,9 @@ def check_depot_validity(depot: Depot) -> None:
|
|
|
204
207
|
|
|
205
208
|
def temperature_for_trip(trip_id: int, session: Session) -> float:
|
|
206
209
|
"""
|
|
207
|
-
Returns the temperature for a trip.
|
|
210
|
+
Returns the temperature for a trip.
|
|
211
|
+
|
|
212
|
+
Finds the temperature for the mid-point of the trip.
|
|
208
213
|
|
|
209
214
|
:param trip_id: The ID of the trip
|
|
210
215
|
:param session: The SQLAlchemy session
|
|
@@ -212,11 +217,18 @@ def temperature_for_trip(trip_id: int, session: Session) -> float:
|
|
|
212
217
|
"""
|
|
213
218
|
|
|
214
219
|
trip = session.query(Trip).filter(Trip.id == trip_id).one()
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
+
try:
|
|
221
|
+
temperatures = (
|
|
222
|
+
session.query(Temperatures)
|
|
223
|
+
.filter(Temperatures.scenario_id == trip.scenario_id)
|
|
224
|
+
.one()
|
|
225
|
+
)
|
|
226
|
+
except NoResultFound:
|
|
227
|
+
warnings.warn(
|
|
228
|
+
f"No temperatures found for scenario {trip.scenario_id}.",
|
|
229
|
+
ConsistencyWarning,
|
|
230
|
+
)
|
|
231
|
+
return None
|
|
220
232
|
|
|
221
233
|
# Find the mid-point of the trip
|
|
222
234
|
mid_time = trip.departure_time + (trip.arrival_time - trip.departure_time) / 2
|
|
@@ -2,10 +2,10 @@ eflips/depot/__init__.py,sha256=FCVnYU7aSfR4BNCo722I1V3uU5336qr1tTt-zT6X4UI,1555
|
|
|
2
2
|
eflips/depot/api/__init__.py,sha256=nq5aHGTOIpDmvDfcGMlCH_jd97E0VZ28KVcT3XTwpbE,67539
|
|
3
3
|
eflips/depot/api/defaults/default_settings.json,sha256=0eUDTw_rtLQFvthP8oJL93iRXlmAOravAg-4qqGMQAY,5375
|
|
4
4
|
eflips/depot/api/private/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
eflips/depot/api/private/consumption.py,sha256=
|
|
5
|
+
eflips/depot/api/private/consumption.py,sha256=494u6FelymWfI-Yt3ybJpLHUL-6zEqBOT2qSrPhRmMo,30038
|
|
6
6
|
eflips/depot/api/private/depot.py,sha256=Vx6mC5YynyQ5hEw9QeXAi84VSaYc3qVJAqE2dSfHGJI,59655
|
|
7
7
|
eflips/depot/api/private/results_to_database.py,sha256=-8qXk8lRsMElm9pke6MWzCNUQKtrd59n4Ye2X8Ojw-M,29814
|
|
8
|
-
eflips/depot/api/private/util.py,sha256=
|
|
8
|
+
eflips/depot/api/private/util.py,sha256=rZzyfEYYhF55f6QkiXjwMvJkg98KeHx8XN4Z1OwtSU8,18287
|
|
9
9
|
eflips/depot/configuration.py,sha256=Op3hlir-dEN7yHr0kTqbYANoCBKFWK6uKOv3NJl8w_w,35678
|
|
10
10
|
eflips/depot/depot.py,sha256=5NBw5bvOP2cplkRGZbKbG3SOA23F2Kw-UsabHubocPU,107555
|
|
11
11
|
eflips/depot/evaluation.py,sha256=qqXyP4jA1zFcKuWhliQ6n25ZlGl9mJV-vtXf0yu8WN8,140842
|
|
@@ -36,7 +36,7 @@ eflips/depot/simulation.py,sha256=ee0qTzOzG-8ybN36ie_NJallXfC7jUaS9JZvaYFziLs,10
|
|
|
36
36
|
eflips/depot/smart_charging.py,sha256=C3BYqzn2-OYY4ipXm0ETtavbAM9QXZMYULBpVoChf0E,54311
|
|
37
37
|
eflips/depot/standalone.py,sha256=8O01zEXghFG9zZBu0fUD0sXvbHQ-AXw6RB5M750a_sM,22419
|
|
38
38
|
eflips/depot/validation.py,sha256=TIuY7cQtEJI4H2VVMSuY5IIVkacEEZ67weeMuY3NSAM,7097
|
|
39
|
-
eflips_depot-4.15.
|
|
40
|
-
eflips_depot-4.15.
|
|
41
|
-
eflips_depot-4.15.
|
|
42
|
-
eflips_depot-4.15.
|
|
39
|
+
eflips_depot-4.15.1.dist-info/METADATA,sha256=K-X0YzOgpwV6fXCxQxDZP9h_uKiOVMZMKdPz2uu2c_k,5961
|
|
40
|
+
eflips_depot-4.15.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
41
|
+
eflips_depot-4.15.1.dist-info/licenses/LICENSE.md,sha256=KB4XTk1fPHjtZCYDyPyreu6h1LVJVZXYg-5vePcWZAc,34143
|
|
42
|
+
eflips_depot-4.15.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|