ChaProEV 1.2.0__tar.gz → 1.2.1__tar.gz

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.
Files changed (96) hide show
  1. {chaproev-1.2.0/src/ChaProEV.egg-info → chaproev-1.2.1}/PKG-INFO +1 -1
  2. {chaproev-1.2.0 → chaproev-1.2.1}/pyproject.toml +1 -1
  3. chaproev-1.2.1/src/ChaProEV/ChaProEV.py +148 -0
  4. chaproev-1.2.0/src/ChaProEV/ChaProEV.py → chaproev-1.2.1/src/ChaProEV/profiles.py +6 -329
  5. chaproev-1.2.1/src/ChaProEV/scenarios_module.py +232 -0
  6. {chaproev-1.2.0 → chaproev-1.2.1/src/ChaProEV.egg-info}/PKG-INFO +1 -1
  7. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV.egg-info/SOURCES.txt +2 -0
  8. {chaproev-1.2.0 → chaproev-1.2.1}/.flake8 +0 -0
  9. {chaproev-1.2.0 → chaproev-1.2.1}/.gitignore +0 -0
  10. {chaproev-1.2.0 → chaproev-1.2.1}/.vscode/ltex.dictionary.en-US.txt +0 -0
  11. {chaproev-1.2.0 → chaproev-1.2.1}/.vscode/settings.json +0 -0
  12. {chaproev-1.2.0 → chaproev-1.2.1}/ChaProEV.pptx +0 -0
  13. {chaproev-1.2.0 → chaproev-1.2.1}/ChaProEV.toml +0 -0
  14. {chaproev-1.2.0 → chaproev-1.2.1}/Gemfile +0 -0
  15. {chaproev-1.2.0 → chaproev-1.2.1}/LICENCE +0 -0
  16. {chaproev-1.2.0 → chaproev-1.2.1}/MOPO_logo_chaproev on wht.svg +0 -0
  17. {chaproev-1.2.0 → chaproev-1.2.1}/MOPO_logo_chaproev.png +0 -0
  18. {chaproev-1.2.0 → chaproev-1.2.1}/MOPO_logo_chaproev.svg +0 -0
  19. {chaproev-1.2.0 → chaproev-1.2.1}/MOPO_logo_main.svg +0 -0
  20. {chaproev-1.2.0 → chaproev-1.2.1}/MOPO_logo_main_onwhite.svg +0 -0
  21. {chaproev-1.2.0 → chaproev-1.2.1}/README.md +0 -0
  22. {chaproev-1.2.0 → chaproev-1.2.1}/comparisons/comparison_template.toml +0 -0
  23. {chaproev-1.2.0 → chaproev-1.2.1}/docs/ChaProEV_workflow.png +0 -0
  24. {chaproev-1.2.0 → chaproev-1.2.1}/docs/Legs.png +0 -0
  25. {chaproev-1.2.0 → chaproev-1.2.1}/docs/Locations.png +0 -0
  26. {chaproev-1.2.0 → chaproev-1.2.1}/docs/Makefile +0 -0
  27. {chaproev-1.2.0 → chaproev-1.2.1}/docs/README.md +0 -0
  28. {chaproev-1.2.0 → chaproev-1.2.1}/docs/Trips.png +0 -0
  29. {chaproev-1.2.0 → chaproev-1.2.1}/docs/Vehicle_Temperature_correction_factor.svg +0 -0
  30. {chaproev-1.2.0 → chaproev-1.2.1}/docs/_config.yml +0 -0
  31. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/doctrees/environment.pickle +0 -0
  32. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/doctrees/index.doctree +0 -0
  33. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/.buildinfo +0 -0
  34. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/_sources/index.rst.txt +0 -0
  35. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/_static/alabaster.css +0 -0
  36. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/_static/basic.css +0 -0
  37. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/_static/custom.css +0 -0
  38. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/_static/doctools.js +0 -0
  39. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/_static/documentation_options.js +0 -0
  40. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/_static/file.png +0 -0
  41. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/_static/language_data.js +0 -0
  42. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/_static/minus.png +0 -0
  43. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/_static/plus.png +0 -0
  44. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/_static/pygments.css +0 -0
  45. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/_static/searchtools.js +0 -0
  46. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/_static/sphinx_highlight.js +0 -0
  47. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/genindex.html +0 -0
  48. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/index.html +0 -0
  49. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/objects.inv +0 -0
  50. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/search.html +0 -0
  51. {chaproev-1.2.0 → chaproev-1.2.1}/docs/build/html/searchindex.js +0 -0
  52. {chaproev-1.2.0 → chaproev-1.2.1}/docs/charging.md +0 -0
  53. {chaproev-1.2.0 → chaproev-1.2.1}/docs/consumption.md +0 -0
  54. {chaproev-1.2.0 → chaproev-1.2.1}/docs/define.md +0 -0
  55. {chaproev-1.2.0 → chaproev-1.2.1}/docs/index.md +0 -0
  56. {chaproev-1.2.0 → chaproev-1.2.1}/docs/make.bat +0 -0
  57. {chaproev-1.2.0 → chaproev-1.2.1}/docs/mobility.md +0 -0
  58. {chaproev-1.2.0 → chaproev-1.2.1}/docs/running_model,md +0 -0
  59. {chaproev-1.2.0 → chaproev-1.2.1}/docs/scenario.md +0 -0
  60. {chaproev-1.2.0 → chaproev-1.2.1}/docs/source/index.rst +0 -0
  61. {chaproev-1.2.0 → chaproev-1.2.1}/docs/using.md +0 -0
  62. {chaproev-1.2.0 → chaproev-1.2.1}/docs/weather.md +0 -0
  63. {chaproev-1.2.0 → chaproev-1.2.1}/eu-emblem-low-res.jpg +0 -0
  64. {chaproev-1.2.0 → chaproev-1.2.1}/mkdocs.yml +0 -0
  65. {chaproev-1.2.0 → chaproev-1.2.1}/requirements.txt +0 -0
  66. {chaproev-1.2.0 → chaproev-1.2.1}/scenarios/Mopo/XX_bus.toml +0 -0
  67. {chaproev-1.2.0 → chaproev-1.2.1}/scenarios/Mopo/XX_car.toml +0 -0
  68. {chaproev-1.2.0 → chaproev-1.2.1}/scenarios/Mopo/XX_truck.toml +0 -0
  69. {chaproev-1.2.0 → chaproev-1.2.1}/scenarios/Mopo/XX_van.toml +0 -0
  70. {chaproev-1.2.0 → chaproev-1.2.1}/scenarios/local_impact_BEVs/baseline.toml +0 -0
  71. {chaproev-1.2.0 → chaproev-1.2.1}/setup.cfg +0 -0
  72. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV/__init__.py +0 -0
  73. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV/charging.py +0 -0
  74. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV/consumption.py +0 -0
  75. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV/define.py +0 -0
  76. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV/make_variants.py +0 -0
  77. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV/mobility.py +0 -0
  78. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV/py.typed +0 -0
  79. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV/run_time.py +0 -0
  80. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV/weather.py +0 -0
  81. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV/writing.py +0 -0
  82. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV.egg-info/PKG-INFO-PC-28624 +0 -0
  83. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV.egg-info/PKG-INFO-PC-28624-2 +0 -0
  84. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV.egg-info/SOURCES-PC-28624-2.txt +0 -0
  85. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV.egg-info/SOURCES-PC-28624.txt +0 -0
  86. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV.egg-info/dependency_links.txt +0 -0
  87. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV.egg-info/requires-PC-28624-2.txt +0 -0
  88. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV.egg-info/requires-PC-28624.txt +0 -0
  89. {chaproev-1.2.0 → chaproev-1.2.1}/src/ChaProEV.egg-info/top_level.txt +0 -0
  90. {chaproev-1.2.0 → chaproev-1.2.1}/tests/test_battery_space.py +0 -0
  91. {chaproev-1.2.0 → chaproev-1.2.1}/tests/test_charge_and_consumption.py +0 -0
  92. {chaproev-1.2.0 → chaproev-1.2.1}/tests/test_empty_values.py +0 -0
  93. {chaproev-1.2.0 → chaproev-1.2.1}/tests/test_same_output.py +0 -0
  94. {chaproev-1.2.0 → chaproev-1.2.1}/todo.txt +0 -0
  95. {chaproev-1.2.0 → chaproev-1.2.1}/variants/Mopo/XX_car.csv +0 -0
  96. {chaproev-1.2.0 → chaproev-1.2.1}/variants/Mopo.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ChaProEV
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: ChaProEV: Charging Profiles of Electric Vehicles
5
5
  Author-email: Omar Usmani <Omar.Usmani@TNO.nl>
6
6
  Project-URL: Homepage, https://github.com/TNO/ChaProEV
@@ -4,7 +4,7 @@ build-backend = 'setuptools.build_meta'
4
4
 
5
5
  [project]
6
6
  name = 'ChaProEV'
7
- version = '1.2.0'
7
+ version = '1.2.1'
8
8
  authors = [
9
9
  { name='Omar Usmani', email='Omar.Usmani@TNO.nl' },
10
10
  ]
@@ -0,0 +1,148 @@
1
+ '''
2
+ Author: Omar Usmani (Omar.Usmani@TNO.nl)
3
+ This is where you run the model
4
+ '''
5
+
6
+ import typing as ty
7
+ from itertools import repeat
8
+ from multiprocessing import Pool
9
+
10
+ import tqdm
11
+ from box import Box
12
+ from ETS_CookBook import ETS_CookBook as cook
13
+
14
+ try:
15
+ import writing # type: ignore
16
+
17
+ # We need to ignore the type because mypy has its own search path for
18
+ # imports and does not resolve imports exactly as Python does and it
19
+ # isn't able to find the module.
20
+ # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
21
+ except ModuleNotFoundError:
22
+ from ChaProEV import writing # type: ignore
23
+ # So that it works both as a standalone (1st) and as a package (2nd)
24
+ # We need to add to type: ignore thing to avoid MypY thinking
25
+ # we are importing again
26
+
27
+
28
+ try:
29
+ import make_variants # type: ignore
30
+
31
+ # We need to ignore the type because mypy has its own search path for
32
+ # imports and does not resolve imports exactly as Python does and it
33
+ # isn't able to find the module.
34
+ # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
35
+ except ModuleNotFoundError:
36
+ from ChaProEV import make_variants # type: ignore
37
+ # So that it works both as a standalone (1st) and as a package (2nd)
38
+ # We need to add to type: ignore thing to avoid MypY thinking
39
+ # we are importing again
40
+
41
+
42
+ try:
43
+ import profiles # type: ignore
44
+
45
+ # We need to ignore the type because mypy has its own search path for
46
+ # imports and does not resolve imports exactly as Python does and it
47
+ # isn't able to find the module.
48
+ # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
49
+ except ModuleNotFoundError:
50
+ from ChaProEV import profiles # type: ignore
51
+ # So that it works both as a standalone (1st) and as a package (2nd)
52
+ # We need to add to type: ignore thing to avoid MypY thinking
53
+ # we are importing again
54
+
55
+ try:
56
+ import scenarios_module # type: ignore
57
+
58
+ # We need to ignore the type because mypy has its own search path for
59
+ # imports and does not resolve imports exactly as Python does and it
60
+ # isn't able to find the module.
61
+ # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
62
+ except ModuleNotFoundError:
63
+ from ChaProEV import scenarios_module # type: ignore
64
+ # So that it works both as a standalone (1st) and as a package (2nd)
65
+ # We need to add to type: ignore thing to avoid MypY thinking
66
+ # we are importing again
67
+
68
+
69
+ @cook.function_timer
70
+ def run_ChaProEV(case_name: str) -> None:
71
+ general_parameters_file_name: str = 'ChaProEV.toml'
72
+ general_parameters: Box = Box(
73
+ cook.parameters_from_TOML(general_parameters_file_name)
74
+ )
75
+ output_root: str = general_parameters.files.output_root
76
+ cook.check_if_folder_exists(f'{output_root}/{case_name}')
77
+ variant_parameters: Box = general_parameters.variants
78
+ use_variants: bool = variant_parameters.use_variants
79
+ if use_variants:
80
+ csv_version: bool = variant_parameters.csv_version
81
+ make_variants.make_variants(case_name, csv_version)
82
+
83
+ scenarios: ty.List[Box] = scenarios_module.load_scenarios(case_name)
84
+
85
+ set_amount_of_processes: bool = (
86
+ general_parameters.parallel_processing.set_amount_of_processes
87
+ )
88
+ if set_amount_of_processes:
89
+ amount_of_parallel_processes: int | None = None
90
+ else:
91
+ amount_of_parallel_processes = (
92
+ general_parameters.parallel_processing.amount_for_scenarios
93
+ )
94
+
95
+ pool_inputs: ty.Iterator[ty.Tuple[Box, str, Box]] | ty.Any = zip(
96
+ scenarios, repeat(case_name), repeat(general_parameters)
97
+ )
98
+ # the ty.Any alternative is there because transforming it with the
99
+ # progress bar makes mypy think it change is type
100
+ progress_bars_parameters: Box = general_parameters.progress_bars
101
+ display_scenario_run: bool = progress_bars_parameters.display_scenario_run
102
+ scenario_run_description: str = (
103
+ progress_bars_parameters.scenario_run_description
104
+ )
105
+ if display_scenario_run:
106
+ pool_inputs = tqdm.tqdm(
107
+ pool_inputs,
108
+ desc=scenario_run_description,
109
+ total=len(scenarios),
110
+ )
111
+
112
+ with Pool(amount_of_parallel_processes) as scenarios_pool:
113
+ scenarios_pool.starmap(scenarios_module.run_scenario, pool_inputs)
114
+
115
+ do_car_home_type_split: bool = (
116
+ general_parameters.home_type.do_car_home_type_split
117
+ )
118
+ if do_car_home_type_split:
119
+ profiles.car_home_parking(case_name, general_parameters)
120
+
121
+ writing.extra_end_outputs(case_name, general_parameters)
122
+
123
+
124
+ if __name__ == '__main__':
125
+ # This is a case name, which is the grouping of all your scenarios.
126
+ # This is principally used to label your output files.
127
+ case_name = 'Mopo'
128
+
129
+ run_ChaProEV(case_name)
130
+
131
+ # print('Add sessions into next day')
132
+ # print('Iterate through sessions and send remainder to next session')
133
+ # print('Compute session first pass')
134
+ # print('Do a second compute with passthrough')
135
+ # print('Convert session-basec charge to profile')
136
+ # print('Have parameter that shifts within a session?')
137
+ # print('Do kilometers/consumption split for sessions?')
138
+ # print('Do effetive session end andthen a match between the approaches')
139
+ # print('Make profile DF (with all) from sessions version')
140
+ # print('Make fleet version')
141
+ # print('Compare profiles')
142
+ # Add actual stop time (if using full power)
143
+ # Then infer profiles
144
+ # DO this in a sperate DF that will be used to compare
145
+ # COnnectivity: does the groupneed to be smaller?
146
+ # Also somehow include legs from before that did not charge because
147
+ # of connectivity
148
+ # Base profile is spread according to partial arrivals.
@@ -1,98 +1,13 @@
1
1
  '''
2
2
  Author: Omar Usmani (Omar.Usmani@TNO.nl)
3
- This is where you run the model
3
+ Functions for profiles and car splits
4
4
  '''
5
5
 
6
- import datetime
7
- import os
8
6
  import typing as ty
9
- from itertools import repeat
10
- from multiprocessing import Pool
11
7
 
12
8
  import numpy as np
13
9
  import pandas as pd
14
- import tqdm
15
10
  from box import Box
16
- from ETS_CookBook import ETS_CookBook as cook
17
-
18
- try:
19
- import define # type: ignore
20
-
21
- # We need to ignore the type because mypy has its own search path for
22
- # imports and does not resolve imports exactly as Python does and it
23
- # isn't able to find the module.
24
- # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
25
- except ModuleNotFoundError:
26
- from ChaProEV import define # type: ignore
27
- # So that it works both as a standalone (1st) and as a package (2nd)
28
- # We need to add to type: ignore thing to avoid MypY thinking
29
- # we are importing again
30
-
31
- try:
32
- import mobility # type: ignore
33
-
34
- # We need to ignore the type because mypy has its own search path for
35
- # imports and does not resolve imports exactly as Python does and it
36
- # isn't able to find the module.
37
- # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
38
- except ModuleNotFoundError:
39
- from ChaProEV import mobility # type: ignore
40
- # So that it works both as a standalone (1st) and as a package (2nd)
41
- # We need to add to type: ignore thing to avoid MypY thinking
42
- # we are importing again
43
-
44
- try:
45
- import consumption # type: ignore
46
-
47
- # We need to ignore the type because mypy has its own search path for
48
- # imports and does not resolve imports exactly as Python does and it
49
- # isn't able to find the module.
50
- # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
51
- except ModuleNotFoundError:
52
- from ChaProEV import consumption # type: ignore
53
- # So that it works both as a standalone (1st) and as a package (2nd)
54
- # We need to add to type: ignore thing to avoid MypY thinking
55
- # we are importing again
56
- try:
57
- import charging # type: ignore
58
-
59
- # We need to ignore the type because mypy has its own search path for
60
- # imports and does not resolve imports exactly as Python does and it
61
- # isn't able to find the module.
62
- # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
63
- except ModuleNotFoundError:
64
- from ChaProEV import charging # type: ignore
65
- # So that it works both as a standalone (1st) and as a package (2nd)
66
- # We need to add to type: ignore thing to avoid MypY thinking
67
- # we are importing again
68
-
69
- try:
70
- import writing # type: ignore
71
-
72
- # We need to ignore the type because mypy has its own search path for
73
- # imports and does not resolve imports exactly as Python does and it
74
- # isn't able to find the module.
75
- # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
76
- except ModuleNotFoundError:
77
- from ChaProEV import writing # type: ignore
78
- # So that it works both as a standalone (1st) and as a package (2nd)
79
- # We need to add to type: ignore thing to avoid MypY thinking
80
- # we are importing again
81
-
82
-
83
- try:
84
- import make_variants # type: ignore
85
-
86
- # We need to ignore the type because mypy has its own search path for
87
- # imports and does not resolve imports exactly as Python does and it
88
- # isn't able to find the module.
89
- # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
90
- except ModuleNotFoundError:
91
- from ChaProEV import make_variants # type: ignore
92
- # So that it works both as a standalone (1st) and as a package (2nd)
93
- # We need to add to type: ignore thing to avoid MypY thinking
94
- # we are importing again
95
-
96
11
 
97
12
  try:
98
13
  import run_time # type: ignore
@@ -187,7 +102,7 @@ def car_home_parking(case_name: str, general_parameters: Box) -> None:
187
102
  )
188
103
  .reset_index()
189
104
  .set_index(sessions_index)
190
- .astype(float)
105
+ # .astype(float)
191
106
  )
192
107
 
193
108
  on_street_values: pd.DataFrame = (
@@ -196,7 +111,7 @@ def car_home_parking(case_name: str, general_parameters: Box) -> None:
196
111
  )
197
112
  .reset_index()
198
113
  .set_index(profiles_index)
199
- .astype(float)
114
+ # .astype(float)
200
115
  )
201
116
 
202
117
  on_street_values_to_vehicles_from_sessions: pd.DataFrame = (
@@ -206,7 +121,7 @@ def car_home_parking(case_name: str, general_parameters: Box) -> None:
206
121
  )
207
122
  .reset_index()
208
123
  .set_index(profiles_index)
209
- .astype(float)
124
+ # .astype(float)
210
125
  )
211
126
  on_street_values_from_network_from_sessions: pd.DataFrame = (
212
127
  pd.read_pickle(
@@ -215,7 +130,7 @@ def car_home_parking(case_name: str, general_parameters: Box) -> None:
215
130
  )
216
131
  .reset_index()
217
132
  .set_index(profiles_index)
218
- .astype(float)
133
+ # .astype(float)
219
134
  )
220
135
  charging_sessions_on_street_values: pd.DataFrame = pd.DataFrame(
221
136
  pd.read_pickle(
@@ -224,7 +139,7 @@ def car_home_parking(case_name: str, general_parameters: Box) -> None:
224
139
  )
225
140
  .reset_index()
226
141
  .set_index(sessions_index)
227
- .astype(float)
142
+ # .astype(float)
228
143
  )
229
144
 
230
145
  combined_values: pd.DataFrame = pd.DataFrame(
@@ -615,139 +530,6 @@ def make_sessions_display_dataframes(
615
530
  )
616
531
 
617
532
 
618
- @cook.function_timer
619
- def run_scenario(
620
- scenario: Box, case_name: str, general_parameters: Box
621
- ) -> None:
622
- scenario_name: str = scenario.name
623
- print(scenario_name)
624
- location_connections, legs, locations, trips = (
625
- define.declare_all_instances(scenario, case_name, general_parameters)
626
- )
627
-
628
- (
629
- run_mobility_matrix,
630
- location_split,
631
- maximal_delivered_power_per_location,
632
- maximal_delivered_power,
633
- connectivity_per_location,
634
- maximal_received_power_per_location,
635
- vehicle_discharge_power_per_location,
636
- discharge_power_to_network_per_location,
637
- run_next_leg_kilometers,
638
- run_next_leg_kilometers_cumulative,
639
- run_next_leg_charge_from_network,
640
- run_next_leg_charge_to_vehicle,
641
- run_charging_sessions,
642
- run_charging_sessions_dataframe,
643
- ) = mobility.make_mobility_data(
644
- location_connections,
645
- legs,
646
- locations,
647
- trips,
648
- scenario,
649
- case_name,
650
- general_parameters,
651
- )
652
-
653
- consumption_table: pd.DataFrame = consumption.get_consumption_data(
654
- run_mobility_matrix,
655
- run_next_leg_kilometers,
656
- run_next_leg_kilometers_cumulative,
657
- scenario,
658
- case_name,
659
- general_parameters,
660
- )
661
-
662
- produce_sessions: bool = general_parameters.sessions.produce
663
- if produce_sessions:
664
- charging_sessions_with_charged_amounts = (
665
- charging.charging_amounts_in_charging_sessions(
666
- run_charging_sessions_dataframe,
667
- scenario,
668
- general_parameters,
669
- case_name,
670
- )
671
- )
672
-
673
- produce_standard_profiles: bool = (
674
- general_parameters.standard_profiles.produce
675
- )
676
- if produce_standard_profiles:
677
- (
678
- battery_spaces,
679
- total_battery_space_per_location,
680
- charge_drawn_by_vehicles,
681
- charge_drawn_from_network,
682
- charging_costs,
683
- ) = charging.get_charging_profile(
684
- location_split,
685
- run_mobility_matrix,
686
- maximal_delivered_power_per_location,
687
- maximal_delivered_power,
688
- scenario,
689
- case_name,
690
- general_parameters,
691
- )
692
-
693
- profiles_from_sessions: bool = (
694
- general_parameters.sessions.generate_profiles
695
- )
696
- if produce_sessions and profiles_from_sessions:
697
- (
698
- charging_profile_to_vehicle_from_sessions,
699
- charging_profile_from_network_from_sessions,
700
- ) = charging.get_profile_from_sessions(
701
- charging_sessions_with_charged_amounts,
702
- scenario,
703
- general_parameters,
704
- case_name,
705
- )
706
- if produce_standard_profiles:
707
- make_profile_display_dataframe(
708
- location_split,
709
- total_battery_space_per_location,
710
- charge_drawn_from_network,
711
- run_next_leg_charge_from_network,
712
- run_next_leg_charge_to_vehicle,
713
- connectivity_per_location,
714
- maximal_delivered_power_per_location,
715
- maximal_received_power_per_location,
716
- vehicle_discharge_power_per_location,
717
- discharge_power_to_network_per_location,
718
- scenario,
719
- general_parameters,
720
- case_name,
721
- )
722
- if produce_sessions:
723
- make_sessions_display_dataframes(
724
- charging_sessions_with_charged_amounts,
725
- scenario,
726
- general_parameters,
727
- case_name,
728
- )
729
-
730
- do_fleet_tables: bool = (
731
- general_parameters.profile_dataframe.do_fleet_tables
732
- )
733
-
734
- if do_fleet_tables:
735
- fleet_profiles(case_name, scenario_name, general_parameters)
736
-
737
- display_run_totals, display_fleet_run_totals = make_display_totals(
738
- charging_costs,
739
- charge_drawn_from_network,
740
- charge_drawn_by_vehicles,
741
- consumption_table,
742
- scenario,
743
- general_parameters,
744
- case_name,
745
- )
746
- # print(scenario.name)
747
- # print(display_run_totals)
748
- # print(display_fleet_run_totals)
749
-
750
-
751
533
  def make_display_totals(
752
534
  charging_costs: pd.DataFrame,
753
535
  charge_drawn_from_network: pd.DataFrame,
@@ -816,108 +598,3 @@ def make_display_totals(
816
598
  )
817
599
 
818
600
  return display_run_totals, display_fleet_run_totals
819
-
820
-
821
- # @cook.function_timer
822
- def load_scenarios(case_name: str) -> ty.List[Box]:
823
- scenario_folder_files: ty.List[str] = os.listdir(f'scenarios/{case_name}')
824
- scenario_files: ty.List[str] = [
825
- scenario_folder_file
826
- for scenario_folder_file in scenario_folder_files
827
- if scenario_folder_file.split('.')[1] == 'toml'
828
- ]
829
- scenario_file_paths: ty.List[str] = [
830
- f'scenarios/{case_name}/{scenario_file}'
831
- for scenario_file in scenario_files
832
- ]
833
- scenarios: ty.List[Box] = [
834
- Box(cook.parameters_from_TOML(scenario_file_path))
835
- for scenario_file_path in scenario_file_paths
836
- ]
837
- for scenario, scenario_file in zip(scenarios, scenario_files):
838
- scenario.name = scenario_file.split('.')[0]
839
- return scenarios
840
-
841
-
842
- @cook.function_timer
843
- def run_ChaProEV(case_name: str) -> None:
844
- general_parameters_file_name: str = 'ChaProEV.toml'
845
- general_parameters: Box = Box(
846
- cook.parameters_from_TOML(general_parameters_file_name)
847
- )
848
- output_root: str = general_parameters.files.output_root
849
- cook.check_if_folder_exists(f'{output_root}/{case_name}')
850
- variant_parameters: Box = general_parameters.variants
851
- use_variants: bool = variant_parameters.use_variants
852
- if use_variants:
853
- csv_version: bool = variant_parameters.csv_version
854
- make_variants.make_variants(case_name, csv_version)
855
-
856
- scenarios: ty.List[Box] = load_scenarios(case_name)
857
-
858
- set_amount_of_processes: bool = (
859
- general_parameters.parallel_processing.set_amount_of_processes
860
- )
861
- if set_amount_of_processes:
862
- amount_of_parallel_processes: int | None = None
863
- else:
864
- amount_of_parallel_processes = (
865
- general_parameters.parallel_processing.amount_for_scenarios
866
- )
867
-
868
- pool_inputs: ty.Iterator[ty.Tuple[Box, str, Box]] | ty.Any = zip(
869
- scenarios, repeat(case_name), repeat(general_parameters)
870
- )
871
- # the ty.Any alternative is there because transforming it with the
872
- # progress bar makes mypy think it change is type
873
- progress_bars_parameters: Box = general_parameters.progress_bars
874
- display_scenario_run: bool = progress_bars_parameters.display_scenario_run
875
- scenario_run_description: str = (
876
- progress_bars_parameters.scenario_run_description
877
- )
878
- if display_scenario_run:
879
- pool_inputs = tqdm.tqdm(
880
- pool_inputs,
881
- desc=scenario_run_description,
882
- total=len(scenarios),
883
- )
884
-
885
- with Pool(amount_of_parallel_processes) as scenarios_pool:
886
- scenarios_pool.starmap(run_scenario, pool_inputs)
887
-
888
- do_car_home_type_split: bool = (
889
- general_parameters.home_type.do_car_home_type_split
890
- )
891
- if do_car_home_type_split:
892
- car_home_parking(case_name, general_parameters)
893
-
894
- writing.extra_end_outputs(case_name, general_parameters)
895
-
896
-
897
- if __name__ == '__main__':
898
- start_: datetime.datetime = datetime.datetime.now()
899
-
900
- # This is a case name, which is the grouping of all your scenarios.
901
- # This is principally used to label your output files.
902
- case_name = 'Mopo'
903
-
904
- run_ChaProEV(case_name)
905
-
906
- # print('Add sessions into next day')
907
- # print('Iterate through sessions and send remainder to next session')
908
- # print('Compute session first pass')
909
- # print('Do a second compute with passthrough')
910
- # print('Convert session-basec charge to profile')
911
- # print('Have parameter that shifts within a session?')
912
- # print('Do kilometers/consumption split for sessions?')
913
- # print('Do effetive session end andthen a match between the approaches')
914
- # print('Make profile DF (with all) from sessions version')
915
- # print('Make fleet version')
916
- # print('Compare profiles')
917
- # Add actual stop time (if using full power)
918
- # Then infer profiles
919
- # DO this in a sperate DF that will be used to compare
920
- # COnnectivity: does the groupneed to be smaller?
921
- # Also somehow include legs from before that did not charge because
922
- # of connectivity
923
- # Base profile is spread according to partial arrivals.
@@ -0,0 +1,232 @@
1
+ '''
2
+ Author: Omar Usmani (Omar.Usmani@TNO.nl)
3
+ This is where you run the model
4
+ '''
5
+
6
+ import os
7
+ import typing as ty
8
+
9
+ import pandas as pd
10
+ from box import Box
11
+ from ETS_CookBook import ETS_CookBook as cook
12
+
13
+ try:
14
+ import define # type: ignore
15
+
16
+ # We need to ignore the type because mypy has its own search path for
17
+ # imports and does not resolve imports exactly as Python does and it
18
+ # isn't able to find the module.
19
+ # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
20
+ except ModuleNotFoundError:
21
+ from ChaProEV import define # type: ignore
22
+ # So that it works both as a standalone (1st) and as a package (2nd)
23
+ # We need to add to type: ignore thing to avoid MypY thinking
24
+ # we are importing again
25
+
26
+ try:
27
+ import mobility # type: ignore
28
+
29
+ # We need to ignore the type because mypy has its own search path for
30
+ # imports and does not resolve imports exactly as Python does and it
31
+ # isn't able to find the module.
32
+ # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
33
+ except ModuleNotFoundError:
34
+ from ChaProEV import mobility # type: ignore
35
+ # So that it works both as a standalone (1st) and as a package (2nd)
36
+ # We need to add to type: ignore thing to avoid MypY thinking
37
+ # we are importing again
38
+
39
+ try:
40
+ import consumption # type: ignore
41
+
42
+ # We need to ignore the type because mypy has its own search path for
43
+ # imports and does not resolve imports exactly as Python does and it
44
+ # isn't able to find the module.
45
+ # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
46
+ except ModuleNotFoundError:
47
+ from ChaProEV import consumption # type: ignore
48
+ # So that it works both as a standalone (1st) and as a package (2nd)
49
+ # We need to add to type: ignore thing to avoid MypY thinking
50
+ # we are importing again
51
+ try:
52
+ import charging # type: ignore
53
+
54
+ # We need to ignore the type because mypy has its own search path for
55
+ # imports and does not resolve imports exactly as Python does and it
56
+ # isn't able to find the module.
57
+ # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
58
+ except ModuleNotFoundError:
59
+ from ChaProEV import charging # type: ignore
60
+ # So that it works both as a standalone (1st) and as a package (2nd)
61
+ # We need to add to type: ignore thing to avoid MypY thinking
62
+ # we are importing again
63
+
64
+
65
+ try:
66
+ import profiles # type: ignore
67
+
68
+ # We need to ignore the type because mypy has its own search path for
69
+ # imports and does not resolve imports exactly as Python does and it
70
+ # isn't able to find the module.
71
+ # https://stackoverflow.com/questions/68695851/mypy-cannot-find-implementation-or-library-stub-for-module
72
+ except ModuleNotFoundError:
73
+ from ChaProEV import profiles # type: ignore
74
+ # So that it works both as a standalone (1st) and as a package (2nd)
75
+ # We need to add to type: ignore thing to avoid MypY thinking
76
+ # we are importing again
77
+
78
+
79
+ @cook.function_timer
80
+ def run_scenario(
81
+ scenario: Box, case_name: str, general_parameters: Box
82
+ ) -> None:
83
+ scenario_name: str = scenario.name
84
+ print(scenario_name)
85
+ location_connections, legs, locations, trips = (
86
+ define.declare_all_instances(scenario, case_name, general_parameters)
87
+ )
88
+
89
+ (
90
+ run_mobility_matrix,
91
+ location_split,
92
+ maximal_delivered_power_per_location,
93
+ maximal_delivered_power,
94
+ connectivity_per_location,
95
+ maximal_received_power_per_location,
96
+ vehicle_discharge_power_per_location,
97
+ discharge_power_to_network_per_location,
98
+ run_next_leg_kilometers,
99
+ run_next_leg_kilometers_cumulative,
100
+ run_next_leg_charge_from_network,
101
+ run_next_leg_charge_to_vehicle,
102
+ run_charging_sessions,
103
+ run_charging_sessions_dataframe,
104
+ ) = mobility.make_mobility_data(
105
+ location_connections,
106
+ legs,
107
+ locations,
108
+ trips,
109
+ scenario,
110
+ case_name,
111
+ general_parameters,
112
+ )
113
+
114
+ consumption_table: pd.DataFrame = consumption.get_consumption_data(
115
+ run_mobility_matrix,
116
+ run_next_leg_kilometers,
117
+ run_next_leg_kilometers_cumulative,
118
+ scenario,
119
+ case_name,
120
+ general_parameters,
121
+ )
122
+
123
+ produce_sessions: bool = general_parameters.sessions.produce
124
+ if produce_sessions:
125
+ charging_sessions_with_charged_amounts = (
126
+ charging.charging_amounts_in_charging_sessions(
127
+ run_charging_sessions_dataframe,
128
+ scenario,
129
+ general_parameters,
130
+ case_name,
131
+ )
132
+ )
133
+
134
+ produce_standard_profiles: bool = (
135
+ general_parameters.standard_profiles.produce
136
+ )
137
+ if produce_standard_profiles:
138
+ (
139
+ battery_spaces,
140
+ total_battery_space_per_location,
141
+ charge_drawn_by_vehicles,
142
+ charge_drawn_from_network,
143
+ charging_costs,
144
+ ) = charging.get_charging_profile(
145
+ location_split,
146
+ run_mobility_matrix,
147
+ maximal_delivered_power_per_location,
148
+ maximal_delivered_power,
149
+ scenario,
150
+ case_name,
151
+ general_parameters,
152
+ )
153
+
154
+ profiles_from_sessions: bool = (
155
+ general_parameters.sessions.generate_profiles
156
+ )
157
+ if produce_sessions and profiles_from_sessions:
158
+ (
159
+ charging_profile_to_vehicle_from_sessions,
160
+ charging_profile_from_network_from_sessions,
161
+ ) = charging.get_profile_from_sessions(
162
+ charging_sessions_with_charged_amounts,
163
+ scenario,
164
+ general_parameters,
165
+ case_name,
166
+ )
167
+ if produce_standard_profiles:
168
+ profiles.make_profile_display_dataframe(
169
+ location_split,
170
+ total_battery_space_per_location,
171
+ charge_drawn_from_network,
172
+ run_next_leg_charge_from_network,
173
+ run_next_leg_charge_to_vehicle,
174
+ connectivity_per_location,
175
+ maximal_delivered_power_per_location,
176
+ maximal_received_power_per_location,
177
+ vehicle_discharge_power_per_location,
178
+ discharge_power_to_network_per_location,
179
+ scenario,
180
+ general_parameters,
181
+ case_name,
182
+ )
183
+ if produce_sessions:
184
+ profiles.make_sessions_display_dataframes(
185
+ charging_sessions_with_charged_amounts,
186
+ scenario,
187
+ general_parameters,
188
+ case_name,
189
+ )
190
+
191
+ do_fleet_tables: bool = (
192
+ general_parameters.profile_dataframe.do_fleet_tables
193
+ )
194
+
195
+ if do_fleet_tables:
196
+ profiles.fleet_profiles(case_name, scenario_name, general_parameters)
197
+
198
+ display_run_totals, display_fleet_run_totals = (
199
+ profiles.make_display_totals(
200
+ charging_costs,
201
+ charge_drawn_from_network,
202
+ charge_drawn_by_vehicles,
203
+ consumption_table,
204
+ scenario,
205
+ general_parameters,
206
+ case_name,
207
+ )
208
+ )
209
+ # print(scenario.name)
210
+ # print(display_run_totals)
211
+ # print(display_fleet_run_totals)
212
+
213
+
214
+ # @cook.function_timer
215
+ def load_scenarios(case_name: str) -> ty.List[Box]:
216
+ scenario_folder_files: ty.List[str] = os.listdir(f'scenarios/{case_name}')
217
+ scenario_files: ty.List[str] = [
218
+ scenario_folder_file
219
+ for scenario_folder_file in scenario_folder_files
220
+ if scenario_folder_file.split('.')[1] == 'toml'
221
+ ]
222
+ scenario_file_paths: ty.List[str] = [
223
+ f'scenarios/{case_name}/{scenario_file}'
224
+ for scenario_file in scenario_files
225
+ ]
226
+ scenarios: ty.List[Box] = [
227
+ Box(cook.parameters_from_TOML(scenario_file_path))
228
+ for scenario_file_path in scenario_file_paths
229
+ ]
230
+ for scenario, scenario_file in zip(scenarios, scenario_files):
231
+ scenario.name = scenario_file.split('.')[0]
232
+ return scenarios
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ChaProEV
3
- Version: 1.2.0
3
+ Version: 1.2.1
4
4
  Summary: ChaProEV: Charging Profiles of Electric Vehicles
5
5
  Author-email: Omar Usmani <Omar.Usmani@TNO.nl>
6
6
  Project-URL: Homepage, https://github.com/TNO/ChaProEV
@@ -70,8 +70,10 @@ src/ChaProEV/consumption.py
70
70
  src/ChaProEV/define.py
71
71
  src/ChaProEV/make_variants.py
72
72
  src/ChaProEV/mobility.py
73
+ src/ChaProEV/profiles.py
73
74
  src/ChaProEV/py.typed
74
75
  src/ChaProEV/run_time.py
76
+ src/ChaProEV/scenarios_module.py
75
77
  src/ChaProEV/weather.py
76
78
  src/ChaProEV/writing.py
77
79
  src/ChaProEV.egg-info/PKG-INFO
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes