Commit f1ef0990 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

erp5_wendelin_drone: create dataframe in a separate function

parent d50714f4
...@@ -36,8 +36,11 @@ def rated_value(next_value, previous_value, rate): ...@@ -36,8 +36,11 @@ def rated_value(next_value, previous_value, rate):
else: else:
return previous_value + (next_value - previous_value) * rate 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) ...@@ -51,10 +54,7 @@ sim_flight_names = list(sim_array)
if len(real_flight_names) == 0: if len(real_flight_names) == 0:
context.log("The real flight data is still missing") context.log("The real flight data is still missing")
return return
nparray = real_array.get(real_flight_names[0]) real_flight = nparray_to_dataframe(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)"])
...@@ -106,9 +106,7 @@ for name in not_seen_list[:]: ...@@ -106,9 +106,7 @@ for name in not_seen_list[:]:
if name[:14] == 'simulation_log': if name[:14] == 'simulation_log':
splitted_filename = name[:-4].split('_') splitted_filename = name[:-4].split('_')
distance_list_tuple = ([],[], [], [], []) distance_list_tuple = ([],[], [], [], [])
nparray = sim_array.get(name) simulated_flight = nparray_to_dataframe(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)"])
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 = 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) simulated_flight_list.append(simulated_flight)
max_simulator_timestamp = simulated_flight["timestamp (ms)"].max() max_simulator_timestamp = simulated_flight["timestamp (ms)"].max()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment