sarapy 0.3.4__tar.gz → 0.3.6__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.
- {sarapy-0.3.4 → sarapy-0.3.6}/PKG-INFO +9 -1
- {sarapy-0.3.4 → sarapy-0.3.6}/README.md +8 -0
- {sarapy-0.3.4 → sarapy-0.3.6}/pyproject.toml +1 -1
- {sarapy-0.3.4 → sarapy-0.3.6}/sarapy/dataProcessing/TLMSensorDataExtractor.py +21 -4
- sarapy-0.3.6/sarapy/preprocessing/DistancesImputer.py +183 -0
- sarapy-0.3.6/sarapy/preprocessing/__init__.py +1 -0
- {sarapy-0.3.4 → sarapy-0.3.6}/sarapy/version.py +1 -1
- {sarapy-0.3.4 → sarapy-0.3.6}/sarapy.egg-info/PKG-INFO +9 -1
- {sarapy-0.3.4 → sarapy-0.3.6}/sarapy.egg-info/SOURCES.txt +3 -1
- {sarapy-0.3.4 → sarapy-0.3.6}/sarapy/__init__.py +0 -0
- {sarapy-0.3.4 → sarapy-0.3.6}/sarapy/dataProcessing/GeoProcessor.py +0 -0
- {sarapy-0.3.4 → sarapy-0.3.6}/sarapy/dataProcessing/PlantinFMCreator.py +0 -0
- {sarapy-0.3.4 → sarapy-0.3.6}/sarapy/dataProcessing/TimeSeriesProcessor.py +0 -0
- {sarapy-0.3.4 → sarapy-0.3.6}/sarapy/dataProcessing/__init__.py +0 -0
- {sarapy-0.3.4 → sarapy-0.3.6}/sarapy.egg-info/dependency_links.txt +0 -0
- {sarapy-0.3.4 → sarapy-0.3.6}/sarapy.egg-info/requires.txt +0 -0
- {sarapy-0.3.4 → sarapy-0.3.6}/sarapy.egg-info/top_level.txt +0 -0
- {sarapy-0.3.4 → sarapy-0.3.6}/setup.cfg +0 -0
- {sarapy-0.3.4 → sarapy-0.3.6}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sarapy
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.6
|
|
4
4
|
Summary: Library for Sarapico Metadata processing
|
|
5
5
|
Home-page: https://github.com/lucasbaldezzari/sarapy
|
|
6
6
|
Author: Lucas Baldezzari
|
|
@@ -24,6 +24,14 @@ Requires-Dist: geopy
|
|
|
24
24
|
|
|
25
25
|
Library for processing SARAPICO project metadata of _AMG_.
|
|
26
26
|
|
|
27
|
+
#### Version 0.3.6
|
|
28
|
+
|
|
29
|
+
- Se agregan argumentos al constructor de _DistanceImputer_ para que Transform y fit_transform puedan entregar un array de shape (n,1) o bien de (n,6) eligiendo la columna a imputar.
|
|
30
|
+
|
|
31
|
+
#### Version 0.3.5
|
|
32
|
+
|
|
33
|
+
- Se implementa clase _DistanceImputer_.
|
|
34
|
+
|
|
27
35
|
#### Version 0.3.4
|
|
28
36
|
|
|
29
37
|
- Se actializa _dataPositions_ de PlantinFMCreator.
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Library for processing SARAPICO project metadata of _AMG_.
|
|
4
4
|
|
|
5
|
+
#### Version 0.3.6
|
|
6
|
+
|
|
7
|
+
- Se agregan argumentos al constructor de _DistanceImputer_ para que Transform y fit_transform puedan entregar un array de shape (n,1) o bien de (n,6) eligiendo la columna a imputar.
|
|
8
|
+
|
|
9
|
+
#### Version 0.3.5
|
|
10
|
+
|
|
11
|
+
- Se implementa clase _DistanceImputer_.
|
|
12
|
+
|
|
5
13
|
#### Version 0.3.4
|
|
6
14
|
|
|
7
15
|
- Se actializa _dataPositions_ de PlantinFMCreator.
|
|
@@ -47,13 +47,22 @@ class TLMSensorDataExtractor(BaseEstimator, TransformerMixin):
|
|
|
47
47
|
|
|
48
48
|
##creamos un diccionario para saber la posición de cada dato dentro del array devuelto por transform()
|
|
49
49
|
self._dataPositions = {
|
|
50
|
-
"RFFlag": 0, "GNSSFlag": 1, "RFIDFlag": 2, "FLASHFlag": 3, "RTCSFlag": 4,
|
|
50
|
+
"RFFlag": 0, "GNSSFlag": 1, "RFIDFlag": 2, "FLASHFlag": 3, "RTCSFlag": 4,
|
|
51
|
+
"MODEFlag": 5, "NBAT": 6, "TIMEAC": 7, "ESTAC": 8, "DSTRPT": 9,
|
|
52
|
+
"INESTPT": 10, "OFFSPT": 11, "DSTRFT": 12, "INESTFT": 13, "OFFSFT": 14,
|
|
53
|
+
"PMSTFlag": 15, "GYROX": 16, "GYROY": 17, "GYROZ": 18, "ACELX": 19, "ACELY": 20,
|
|
54
|
+
"ACELZ": 21, "ESTMOFlag": 22, "ESTORFlag": 23, "SBAT": 24, "VBAT": 25, "CBAT": 26,
|
|
55
|
+
"ESTBMSFlag": 27, "FIX": 28, "SIV": 29}
|
|
51
56
|
|
|
52
57
|
# self.kilometers = kwargs.pop('kilometers', 0)
|
|
53
58
|
self.is_fitted = False
|
|
54
59
|
|
|
55
60
|
def fit(self, X, y=None):
|
|
56
|
-
"""Método para generar datos a partir de la metadata.
|
|
61
|
+
"""Método para generar datos a partir de la metadata.
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
- X: Es un array con los datos provenientes (strings) de la base de datos histórica. La forma de X es (n,1) donde n es la cantidad de datos.
|
|
65
|
+
"""
|
|
57
66
|
|
|
58
67
|
##chequeamos si todos los strings de X tienen la misma longitud, sino arrojamos un assert
|
|
59
68
|
assert all(len(x) == len(X[0]) for x in X), "Todos los strings de X deben tener la misma longitud"
|
|
@@ -93,7 +102,11 @@ class TLMSensorDataExtractor(BaseEstimator, TransformerMixin):
|
|
|
93
102
|
|
|
94
103
|
|
|
95
104
|
def transform(self, X, y=None):
|
|
96
|
-
"""Transforma los datos de entrada en un array de numpy.
|
|
105
|
+
"""Transforma los datos de entrada en un array de numpy.
|
|
106
|
+
|
|
107
|
+
Args:
|
|
108
|
+
- X: Es un array con los datos provenientes (strings) de la base de datos histórica. La forma de X es (n,1) donde n es la cantidad de datos.
|
|
109
|
+
"""
|
|
97
110
|
|
|
98
111
|
##chequeamos si se ha llamado a fit(). Sino, se arroja un error
|
|
99
112
|
if not self.is_fitted:
|
|
@@ -131,7 +144,11 @@ class TLMSensorDataExtractor(BaseEstimator, TransformerMixin):
|
|
|
131
144
|
self._SIV]).T
|
|
132
145
|
|
|
133
146
|
def fit_transform(self, X, y=None):
|
|
134
|
-
"""Combinamos fit() y transform() en un solo método.
|
|
147
|
+
"""Combinamos fit() y transform() en un solo método.
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
- X: Es un array con los datos provenientes (strings) de la base de datos histórica. La forma de X es (n,1) donde n es la cantidad de datos.
|
|
151
|
+
"""
|
|
135
152
|
self.fit(X)
|
|
136
153
|
return self.transform(X)
|
|
137
154
|
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
###Documentación en https://github.com/lucasbaldezzari/sarapy/blob/main/docs/Docs.md
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
from sklearn.base import BaseEstimator, TransformerMixin
|
|
5
|
+
from sarapy.dataProcessing import TLMSensorDataExtractor, TimeSeriesProcessor, GeoProcessor
|
|
6
|
+
|
|
7
|
+
class DistancesImputer(BaseEstimator, TransformerMixin):
|
|
8
|
+
"""La clase PlantinDataImuter se encarga de imputar/modificar los datos de telemetría entregados por el sistema. Se utilizan las clases TLMSensorDataExtractor, TimeSeriesProcessor y GeoProcessor para realizar las transformaciones necesarias y luego aplicar las modificaciones necesarias en base a las reglas definidas luego del análisis estadístico.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
def __init__(self, distanciaMedia:float = 1.8, umbral_mismo_lugar:float = 0.3, umbral_ratio_dCdP:float = 0.5, deltaO_medio = 4, keepDims = False, columnToImpute = 0):
|
|
12
|
+
"""Constructor de la clase PlantinDataImputer.
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
- distanciaMedia: Distancia media entre operaciones.
|
|
16
|
+
- umbral_mismo_lugar: Umbral para considerar que dos operaciones son el mismo lugar.
|
|
17
|
+
- umbral_ratio_dCdP: Umbral para el ratio entre el delta de caminata y el delta de pico abierto.
|
|
18
|
+
- deltaO_medio: delta de operación medio entre operaciones.
|
|
19
|
+
- columnToImpute: Columna a imputar.
|
|
20
|
+
- keepDims: Si es True, se mantienen las dimensiones del array de entrada. Si es False, se devuelve un array de una dimensión.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
self.is_fitted = False
|
|
24
|
+
self._distanciaMedia = distanciaMedia
|
|
25
|
+
self._umbral_mismo_lugar = umbral_mismo_lugar
|
|
26
|
+
self._umbral_ratio_dCdP = umbral_ratio_dCdP
|
|
27
|
+
self._deltaO_medio = deltaO_medio
|
|
28
|
+
self._keepDims = keepDims
|
|
29
|
+
self._columnToImpute = columnToImpute
|
|
30
|
+
self._dataPositions = {"distancias":0} #posición de los datos en el array devuelto por transform()
|
|
31
|
+
|
|
32
|
+
def fit(self, X:np.array, y = None):
|
|
33
|
+
"""Fittea el objeto
|
|
34
|
+
|
|
35
|
+
Params:
|
|
36
|
+
- X: Es un array con los datos provenientes (strings) de la base de datos histórica. La forma de X es (n,6)Las columnas de X son,
|
|
37
|
+
- 0: distancia entre operaciones
|
|
38
|
+
- 1: presición del GPS
|
|
39
|
+
- 2: GNSSflag. Nandera para saber si hay dato GPS, donde 0 es que hay dato y 1 que no hay dato
|
|
40
|
+
- 3: FIX bandera para tipo de fijación GNSS (ver valores enhttps://trello.com/c/M6DWjpwr/70-definici%C3%B3n-metadatos-a-relevar)
|
|
41
|
+
- 4: deltaO
|
|
42
|
+
- 5: ratio_dCdP
|
|
43
|
+
|
|
44
|
+
NOTA: En versiones futuras se considerarán los datos de la posición (vertical, horizontal, etc) del sarapico
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
##agregar asserts y warnings
|
|
48
|
+
|
|
49
|
+
self._distancias = X[:,0] #distancias
|
|
50
|
+
self._precision = X[:,1]
|
|
51
|
+
self._GNSSflag = X[:,2]
|
|
52
|
+
self._FIX = X[:,3]
|
|
53
|
+
self._deltaO = X[:,4]
|
|
54
|
+
self._ratio_dCdP = X[:,5]
|
|
55
|
+
|
|
56
|
+
def transform(self, X:np.array, y = None):
|
|
57
|
+
"""Aplica las imputaciones para transformar el objeto y retorna el array transformado.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
- X: Es un array con los datos provenientes (strings) de la base de datos histórica. La forma de X es (n,6)Las columnas de X son,
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
- updatedDistances: Array con las distancias imputadas.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
self._updatedDistances = self._imputeDistance()
|
|
68
|
+
##si keepDims es True, devolvemos x con las mismas dimensiones que el array de entrada. Los valores de self._updatedDistances se colocan en self._columnToImpute
|
|
69
|
+
if not self._keepDims:
|
|
70
|
+
return self._updatedDistances
|
|
71
|
+
|
|
72
|
+
else:
|
|
73
|
+
X[:,self._columnToImpute] = self._updatedDistances
|
|
74
|
+
return X
|
|
75
|
+
|
|
76
|
+
def fit_transform(self, X:np.array, y = None):
|
|
77
|
+
"""Fitea y aplica las imputaciones para transformar el objeto. Retorna el array transformado.
|
|
78
|
+
|
|
79
|
+
Args:
|
|
80
|
+
- X: Es un array con los datos provenientes (strings) de la base de datos histórica. La forma de X es (n,6)Las columnas de X son,
|
|
81
|
+
|
|
82
|
+
Returns:
|
|
83
|
+
- updatedDistances: Array con las distancias imputadas.
|
|
84
|
+
"""
|
|
85
|
+
self.fit(X)
|
|
86
|
+
return self.transform(X)
|
|
87
|
+
|
|
88
|
+
def _imputeDistance(self):
|
|
89
|
+
"""Imputa la distancia entre operaciones.
|
|
90
|
+
|
|
91
|
+
Si GNSSflag = 0, hay dato GPS, si GNSSflag = 1, no hay dato GPS.
|
|
92
|
+
Si la precisión es menor al umbral del mismo lugar entonces se considera que la precision es buena.
|
|
93
|
+
|
|
94
|
+
Luego,
|
|
95
|
+
|
|
96
|
+
Caso 0: GNSSflag = 0 y precision < umbral_mismo_lugar -> la distancia no cambia
|
|
97
|
+
Caso 1: GNSSflag = 0 y precision > umbral_mismo_lugar -> la distancia se reemplazará por la distancia media si el ratio_dCdP es mayor al umbral_ratio_dCdP, sino por la distancia umbral_mismo_lugar
|
|
98
|
+
"""
|
|
99
|
+
|
|
100
|
+
caso1_indexes = np.where((self._GNSSflag == 0) & (self._precision > self._umbral_mismo_lugar))
|
|
101
|
+
|
|
102
|
+
#copiamos self._distances en updatedDistances
|
|
103
|
+
updatedDistances = self._distancias
|
|
104
|
+
|
|
105
|
+
if len(caso1_indexes[0]) > 0:
|
|
106
|
+
updatedDistances[caso1_indexes] = np.vectorize(lambda x: self._umbral_mismo_lugar
|
|
107
|
+
if x < self._umbral_ratio_dCdP
|
|
108
|
+
else self._distanciaMedia)(self.ratio_dCdP[caso1_indexes])
|
|
109
|
+
|
|
110
|
+
return updatedDistances
|
|
111
|
+
|
|
112
|
+
def _checkDeltaTimes(self, ratio_dCdP):
|
|
113
|
+
"""Chqequea que el ratio_dCdP"""
|
|
114
|
+
|
|
115
|
+
return self._umbral_mismo_lugar if ratio_dCdP < self._umbral_ratio_dCdP else self._distanciaMedia
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def distancias(self):
|
|
119
|
+
return self._distancias
|
|
120
|
+
|
|
121
|
+
@property
|
|
122
|
+
def precision(self):
|
|
123
|
+
return self._precision
|
|
124
|
+
|
|
125
|
+
@property
|
|
126
|
+
def GNSSflag(self):
|
|
127
|
+
return self._GNSSflag
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def FIX(self):
|
|
131
|
+
return self._FIX
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def deltaO(self):
|
|
135
|
+
return self._deltaO
|
|
136
|
+
|
|
137
|
+
@property
|
|
138
|
+
def ratio_dCdP(self):
|
|
139
|
+
return self._ratio_dCdP
|
|
140
|
+
|
|
141
|
+
@property
|
|
142
|
+
def updatedDistances(self):
|
|
143
|
+
return self._updatedDistances
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
if __name__ == "__main__":
|
|
147
|
+
tlmda = TLMSensorDataExtractor()
|
|
148
|
+
tsa = TimeSeriesProcessor()
|
|
149
|
+
gpa = GeoProcessor()
|
|
150
|
+
|
|
151
|
+
##datos de ejemplo
|
|
152
|
+
tlmsbp_sample = np.array(['0010001000010010110000011000000111111101001000000000000000000000',
|
|
153
|
+
'0010001000010100110000011000000111111101001000000000000000000000',
|
|
154
|
+
'0010001000010000110000011000000111111101001000000000000000000000',
|
|
155
|
+
'0010001000011010110000011000110111111101001000000000000000000000'])
|
|
156
|
+
|
|
157
|
+
date_oprc = np.array([35235, 35240, 35244, 35248])
|
|
158
|
+
lats = np.array(["-32.331093", "-32.331116", "-32.331131", "-32.331146"]).astype(float)
|
|
159
|
+
lons = np.array(["-57.229733", "-57.229733", "-57.229733", "-57.22974"]).astype(float)
|
|
160
|
+
|
|
161
|
+
precisiones = np.array([1, 0.1, 0.1, 1])
|
|
162
|
+
|
|
163
|
+
tlmda_data = tlmda.fit_transform(tlmsbp_sample)
|
|
164
|
+
timesAC = tlmda.ESTAC
|
|
165
|
+
|
|
166
|
+
time_data = np.hstack((date_oprc.reshape(-1, 1), timesAC.reshape(-1, 1)))
|
|
167
|
+
tsa_data = tsa.fit_transform(time_data)
|
|
168
|
+
|
|
169
|
+
##genero puntos donde la primer columna es latitud y la segunda longitud
|
|
170
|
+
puntos = np.hstack((lats.reshape(-1, 1), lons.reshape(-1, 1)))
|
|
171
|
+
distancias = gpa.fit_transform(puntos)
|
|
172
|
+
|
|
173
|
+
X = np.hstack((distancias.reshape(-1, 1),
|
|
174
|
+
precisiones.reshape(-1, 1),
|
|
175
|
+
tlmda.GNSSFlag.reshape(-1,1),
|
|
176
|
+
tlmda.FIX.reshape(-1,1), tsa.deltaO.reshape(-1,1),
|
|
177
|
+
tsa.ratio_dCdP.reshape(-1,1)))
|
|
178
|
+
|
|
179
|
+
distanceimputer = DistancesImputer()
|
|
180
|
+
distanceimputer.fit(X)
|
|
181
|
+
|
|
182
|
+
print(distanceimputer.transform(X))
|
|
183
|
+
print(distanceimputer.fit_transform(X))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .DistancesImputer import DistancesImputer
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
## Version of the package
|
|
2
|
-
__version__ = "0.3.
|
|
2
|
+
__version__ = "0.3.6"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sarapy
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.6
|
|
4
4
|
Summary: Library for Sarapico Metadata processing
|
|
5
5
|
Home-page: https://github.com/lucasbaldezzari/sarapy
|
|
6
6
|
Author: Lucas Baldezzari
|
|
@@ -24,6 +24,14 @@ Requires-Dist: geopy
|
|
|
24
24
|
|
|
25
25
|
Library for processing SARAPICO project metadata of _AMG_.
|
|
26
26
|
|
|
27
|
+
#### Version 0.3.6
|
|
28
|
+
|
|
29
|
+
- Se agregan argumentos al constructor de _DistanceImputer_ para que Transform y fit_transform puedan entregar un array de shape (n,1) o bien de (n,6) eligiendo la columna a imputar.
|
|
30
|
+
|
|
31
|
+
#### Version 0.3.5
|
|
32
|
+
|
|
33
|
+
- Se implementa clase _DistanceImputer_.
|
|
34
|
+
|
|
27
35
|
#### Version 0.3.4
|
|
28
36
|
|
|
29
37
|
- Se actializa _dataPositions_ de PlantinFMCreator.
|
|
@@ -12,4 +12,6 @@ sarapy/dataProcessing/GeoProcessor.py
|
|
|
12
12
|
sarapy/dataProcessing/PlantinFMCreator.py
|
|
13
13
|
sarapy/dataProcessing/TLMSensorDataExtractor.py
|
|
14
14
|
sarapy/dataProcessing/TimeSeriesProcessor.py
|
|
15
|
-
sarapy/dataProcessing/__init__.py
|
|
15
|
+
sarapy/dataProcessing/__init__.py
|
|
16
|
+
sarapy/preprocessing/DistancesImputer.py
|
|
17
|
+
sarapy/preprocessing/__init__.py
|
|
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
|