Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
wendelin
Commits
f1ef0990
Commit
f1ef0990
authored
Aug 19, 2024
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_wendelin_drone: create dataframe in a separate function
parent
d50714f4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
29 deletions
+27
-29
bt5/erp5_wendelin_drone/PathTemplateItem/portal_callables/DataAnalysisLine_convertDroneDataArrayToScoreArray.py
...les/DataAnalysisLine_convertDroneDataArrayToScoreArray.py
+27
-29
No files found.
bt5/erp5_wendelin_drone/PathTemplateItem/portal_callables/DataAnalysisLine_convertDroneDataArrayToScoreArray.py
View file @
f1ef0990
...
...
@@ -36,8 +36,11 @@ def rated_value(next_value, previous_value, rate):
else
:
return
previous_value
+
(
next_value
-
previous_value
)
*
rate
def
nparray_to_dataframe
(
nparray
):
return
pd
.
DataFrame
(
data
=
nparray
.
getArray
(),
columns
=
[
"timestamp (ms)"
,
"latitude ()"
,
"longitude ()"
,
"AMSL (m)"
,
"rel altitude (m)"
,
"yaw ()"
,
"ground speed (m/s)"
,
"climb rate (m/s)"
],
)
...
...
@@ -51,10 +54,7 @@ sim_flight_names = list(sim_array)
if
len
(
real_flight_names
)
==
0
:
context
.
log
(
"The real flight data is still missing"
)
return
nparray
=
real_array
.
get
(
real_flight_names
[
0
])
nparray_real
=
nparray
.
getArray
()
real_flight
=
pd
.
DataFrame
(
data
=
nparray_real
,
columns
=
[
"timestamp (ms)"
,
"latitude ()"
,
"longitude ()"
,
"AMSL (m)"
,
"rel altitude (m)"
,
"yaw ()"
,
"ground speed (m/s)"
,
"climb rate (m/s)"
])
real_flight
=
nparray_to_dataframe
(
real_array
.
get
(
real_flight_names
[
0
]))
...
...
@@ -65,10 +65,10 @@ seen_sims = progress_indicator_sim.getStringOffsetIndex()
new_seen
=
""
if
seen_sims
is
None
:
seen_sims
=
""
score_dtypes
=
{
'name'
:
'S256'
,
'Param1'
:
'f16'
,
'Param2'
:
'f16'
,
'distance_reciprocal'
:
'f8'
,
'ASML_reciprocal'
:
'f8'
,
'ground_speed_reciprocal'
:
'f8'
,
'climb_rate_reciprocal'
:
'f8'
,
'score_reciprocal'
:
'f16'
,
'score_cosine_row'
:
'f16'
,
score_dtypes
=
{
'name'
:
'S256'
,
'Param1'
:
'f16'
,
'Param2'
:
'f16'
,
'distance_reciprocal'
:
'f8'
,
'ASML_reciprocal'
:
'f8'
,
'ground_speed_reciprocal'
:
'f8'
,
'climb_rate_reciprocal'
:
'f8'
,
'score_reciprocal'
:
'f16'
,
'score_cosine_row'
:
'f16'
,
'score_cosine_column'
:
'f16'
}
_
=
out_array_scores
[
"Data Array"
].
initArray
(
shape
=
(
0
,),
dtype
=
list
(
score_dtypes
.
items
()))
...
...
@@ -105,16 +105,14 @@ not_seen_list = [x for x in sim_flight_names if x not in seen_sims]
for
name
in
not_seen_list
[:]:
if
name
[:
14
]
==
'simulation_log'
:
splitted_filename
=
name
[:
-
4
].
split
(
'_'
)
distance_list_tuple
=
([],[],
[],
[],
[])
nparray
=
sim_array
.
get
(
name
)
nparray_sim
=
nparray
.
getArray
()
simulated_flight
=
pd
.
DataFrame
(
data
=
nparray_sim
,
columns
=
[
"timestamp (ms)"
,
"latitude ()"
,
"longitude ()"
,
"AMSL (m)"
,
"rel altitude (m)"
,
"yaw ()"
,
"ground speed (m/s)"
,
"climb rate (m/s)"
])
distance_list_tuple
=
([],[],
[],
[],
[])
simulated_flight
=
nparray_to_dataframe
(
sim_array
.
get
(
name
))
simulated_flight
=
simulated_flight
.
applymap
(
lambda
value
:
np
.
format_float_scientific
(
float
(
value
))
if
isinstance
(
value
,
str
)
and
'e'
in
value
else
value
)
simulated_flight_list
.
append
(
simulated_flight
)
max_simulator_timestamp
=
simulated_flight
[
"timestamp (ms)"
].
max
()
min_simulator_timestamp
=
simulated_flight
[
"timestamp (ms)"
].
min
()
tmp_sim
=
{
'longitude'
:
[],
'latitude'
:
[],
...
...
@@ -129,7 +127,7 @@ for name in not_seen_list[:]:
'ground_speed'
:
[],
'climb_rate'
:
[]
}
for
idx
,
row
in
real_flight
.
iterrows
():
if
max_simulator_timestamp
<
row
[
"timestamp (ms)"
]:
break
...
...
@@ -137,17 +135,17 @@ for name in not_seen_list[:]:
continue
over_timestamp
=
simulated_flight
[
simulated_flight
[
"timestamp (ms)"
]
>=
row
[
"timestamp (ms)"
]].
head
(
1
)
under_timestamp
=
simulated_flight
[
simulated_flight
[
"timestamp (ms)"
]
<=
row
[
"timestamp (ms)"
]].
tail
(
1
)
if
(
float
(
over_timestamp
[
"timestamp (ms)"
])
-
float
(
under_timestamp
[
"timestamp (ms)"
]))
==
0
:
rate
=
0
else
:
rate
=
(
float
(
over_timestamp
[
"timestamp (ms)"
])
-
row
[
"timestamp (ms)"
])
/
(
float
(
over_timestamp
[
"timestamp (ms)"
])
-
float
(
under_timestamp
[
"timestamp (ms)"
]))
tmp_sim
[
"latitude"
].
append
(
rated_value
(
float
(
over_timestamp
[
"latitude ()"
]),
float
(
under_timestamp
[
"latitude ()"
]),
rate
))
tmp_sim
[
"latitude"
].
append
(
rated_value
(
float
(
over_timestamp
[
"latitude ()"
]),
float
(
under_timestamp
[
"latitude ()"
]),
rate
))
tmp_sim
[
"longitude"
].
append
(
rated_value
(
float
(
over_timestamp
[
"longitude ()"
]),
float
(
under_timestamp
[
"longitude ()"
]),
rate
))
tmp_sim
[
"asml"
].
append
(
rated_value
(
float
(
over_timestamp
[
"AMSL (m)"
]),
float
(
under_timestamp
[
"AMSL (m)"
]),
rate
))
tmp_sim
[
"ground_speed"
].
append
(
rated_value
(
float
(
over_timestamp
[
"ground speed (m/s)"
]),
float
(
under_timestamp
[
"ground speed (m/s)"
]),
rate
))
tmp_sim
[
"climb_rate"
].
append
(
rated_value
(
float
(
over_timestamp
[
"climb rate (m/s)"
]),
float
(
under_timestamp
[
"climb rate (m/s)"
]),
rate
))
tmp_sim
[
"climb_rate"
].
append
(
rated_value
(
float
(
over_timestamp
[
"climb rate (m/s)"
]),
float
(
under_timestamp
[
"climb rate (m/s)"
]),
rate
))
tmp_real
[
"latitude"
].
append
(
row
[
"latitude ()"
])
tmp_real
[
"longitude"
].
append
(
row
[
"longitude ()"
])
tmp_real
[
"asml"
].
append
(
row
[
"AMSL (m)"
])
...
...
@@ -179,7 +177,7 @@ for name in not_seen_list[:]:
if
match
:
values_str
=
match
.
group
(
1
)
parameters
=
[
float
(
val
.
strip
())
for
val
in
values_str
.
split
(
','
)]
reciprocal_of_difference
=
[
1
/
(
1
+
mean_operation
(
list
(
map
(
abs
,
x
))))
for
x
in
distance_list_tuple
[
1
:]]
score_reciprocal
=
sum
(
reciprocal_of_difference
)
...
...
@@ -243,9 +241,9 @@ plot_dtypes = {
'ASML_reciprocal'
:
'float64'
,
'ground_speed_reciprocal'
:
'float64'
,
'climb_rate_reciprocal'
:
'float64'
,
'score_reciprocal'
:
'float64'
,
'score_cosine_row'
:
'float64'
,
'score_cosine_column'
:
'float64'
,
'score_reciprocal'
:
'float64'
,
'score_cosine_row'
:
'float64'
,
'score_cosine_column'
:
'float64'
,
}
...
...
@@ -266,16 +264,16 @@ for data_dict in selected_simulation_data_dict_list:
# Initialize a list for the key if it doesn't exist
if
key
not
in
combined_data
:
combined_data
[
key
]
=
[]
# Append the value to the list
combined_data
[
key
].
append
(
value
)
score_dtypes
=
{
'name'
:
'S256'
,
'Param1'
:
'float64'
,
'Param2'
:
'float64'
,
'distance_reciprocal'
:
'float64'
,
'ASML_reciprocal'
:
'float64'
,
'ground_speed_reciprocal'
:
'float64'
,
'climb_rate_reciprocal'
:
'float64'
,
'score_reciprocal'
:
'float64'
,
'score_cosine_row'
:
'float64'
,
score_dtypes
=
{
'name'
:
'S256'
,
'Param1'
:
'float64'
,
'Param2'
:
'float64'
,
'distance_reciprocal'
:
'float64'
,
'ASML_reciprocal'
:
'float64'
,
'ground_speed_reciprocal'
:
'float64'
,
'climb_rate_reciprocal'
:
'float64'
,
'score_reciprocal'
:
'float64'
,
'score_cosine_row'
:
'float64'
,
'score_cosine_column'
:
'float64'
}
scores_df
=
pd
.
DataFrame
(
combined_data
)
scores_df
=
scores_df
.
astype
(
score_dtypes
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment