saba000farahani
commited on
Commit
•
09de96b
1
Parent(s):
f265442
Update app.py
Browse files
app.py
CHANGED
@@ -105,6 +105,8 @@ def predict_and_plot(velocity, temperature, precipitation, humidity):
|
|
105 |
cleaning_time = t1 + (threshold - c1) * (t2 - t1) / (c2 - c1)
|
106 |
cleaning_times.append(cleaning_time)
|
107 |
break
|
|
|
|
|
108 |
return cleaning_times
|
109 |
|
110 |
# Calculate cleaning times for all 6 lidars
|
@@ -114,22 +116,22 @@ def predict_and_plot(velocity, temperature, precipitation, humidity):
|
|
114 |
lidar_names = ['F/L', 'F/R', 'Left', 'Right', 'Roof', 'Rear']
|
115 |
|
116 |
# Plot the graph
|
117 |
-
plt.
|
118 |
|
119 |
for i in range(simulated_contamination_levels.shape[1]):
|
120 |
-
|
121 |
-
|
122 |
if i < len(cleaning_times):
|
123 |
-
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
|
131 |
# Flatten the results into a single list of 13 outputs
|
132 |
-
plot_output =
|
133 |
contamination_output = [f"{val * 100:.2f}%" for val in contamination_levels[0]]
|
134 |
cleaning_time_output = [f"{val:.2f}" for val in cleaning_times]
|
135 |
|
|
|
105 |
cleaning_time = t1 + (threshold - c1) * (t2 - t1) / (c2 - c1)
|
106 |
cleaning_times.append(cleaning_time)
|
107 |
break
|
108 |
+
else:
|
109 |
+
cleaning_times.append(time_intervals[-1]) # If threshold is not reached
|
110 |
return cleaning_times
|
111 |
|
112 |
# Calculate cleaning times for all 6 lidars
|
|
|
116 |
lidar_names = ['F/L', 'F/R', 'Left', 'Right', 'Roof', 'Rear']
|
117 |
|
118 |
# Plot the graph
|
119 |
+
fig, ax = plt.subplots(figsize=(12, 8))
|
120 |
|
121 |
for i in range(simulated_contamination_levels.shape[1]):
|
122 |
+
ax.plot(time_intervals, simulated_contamination_levels[:, i], label=f'{lidar_names[i]}')
|
123 |
+
ax.axhline(y=0.4, color='r', linestyle='--', label='Contamination Threshold' if i == 0 else "")
|
124 |
if i < len(cleaning_times):
|
125 |
+
ax.scatter(cleaning_times[i], 0.4, color='k') # Mark the cleaning time point
|
126 |
|
127 |
+
ax.set_title('Contamination Levels Over Time for Each Lidar')
|
128 |
+
ax.set_xlabel('Time (seconds)')
|
129 |
+
ax.set_ylabel('Contamination Level')
|
130 |
+
ax.legend()
|
131 |
+
ax.grid(True)
|
132 |
|
133 |
# Flatten the results into a single list of 13 outputs
|
134 |
+
plot_output = fig
|
135 |
contamination_output = [f"{val * 100:.2f}%" for val in contamination_levels[0]]
|
136 |
cleaning_time_output = [f"{val:.2f}" for val in cleaning_times]
|
137 |
|