This repository was archived by the owner on Jul 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEventOfInterest.py
More file actions
55 lines (48 loc) · 2.05 KB
/
Copy pathEventOfInterest.py
File metadata and controls
55 lines (48 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"""
This file is part of BeSafeBox Android application.
Copyright (C) 2019 Tomáš Repčík
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import numpy as np
class EventOfInterest:
def __init__(
self,
event_time: np.ndarray,
event_magnitude: np.ndarray,
begin_index: np.integer,
end_index: np.integer,
max_index: np.integer,
free_fall_end_index: np.integer,
):
"""
Basic object, which holds raw data from period of interest and basic information about indexes
:param event_time: vector of time - seconds
:param event_magnitude: vector of magnitude - 1D
:param begin_index: index of the beginning in SensorData
:param end_index: index of the ending in SensorData
:param max_index: index of the maximum peak
:param free_fall_end_index: index of the ending of the free fall
"""
self.event_time = event_time
self.event_magnitude = event_magnitude
self.begin_index = begin_index
self.end_index = end_index
self.max_index = max_index
self.free_fall_end_index = free_fall_end_index
@property
def get_from_free_fall(self) -> np.ndarray:
"""
:return: sometimes we are interested only in the part, when the person hits the ground
"""
if self.free_fall_end_index is not None:
return self.event_magnitude[self.free_fall_end_index - self.begin_index :]
return self.event_magnitude