ubc-solar-physics 1.5.0__tar.gz → 1.6.0__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.
- ubc_solar_physics-1.6.0/.gitattributes +1 -0
- ubc_solar_physics-1.6.0/.github/PULL_REQUEST_TEMPLATE.md +24 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/PKG-INFO +1 -1
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/docs_requirements.txt +2 -2
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/source/conf.py +7 -14
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/_version.py +2 -2
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/gis/base_gis.py +14 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/gis/gis.py +34 -0
- ubc_solar_physics-1.6.0/physics/environment/gis/gis.rs +113 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/lib.rs +29 -5
- ubc_solar_physics-1.6.0/tests/gis_tests/test_calculate_driving_speeds.py +70 -0
- ubc_solar_physics-1.6.0/tests/gis_tests/test_gis_driving_speeds.py +322 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/ubc_solar_physics.egg-info/PKG-INFO +1 -1
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/ubc_solar_physics.egg-info/SOURCES.txt +4 -1
- ubc_solar_physics-1.5.0/.github/pull_request_template.md +0 -1
- ubc_solar_physics-1.5.0/physics/environment/gis/gis.rs +0 -25
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/.github/workflows/build_and_publish.yaml +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/.github/workflows/run_tests.yaml +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/.gitignore +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/.readthedocs.yaml +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/Cargo.lock +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/Cargo.toml +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/LICENSE +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/README.md +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/data.png +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/Makefile +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/_generate_version.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/make.bat +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/source/README.md +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/source/api.rst +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/source/environment/gis.rst +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/source/environment/index.rst +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/source/environment/meteorology.rst +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/source/index.rst +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/source/models/arrays.rst +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/source/models/battery.rst +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/source/models/index.rst +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/source/models/lvs.rst +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/source/models/motor.rst +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/docs/source/models/regen.rst +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/battery_model_examples/battery_config.toml +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/battery_model_examples/battery_model_example.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/battery_model_examples/data_py.png +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/battery_model_examples/data_rust.png +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/data_query/current.csv +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/data_query/poetry.lock +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/data_query/pyproject.toml +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/data_query/query_data.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/data_query/voltage.csv +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/kalman_filter_examples/battery_config.toml +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/kalman_filter_examples/current.csv +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/kalman_filter_examples/kalman_filter_example.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/kalman_filter_examples/voltage.csv +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/__init__.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/__init__.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/environment.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/gis/__init__.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/gis.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/meteorology/__init__.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/meteorology/base_meteorology.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/meteorology/clouded_meteorology.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/meteorology/irradiant_meteorology.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/meteorology/meteorology.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/meteorology.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/__init__.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/arrays/__init__.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/arrays/arrays.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/arrays/base_array.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/arrays/basic_array.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/arrays.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/battery/__init__.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/battery/base_battery.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/battery/basic_battery.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/battery/battery.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/battery/battery_config.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/battery/battery_config.toml +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/battery/battery_model.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/battery/kalman_filter.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/battery.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/constants.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/lvs/__init__.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/lvs/base_lvs.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/lvs/basic_lvs.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/lvs/lvs.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/lvs.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/motor/__init__.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/motor/advanced_motor.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/motor/base_motor.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/motor/basic_motor.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/motor/motor.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/motor.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/regen/__init__.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/regen/base_regen.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/regen/basic_regen.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/regen/regen.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/regen.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models.rs +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/pyproject.toml +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/setup.cfg +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/tests/battery_config.toml +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/tests/kalman_filter_tests/current.csv +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/tests/kalman_filter_tests/test_basic_kalman_filter.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/tests/kalman_filter_tests/test_filter_real_data.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/tests/kalman_filter_tests/voltage.csv +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/tests/test_versioning.py +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/ubc_solar_physics.egg-info/dependency_links.txt +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/ubc_solar_physics.egg-info/requires.txt +0 -0
- {ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/ubc_solar_physics.egg-info/top_level.txt +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
**/*.csv linguist-generated=true
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# [FEAT/FIX/DOCS]: Pull Request Name
|
2
|
+
|
3
|
+
- [ ] Linter Check Succeeded
|
4
|
+
- [ ] All Tests Succeeded
|
5
|
+
- [ ] Module Documentation
|
6
|
+
- [ ] Method/Class/Function Documentation
|
7
|
+
- [ ] Documentation Correctly Builds
|
8
|
+
- [x] Pull Request Completed
|
9
|
+
|
10
|
+
## What's New
|
11
|
+
[What has been added?]
|
12
|
+
|
13
|
+
## Bugfixes
|
14
|
+
[Have you added any bug fixes?]
|
15
|
+
|
16
|
+
## Deprecated/Removed
|
17
|
+
[Has anything been removed or deprecated?]
|
18
|
+
|
19
|
+
## Dependencies
|
20
|
+
[Any changes in dependencies?]
|
21
|
+
|
22
|
+
## Notes
|
23
|
+
[Anything else relevant?]
|
24
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ubc-solar-physics
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.6.0
|
4
4
|
Summary: UBC Solar's Simulation Environment
|
5
5
|
Author: Fisher Xue, Mihir Nimgade, Chris Chang, David Widjaja, Justin Hua, Ilya Veksler, Renu Rajamagesh, Ritchie Xia, Erik Langille, Chris Aung, Nicolas Ric, Ishaan Trivedi, Jason Liang, Felix Toft, Mack Wilson, Jonah Lee, Tamzeed Quazi, Joshua Riefman
|
6
6
|
Author-email: UBC Solar <strategy@ubcsolar.com>
|
@@ -38,7 +38,6 @@ rich
|
|
38
38
|
snowballstemmer
|
39
39
|
Sphinx
|
40
40
|
sphinx-autodoc-typehints
|
41
|
-
sphinx-rtd-theme==2.0.0
|
42
41
|
sphinxcontrib-applehelp
|
43
42
|
sphinxcontrib-devhelp
|
44
43
|
sphinxcontrib-htmlhelp
|
@@ -50,4 +49,5 @@ tqdm
|
|
50
49
|
urllib3
|
51
50
|
zipp
|
52
51
|
setuptools_scm
|
53
|
-
pydata-sphinx-theme==0.15.4
|
52
|
+
pydata-sphinx-theme==0.15.4
|
53
|
+
ubc-solar-physics==1.5.0
|
@@ -1,16 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# version_file = Path('physics/_version.py')
|
8
|
-
# version_file.write_text(f"__version__ = '{version}'\n")
|
9
|
-
|
10
|
-
# Dynamically import the version
|
11
|
-
# importlib.invalidate_caches()
|
12
|
-
# physics_module = importlib.import_module("physics")
|
13
|
-
# __version__ = physics_module.__version__
|
1
|
+
import os
|
2
|
+
import sys
|
3
|
+
sys.path.insert(0, os.path.abspath('../../')) # Adjust as necessary
|
4
|
+
print(sys.path)
|
5
|
+
print(os.listdir(os.getcwd()))
|
6
|
+
print(os.listdir(sys.path[0]))
|
14
7
|
|
15
8
|
# Configuration file for the Sphinx documentation builder.
|
16
9
|
#
|
@@ -23,7 +16,7 @@
|
|
23
16
|
project = 'UBC Solar Physics'
|
24
17
|
copyright = '2024, UBC Solar'
|
25
18
|
author = 'Joshua Riefman'
|
26
|
-
release =
|
19
|
+
release = "1.0.0"
|
27
20
|
|
28
21
|
# -- General configuration ---------------------------------------------------
|
29
22
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from abc import ABC, abstractmethod
|
2
2
|
import numpy as np
|
3
|
+
from numpy.typing import ArrayLike, NDArray
|
3
4
|
|
4
5
|
|
5
6
|
class BaseGIS(ABC):
|
@@ -22,3 +23,16 @@ class BaseGIS(ABC):
|
|
22
23
|
@abstractmethod
|
23
24
|
def get_path(self) -> np.ndarray:
|
24
25
|
raise NotImplementedError
|
26
|
+
|
27
|
+
@abstractmethod
|
28
|
+
def calculate_current_heading_array(self) -> np.ndarray:
|
29
|
+
raise NotImplementedError
|
30
|
+
|
31
|
+
def calculate_driving_speeds(
|
32
|
+
self,
|
33
|
+
average_lap_speeds: ArrayLike,
|
34
|
+
simulation_dt: int,
|
35
|
+
driving_allowed: ArrayLike,
|
36
|
+
idle_time: int
|
37
|
+
) -> NDArray[float]:
|
38
|
+
raise NotImplementedError
|
@@ -4,6 +4,7 @@ import core
|
|
4
4
|
import numpy as np
|
5
5
|
import sys
|
6
6
|
|
7
|
+
from numpy.typing import ArrayLike, NDArray
|
7
8
|
from tqdm import tqdm
|
8
9
|
from xml.dom import minidom
|
9
10
|
from haversine import haversine, Unit
|
@@ -82,6 +83,39 @@ class GIS(BaseGIS):
|
|
82
83
|
"""
|
83
84
|
return core.closest_gis_indices_loop(distances, self.path_distances)
|
84
85
|
|
86
|
+
def calculate_driving_speeds(
|
87
|
+
self,
|
88
|
+
average_lap_speeds: ArrayLike,
|
89
|
+
simulation_dt: int,
|
90
|
+
driving_allowed: ArrayLike,
|
91
|
+
idle_time: int
|
92
|
+
) -> NDArray[float]:
|
93
|
+
"""
|
94
|
+
Generate valid driving speeds as a simulation-time array given a set of average speeds for each
|
95
|
+
simulated lap.
|
96
|
+
Driving speeds will only be non-zero when we are allowed to drive, and the speed
|
97
|
+
for every tick during a lap will be that lap's corresponding desired average speed for as long
|
98
|
+
as it takes to complete the lap.
|
99
|
+
|
100
|
+
:param average_lap_speeds: An array of average speeds in m/s, one for each simulated lap.
|
101
|
+
If there are more speeds given than laps available, the unused speeds will be silently ignored.
|
102
|
+
If there are too few, an error will be returned.
|
103
|
+
:param simulation_dt: The simulated tick length.
|
104
|
+
:param driving_allowed: A simulation-time boolean where the `True` elements are when we
|
105
|
+
are allowed to drive, and `False` is when we are not. Requires that (at least) the first element is
|
106
|
+
`False` due to the race beginning in the morning before we are allowed to drive.
|
107
|
+
:param idle_time: The length of time to pause driving upon processing a "0m/s" average speed.
|
108
|
+
:return: A simulation-time array of driving speeds in m/s, or an error if there weren't enough
|
109
|
+
laps provided to fill the entire simulation time.
|
110
|
+
"""
|
111
|
+
return core.get_driving_speeds(
|
112
|
+
np.array(average_lap_speeds).astype(np.float64),
|
113
|
+
simulation_dt,
|
114
|
+
np.array(driving_allowed).astype(bool),
|
115
|
+
self.path_length,
|
116
|
+
idle_time
|
117
|
+
)
|
118
|
+
|
85
119
|
@staticmethod
|
86
120
|
def _python_calculate_closest_gis_indices(distances, path_distances):
|
87
121
|
"""
|
@@ -0,0 +1,113 @@
|
|
1
|
+
use numpy::ndarray::{ArrayViewD, ArrayView1};
|
2
|
+
|
3
|
+
pub fn rust_closest_gis_indices_loop(
|
4
|
+
distances: ArrayViewD<'_, f64>,
|
5
|
+
path_distances: ArrayViewD<'_, f64>,
|
6
|
+
) -> Vec<i64> {
|
7
|
+
let mut current_coord_index: usize = 0;
|
8
|
+
let mut distance_travelled: f64 = 0.0;
|
9
|
+
let mut result: Vec<i64> = Vec::with_capacity(distances.len());
|
10
|
+
|
11
|
+
for &distance in distances {
|
12
|
+
distance_travelled += distance;
|
13
|
+
|
14
|
+
while distance_travelled > path_distances[current_coord_index] {
|
15
|
+
distance_travelled -= path_distances[current_coord_index];
|
16
|
+
current_coord_index += 1;
|
17
|
+
if current_coord_index >= path_distances.len() {
|
18
|
+
current_coord_index = 0;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
current_coord_index = std::cmp::min(current_coord_index, path_distances.len() - 1);
|
23
|
+
result.push(current_coord_index as i64);
|
24
|
+
}
|
25
|
+
|
26
|
+
result
|
27
|
+
}
|
28
|
+
|
29
|
+
///
|
30
|
+
/// Generate valid driving speeds as a simulation-time array given a set of average speeds for each
|
31
|
+
/// simulated lap.
|
32
|
+
/// Driving speeds will only be non-zero when we are allowed to drive, and the speed
|
33
|
+
/// for every tick during a lap will be that lap's corresponding desired average speed for as long
|
34
|
+
/// as it takes to complete the lap.
|
35
|
+
/// An average speed of 0m/s for a lap will be interpreted as "sit and charge" for `idle_time`
|
36
|
+
/// ticks.
|
37
|
+
///
|
38
|
+
/// # Arguments
|
39
|
+
///
|
40
|
+
/// * `average_speeds`: An array of average speeds in m/s, one for each simulated lap. If there are more
|
41
|
+
/// speeds given than laps available, the unused speeds will be silently ignored. If there are too
|
42
|
+
/// few, an error will be returned.
|
43
|
+
/// * `simulation_dt`: The simulated tick length
|
44
|
+
/// * `driving_allowed_boolean`: A simulation-time boolean where the `True` elements are when we
|
45
|
+
/// are allowed to drive, and `False` is when we are not.
|
46
|
+
/// * `track_length`: The length of the track in meters.
|
47
|
+
/// * `idle_time`: The number of ticks to "sit and charge" when desired.
|
48
|
+
///
|
49
|
+
/// Returns: A simulation-time array of driving speeds in m/s, or an error if there weren't enough
|
50
|
+
/// laps provided to fill the entire simulation time.
|
51
|
+
///
|
52
|
+
pub fn get_driving_speeds(
|
53
|
+
average_speeds: ArrayView1<'_, f64>, // Average speeds in m/s
|
54
|
+
simulation_dt: i64, // Time step in seconds
|
55
|
+
driving_allowed_boolean: ArrayView1<'_, bool>, // Simulation-time boolean array
|
56
|
+
track_length: f64, // Track length in meters
|
57
|
+
idle_time: i64 // Time to idle in seconds
|
58
|
+
) -> Result<Vec<f64>, &'static str> {
|
59
|
+
let ticks_to_complete_lap: Vec<i64> = average_speeds.iter().map(| &average_speed | {
|
60
|
+
if average_speed > 0.0 {
|
61
|
+
// The number of ticks is the number of seconds, divided by seconds per tick
|
62
|
+
(track_length / average_speed / simulation_dt as f64).ceil() as i64
|
63
|
+
} else {
|
64
|
+
(idle_time as f64 / simulation_dt as f64).ceil() as i64
|
65
|
+
}
|
66
|
+
}).collect();
|
67
|
+
|
68
|
+
let mut lap_index: usize = 0;
|
69
|
+
let mut lap_speed: f64 = average_speeds[lap_index];
|
70
|
+
|
71
|
+
let mut ticks_to_lap_completion: i64 = ticks_to_complete_lap[lap_index];
|
72
|
+
|
73
|
+
let mut driving_speeds: Vec<f64> = Vec::with_capacity(driving_allowed_boolean.len());
|
74
|
+
for driving_allowed in driving_allowed_boolean.iter() {
|
75
|
+
if !driving_allowed {
|
76
|
+
// If we aren't allowed to drive, speed should be zero. Also, we should mark that we are
|
77
|
+
// done our lap since it means we ended the day in the middle of the lap, and we will
|
78
|
+
// start the next day at the beginning of a new lap, not where we ended off.
|
79
|
+
|
80
|
+
// If it's the first lap, we don't want to skip because we are probably in the morning
|
81
|
+
// where we haven't begun driving yet.
|
82
|
+
if lap_index > 0 {
|
83
|
+
ticks_to_lap_completion = 0;
|
84
|
+
}
|
85
|
+
|
86
|
+
driving_speeds.push(0.0)
|
87
|
+
} else {
|
88
|
+
// If we are driving, we should decrement ticks to lap completion. If its already
|
89
|
+
// zero, that means that we are done the lap and should move onto the next lap.
|
90
|
+
if ticks_to_lap_completion > 0 {
|
91
|
+
ticks_to_lap_completion -= 1;
|
92
|
+
|
93
|
+
driving_speeds.push(lap_speed)
|
94
|
+
} else {
|
95
|
+
// To advance to the next lap, increment the index and evaluate new variables
|
96
|
+
lap_index += 1;
|
97
|
+
if lap_index >= average_speeds.len() {
|
98
|
+
return Err("Not enough average speeds!")
|
99
|
+
}
|
100
|
+
|
101
|
+
// We subtract 1 since this iteration counts for the next lap, not the one
|
102
|
+
// that we just finished
|
103
|
+
ticks_to_lap_completion = ticks_to_complete_lap[lap_index] - 1;
|
104
|
+
lap_speed = average_speeds[lap_index];
|
105
|
+
|
106
|
+
driving_speeds.push(lap_speed)
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
}
|
111
|
+
|
112
|
+
Ok(driving_speeds)
|
113
|
+
}
|
@@ -1,13 +1,12 @@
|
|
1
|
-
use
|
2
|
-
use numpy::
|
3
|
-
use numpy::{PyArray, PyArrayDyn, PyReadwriteArrayDyn};
|
1
|
+
use numpy::ndarray::ArrayViewD;
|
2
|
+
use numpy::{PyArray, PyArrayDyn, PyReadwriteArrayDyn, PyReadonlyArray1, PyArray1};
|
4
3
|
use pyo3::prelude::*;
|
5
4
|
use pyo3::types::PyModule;
|
6
5
|
|
7
6
|
pub mod environment;
|
8
7
|
pub mod models;
|
9
|
-
use crate::environment::gis::gis::rust_closest_gis_indices_loop;
|
10
|
-
use crate::environment::meteorology::meteorology::{rust_calculate_array_ghi_times, rust_closest_weather_indices_loop, rust_weather_in_time
|
8
|
+
use crate::environment::gis::gis::{rust_closest_gis_indices_loop, get_driving_speeds};
|
9
|
+
use crate::environment::meteorology::meteorology::{rust_calculate_array_ghi_times, rust_closest_weather_indices_loop, rust_weather_in_time};
|
11
10
|
use crate::models::battery::battery::update_battery_array;
|
12
11
|
|
13
12
|
fn constrain_speeds(speed_limits: ArrayViewD<f64>, speeds: ArrayViewD<f64>, tick: i32) -> Vec<f64> {
|
@@ -128,5 +127,30 @@ fn rust_simulation(_py: Python, m: &PyModule) -> PyResult<()> {
|
|
128
127
|
(py_soc_array, py_voltage_array)
|
129
128
|
}
|
130
129
|
|
130
|
+
#[pyfn(m)]
|
131
|
+
#[pyo3(name = "get_driving_speeds")]
|
132
|
+
fn py_get_driving_speeds<'py>(
|
133
|
+
py: Python<'py>,
|
134
|
+
py_average_speeds: PyReadonlyArray1<'py, f64>, // Average speeds in m/s
|
135
|
+
simulation_dt: i64, // Time step in seconds
|
136
|
+
py_driving_allowed_boolean: PyReadonlyArray1<'py, bool>, // Simulation-time boolean array
|
137
|
+
track_length: f64, // Track length in meters
|
138
|
+
idle_time: i64 // Time to idle in seconds
|
139
|
+
) -> PyResult<&'py PyArray1<f64>> {
|
140
|
+
let average_speeds = py_average_speeds.as_array();
|
141
|
+
let driving_allowed_boolean = py_driving_allowed_boolean.as_array();
|
142
|
+
|
143
|
+
match get_driving_speeds(
|
144
|
+
average_speeds,
|
145
|
+
simulation_dt,
|
146
|
+
driving_allowed_boolean,
|
147
|
+
track_length,
|
148
|
+
idle_time
|
149
|
+
) {
|
150
|
+
Ok(driving_speeds) => Ok(PyArray1::from_vec(py, driving_speeds)),
|
151
|
+
Err(error) => Err(pyo3::exceptions::PyValueError::new_err(error))
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
131
155
|
Ok(())
|
132
156
|
}
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import core
|
2
|
+
import numpy as np
|
3
|
+
import pytest
|
4
|
+
|
5
|
+
|
6
|
+
def test_calculate_driving_speeds_simple():
|
7
|
+
"""
|
8
|
+
Test a simple case of the driving speeds with no rounding
|
9
|
+
"""
|
10
|
+
average_speeds = np.array([10, 14, 30, 0, 10, 20, 30], dtype=np.float64)
|
11
|
+
track_length = 30
|
12
|
+
simulation_dt = 1
|
13
|
+
|
14
|
+
idle_time = 3
|
15
|
+
driving_allowed = np.array([0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=bool)
|
16
|
+
driving_speeds = core.get_driving_speeds(average_speeds, simulation_dt, driving_allowed, track_length, idle_time)
|
17
|
+
|
18
|
+
assert np.all(np.equal(driving_speeds, [0, 10, 10, 10, 14, 14, 0, 0, 0, 0, 0, 30, 0, 0, 0, 10, 10, 10, 20, 20, 30]))
|
19
|
+
|
20
|
+
|
21
|
+
def test_calculate_driving_speeds_fp():
|
22
|
+
"""
|
23
|
+
Test the driving speeds with floating point rounding going on
|
24
|
+
:return:
|
25
|
+
"""
|
26
|
+
average_speeds = np.array([9.9, 30.7, 15.2, 15.3], dtype=np.float64)
|
27
|
+
track_length = 30.6
|
28
|
+
simulation_dt = 1
|
29
|
+
|
30
|
+
idle_time = 3
|
31
|
+
driving_allowed = np.array([0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=bool)
|
32
|
+
driving_speeds = core.get_driving_speeds(average_speeds, simulation_dt, driving_allowed, track_length, idle_time)
|
33
|
+
|
34
|
+
assert np.allclose(driving_speeds, np.array([0, 0, 9.9, 9.9, 9.9, 9.9, 30.7, 15.2, 15.2, 15.2, 15.3, 15.3]), atol=1e-3)
|
35
|
+
|
36
|
+
|
37
|
+
def test_calculate_driving_speeds_fp_with_tick():
|
38
|
+
"""
|
39
|
+
Test the driving speeds with floating point rounding going on and tick != 1.
|
40
|
+
"""
|
41
|
+
average_speeds = np.array([10.2, 30.7, 15.2, 15.3], dtype=np.float64)
|
42
|
+
track_length = 30.6
|
43
|
+
simulation_dt = 2
|
44
|
+
|
45
|
+
idle_time = 3
|
46
|
+
driving_allowed = np.array([0, 0, 1, 1, 1, 1, 1, 1], dtype=bool)
|
47
|
+
driving_speeds = core.get_driving_speeds(average_speeds, simulation_dt, driving_allowed, track_length, idle_time)
|
48
|
+
|
49
|
+
assert np.allclose(driving_speeds, np.array([0, 0, 10.2, 10.2, 30.7, 15.2, 15.2, 15.3]), atol=1e-3)
|
50
|
+
pass
|
51
|
+
|
52
|
+
|
53
|
+
def test_failure():
|
54
|
+
"""
|
55
|
+
Test that nothing fails when too many average speeds are provided, and that ValueError is raised when
|
56
|
+
not enough laps are provided.
|
57
|
+
"""
|
58
|
+
average_speeds_too_many = np.array([10, 14, 30, 0, 10, 20, 30, 10, 10], dtype=np.float64)
|
59
|
+
average_speeds_too_few = np.array([10, 14, 30, 0, 10, 20], dtype=np.float64)
|
60
|
+
track_length = 30
|
61
|
+
simulation_dt = 1
|
62
|
+
idle_time = 3
|
63
|
+
driving_allowed = np.array([0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=bool)
|
64
|
+
|
65
|
+
with pytest.raises(ValueError):
|
66
|
+
core.get_driving_speeds(average_speeds_too_few, simulation_dt, driving_allowed, track_length, idle_time)
|
67
|
+
|
68
|
+
driving_speeds = core.get_driving_speeds(average_speeds_too_many, simulation_dt, driving_allowed, track_length, idle_time)
|
69
|
+
|
70
|
+
assert np.all(np.equal(driving_speeds, [0, 10, 10, 10, 14, 14, 0, 0, 0, 0, 0, 30, 0, 0, 0, 10, 10, 10, 20, 20, 30]))
|
@@ -0,0 +1,322 @@
|
|
1
|
+
from physics.environment import GIS
|
2
|
+
import numpy as np
|
3
|
+
import math
|
4
|
+
|
5
|
+
|
6
|
+
coordinates = [
|
7
|
+
[36.99932082, -86.37230251],
|
8
|
+
[36.99940337, -86.37214797],
|
9
|
+
[36.99948814, -86.37199725],
|
10
|
+
[36.99958754, -86.37189043],
|
11
|
+
[36.99970528, -86.37178738],
|
12
|
+
[36.99982625, -86.37169183],
|
13
|
+
[36.99997073, -86.37159181],
|
14
|
+
[37.00011471, -86.3714889],
|
15
|
+
[37.00027357, -86.37138907],
|
16
|
+
[37.0003852, -86.37123775],
|
17
|
+
[37.00042033, -86.37099884],
|
18
|
+
[37.00038811, -86.3707825],
|
19
|
+
[37.00031195, -86.37062837],
|
20
|
+
[37.00026491, -86.37041498],
|
21
|
+
[37.00030254, -86.37020247],
|
22
|
+
[37.00038472, -86.3700261],
|
23
|
+
[37.0004699, -86.36984594],
|
24
|
+
[37.00056383, -86.36964375],
|
25
|
+
[37.00064015, -86.3694857],
|
26
|
+
[37.00070993, -86.36934481],
|
27
|
+
[37.0008098, -86.36912411],
|
28
|
+
[37.00090662, -86.36891836],
|
29
|
+
[37.00098578, -86.36874579],
|
30
|
+
[37.00107373, -86.36854755],
|
31
|
+
[37.0011529, -86.36837867],
|
32
|
+
[37.00122817, -86.3682181],
|
33
|
+
[37.00133071, -86.36801267],
|
34
|
+
[37.00143614, -86.36779264],
|
35
|
+
[37.00152389, -86.3675912],
|
36
|
+
[37.00160574, -86.36740819],
|
37
|
+
[37.00167596, -86.36725066],
|
38
|
+
[37.00175285, -86.36709064],
|
39
|
+
[37.00183166, -86.36691875],
|
40
|
+
[37.00192538, -86.36670617],
|
41
|
+
[37.00200136, -86.36653034],
|
42
|
+
[37.00208623, -86.36635086],
|
43
|
+
[37.00215644, -86.36619701],
|
44
|
+
[37.00222549, -86.36603626],
|
45
|
+
[37.00229839, -86.3658645],
|
46
|
+
[37.00237732, -86.36569622],
|
47
|
+
[37.00245038, -86.36553914],
|
48
|
+
[37.00252912, -86.36537128],
|
49
|
+
[37.00259904, -86.36521818],
|
50
|
+
[37.00266755, -86.36507091],
|
51
|
+
[37.00274639, -86.36490341],
|
52
|
+
[37.00283342, -86.36471029],
|
53
|
+
[37.00291248, -86.36454704],
|
54
|
+
[37.00298517, -86.36439075],
|
55
|
+
[37.0030636, -86.36423803],
|
56
|
+
[37.00313338, -86.36408574],
|
57
|
+
[37.00320937, -86.36393701],
|
58
|
+
[37.00330797, -86.36377724],
|
59
|
+
[37.00343811, -86.36368662],
|
60
|
+
[37.00357758, -86.36365019],
|
61
|
+
[37.00372489, -86.36360692],
|
62
|
+
[37.00388711, -86.36356354],
|
63
|
+
[37.00405472, -86.36352621],
|
64
|
+
[37.00423763, -86.36348621],
|
65
|
+
[37.00437129, -86.36338074],
|
66
|
+
[37.00448184, -86.36323899],
|
67
|
+
[37.00457515, -86.36307953],
|
68
|
+
[37.0047012, -86.36286956],
|
69
|
+
[37.00486024, -86.36273924],
|
70
|
+
[37.00505061, -86.36270756],
|
71
|
+
[37.00527945, -86.36272947],
|
72
|
+
[37.00548802, -86.36263566],
|
73
|
+
[37.00565341, -86.36245496],
|
74
|
+
[37.00573513, -86.3621647],
|
75
|
+
[37.00568611, -86.36182869],
|
76
|
+
[37.00548782, -86.36157939],
|
77
|
+
[37.0052881, -86.36149696],
|
78
|
+
[37.00511652, -86.36149669],
|
79
|
+
[37.0049746, -86.36158761],
|
80
|
+
[37.00485989, -86.3616726],
|
81
|
+
[37.00469955, -86.3617696],
|
82
|
+
[37.00451492, -86.36178471],
|
83
|
+
[37.00435852, -86.36173599],
|
84
|
+
[37.00419576, -86.36162316],
|
85
|
+
[37.00409127, -86.36146652],
|
86
|
+
[37.00404463, -86.3612301],
|
87
|
+
[37.00407232, -86.36097832],
|
88
|
+
[37.00415922, -86.36078578],
|
89
|
+
[37.00426711, -86.36066944],
|
90
|
+
[37.00439509, -86.36060407],
|
91
|
+
[37.00452844, -86.36057503],
|
92
|
+
[37.00466778, -86.36054604],
|
93
|
+
[37.004833, -86.36050987],
|
94
|
+
[37.00499495, -86.36047743],
|
95
|
+
[37.00514229, -86.36044484],
|
96
|
+
[37.00524902, -86.36041601],
|
97
|
+
[37.00541074, -86.36037856],
|
98
|
+
[37.00558676, -86.36034575],
|
99
|
+
[37.00578957, -86.36038183],
|
100
|
+
[37.00596102, -86.36045445],
|
101
|
+
[37.00607154, -86.36065091],
|
102
|
+
[37.0061651, -86.36090615],
|
103
|
+
[37.00626234, -86.3611639],
|
104
|
+
[37.00637312, -86.36147776],
|
105
|
+
[37.00642557, -86.36179897],
|
106
|
+
[37.00644459, -86.36216748],
|
107
|
+
[37.00637929, -86.36250433],
|
108
|
+
[37.00629836, -86.36273906],
|
109
|
+
[37.00622229, -86.36291634],
|
110
|
+
[37.00611158, -86.36309997],
|
111
|
+
[37.00600738, -86.36323379],
|
112
|
+
[37.00589169, -86.3633461],
|
113
|
+
[37.00576471, -86.36344689],
|
114
|
+
[37.00564905, -86.36353398],
|
115
|
+
[37.00551878, -86.36359932],
|
116
|
+
[37.00537978, -86.36365448],
|
117
|
+
[37.00525188, -86.36370605],
|
118
|
+
[37.0051236, -86.36376501],
|
119
|
+
[37.00497727, -86.36382802],
|
120
|
+
[37.00484855, -86.36391978],
|
121
|
+
[37.00471266, -86.36403361],
|
122
|
+
[37.0045783, -86.36422396],
|
123
|
+
[37.00447907, -86.36439954],
|
124
|
+
[37.00435695, -86.36453807],
|
125
|
+
[37.00424813, -86.36465022],
|
126
|
+
[37.00411061, -86.36480228],
|
127
|
+
[37.00397977, -86.36492984],
|
128
|
+
[37.0038682, -86.36504946],
|
129
|
+
[37.00376295, -86.36516126],
|
130
|
+
[37.00365436, -86.36527329],
|
131
|
+
[37.00354759, -86.36539144],
|
132
|
+
[37.00341675, -86.36552332],
|
133
|
+
[37.00329206, -86.3656715],
|
134
|
+
[37.00316095, -86.36581567],
|
135
|
+
[37.00303256, -86.36594441],
|
136
|
+
[37.00291203, -86.36607157],
|
137
|
+
[37.00278014, -86.36622802],
|
138
|
+
[37.00269333, -86.36641303],
|
139
|
+
[37.00260606, -86.36659437],
|
140
|
+
[37.00252845, -86.36675984],
|
141
|
+
[37.00243487, -86.36695271],
|
142
|
+
[37.00234795, -86.36716654],
|
143
|
+
[37.00226102, -86.36735999],
|
144
|
+
[37.00218046, -86.36754144],
|
145
|
+
[37.00210026, -86.36771854],
|
146
|
+
[37.00202358, -86.36787901],
|
147
|
+
[37.00194406, -86.36806693],
|
148
|
+
[37.00185835, -86.36825428],
|
149
|
+
[37.00177578, -86.36843604],
|
150
|
+
[37.00169902, -86.36860048],
|
151
|
+
[37.0016732, -86.3687928],
|
152
|
+
[37.001679, -86.3689974],
|
153
|
+
[37.00168488, -86.36919051],
|
154
|
+
[37.00169122, -86.36938766],
|
155
|
+
[37.00169469, -86.3695562],
|
156
|
+
[37.00170118, -86.36974238],
|
157
|
+
[37.00171055, -86.36993991],
|
158
|
+
[37.00167198, -86.37010864],
|
159
|
+
[37.00158558, -86.37021273],
|
160
|
+
[37.00148934, -86.37030898],
|
161
|
+
[37.00139295, -86.37041757],
|
162
|
+
[37.00129011, -86.37051816],
|
163
|
+
[37.00120286, -86.37061913],
|
164
|
+
[37.00112253, -86.37073184],
|
165
|
+
[37.00106144, -86.37085264],
|
166
|
+
[37.00099678, -86.37100197],
|
167
|
+
[37.00092255, -86.37116696],
|
168
|
+
[37.00083249, -86.37137665],
|
169
|
+
[37.00073506, -86.37159438],
|
170
|
+
[37.00065426, -86.37177611],
|
171
|
+
[37.00057398, -86.37196168],
|
172
|
+
[37.00060097, -86.37214635],
|
173
|
+
[37.00074272, -86.37221467],
|
174
|
+
[37.0009059, -86.37222018],
|
175
|
+
[37.00107657, -86.37218846],
|
176
|
+
[37.00122503, -86.37211976],
|
177
|
+
[37.00133803, -86.37204677],
|
178
|
+
[37.00145467, -86.37192099],
|
179
|
+
[37.00156457, -86.37178347],
|
180
|
+
[37.00167114, -86.37162599],
|
181
|
+
[37.00176434, -86.37145299],
|
182
|
+
[37.00183833, -86.37126821],
|
183
|
+
[37.00188646, -86.37112396],
|
184
|
+
[37.0019441, -86.37095574],
|
185
|
+
[37.00197296, -86.370787],
|
186
|
+
[37.00202945, -86.37067751],
|
187
|
+
[37.00209668, -86.37048098],
|
188
|
+
[37.00218305, -86.37031655],
|
189
|
+
[37.00228558, -86.37016005],
|
190
|
+
[37.00238818, -86.37002764],
|
191
|
+
[37.00249377, -86.36991909],
|
192
|
+
[37.00259639, -86.36983868],
|
193
|
+
[37.00270864, -86.36976266],
|
194
|
+
[37.00281411, -86.3697033],
|
195
|
+
[37.00292264, -86.36964769],
|
196
|
+
[37.00303847, -86.369599],
|
197
|
+
[37.00316942, -86.36952703],
|
198
|
+
[37.00332578, -86.36939126],
|
199
|
+
[37.00342743, -86.36921198],
|
200
|
+
[37.00346211, -86.36901195],
|
201
|
+
[37.00343231, -86.36879509],
|
202
|
+
[37.00336736, -86.36861758],
|
203
|
+
[37.00327983, -86.36847602],
|
204
|
+
[37.00316589, -86.36828932],
|
205
|
+
[37.00305696, -86.36810259],
|
206
|
+
[37.00296937, -86.36793662],
|
207
|
+
[37.00293802, -86.36773416],
|
208
|
+
[37.00295792, -86.36753614],
|
209
|
+
[37.00301643, -86.36739089],
|
210
|
+
[37.00307192, -86.36724611],
|
211
|
+
[37.00312788, -86.36711056],
|
212
|
+
[37.00320856, -86.36698638],
|
213
|
+
[37.00331523, -86.36684361],
|
214
|
+
[37.00340519, -86.36672019],
|
215
|
+
[37.00350264, -86.36658791],
|
216
|
+
[37.00361135, -86.36649982],
|
217
|
+
[37.00374245, -86.36645177],
|
218
|
+
[37.00387034, -86.3664758],
|
219
|
+
[37.00395668, -86.36655587],
|
220
|
+
[37.00402368, -86.36670753],
|
221
|
+
[37.00407807, -86.36686779],
|
222
|
+
[37.00412607, -86.36701603],
|
223
|
+
[37.00418686, -86.36718831],
|
224
|
+
[37.00427315, -86.36742386],
|
225
|
+
[37.00436296, -86.3676927],
|
226
|
+
[37.00442144, -86.36790543],
|
227
|
+
[37.00445858, -86.36815496],
|
228
|
+
[37.00447715, -86.36847342],
|
229
|
+
[37.00444541, -86.36882644],
|
230
|
+
[37.00434238, -86.36911386],
|
231
|
+
[37.00425654, -86.36927291],
|
232
|
+
[37.00418289, -86.36939303],
|
233
|
+
[37.00410293, -86.36950912],
|
234
|
+
[37.00399731, -86.36962489],
|
235
|
+
[37.00390147, -86.36973254],
|
236
|
+
[37.00379293, -86.36984054],
|
237
|
+
[37.00369701, -86.36994104],
|
238
|
+
[37.00359474, -86.37004514],
|
239
|
+
[37.0034838, -86.3701598],
|
240
|
+
[37.00338477, -86.37024376],
|
241
|
+
[37.00327609, -86.37032788],
|
242
|
+
[37.00318982, -86.37040789],
|
243
|
+
[37.00306205, -86.37049992],
|
244
|
+
[37.00294389, -86.37059192],
|
245
|
+
[37.00283177, -86.37070006],
|
246
|
+
[37.00272312, -86.37083897],
|
247
|
+
[37.00264003, -86.37094293],
|
248
|
+
[37.00255683, -86.37103895],
|
249
|
+
[37.00249914, -86.37115127],
|
250
|
+
[37.00243497, -86.37126771],
|
251
|
+
[37.00236746, -86.3713964],
|
252
|
+
[37.00230001, -86.37152106],
|
253
|
+
[37.00223561, -86.37164596],
|
254
|
+
[37.00217132, -86.37175865],
|
255
|
+
[37.0021135, -86.37187932],
|
256
|
+
[37.00204601, -86.37200003],
|
257
|
+
[37.00196791, -86.37211434],
|
258
|
+
[37.00188761, -86.3722312],
|
259
|
+
[37.00180726, -86.37233202],
|
260
|
+
[37.00173651, -86.37241676],
|
261
|
+
[37.00165284, -86.37250555],
|
262
|
+
[37.00155067, -86.3726109],
|
263
|
+
[37.00144762, -86.37271211],
|
264
|
+
[37.00136704, -86.37279282],
|
265
|
+
[37.00126713, -86.37288565],
|
266
|
+
[37.00115123, -86.37299929],
|
267
|
+
[37.00103518, -86.37310829],
|
268
|
+
[37.0009191, -86.37321738],
|
269
|
+
[37.00082561, -86.37329809],
|
270
|
+
[37.00072863, -86.37339546],
|
271
|
+
[37.00061364, -86.37350099],
|
272
|
+
[37.00051698, -86.37360214],
|
273
|
+
[37.00042667, -86.37368311],
|
274
|
+
[37.00032338, -86.37378434],
|
275
|
+
[37.00022342, -86.37387665],
|
276
|
+
[37.00012018, -86.3739737],
|
277
|
+
[37.00002051, -86.37405916],
|
278
|
+
[36.99991404, -86.37415222],
|
279
|
+
[36.99981076, -86.37423248],
|
280
|
+
[36.99970432, -86.37430523],
|
281
|
+
[36.99958169, -86.37432571],
|
282
|
+
[36.99946928, -86.37430399],
|
283
|
+
[36.99934964, -86.37428072],
|
284
|
+
[36.99922365, -86.37425686],
|
285
|
+
[36.99908793, -86.37422888],
|
286
|
+
[36.99899069, -86.37413638],
|
287
|
+
[36.99896465, -86.37397888],
|
288
|
+
[36.9989808, -86.37380904],
|
289
|
+
[36.99900664, -86.37362303],
|
290
|
+
[36.99904589, -86.37342887],
|
291
|
+
[36.9990885, -86.37323096],
|
292
|
+
[36.99912743, -86.3730292],
|
293
|
+
[36.99916641, -86.37284378],
|
294
|
+
[36.99921127, -86.37261758],
|
295
|
+
[36.99924349, -86.37245211],
|
296
|
+
]
|
297
|
+
|
298
|
+
|
299
|
+
def test_gis():
|
300
|
+
route_data = {
|
301
|
+
"path": coordinates,
|
302
|
+
"elevations": np.ones(len(coordinates)),
|
303
|
+
"time_zones": np.ones(len(coordinates)),
|
304
|
+
"num_unique_coords": len(coordinates),
|
305
|
+
}
|
306
|
+
|
307
|
+
gis = GIS(route_data, origin_coord=coordinates[0])
|
308
|
+
|
309
|
+
track_length = gis.path_length
|
310
|
+
speed = 120
|
311
|
+
time_to_complete_lap = math.ceil(track_length / speed)
|
312
|
+
idle_time = 30
|
313
|
+
|
314
|
+
driving_allowed = [False] * 10 + [True] * time_to_complete_lap + [True] * idle_time + [False] * 10
|
315
|
+
|
316
|
+
driving_speeds = gis.calculate_driving_speeds(
|
317
|
+
average_lap_speeds=[speed, 0],
|
318
|
+
driving_allowed=driving_allowed,
|
319
|
+
idle_time=idle_time,
|
320
|
+
simulation_dt=1)
|
321
|
+
|
322
|
+
assert np.allclose(driving_speeds, np.array([[0] * 10 + [speed] * time_to_complete_lap + [0] * idle_time + [0] * 10]), atol=1e-3)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ubc-solar-physics
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.6.0
|
4
4
|
Summary: UBC Solar's Simulation Environment
|
5
5
|
Author: Fisher Xue, Mihir Nimgade, Chris Chang, David Widjaja, Justin Hua, Ilya Veksler, Renu Rajamagesh, Ritchie Xia, Erik Langille, Chris Aung, Nicolas Ric, Ishaan Trivedi, Jason Liang, Felix Toft, Mack Wilson, Jonah Lee, Tamzeed Quazi, Joshua Riefman
|
6
6
|
Author-email: UBC Solar <strategy@ubcsolar.com>
|
@@ -1,3 +1,4 @@
|
|
1
|
+
.gitattributes
|
1
2
|
.gitignore
|
2
3
|
.readthedocs.yaml
|
3
4
|
Cargo.lock
|
@@ -6,7 +7,7 @@ LICENSE
|
|
6
7
|
README.md
|
7
8
|
data.png
|
8
9
|
pyproject.toml
|
9
|
-
.github/
|
10
|
+
.github/PULL_REQUEST_TEMPLATE.md
|
10
11
|
.github/workflows/build_and_publish.yaml
|
11
12
|
.github/workflows/run_tests.yaml
|
12
13
|
docs/Makefile
|
@@ -91,6 +92,8 @@ physics/models/regen/basic_regen.py
|
|
91
92
|
physics/models/regen/regen.rs
|
92
93
|
tests/battery_config.toml
|
93
94
|
tests/test_versioning.py
|
95
|
+
tests/gis_tests/test_calculate_driving_speeds.py
|
96
|
+
tests/gis_tests/test_gis_driving_speeds.py
|
94
97
|
tests/kalman_filter_tests/current.csv
|
95
98
|
tests/kalman_filter_tests/test_basic_kalman_filter.py
|
96
99
|
tests/kalman_filter_tests/test_filter_real_data.py
|
@@ -1 +0,0 @@
|
|
1
|
-
# Physics Pull Request Template
|
@@ -1,25 +0,0 @@
|
|
1
|
-
use chrono::{Datelike, NaiveDateTime, Timelike};
|
2
|
-
use numpy::ndarray::{s, Array, Array2, ArrayViewD, ArrayViewMut2, ArrayViewMut3, Axis};
|
3
|
-
|
4
|
-
pub fn rust_closest_gis_indices_loop(
|
5
|
-
distances: ArrayViewD<'_, f64>,
|
6
|
-
path_distances: ArrayViewD<'_, f64>,
|
7
|
-
) -> Vec<i64> {
|
8
|
-
let mut current_coord_index: usize = 0;
|
9
|
-
let mut distance_travelled: f64 = 0.0;
|
10
|
-
let mut result: Vec<i64> = Vec::with_capacity(distances.len());
|
11
|
-
|
12
|
-
for &distance in distances {
|
13
|
-
distance_travelled += distance;
|
14
|
-
|
15
|
-
while distance_travelled > path_distances[current_coord_index] {
|
16
|
-
distance_travelled -= path_distances[current_coord_index];
|
17
|
-
current_coord_index += 1;
|
18
|
-
}
|
19
|
-
|
20
|
-
current_coord_index = std::cmp::min(current_coord_index, path_distances.len() - 1);
|
21
|
-
result.push(current_coord_index as i64);
|
22
|
-
}
|
23
|
-
|
24
|
-
result
|
25
|
-
}
|
{ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/.github/workflows/build_and_publish.yaml
RENAMED
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
|
{ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/battery_model_examples/data_py.png
RENAMED
File without changes
|
{ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/battery_model_examples/data_rust.png
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/kalman_filter_examples/current.csv
RENAMED
File without changes
|
File without changes
|
{ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/examples/kalman_filter_examples/voltage.csv
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/meteorology/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/environment/meteorology/meteorology.rs
RENAMED
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
|
{ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/battery/battery_config.py
RENAMED
File without changes
|
{ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/physics/models/battery/battery_config.toml
RENAMED
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
|
{ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/ubc_solar_physics.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
{ubc_solar_physics-1.5.0 → ubc_solar_physics-1.6.0}/ubc_solar_physics.egg-info/top_level.txt
RENAMED
File without changes
|