saba000farahani commited on
Commit
09de96b
1 Parent(s): f265442

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
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.figure(figsize=(12, 8))
118
 
119
  for i in range(simulated_contamination_levels.shape[1]):
120
- plt.plot(time_intervals, simulated_contamination_levels[:, i], label=f'{lidar_names[i]}')
121
- plt.axhline(y=0.4, color='r', linestyle='--', label='Contamination Threshold' if i == 0 else "")
122
  if i < len(cleaning_times):
123
- plt.scatter(cleaning_times[i], 0.4, color='k') # Mark the cleaning time point
124
 
125
- plt.title('Contamination Levels Over Time for Each Lidar')
126
- plt.xlabel('Time (seconds)')
127
- plt.ylabel('Contamination Level')
128
- plt.legend()
129
- plt.grid(True)
130
 
131
  # Flatten the results into a single list of 13 outputs
132
- plot_output = plt
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