CatherineProtas commited on
Commit
1713d64
1 Parent(s): f2f15d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -68,7 +68,7 @@ def get_weather_data(location):
68
  'wind_speed': data['wind'].get('speed', 0),
69
  'pressure': data['main'].get('pressure', 0),
70
  'humidity': data['main'].get('humidity', 0),
71
- 'visibility': data.get('visibility', 10000) / 1000,
72
  'timestamp': datetime.fromtimestamp(data['dt'])
73
  }
74
  except requests.exceptions.RequestException as e:
@@ -90,7 +90,7 @@ def get_forecast_data(location):
90
  'description': item['weather'][0].get('description', ''),
91
  'wind_speed': item['wind'].get('speed', 0),
92
  'pressure': item['main'].get('pressure', 0),
93
- 'visibility': item.get('visibility', 10000) / 1000,
94
  'timestamp': datetime.fromtimestamp(item['dt'])
95
  })
96
  return forecasts
@@ -122,7 +122,6 @@ def determine_transmission_power(image_prediction, weather_data, forecast_data=N
122
  current_fog_risk = calculate_fog_risk_score(weather_data)
123
 
124
  # Combine image and weather predictions with weighted average
125
- # Give slightly more weight to image prediction as it's more reliable
126
  combined_fog_risk = (image_fog_confidence * 0.6) + (current_fog_risk * 0.4)
127
 
128
  # Initialize explanation
@@ -150,7 +149,6 @@ def determine_transmission_power(image_prediction, weather_data, forecast_data=N
150
  # Find periods of high risk
151
  high_risk_periods = [risk > 0.6 for risk in future_risks]
152
  if any(high_risk_periods):
153
- # Find the last high-risk timestamp
154
  last_high_risk_idx = len(high_risk_periods) - 1 - high_risk_periods[::-1].index(True)
155
  duration = forecast_data[last_high_risk_idx]['timestamp'] - weather_data['timestamp']
156
 
@@ -187,7 +185,6 @@ def integrated_prediction(image, location):
187
  f"Current Conditions ({current_weather['timestamp'].strftime('%Y-%m-%d %H:%M')})",
188
  f"Temperature: {current_weather['temperature']:.1f}°C",
189
  f"Humidity: {current_weather['humidity']}%",
190
- f"Visibility: {current_weather['visibility']:.1f} km",
191
  f"Wind Speed: {current_weather['wind_speed']} m/s",
192
  "",
193
  "Analysis Results:",
 
68
  'wind_speed': data['wind'].get('speed', 0),
69
  'pressure': data['main'].get('pressure', 0),
70
  'humidity': data['main'].get('humidity', 0),
71
+ 'visibility': data.get('visibility', 10000) / 1000, # Still needed for calculations
72
  'timestamp': datetime.fromtimestamp(data['dt'])
73
  }
74
  except requests.exceptions.RequestException as e:
 
90
  'description': item['weather'][0].get('description', ''),
91
  'wind_speed': item['wind'].get('speed', 0),
92
  'pressure': item['main'].get('pressure', 0),
93
+ 'visibility': item.get('visibility', 10000) / 1000, # Still needed for calculations
94
  'timestamp': datetime.fromtimestamp(item['dt'])
95
  })
96
  return forecasts
 
122
  current_fog_risk = calculate_fog_risk_score(weather_data)
123
 
124
  # Combine image and weather predictions with weighted average
 
125
  combined_fog_risk = (image_fog_confidence * 0.6) + (current_fog_risk * 0.4)
126
 
127
  # Initialize explanation
 
149
  # Find periods of high risk
150
  high_risk_periods = [risk > 0.6 for risk in future_risks]
151
  if any(high_risk_periods):
 
152
  last_high_risk_idx = len(high_risk_periods) - 1 - high_risk_periods[::-1].index(True)
153
  duration = forecast_data[last_high_risk_idx]['timestamp'] - weather_data['timestamp']
154
 
 
185
  f"Current Conditions ({current_weather['timestamp'].strftime('%Y-%m-%d %H:%M')})",
186
  f"Temperature: {current_weather['temperature']:.1f}°C",
187
  f"Humidity: {current_weather['humidity']}%",
 
188
  f"Wind Speed: {current_weather['wind_speed']} m/s",
189
  "",
190
  "Analysis Results:",