AkashMnd commited on
Commit
2c45f84
·
verified ·
1 Parent(s): 0c7aed3

Upload 4 files

Browse files
Files changed (4) hide show
  1. app.py +609 -0
  2. bronx.csv +170 -0
  3. check.csv +0 -0
  4. manhattan.csv +170 -0
app.py ADDED
@@ -0,0 +1,609 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import geopandas as gpd
5
+ from shapely.geometry import Point, box
6
+ import pydeck as pdk
7
+ import google.generativeai as genai
8
+ import datetime
9
+ import warnings
10
+ import traceback
11
+ import folium
12
+ from streamlit_folium import st_folium
13
+ import os
14
+ import matplotlib.colors
15
+ import matplotlib.cm as cm
16
+
17
+ # Required imports for satellite data
18
+ import pystac_client
19
+ import planetary_computer as pc
20
+ import rioxarray
21
+ import xarray as xr
22
+
23
+ # --- Configuration ---
24
+ APP_TITLE = "UHI Analysis Tool"
25
+ NYC_CENTER_APPROX = [40.78, -73.96]
26
+ PYDECK_MAP_ZOOM = 11.5 # Slightly closer zoom
27
+ FOLIUM_MAP_ZOOM = 12
28
+ TARGET_CRS = "EPSG:4326" # WGS 84 (Latitude/Longitude)
29
+ PROCESSING_CRS = "EPSG:32618" # UTM Zone 18N (for distance calculations)
30
+ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
31
+ TARGET_FILE = os.path.join(BASE_DIR, 'check.csv') # User's UHI data
32
+ WEATHER_FILE_MANHATTAN = os.path.join(BASE_DIR, 'manhattan.csv')
33
+ WEATHER_FILE_BRONX = os.path.join(BASE_DIR, 'bronx.csv')
34
+ WEATHER_STATIONS = {
35
+ 'Manhattan': {'file': WEATHER_FILE_MANHATTAN, 'coords': (-73.96, 40.78), 'desc': 'Central Park Area'},
36
+ 'Bronx': {'file': WEATHER_FILE_BRONX, 'coords': (-73.89, 40.86), 'desc': 'Bronx Area'}
37
+ }
38
+ BANDS_TO_LOAD = ["B02", "B03", "B04", "B08", "B11", "B12"]
39
+
40
+ # Visualization & Analysis Parameters
41
+ VIS_VARIABLES = ['UHI Index', 'Temperature (°C)', 'Relative Humidity (%)', 'NDBI', 'Albedo']
42
+ DEFAULT_COLOR_VAR = 'NDBI'
43
+ NEARBY_RADIUS_M = 150 # Radius for calculating nearby stats for AI context
44
+
45
+ # Pydeck Height Scaling
46
+ UHI_BASELINE_FOR_HEIGHT = 1.0
47
+ ELEVATION_SCALING_FACTOR = 1200 # Tunable height multiplier
48
+ COLUMN_RADIUS = 30
49
+
50
+ # --- Warnings ---
51
+ warnings.filterwarnings('ignore', category=FutureWarning)
52
+ warnings.filterwarnings('ignore', category=UserWarning, module='shapely')
53
+ warnings.filterwarnings('ignore', category=UserWarning, module='pyproj')
54
+ warnings.filterwarnings("ignore", message="The value of the smallest subnormal for <class 'numpy.float64'> type is zero.")
55
+
56
+ # --- Logging ---
57
+ if 'interaction_logs' not in st.session_state: st.session_state.interaction_logs = []
58
+ if 'data_load_logs' not in st.session_state: st.session_state.data_load_logs = []
59
+ def log_interaction(msg):
60
+ timestamp = datetime.datetime.now().strftime('%H:%M:%S.%f')[:-3]; log_entry = f"{timestamp} INTERACTION DEBUG: {msg}"; st.session_state.interaction_logs.append(log_entry); print(log_entry)
61
+ def log_data(msg):
62
+ timestamp = datetime.datetime.now().strftime('%H:%M:%S.%f')[:-3]; log_entry = f"{timestamp} DATA_LOAD DEBUG: {msg}"; st.session_state.data_load_logs.append(log_entry); print(log_entry)
63
+
64
+ # --- Gemini API ---
65
+ def configure_gemini(api_key):
66
+ log_interaction("Attempting to configure Gemini API...")
67
+ try: genai.configure(api_key=api_key); log_interaction("Gemini API configured successfully."); return True
68
+ except Exception as e: st.error(f"Error configuring Gemini API: {e}"); log_interaction(f"Gemini API config error: {e}"); return False
69
+
70
+ def get_gemini_response(prompt):
71
+ log_interaction("Sending prompt to Gemini...")
72
+ print(f"--- GEMINI PROMPT START ---\n{prompt}\n--- GEMINI PROMPT END ---")
73
+ try:
74
+ model = genai.GenerativeModel('gemini-1.5-flash'); response = model.generate_content(prompt)
75
+ if not response.parts:
76
+ safety_feedback = response.prompt_feedback if hasattr(response, 'prompt_feedback') else 'No specific feedback.'; log_interaction(f"Gemini response blocked/empty. Feedback: {safety_feedback}")
77
+ st.warning(f"Gemini response blocked/empty. Feedback: {safety_feedback}"); return f"Response blocked (Feedback: {safety_feedback})"
78
+ log_interaction(f"Gemini response received (Length: {len(response.text)})."); return response.text
79
+ except Exception as e: log_interaction(f"Error contacting Gemini: {e}"); st.error(f"Error contacting Gemini: {str(e)}"); return f"Error contacting Gemini: {str(e)}"
80
+
81
+ # --- Data Loading & Processing Functions ---
82
+
83
+ def parse_weather_datetime(df, filename):
84
+ log_data(f"Attempting to parse datetime in {filename}...")
85
+ try:
86
+ df['datetime_str_cleaned'] = df['Date / Time'].str.replace(' EDT', '', regex=False)
87
+ df['datetime_local'] = pd.to_datetime(df['datetime_str_cleaned'], format='%Y-%m-%d %H:%M:%S')
88
+ df['datetime_utc'] = df['datetime_local'].dt.tz_localize('US/Eastern', ambiguous='infer').dt.tz_convert('UTC')
89
+ log_data(f"Successfully parsed weather datetime for {filename}.")
90
+ return df.drop(columns=['Date / Time', 'datetime_str_cleaned', 'datetime_local'])
91
+ except Exception as e:
92
+ problematic_value = "N/A"
93
+ try: pd.to_datetime(df['Date / Time'].str.replace(' EDT', '', regex=False), format='%Y-%m-%d %H:%M:%S', errors='raise')
94
+ except Exception as e_inner:
95
+ if hasattr(e_inner, 'args') and len(e_inner.args) > 0: err_str = str(e_inner.args[0]); import re; match = re.search(r"time data '([^']*)'", err_str);
96
+ if match: problematic_value = match.group(1)
97
+ log_data(f"ERROR parsing datetime in {filename}: {e}. Problematic value example: '{problematic_value}'")
98
+ return None
99
+
100
+ def parse_target_datetime(df, filename):
101
+ log_data(f"Attempting to parse datetime in {filename}...")
102
+ try:
103
+ df['datetime_local'] = pd.to_datetime(df['datetime'], format='%d-%m-%Y %H:%M')
104
+ df['datetime_utc'] = df['datetime_local'].dt.tz_localize('US/Eastern', ambiguous='infer').dt.tz_convert('UTC')
105
+ log_data(f"Successfully parsed target datetime for {filename}.")
106
+ return df.drop(columns=['datetime', 'datetime_local'])
107
+ except Exception as e:
108
+ problematic_value = "N/A"
109
+ try: pd.to_datetime(df['datetime'], format='%d-%m-%Y %H:%M', errors='raise')
110
+ except Exception as e_inner:
111
+ if hasattr(e_inner, 'args') and len(e_inner.args) > 0: err_str = str(e_inner.args[0]); import re; match = re.search(r"time data '([^']*)'", err_str);
112
+ if match: problematic_value = match.group(1)
113
+ log_data(f"ERROR parsing datetime in {filename}: {e}. Problematic value example: '{problematic_value}'")
114
+ return None
115
+
116
+ @st.cache_data(ttl=3600)
117
+ def load_and_merge_csv_data():
118
+ st.session_state.data_load_logs = []
119
+ log_data("Starting CSV data load and merge...")
120
+ gdf_target = None; gdf_merged = None
121
+ try:
122
+ df_target = pd.read_csv(TARGET_FILE)
123
+ log_data(f"Loaded target file: {TARGET_FILE} ({len(df_target)} rows)")
124
+ df_target = df_target.rename(columns={'Longitude': 'longitude', 'Latitude': 'latitude', 'UHI Index': 'uhi_index'})
125
+ df_target_parsed = parse_target_datetime(df_target.copy(), os.path.basename(TARGET_FILE))
126
+ if df_target_parsed is None: log_data("Stopping merge: target datetime parse failed."); st.error(f"Datetime parse error in {os.path.basename(TARGET_FILE)}"); return None
127
+ geometry = [Point(xy) for xy in zip(df_target_parsed.longitude, df_target_parsed.latitude)]
128
+ gdf_target = gpd.GeoDataFrame(df_target_parsed, geometry=geometry, crs=TARGET_CRS); log_data("Created GeoDataFrame from target data.")
129
+ gdf_target = gdf_target.sort_values(by='datetime_utc'); log_data("Sorted target GeoDataFrame by datetime_utc.")
130
+ gdf_target_proj = gdf_target.to_crs(PROCESSING_CRS); log_data(f"Projected target data to {PROCESSING_CRS}.")
131
+ except FileNotFoundError: st.error(f"Error: Target file '{TARGET_FILE}' not found."); log_data(f"ERROR: Target file not found: {TARGET_FILE}"); return None
132
+ except Exception as e: st.error(f"Error loading/processing target file {TARGET_FILE}: {e}"); log_data(f"ERROR loading target file: {e}\n{traceback.format_exc()}"); return None
133
+
134
+ loaded_weather_dfs = {}
135
+ for name, info in WEATHER_STATIONS.items():
136
+ try:
137
+ df_w = pd.read_csv(info['file']); log_data(f"Loaded weather file: {info['file']} ({len(df_w)} rows)")
138
+ required_cols = ['Date / Time', 'Air Temp at Surface [degC]', 'Relative Humidity [percent]', 'Avg Wind Speed [m/s]', 'Solar Flux [W/m^2]']
139
+ if not all(col in df_w.columns for col in required_cols): log_data(f"WARNING: Missing cols in {info['file']}. Skipping."); continue
140
+ df_w = df_w[required_cols].copy(); df_w.columns = ['Date / Time', 'weather_temp', 'weather_rh', 'weather_wind', 'weather_solar']
141
+ df_w_parsed = parse_weather_datetime(df_w.copy(), os.path.basename(info['file']))
142
+ if df_w_parsed is None: st.warning(f"Datetime parse failed for {os.path.basename(info['file'])}."); continue
143
+ df_w_parsed.set_index('datetime_utc', inplace=True)
144
+ df_w_parsed.dropna(subset=['weather_temp', 'weather_rh'], inplace=True)
145
+ loaded_weather_dfs[name] = df_w_parsed.sort_index(); log_data(f"Processed weather data for {name}.")
146
+ except FileNotFoundError: st.warning(f"Weather file '{info['file']}' not found."); log_data(f"WARNING: Weather file not found: {info['file']}")
147
+ except Exception as e: st.error(f"Error loading weather file {info['file']}: {e}"); log_data(f"ERROR loading weather file {info['file']}: {e}\n{traceback.format_exc()}")
148
+
149
+ if not loaded_weather_dfs:
150
+ log_data("WARNING: No weather data loaded. Merged data will lack weather info.")
151
+ for col in ['weather_temp', 'weather_rh', 'weather_wind', 'weather_solar', 'nearest_station']:
152
+ if col not in gdf_target.columns: gdf_target[col] = np.nan
153
+ gdf_merged = gdf_target
154
+ else:
155
+ log_data("Assigning nearest weather station..."); station_points = {name: Point(info['coords'][0], info['coords'][1]) for name, info in WEATHER_STATIONS.items() if name in loaded_weather_dfs}
156
+ station_gdf = gpd.GeoDataFrame({'station_name': list(station_points.keys())}, geometry=list(station_points.values()), crs=TARGET_CRS)
157
+ station_gdf_proj = station_gdf.to_crs(PROCESSING_CRS)
158
+ nearest_station_indices = gdf_target_proj.geometry.apply(lambda p: station_gdf_proj.distance(p).idxmin())
159
+ gdf_target['nearest_station'] = nearest_station_indices.map(station_gdf_proj['station_name']); log_data("Nearest stations assigned.")
160
+ log_data("Merging weather data..."); weather_data_list = []
161
+ merge_failures = 0
162
+ for index, target_point in gdf_target.iterrows():
163
+ station_name = target_point['nearest_station']; target_dt = target_point['datetime_utc']
164
+ point_weather = {'weather_temp': np.nan, 'weather_rh': np.nan, 'weather_wind': np.nan, 'weather_solar': np.nan}
165
+ if pd.notna(target_dt) and station_name in loaded_weather_dfs:
166
+ df_w_station = loaded_weather_dfs[station_name]; target_time_df = pd.DataFrame([target_dt], columns=['datetime_utc']).set_index('datetime_utc')
167
+ try:
168
+ merged = pd.merge_asof(target_time_df, df_w_station, left_index=True, right_index=True, direction='nearest', tolerance=pd.Timedelta(minutes=15))
169
+ if merged.empty or merged[['weather_temp', 'weather_rh']].isnull().any(axis=1).iloc[0]: merge_failures += 1
170
+ else: nearest_weather = merged.iloc[0]; point_weather = {'weather_temp': nearest_weather['weather_temp'], 'weather_rh': nearest_weather['weather_rh'], 'weather_wind': nearest_weather.get('weather_wind', np.nan), 'weather_solar': nearest_weather.get('weather_solar', np.nan)}
171
+ except Exception as merge_e: log_data(f" Index {index}: ERROR during merge_asof: {merge_e}"); merge_failures += 1
172
+ else: merge_failures += 1
173
+ weather_data_list.append(point_weather)
174
+ weather_df = pd.DataFrame(weather_data_list, index=gdf_target.index); gdf_merged = gdf_target.join(weather_df); log_data("Weather data merged.")
175
+ if merge_failures > 0: log_data(f"WARNING: Failed to find matching weather data for {merge_failures}/{len(gdf_target)} points.")
176
+ merged_nan_count = gdf_merged[['weather_temp', 'weather_rh']].isnull().sum().sum()
177
+ if merged_nan_count > 0: log_data(f"INFO: {merged_nan_count} NaN values present in merged Temp/RH columns.")
178
+ log_data("Finished load_and_merge_csv_data function.")
179
+ return gdf_merged
180
+
181
+ @st.cache_data(ttl=3600)
182
+ def add_satellite_features(_gdf_data, selected_date_str):
183
+ sat_logs = []
184
+ def log_sat(msg): sat_logs.append(f"{datetime.datetime.now().strftime('%H:%M:%S.%f')[:-3]} SAT_DEBUG: {msg}")
185
+ log_sat(f"Starting satellite feature sampling for {selected_date_str} at {len(_gdf_data)} points...")
186
+ if _gdf_data is None or _gdf_data.empty: log_sat("Input GDF empty, skipping satellite."); return _gdf_data, sat_logs
187
+ gdf_processed = _gdf_data
188
+ if _gdf_data.crs != TARGET_CRS:
189
+ try: gdf_processed = _gdf_data.to_crs(TARGET_CRS); log_sat(f"Converted input GDF CRS from {_gdf_data.crs} to {TARGET_CRS}.")
190
+ except Exception as e: log_sat(f"ERROR converting GDF to {TARGET_CRS}: {e}"); gdf_with_sat = _gdf_data.copy(); gdf_with_sat['NDBI'] = np.nan; gdf_with_sat['Albedo'] = np.nan; return gdf_with_sat, sat_logs
191
+ bounds = gdf_processed.total_bounds; log_sat(f"Bounds for satellite search: {np.round(bounds, 4)}"); selected_date = datetime.datetime.strptime(selected_date_str, '%Y-%m-%d').date()
192
+ gdf_with_sat = gdf_processed.copy()
193
+ try:
194
+ catalog = pystac_client.Client.open("https://planetarycomputer.microsoft.com/api/stac/v1", modifier=pc.sign_inplace)
195
+ start_date = selected_date - datetime.timedelta(days=2); end_date = selected_date + datetime.timedelta(days=2); search_window = f"{start_date.strftime('%Y-%m-%d')}/{end_date.strftime('%Y-%m-%d')}"
196
+ log_sat(f"Searching STAC API: bbox={np.round(bounds,4)}, datetime={search_window}")
197
+ cloud_cover_limit = st.session_state.get('cloud_slider', 35); log_sat(f"Using max cloud cover limit: {cloud_cover_limit}%")
198
+ search = catalog.search(collections=["sentinel-2-l2a"], bbox=bounds, datetime=search_window, query={"eo:cloud_cover": {"lt": cloud_cover_limit}})
199
+ items = list(search.get_items()); log_sat(f"Found {len(items)} potential satellite items.")
200
+ if not items: log_sat(f"No suitable satellite items found."); gdf_with_sat['NDBI'] = np.nan; gdf_with_sat['Albedo'] = np.nan; return gdf_with_sat, sat_logs
201
+ items.sort(key=lambda item: (item.properties["eo:cloud_cover"], abs((datetime.datetime.fromisoformat(item.properties['datetime'].replace("Z", "+00:00")).date() - selected_date).days)))
202
+ selected_item = items[0]; item_datetime = datetime.datetime.fromisoformat(selected_item.properties['datetime'].replace("Z", "+00:00"))
203
+ log_sat(f"Selected satellite item: {selected_item.id} ({item_datetime.strftime('%Y-%m-%d %H:%M:%S UTC')}, Cloud: {selected_item.properties['eo:cloud_cover']:.1f}%)")
204
+ band_data = {}; raster_crs = None; gdf_points_proj = None; all_bands_sampled = True
205
+ for band in BANDS_TO_LOAD:
206
+ try:
207
+ asset = selected_item.assets.get(band)
208
+ if not asset: log_sat(f"Asset {band} not found."); band_data[band] = pd.Series(np.nan, index=gdf_with_sat.index); all_bands_sampled = False; continue
209
+ href = pc.sign(asset.href)
210
+ try:
211
+ with rioxarray.open_rasterio(href, chunks={'x': 1024, 'y': 1024}) as da:
212
+ if 'band' in da.dims: da = da.squeeze('band', drop=True); da = da.rio.write_crs(da.rio.crs)
213
+ if raster_crs is None:
214
+ raster_crs = da.rio.crs; log_sat(f"Satellite raster CRS: {raster_crs}")
215
+ if gdf_with_sat.crs != raster_crs:
216
+ # --- CORRECTED BLOCK ---
217
+ try:
218
+ with warnings.catch_warnings():
219
+ warnings.simplefilter("ignore", category=UserWarning) # Statement 1 inside with
220
+ gdf_points_proj = gdf_with_sat.to_crs(raster_crs) # Statement 2 inside with
221
+ # Log outside the warnings context, after successful projection
222
+ log_sat(f"Projected CSV points from {gdf_with_sat.crs} to raster CRS {raster_crs} for sampling.")
223
+ except Exception as crs_e:
224
+ log_sat(f"ERROR projecting CSV points to raster CRS {raster_crs}: {crs_e}") # Log specific CRS
225
+ all_bands_sampled = False
226
+ break # Critical error, stop processing bands
227
+ # --- END CORRECTED BLOCK ---
228
+ else:
229
+ gdf_points_proj = gdf_with_sat
230
+ log_sat("CSV points already in raster CRS.")
231
+ if gdf_points_proj is None: log_sat("Projected GDF is None, skipping band."); all_bands_sampled = False; band_data[band] = pd.Series(np.nan, index=gdf_with_sat.index); continue
232
+ x_coords = xr.DataArray(gdf_points_proj.geometry.x.values, dims="points"); y_coords = xr.DataArray(gdf_points_proj.geometry.y.values, dims="points")
233
+ log_sat(f"Sampling satellite band {band}..."); sampled_values = da.sel(x=x_coords, y=y_coords, method="nearest").compute().values; band_data[band] = pd.Series(sampled_values, index=gdf_with_sat.index)
234
+ log_sat(f"Sampled {band} ({pd.isna(sampled_values).sum()}/{len(gdf_with_sat)} points were NaN).")
235
+ except ImportError as imp_err:
236
+ if 'dask' in str(imp_err): st.error("CRITICAL: 'dask' needed."); log_sat("CRITICAL: 'dask' not found."); all_bands_sampled = False; break
237
+ else: log_sat(f"Import error sampling {band}: {imp_err}"); all_bands_sampled = False; band_data[band] = pd.Series(np.nan, index=gdf_with_sat.index)
238
+ except Exception as rio_open_err: log_sat(f"Raster error sampling {band}: {rio_open_err}"); all_bands_sampled = False; band_data[band] = pd.Series(np.nan, index=gdf_with_sat.index); continue
239
+ except Exception as e: log_sat(f"General error sampling {band}: {e}"); all_bands_sampled = False; band_data[band] = pd.Series(np.nan, index=gdf_with_sat.index)
240
+ if all_bands_sampled or band_data:
241
+ sampled_df = pd.DataFrame(band_data, index=gdf_with_sat.index); log_sat("Calculating NDBI and Albedo...")
242
+ scale = 10000.0
243
+ b02 = sampled_df.get("B02", pd.Series(np.nan, index=gdf_with_sat.index)).astype(float); b04 = sampled_df.get("B04", pd.Series(np.nan, index=gdf_with_sat.index)).astype(float); b08 = sampled_df.get("B08", pd.Series(np.nan, index=gdf_with_sat.index)).astype(float); b11 = sampled_df.get("B11", pd.Series(np.nan, index=gdf_with_sat.index)).astype(float); b12 = sampled_df.get("B12", pd.Series(np.nan, index=gdf_with_sat.index)).astype(float)
244
+ with np.errstate(divide='ignore', invalid='ignore'):
245
+ ndbi = (b11 - b08) / (b11 + b08)
246
+ albedo = (0.356*(b02/scale) + 0.130*(b04/scale) + 0.373*(b08/scale) + 0.085*(b11/scale) + 0.072*(b12/scale) - 0.0018); albedo = np.clip(albedo, 0, 1)
247
+ gdf_with_sat['NDBI'] = ndbi; gdf_with_sat['Albedo'] = albedo
248
+ log_sat(f"Added NDBI/Albedo columns. NDBI NaNs: {gdf_with_sat['NDBI'].isnull().sum()}, Albedo NaNs: {gdf_with_sat['Albedo'].isnull().sum()}")
249
+ if not all_bands_sampled: log_sat("WARNING: Sampling issues occurred for one or more bands.")
250
+ else: log_sat("Skipping NDBI/Albedo calculation."); gdf_with_sat['NDBI'] = np.nan; gdf_with_sat['Albedo'] = np.nan
251
+ except pystac_client.exceptions.APIError as api_err: log_sat(f"PC API error: {api_err}"); st.error(f"STAC API Error: {api_err}"); gdf_with_sat['NDBI'] = np.nan; gdf_with_sat['Albedo'] = np.nan
252
+ except ImportError as imp_err: log_sat(f"Import error: {imp_err}"); st.error(f"Import Error: {imp_err}"); gdf_with_sat['NDBI'] = np.nan; gdf_with_sat['Albedo'] = np.nan
253
+ except Exception as e: log_sat(f"Unexpected error: {e}\n{traceback.format_exc()}"); st.error(f"Error during satellite processing: {e}"); gdf_with_sat['NDBI'] = np.nan; gdf_with_sat['Albedo'] = np.nan
254
+ log_sat("Finished adding satellite features."); return gdf_with_sat, sat_logs
255
+
256
+ # --- Helper Function for AI Context ---
257
+ def get_context_for_gemini(map_data, lat, lon, radius_m=NEARBY_RADIUS_M):
258
+ """Gathers data for the nearest point and summarizes nearby points."""
259
+ nearest_point_str = "Nearest Point: No data loaded or point not found."
260
+ nearby_summary_str = f"Nearby Area (within {radius_m}m): No nearby points found or data unavailable."
261
+ nearest_station_name = "N/A"
262
+
263
+ if map_data is None or map_data.empty:
264
+ return nearest_point_str, nearby_summary_str, nearest_station_name
265
+
266
+ try:
267
+ entered_point = Point(lon, lat)
268
+ map_data_for_analysis = map_data.copy()
269
+
270
+ # Ensure CRS
271
+ if map_data_for_analysis.crs is None: map_data_for_analysis.set_crs(TARGET_CRS, inplace=True)
272
+ elif map_data_for_analysis.crs != TARGET_CRS: map_data_for_analysis = map_data_for_analysis.to_crs(TARGET_CRS)
273
+
274
+ # Project for distance/buffer
275
+ map_data_proj = map_data_for_analysis.to_crs(PROCESSING_CRS)
276
+ entered_point_gdf = gpd.GeoDataFrame([1], geometry=[entered_point], crs=TARGET_CRS)
277
+ entered_point_proj = entered_point_gdf.to_crs(PROCESSING_CRS).geometry.iloc[0]
278
+
279
+ # --- Nearest Point ---
280
+ distances_m = map_data_proj.geometry.distance(entered_point_proj)
281
+ if distances_m.empty: # Handle case where no points exist after projection? (unlikely but safe)
282
+ return nearest_point_str, nearby_summary_str, nearest_station_name
283
+ nearest_index = distances_m.idxmin()
284
+ nearest_point_data = map_data_for_analysis.loc[nearest_index]
285
+ min_distance_m = distances_m.min()
286
+ nearest_station_name = nearest_point_data.get('nearest_station', 'N/A')
287
+
288
+ # Format nearest point data
289
+ np_ndbi = nearest_point_data.get('NDBI', np.nan); np_albedo = nearest_point_data.get('Albedo', np.nan)
290
+ np_uhi = nearest_point_data.get('uhi_index', np.nan); np_temp = nearest_point_data.get('weather_temp', np.nan)
291
+ np_rh = nearest_point_data.get('weather_rh', np.nan); np_dt_utc = nearest_point_data.get('datetime_utc', pd.NaT)
292
+ np_dt_str = np_dt_utc.strftime('%Y-%m-%d %H:%M UTC') if pd.notna(np_dt_utc) else 'N/A'
293
+
294
+ nearest_point_str = (
295
+ f"Nearest Point (approx {min_distance_m:.0f}m away, recorded around {np_dt_str}):\n"
296
+ f"- UHI Index: {np_uhi:.3f}\n" if pd.notna(np_uhi) else "- UHI Index: N/A\n"
297
+ f"- Air Temperature: {np_temp:.1f}°C\n" if pd.notna(np_temp) else "- Air Temperature: N/A\n"
298
+ f"- Relative Humidity: {np_rh:.1f}%\n" if pd.notna(np_rh) else "- Relative Humidity: N/A\n"
299
+ f"- NDBI (Satellite): {np_ndbi:.3f}\n" if pd.notna(np_ndbi) else "- NDBI (Satellite): N/A\n"
300
+ f"- Albedo (Satellite): {np_albedo:.3f}" if pd.notna(np_albedo) else "- Albedo (Satellite): N/A"
301
+ )
302
+
303
+ # --- Nearby Points Summary ---
304
+ nearby_indices = map_data_proj.geometry.within(entered_point_proj.buffer(radius_m))
305
+ nearby_points = map_data_for_analysis[nearby_indices]
306
+
307
+ if not nearby_points.empty and len(nearby_points) > 1:
308
+ cols_to_summarize = {'uhi_index': '.3f', 'weather_temp': '.1f', 'weather_rh': '.1f', 'NDBI': '.3f', 'Albedo': '.3f'}
309
+ summary_lines = [f"Nearby Area Summary ({len(nearby_points)} points within {radius_m}m):"]
310
+ for col, fmt in cols_to_summarize.items():
311
+ if col in nearby_points.columns:
312
+ valid_data = nearby_points[col].dropna()
313
+ if not valid_data.empty:
314
+ mean_val = valid_data.mean(); min_val = valid_data.min(); max_val = valid_data.max()
315
+ summary_lines.append(f"- {col}: Avg={mean_val:{fmt}}, Min={min_val:{fmt}}, Max={max_val:{fmt}}")
316
+ else: summary_lines.append(f"- {col}: No valid data nearby")
317
+ else: summary_lines.append(f"- {col}: Data not available")
318
+ nearby_summary_str = "\n".join(summary_lines)
319
+ elif len(nearby_points) == 1: nearby_summary_str = f"Nearby Area (within {radius_m}m): Only the nearest point was found in this radius."
320
+ else: nearby_summary_str = f"Nearby Area (within {radius_m}m): No measurement points found in this radius." # Explicitly state if none found
321
+
322
+ except Exception as e:
323
+ log_interaction(f"Error getting AI context: {e}")
324
+ nearest_point_str = f"Nearest Point: Error processing data - {e}"
325
+ nearby_summary_str = f"Nearby Area (within {radius_m}m): Error processing data - {e}"
326
+
327
+ return nearest_point_str, nearby_summary_str, nearest_station_name
328
+
329
+ # --- Helper Function for Color Mapping ---
330
+ def get_color_for_variable(value, variable_name, v_min, v_max, output_format='rgba'):
331
+ """Maps a variable's value to a color based on predefined schemes."""
332
+ cmap_temp = cm.get_cmap('coolwarm'); cmap_rh = cm.get_cmap('YlGnBu'); cmap_ndbi = cm.get_cmap('RdYlGn_r')
333
+ cmap_albedo = cm.get_cmap('Greys'); cmap_uhi = cm.get_cmap('YlOrRd')
334
+
335
+ invert_norm = False
336
+ if variable_name == 'Temperature (°C)': cmap = cmap_temp
337
+ elif variable_name == 'Relative Humidity (%)': cmap = cmap_rh
338
+ elif variable_name == 'NDBI': cmap = cmap_ndbi
339
+ elif variable_name == 'Albedo': cmap = cmap_albedo
340
+ elif variable_name == 'UHI Index': cmap = cmap_uhi
341
+ else: cmap = cm.get_cmap('viridis')
342
+
343
+ if pd.isna(value) or pd.isna(v_min) or pd.isna(v_max) or v_min >= v_max:
344
+ if output_format == 'rgba': return [128, 128, 128, 150] # Grey RGBA
345
+ else: return '#808080' # Grey Hex
346
+
347
+ norm_value = (value - v_min) / (v_max - v_min); norm_value = max(0.0, min(1.0, norm_value))
348
+ if invert_norm: norm_value = 1.0 - norm_value
349
+ color = cmap(norm_value)
350
+
351
+ if output_format == 'rgba': return [int(c * 255) for c in color[:3]] + [200]
352
+ else: return matplotlib.colors.to_hex(color)
353
+
354
+ # --- Streamlit App Layout ---
355
+ st.set_page_config(page_title=APP_TITLE, layout="wide")
356
+ st.title(APP_TITLE)
357
+ st.markdown("Select date, load data, choose map variables, view maps, **enter coordinates below**, then click **'Get Analysis & Advice'**.")
358
+ log_interaction("App script started/restarted.")
359
+
360
+ # --- Initialize Session State ---
361
+ if "gemini_configured" not in st.session_state: st.session_state.gemini_configured = False
362
+ if "map_data" not in st.session_state: st.session_state.map_data = None
363
+ if "load_attempted" not in st.session_state: st.session_state.load_attempted = False
364
+ if "mitigation_advice" not in st.session_state: st.session_state.mitigation_advice = None
365
+ if "data_load_logs" not in st.session_state: st.session_state.data_load_logs = []
366
+ if 'interaction_logs' not in st.session_state: st.session_state.interaction_logs = []
367
+ if 'vis_ranges' not in st.session_state: st.session_state.vis_ranges = {}
368
+ if 'color_variable_3d' not in st.session_state: st.session_state.color_variable_3d = DEFAULT_COLOR_VAR
369
+ if 'color_variable_2d' not in st.session_state: st.session_state.color_variable_2d = DEFAULT_COLOR_VAR
370
+
371
+ # --- Map Column Name Mapping ---
372
+ COLUMN_MAPPING = {'UHI Index': 'uhi_index', 'Temperature (°C)': 'weather_temp', 'Relative Humidity (%)': 'weather_rh', 'NDBI': 'NDBI', 'Albedo': 'Albedo'}
373
+
374
+ # --- Sidebar ---
375
+ with st.sidebar:
376
+ st.header("Configuration")
377
+ api_key = st.text_input("Enter Google Gemini API Key:", type="password", key="api_key_input")
378
+ if api_key and not st.session_state.gemini_configured:
379
+ st.session_state.gemini_configured = configure_gemini(api_key)
380
+ if st.session_state.gemini_configured: st.success("Gemini API Configured!")
381
+ else: st.error("Invalid API Key or configuration error.")
382
+
383
+ st.header("Data Source & Date")
384
+ st.info(f"Target: {os.path.basename(TARGET_FILE)}\nWeather: Manhattan, Bronx")
385
+ today = datetime.date.today(); min_date = datetime.date(2017, 3, 28)
386
+ selected_date = st.date_input("Select Date (for Satellite Image):", datetime.date(2021, 7, 24), min_value=min_date, max_value=today, key="date_selector")
387
+ st.slider("Max Cloud Cover (%):", 0, 100, 35, key="cloud_slider", help="Max cloud cover for satellite image search.")
388
+
389
+ if st.button("Load/Refresh Data", key="load_data_button", type="primary", use_container_width=True):
390
+ log_interaction("'Load/Refresh Data' button clicked.")
391
+ st.session_state.load_attempted = True
392
+ st.session_state.map_data = None; st.session_state.mitigation_advice = None; st.session_state.vis_ranges = {}
393
+ st.session_state.data_load_logs = []
394
+ merged_gdf = None; final_gdf = None; logs_csv = []; logs_sat = []
395
+ with st.spinner("Loading CSV, merging weather, sampling satellite..."):
396
+ log_interaction("Starting CSV load and merge..."); merged_gdf = load_and_merge_csv_data()
397
+ logs_csv = st.session_state.get('data_load_logs', []).copy()
398
+ if merged_gdf is not None and not merged_gdf.empty:
399
+ log_interaction("Starting satellite sampling..."); final_gdf, logs_sat_func = add_satellite_features(merged_gdf, selected_date.strftime('%Y-%m-%d'))
400
+ st.session_state.map_data = final_gdf; logs_sat = logs_sat_func
401
+ st.session_state.vis_ranges = {} # Reset ranges before calculating
402
+ for display_name, col_name in COLUMN_MAPPING.items():
403
+ if col_name in final_gdf.columns:
404
+ valid_data = final_gdf[col_name].dropna()
405
+ if not valid_data.empty:
406
+ st.session_state.vis_ranges[display_name] = {'min': valid_data.min(), 'max': valid_data.max(), 'col': col_name}
407
+ log_data(f"Vis range for {display_name}: min={valid_data.min():.2f}, max={valid_data.max():.2f}")
408
+ else: log_data(f"No valid data for {display_name} to calculate range.")
409
+ else: log_data(f"Column {col_name} not found for vis range calculation.")
410
+ # Ensure default color vars are valid after load
411
+ if DEFAULT_COLOR_VAR not in st.session_state.vis_ranges:
412
+ first_valid_var = next(iter(st.session_state.vis_ranges), None)
413
+ st.session_state.color_variable_3d = first_valid_var
414
+ st.session_state.color_variable_2d = first_valid_var
415
+ else:
416
+ st.session_state.color_variable_3d = DEFAULT_COLOR_VAR
417
+ st.session_state.color_variable_2d = DEFAULT_COLOR_VAR
418
+
419
+ else: log_interaction("Base data load failed."); st.error("Failed to load/merge base data."); st.session_state.map_data = None
420
+ st.session_state.data_load_logs = logs_csv + logs_sat
421
+ log_interaction("Data loading process finished.")
422
+ st.rerun()
423
+
424
+ st.markdown("---")
425
+ st.subheader("Map Legend")
426
+ st.markdown("*(Legend shows range for selected Color Variable)*")
427
+ st.markdown("**3D Map Columns:**")
428
+ st.markdown(f"- **Height:** UHI Index (scaled x{ELEVATION_SCALING_FACTOR})")
429
+ # Display legend for 3D color variable
430
+ color_var_3d_sb = st.session_state.get('color_variable_3d', None)
431
+ if color_var_3d_sb and color_var_3d_sb in st.session_state.vis_ranges:
432
+ range_3d = st.session_state.vis_ranges[color_var_3d_sb]
433
+ st.markdown(f"- **Color:** {color_var_3d_sb} ({range_3d['min']:.2f} to {range_3d['max']:.2f})")
434
+ else: st.markdown("- **Color:** *(Select variable on map)*")
435
+
436
+ st.markdown("**2D Map Circles:**")
437
+ # Display legend for 2D color variable
438
+ color_var_2d_sb = st.session_state.get('color_variable_2d', None)
439
+ if color_var_2d_sb and color_var_2d_sb in st.session_state.vis_ranges:
440
+ range_2d = st.session_state.vis_ranges[color_var_2d_sb]
441
+ st.markdown(f"- **Color:** {color_var_2d_sb} ({range_2d['min']:.2f} to {range_2d['max']:.2f})")
442
+ else: st.markdown("- **Color:** *(Select variable on map)*")
443
+
444
+ st.markdown("---")
445
+ st.caption("Data: Local CSVs + Sentinel-2 via MS Planetary Computer.")
446
+ # End sidebar
447
+
448
+ # Display Data Loading Logs
449
+ if st.session_state.data_load_logs:
450
+ expand_logs = st.session_state.load_attempted and st.session_state.map_data is None
451
+ with st.expander("Show Data Loading Logs", expanded=expand_logs): st.text("\n".join(st.session_state.data_load_logs))
452
+
453
+ # --- Main Area Layout (Maps and Controls) ---
454
+ col1, col2 = st.columns([0.65, 0.35], gap="medium")
455
+
456
+ map_data = st.session_state.get('map_data', None)
457
+ vis_ranges = st.session_state.get('vis_ranges', {})
458
+ available_vis_vars = list(vis_ranges.keys()) # Get available variables AFTER data load attempt
459
+
460
+ with col1:
461
+ # --- 3D Map Section ---
462
+ st.subheader("3D Map Viewer (PyDeck)")
463
+ # Ensure options are valid before setting selectbox
464
+ idx_3d = available_vis_vars.index(st.session_state.color_variable_3d) if st.session_state.color_variable_3d in available_vis_vars else 0
465
+ color_var_3d = st.selectbox("Select variable for **Column Color**:", options=available_vis_vars, key='sb_color_variable_3d', index=idx_3d)
466
+ # Update session state if changed
467
+ if color_var_3d != st.session_state.color_variable_3d:
468
+ st.session_state.color_variable_3d = color_var_3d
469
+ st.rerun() # Rerun to update map with new color
470
+
471
+ if map_data is not None and not map_data.empty and color_var_3d and color_var_3d in vis_ranges: # Check if var exists in ranges
472
+ try:
473
+ pydeck_data = map_data.copy()
474
+ pydeck_data['latitude'] = pydeck_data.geometry.y; pydeck_data['longitude'] = pydeck_data.geometry.x
475
+ pydeck_data['uhi_for_elevation'] = pd.to_numeric(pydeck_data['uhi_index'], errors='coerce').fillna(UHI_BASELINE_FOR_HEIGHT)
476
+
477
+ color_col_info = vis_ranges[color_var_3d]; color_col_name = color_col_info['col']; v_min = color_col_info['min']; v_max = color_col_info['max']
478
+ pydeck_data['color'] = pydeck_data[color_col_name].apply(get_color_for_variable, args=(color_var_3d, v_min, v_max, 'rgba'))
479
+
480
+ pydeck_data['NDBI_str'] = pydeck_data['NDBI'].map('{:.3f}'.format).fillna('N/A') if 'NDBI' in pydeck_data else 'N/A'
481
+ pydeck_data['Albedo_str'] = pydeck_data['Albedo'].map('{:.3f}'.format).fillna('N/A') if 'Albedo' in pydeck_data else 'N/A'
482
+ pydeck_data['weather_temp_str'] = pydeck_data['weather_temp'].map('{:.1f}'.format).fillna('N/A') if 'weather_temp' in pydeck_data else 'N/A'
483
+ pydeck_data['weather_rh_str'] = pydeck_data['weather_rh'].map('{:.1f}'.format).fillna('N/A') if 'weather_rh' in pydeck_data else 'N/A'
484
+ pydeck_data['uhi_index_str'] = pydeck_data['uhi_index'].map('{:.3f}'.format).fillna('N/A') if 'uhi_index' in pydeck_data else 'N/A'
485
+
486
+ PYDECK_TOOLTIP = {
487
+ "html": """
488
+ <b>Coords:</b> {latitude:.4f}, {longitude:.4f}<br/>
489
+ <b>UHI Index:</b> {uhi_index_str}<br/>
490
+ <b>Temp (°C):</b> {weather_temp_str}<br/>
491
+ <b>RH (%):</b> {weather_rh_str}<br/>
492
+ <b>NDBI:</b> {NDBI_str}<br/>
493
+ <b>Albedo:</b> {Albedo_str}<br/>
494
+ <hr style='margin: 2px 0;'>
495
+ <i>Height ~ UHI Index (Raw: {uhi_for_elevation:.3f})</i>
496
+ """,
497
+ "style": {"backgroundColor": "darkslategray", "color": "white", "font-size": "11px"}
498
+ }
499
+ required_pydeck_cols = ['longitude', 'latitude', 'color','uhi_for_elevation', 'uhi_index_str', 'weather_temp_str', 'weather_rh_str', 'NDBI_str', 'Albedo_str']
500
+
501
+ if all(col in pydeck_data.columns for col in required_pydeck_cols):
502
+ pydeck_view_state = pdk.ViewState(latitude=NYC_CENTER_APPROX[0], longitude=NYC_CENTER_APPROX[1], zoom=PYDECK_MAP_ZOOM, pitch=55, bearing=-15)
503
+ pydeck_layer = pdk.Layer("ColumnLayer", data=pd.DataFrame(pydeck_data[required_pydeck_cols]), get_position=["longitude", "latitude"], get_elevation='uhi_for_elevation', elevation_scale=ELEVATION_SCALING_FACTOR, radius=COLUMN_RADIUS, get_fill_color="color", pickable=True, auto_highlight=True, extruded=True)
504
+ pydeck_deck = pdk.Deck(layers=[pydeck_layer], initial_view_state=pydeck_view_state, map_style="mapbox://styles/mapbox/light-v10", tooltip=PYDECK_TOOLTIP)
505
+ st.pydeck_chart(pydeck_deck, use_container_width=True)
506
+ else: missing_cols = [c for c in required_pydeck_cols if c not in pydeck_data.columns]; st.warning(f"3D map missing columns: {missing_cols}"); log_interaction(f"PyDeck missing columns: {missing_cols}")
507
+ except Exception as pydeck_err: st.error(f"Error rendering 3D map: {pydeck_err}"); log_interaction(f"PyDeck render failed: {pydeck_err}\n{traceback.format_exc()}")
508
+ elif st.session_state.load_attempted: st.info("Load data to view 3D map.")
509
+ else: st.info("Click 'Load/Refresh Data' to begin.")
510
+
511
+ st.markdown("---")
512
+
513
+ # --- 2D Map Section ---
514
+ st.subheader("2D Map Viewer (Folium)")
515
+ idx_2d = available_vis_vars.index(st.session_state.color_variable_2d) if st.session_state.color_variable_2d in available_vis_vars else 0
516
+ color_var_2d = st.selectbox("Select variable for **Circle Color**:", options=available_vis_vars, key='sb_color_variable_2d', index=idx_2d)
517
+ if color_var_2d != st.session_state.color_variable_2d:
518
+ st.session_state.color_variable_2d = color_var_2d
519
+ st.rerun()
520
+
521
+ if map_data is not None and not map_data.empty and color_var_2d and color_var_2d in vis_ranges:
522
+ try:
523
+ m = folium.Map(location=NYC_CENTER_APPROX, zoom_start=FOLIUM_MAP_ZOOM, tiles="CartoDB positron")
524
+ folium_data = map_data.copy()
525
+ color_col_info_2d = vis_ranges[color_var_2d]; color_col_name_2d = color_col_info_2d['col']; v_min_2d = color_col_info_2d['min']; v_max_2d = color_col_info_2d['max']
526
+ folium_data['hex_color'] = folium_data[color_col_name_2d].apply(get_color_for_variable, args=(color_var_2d, v_min_2d, v_max_2d, 'hex'))
527
+
528
+ for idx, row in folium_data.iterrows():
529
+ lat = row.geometry.y; lon = row.geometry.x; color = row['hex_color']
530
+ uhi_val = row.get('uhi_index', np.nan); temp_val = row.get('weather_temp', np.nan); rh_val = row.get('weather_rh', np.nan); ndbi_val = row.get('NDBI', np.nan); albedo_val = row.get('Albedo', np.nan)
531
+ uhi_str = f"{uhi_val:.3f}" if pd.notna(uhi_val) else "N/A"; temp_str = f"{temp_val:.1f}°C" if pd.notna(temp_val) else "N/A"; rh_str = f"{rh_val:.1f}%" if pd.notna(rh_val) else "N/A"; ndbi_str = f"{ndbi_val:.3f}" if pd.notna(ndbi_val) else "N/A"; albedo_str = f"{albedo_val:.3f}" if pd.notna(albedo_val) else "N/A"
532
+ tooltip_html = f"<b>Coords:</b> {lat:.4f}, {lon:.4f}<br><b>UHI:</b> {uhi_str}<br><b>Temp:</b> {temp_str}<br><b>RH:</b> {rh_str}<br><b>NDBI:</b> {ndbi_str}<br><b>Albedo:</b> {albedo_str}"
533
+ folium.CircleMarker(location=[lat, lon], radius=4, color=color, fill=True, fill_color=color, fill_opacity=0.7, tooltip=tooltip_html).add_to(m)
534
+ st_folium(m, use_container_width=True, height=450, key="folium_map_display_only")
535
+ except Exception as map_render_error: st.error(f"Error rendering 2D map: {map_render_error}"); log_interaction(f"Folium render error: {map_render_error}\n{traceback.format_exc()}")
536
+ elif st.session_state.load_attempted: st.info("Load data to view 2D map.")
537
+ # End col1
538
+
539
+ with col2:
540
+ # --- Coordinate Input and Analysis ---
541
+ st.subheader("Location Analysis & Advice")
542
+ log_interaction("Setting up coordinate input section.")
543
+ default_lat = NYC_CENTER_APPROX[0]; default_lon = NYC_CENTER_APPROX[1]
544
+ lat_input = st.number_input("Enter Latitude:", min_value=40.4, max_value=41.0, value=default_lat, step=0.0001, format="%.4f", key="lat_coord_input")
545
+ lon_input = st.number_input("Enter Longitude:", min_value=-74.3, max_value=-73.7, value=default_lon, step=0.0001, format="%.4f", key="lon_coord_input")
546
+ advice_button_disabled = not st.session_state.gemini_configured or map_data is None or map_data.empty
547
+
548
+ if st.button("Get Analysis & Advice", disabled=advice_button_disabled, key="get_advice_button", type="primary", use_container_width=True):
549
+ log_interaction("'Get Analysis & Advice' button clicked.")
550
+ if map_data is not None and not map_data.empty:
551
+ with st.spinner("Analyzing location and asking assistant..."):
552
+ try:
553
+ log_interaction(f"Analyzing entered coords: Lat={lat_input:.4f}, Lon={lon_input:.4f}")
554
+ nearest_point_str, nearby_summary_str, nearest_station_name = get_context_for_gemini(map_data, lat_input, lon_input)
555
+ station_desc = WEATHER_STATIONS.get(nearest_station_name, {}).get('desc', 'Unknown Area')
556
+
557
+ # Construct the NEW prompt for Gemini
558
+ full_prompt = f"""You are an AI assistant providing clear, easy-to-understand advice on urban heat island (UHI) effects and mitigation for residents or local planners in NYC. Your language should be simple and avoid technical terms where possible.
559
+
560
+ Location Context:
561
+ User Coordinates: Lat={lat_input:.4f}, Lon={lon_input:.4f}
562
+ Nearest Weather Station Data From: {nearest_station_name} ({station_desc})
563
+
564
+ Data Summary:
565
+ {nearest_point_str}
566
+ {nearby_summary_str}
567
+
568
+ Your Task:
569
+ Based *only* on the provided data summary:
570
+
571
+ 1. **Explain the Findings (Simple Language):** Describe the heat situation near the requested coordinates in plain terms.
572
+ * Instead of just stating the UHI index, explain if the location tends to be hotter than average rural surroundings and roughly by how much (e.g., "This spot seems significantly warmer than areas outside the city." or "This location is moderately warmer...").
573
+ * Explain what the temperature and humidity levels *feel* like or imply for comfort/risk (e.g., "The reported temperature is quite high, and combined with the humidity, it would likely feel very uncomfortable and potentially dangerous during peak sun.").
574
+ * Explain what the satellite data suggests about the physical environment (e.g., "Satellite views suggest this area has many buildings and paved surfaces, with less green space like parks or trees." or "Satellite views indicate a mix of buildings and some vegetation."). Do *not* use the terms "NDBI" or "Index".
575
+ * Explain what the satellite data suggests about the surfaces (e.g., "The surfaces in this area appear mostly dark, meaning they likely absorb a lot of sun heat." or "There's a mix of darker and lighter surfaces."). Do *not* use the term "Albedo" or "Index".
576
+ * Briefly comment on whether the immediate surroundings (nearby area summary) show similar or different conditions, indicating if the specific point is typical for its neighborhood (e.g., "The surrounding area generally shares these characteristics." or "Conditions vary somewhat nearby, with some spots showing [different characteristic].").
577
+ * Acknowledge if data is from a point somewhat distant (>100m) from the user's precise coordinates (e.g., "Note: The closest measurement was taken about [X] meters away, so conditions at your exact spot might differ slightly.").
578
+
579
+ 2. **Provide Actionable Mitigation Advice (with Reasoning):** Offer 2-4 practical, localized suggestions relevant to the findings.
580
+ * For each suggestion, briefly explain *why* it helps reduce local heat in simple terms (e.g., "Planting trees helps because their leaves provide shade, cooling the ground and the air around them." or "Using lighter-colored materials for roofs and pavements helps because they reflect sunlight away instead of absorbing it as heat.").
581
+ * Tailor suggestions to the findings (e.g., if the area seems built-up with dark surfaces, focus on greening, cool roofs/pavements. If humidity is high, mention ventilation or reducing waste heat.).
582
+ * Keep advice realistic for an NYC setting (mentioning things like street trees, green roofs, community gardens, cool pavement coatings, choosing lighter paint colors where possible).
583
+
584
+ Structure your response clearly with headings like "Heat Situation Explained" and "Mitigation Suggestions". Use bullet points for clarity.
585
+ """
586
+ response_text = get_gemini_response(full_prompt)
587
+ st.session_state.mitigation_advice = response_text
588
+ log_interaction("Mitigation advice generated and stored in session state.")
589
+ st.rerun()
590
+ except Exception as advice_err: st.error(f"Error getting advice: {advice_err}"); log_interaction(f"Error during advice: {advice_err}\n{traceback.format_exc()}"); st.session_state.mitigation_advice = "Error retrieving advice."
591
+ else: log_interaction("Get advice clicked but map_data not available."); st.warning("Map data is not loaded.")
592
+
593
+ # Display status messages or advice
594
+ if not st.session_state.gemini_configured: st.warning("Enter Google Gemini API Key in sidebar to enable analysis.")
595
+ elif map_data is None or map_data.empty:
596
+ if st.session_state.load_attempted: st.warning("Data loading failed or is empty. Cannot get advice.")
597
+ else: st.info("Load data via sidebar to enable analysis.")
598
+
599
+ if st.session_state.mitigation_advice:
600
+ st.markdown("---"); log_interaction("Displaying stored mitigation advice.")
601
+ st.subheader("Analysis & Mitigation Advice")
602
+ with st.container(border=True): st.markdown(st.session_state.mitigation_advice)
603
+
604
+ if st.session_state.interaction_logs:
605
+ st.markdown("---")
606
+ with st.expander("Show Interaction Logs"): st.text("\n".join(st.session_state.interaction_logs[::-1]))
607
+ # End col2
608
+
609
+ log_interaction("App script run finished.")
bronx.csv ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Date / Time,Air Temp at Surface [degC],Relative Humidity [percent],Avg Wind Speed [m/s],Wind Direction [degrees],Solar Flux [W/m^2]
2
+ 2021-07-24 06:00:00 EDT,19.3,88.2,0.8,335,12
3
+ 2021-07-24 06:05:00 EDT,19.4,87.9,0.8,329,18
4
+ 2021-07-24 06:10:00 EDT,19.3,87.6,0.7,321,25
5
+ 2021-07-24 06:15:00 EDT,19.4,87.4,0.5,307,33
6
+ 2021-07-24 06:20:00 EDT,19.4,87,0.2,301,42
7
+ 2021-07-24 06:25:00 EDT,19.4,85.1,0.3,64,53
8
+ 2021-07-24 06:30:00 EDT,19.4,84.3,0.2,56,65
9
+ 2021-07-24 06:35:00 EDT,19.4,83.7,0.4,56,78
10
+ 2021-07-24 06:40:00 EDT,19.4,83.2,0.8,40,91
11
+ 2021-07-24 06:45:00 EDT,19.4,82.5,1.1,39,103
12
+ 2021-07-24 06:50:00 EDT,19.4,81.1,1.7,38,115
13
+ 2021-07-24 06:55:00 EDT,19.5,80.9,1.9,36,127
14
+ 2021-07-24 07:00:00 EDT,19.6,80.5,1.1,47,140
15
+ 2021-07-24 07:05:00 EDT,19.7,78.2,1.7,38,153
16
+ 2021-07-24 07:10:00 EDT,19.8,77,1.1,25,167
17
+ 2021-07-24 07:15:00 EDT,19.9,75.1,1.2,35,181
18
+ 2021-07-24 07:20:00 EDT,20,74.4,1.8,17,195
19
+ 2021-07-24 07:25:00 EDT,20,72.7,2.3,24,209
20
+ 2021-07-24 07:30:00 EDT,20.1,72.3,2.1,17,225
21
+ 2021-07-24 07:35:00 EDT,20.2,71.2,2.3,11,241
22
+ 2021-07-24 07:40:00 EDT,20.3,71,2.3,12,254
23
+ 2021-07-24 07:45:00 EDT,20.3,70.3,2.1,9,267
24
+ 2021-07-24 07:50:00 EDT,20.5,70.6,1.4,15,279
25
+ 2021-07-24 07:55:00 EDT,20.7,69.4,1.6,12,293
26
+ 2021-07-24 08:00:00 EDT,20.9,68.9,1.7,12,309
27
+ 2021-07-24 08:05:00 EDT,21,68.1,1.6,10,325
28
+ 2021-07-24 08:10:00 EDT,21.1,67.5,2,6,339
29
+ 2021-07-24 08:15:00 EDT,21.4,66.7,1.3,3,354
30
+ 2021-07-24 08:20:00 EDT,21.5,65.8,1.8,1,370
31
+ 2021-07-24 08:25:00 EDT,21.7,64.6,1,18,385
32
+ 2021-07-24 08:30:00 EDT,21.8,64.1,1.6,358,401
33
+ 2021-07-24 08:35:00 EDT,21.8,65,1.6,15,416
34
+ 2021-07-24 08:40:00 EDT,22,64.6,1.9,9,429
35
+ 2021-07-24 08:45:00 EDT,22,64.9,2,10,444
36
+ 2021-07-24 08:50:00 EDT,22.2,64.3,1.9,10,460
37
+ 2021-07-24 08:55:00 EDT,22.6,62.9,1.5,358,475
38
+ 2021-07-24 09:00:00 EDT,22.8,62.1,1.5,353,489
39
+ 2021-07-24 09:05:00 EDT,22.9,61.6,1.7,358,504
40
+ 2021-07-24 09:10:00 EDT,22.8,60.7,2.3,4,517
41
+ 2021-07-24 09:15:00 EDT,23,59.8,1.5,359,531
42
+ 2021-07-24 09:20:00 EDT,23.4,58.7,1.5,20,546
43
+ 2021-07-24 09:25:00 EDT,23.8,59.4,1.3,32,560
44
+ 2021-07-24 09:30:00 EDT,24.2,56.5,1.6,42,573
45
+ 2021-07-24 09:35:00 EDT,23.9,55.3,2,37,587
46
+ 2021-07-24 09:40:00 EDT,24,56.2,1.9,35,600
47
+ 2021-07-24 09:45:00 EDT,24.2,56.2,2,1,611
48
+ 2021-07-24 09:50:00 EDT,24.2,54.7,1.6,29,624
49
+ 2021-07-24 09:55:00 EDT,24.1,53.2,2.2,27,636
50
+ 2021-07-24 10:00:00 EDT,24.4,53,2.5,12,647
51
+ 2021-07-24 10:05:00 EDT,24.2,53.1,2.7,8,656
52
+ 2021-07-24 10:10:00 EDT,24.7,52.9,1.6,334,664
53
+ 2021-07-24 10:15:00 EDT,24.7,53.1,2.6,322,675
54
+ 2021-07-24 10:20:00 EDT,24.6,52.9,2.2,315,691
55
+ 2021-07-24 10:25:00 EDT,25,53.3,1.2,305,704
56
+ 2021-07-24 10:30:00 EDT,25.3,52.4,1,359,465
57
+ 2021-07-24 10:35:00 EDT,25.1,52,1.5,45,655
58
+ 2021-07-24 10:40:00 EDT,25,52.3,1.8,44,717
59
+ 2021-07-24 10:45:00 EDT,25,52.3,2.1,29,765
60
+ 2021-07-24 10:50:00 EDT,25.1,53.1,2,343,768
61
+ 2021-07-24 10:55:00 EDT,25.1,52.2,1.1,303,775
62
+ 2021-07-24 11:00:00 EDT,25.2,51.4,1.4,294,787
63
+ 2021-07-24 11:05:00 EDT,25.7,51.4,1,307,803
64
+ 2021-07-24 11:10:00 EDT,25.6,50.8,1.3,87,822
65
+ 2021-07-24 11:15:00 EDT,25.9,47.8,1.8,74,840
66
+ 2021-07-24 11:20:00 EDT,25.8,49.1,1.2,107,833
67
+ 2021-07-24 11:25:00 EDT,25.7,49.2,1.1,227,838
68
+ 2021-07-24 11:30:00 EDT,26.1,49.3,2.1,66,872
69
+ 2021-07-24 11:35:00 EDT,26.3,52.3,2.2,108,623
70
+ 2021-07-24 11:40:00 EDT,26.1,51.3,1.9,99,330
71
+ 2021-07-24 11:45:00 EDT,25.7,51.9,2.2,108,542
72
+ 2021-07-24 11:50:00 EDT,25.7,52,2.5,87,618
73
+ 2021-07-24 11:55:00 EDT,26.5,50.9,2.1,105,449
74
+ 2021-07-24 12:00:00 EDT,26.6,49.5,2.2,131,498
75
+ 2021-07-24 12:05:00 EDT,26.7,48.8,2.3,132,828
76
+ 2021-07-24 12:10:00 EDT,26.1,49.1,2.1,73,861
77
+ 2021-07-24 12:15:00 EDT,26.2,50,2.3,74,374
78
+ 2021-07-24 12:20:00 EDT,25.7,50.4,1.9,47,404
79
+ 2021-07-24 12:25:00 EDT,25.9,50.5,0.9,21,762
80
+ 2021-07-24 12:30:00 EDT,27,48.8,2.4,74,960
81
+ 2021-07-24 12:35:00 EDT,27.8,46.6,2,90,837
82
+ 2021-07-24 12:40:00 EDT,26.3,47.8,2.8,67,243
83
+ 2021-07-24 12:45:00 EDT,26.7,48.7,2,114,220
84
+ 2021-07-24 12:50:00 EDT,26.1,48.2,1.2,109,185
85
+ 2021-07-24 12:55:00 EDT,26.4,48.9,1.6,93,554
86
+ 2021-07-24 13:00:00 EDT,27.4,47.2,2.2,110,781
87
+ 2021-07-24 13:05:00 EDT,27.3,45.8,1.9,132,577
88
+ 2021-07-24 13:10:00 EDT,26.5,46.8,1.4,134,449
89
+ 2021-07-24 13:15:00 EDT,26.5,47.4,1.2,125,368
90
+ 2021-07-24 13:20:00 EDT,26.7,47,2.1,133,304
91
+ 2021-07-24 13:25:00 EDT,26.8,46.4,1.1,59,491
92
+ 2021-07-24 13:30:00 EDT,26.6,46.7,1.9,99,691
93
+ 2021-07-24 13:35:00 EDT,26.9,46.6,1.4,110,392
94
+ 2021-07-24 13:40:00 EDT,26.8,46.2,2.8,82,532
95
+ 2021-07-24 13:45:00 EDT,27.4,46,2.9,104,670
96
+ 2021-07-24 13:50:00 EDT,27.4,44.7,3.2,102,825
97
+ 2021-07-24 13:55:00 EDT,27,45.2,2.3,65,881
98
+ 2021-07-24 14:00:00 EDT,27,45.3,2,52,582
99
+ 2021-07-24 14:05:00 EDT,26.6,46.3,1.9,57,255
100
+ 2021-07-24 14:10:00 EDT,27,46,2.7,116,211
101
+ 2021-07-24 14:15:00 EDT,27.2,44.6,2.8,127,498
102
+ 2021-07-24 14:20:00 EDT,26.5,44.8,1.9,184,688
103
+ 2021-07-24 14:25:00 EDT,27,44.8,2.4,152,793
104
+ 2021-07-24 14:30:00 EDT,27.5,42.8,2.3,98,848
105
+ 2021-07-24 14:35:00 EDT,28.2,42.2,2,117,843
106
+ 2021-07-24 14:40:00 EDT,28.1,40.5,1.6,140,743
107
+ 2021-07-24 14:45:00 EDT,28,40.7,1.6,107,767
108
+ 2021-07-24 14:50:00 EDT,28.3,40.4,1.6,175,738
109
+ 2021-07-24 14:55:00 EDT,28.4,39.6,2.1,82,724
110
+ 2021-07-24 15:00:00 EDT,28,40.3,3,75,725
111
+ 2021-07-24 15:05:00 EDT,28.1,40.2,1.7,92,558
112
+ 2021-07-24 15:10:00 EDT,28.3,40.3,2.9,91,216
113
+ 2021-07-24 15:15:00 EDT,28,40.7,3.1,114,236
114
+ 2021-07-24 15:20:00 EDT,27.9,41.8,2.8,105,229
115
+ 2021-07-24 15:25:00 EDT,27.3,44.4,3.7,162,511
116
+ 2021-07-24 15:30:00 EDT,27.1,47.3,4.5,170,563
117
+ 2021-07-24 15:35:00 EDT,26.9,47.7,3.5,149,292
118
+ 2021-07-24 15:40:00 EDT,26.9,48.3,3,166,371
119
+ 2021-07-24 15:45:00 EDT,27.3,47.4,3.5,146,646
120
+ 2021-07-24 15:50:00 EDT,27.2,47.8,3.2,157,491
121
+ 2021-07-24 15:55:00 EDT,27.2,47.3,2.6,165,621
122
+ 2021-07-24 16:00:00 EDT,27.2,46.5,2.8,164,335
123
+ 2021-07-24 16:05:00 EDT,27,47.4,3.7,129,195
124
+ 2021-07-24 16:10:00 EDT,27,47.4,3.1,144,239
125
+ 2021-07-24 16:15:00 EDT,26.7,47.5,4,173,246
126
+ 2021-07-24 16:20:00 EDT,26.6,47.3,3.5,168,236
127
+ 2021-07-24 16:25:00 EDT,26.9,47.7,2.7,145,204
128
+ 2021-07-24 16:30:00 EDT,27.1,46.4,2.9,128,251
129
+ 2021-07-24 16:35:00 EDT,26.7,46.5,3.7,177,252
130
+ 2021-07-24 16:40:00 EDT,26.8,46.8,3.1,163,235
131
+ 2021-07-24 16:45:00 EDT,26.8,46.9,2,160,159
132
+ 2021-07-24 16:50:00 EDT,26.8,46.5,3.1,176,138
133
+ 2021-07-24 16:55:00 EDT,26.7,46.8,2.2,141,134
134
+ 2021-07-24 17:00:00 EDT,26.6,47.2,3.8,168,132
135
+ 2021-07-24 17:05:00 EDT,26.6,47.5,2.8,162,163
136
+ 2021-07-24 17:10:00 EDT,26.4,48.7,3.4,167,150
137
+ 2021-07-24 17:15:00 EDT,26.3,49.8,3,163,132
138
+ 2021-07-24 17:20:00 EDT,26.3,50.1,3.5,166,122
139
+ 2021-07-24 17:25:00 EDT,26,50,4,168,146
140
+ 2021-07-24 17:30:00 EDT,26,50.1,3.1,170,156
141
+ 2021-07-24 17:35:00 EDT,25.9,50.1,3.1,165,191
142
+ 2021-07-24 17:40:00 EDT,26,49.5,3.6,182,296
143
+ 2021-07-24 17:45:00 EDT,25.7,50.3,4.4,169,323
144
+ 2021-07-24 17:50:00 EDT,25.6,50.4,4,152,300
145
+ 2021-07-24 17:55:00 EDT,25.7,49.5,3.2,159,192
146
+ 2021-07-24 18:00:00 EDT,25.5,48.7,4,161,162
147
+ 2021-07-24 18:05:00 EDT,25.5,48.7,3.9,171,142
148
+ 2021-07-24 18:10:00 EDT,25.4,49.1,4.5,182,150
149
+ 2021-07-24 18:15:00 EDT,25.3,50.7,3.8,179,157
150
+ 2021-07-24 18:20:00 EDT,25.1,50.9,4.2,168,165
151
+ 2021-07-24 18:25:00 EDT,25.1,50,4.5,162,138
152
+ 2021-07-24 18:30:00 EDT,25.1,49.2,4.8,162,113
153
+ 2021-07-24 18:35:00 EDT,25.2,49.2,4.3,165,109
154
+ 2021-07-24 18:40:00 EDT,25.1,49.9,4,161,110
155
+ 2021-07-24 18:45:00 EDT,25.2,49.7,3,171,121
156
+ 2021-07-24 18:50:00 EDT,25.2,49.8,3,157,111
157
+ 2021-07-24 18:55:00 EDT,25,50.1,3.5,158,105
158
+ 2021-07-24 19:00:00 EDT,25,49.8,2.8,144,115
159
+ 2021-07-24 19:05:00 EDT,25.2,49.1,2.4,164,169
160
+ 2021-07-24 19:10:00 EDT,25.4,47.9,3.3,168,142
161
+ 2021-07-24 19:15:00 EDT,25.1,48,3.7,164,93
162
+ 2021-07-24 19:20:00 EDT,25.1,47.9,3.3,159,71
163
+ 2021-07-24 19:25:00 EDT,25,48.3,4.5,177,57
164
+ 2021-07-24 19:30:00 EDT,24.9,48.7,4,178,44
165
+ 2021-07-24 19:35:00 EDT,24.9,49.1,3.4,187,34
166
+ 2021-07-24 19:40:00 EDT,24.9,49,3.5,184,24
167
+ 2021-07-24 19:45:00 EDT,24.8,49,3.3,173,19
168
+ 2021-07-24 19:50:00 EDT,24.9,48.7,3.8,168,17
169
+ 2021-07-24 19:55:00 EDT,24.9,47.3,4.1,171,16
170
+ 2021-07-24 20:00:00 EDT,24.9,47.4,3.6,162,13
check.csv ADDED
The diff for this file is too large to render. See raw diff
 
manhattan.csv ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Date / Time,Air Temp at Surface [degC],Relative Humidity [percent],Avg Wind Speed [m/s],Wind Direction [degrees],Solar Flux [W/m^2]
2
+ 2021-07-24 06:00:00 EDT,21.3,66.5,0.9,348,10
3
+ 2021-07-24 06:05:00 EDT,21.4,66.1,1.1,345,12
4
+ 2021-07-24 06:10:00 EDT,21.4,66.5,1.3,4,14
5
+ 2021-07-24 06:15:00 EDT,21.5,65.4,1.3,5,17
6
+ 2021-07-24 06:20:00 EDT,21.5,65,1.5,346,19
7
+ 2021-07-24 06:25:00 EDT,21.6,66.4,1.4,19,34
8
+ 2021-07-24 06:30:00 EDT,21.7,65.6,1.3,41,61
9
+ 2021-07-24 06:35:00 EDT,21.8,64.8,1.1,22,73
10
+ 2021-07-24 06:40:00 EDT,21.9,62.7,1.2,11,84
11
+ 2021-07-24 06:45:00 EDT,21.9,62.4,1.1,10,94
12
+ 2021-07-24 06:50:00 EDT,22.1,61.5,1.3,43,106
13
+ 2021-07-24 06:55:00 EDT,22.2,60.1,1,43,118
14
+ 2021-07-24 07:00:00 EDT,22.1,60.4,1.2,2,130
15
+ 2021-07-24 07:05:00 EDT,22.3,59.3,1,50,143
16
+ 2021-07-24 07:10:00 EDT,22.3,59.1,2,38,156
17
+ 2021-07-24 07:15:00 EDT,22.4,58.1,2,35,171
18
+ 2021-07-24 07:20:00 EDT,22.6,57.8,2.6,43,183
19
+ 2021-07-24 07:25:00 EDT,22.4,57.8,3.5,34,196
20
+ 2021-07-24 07:30:00 EDT,22.4,58.7,2.1,23,207
21
+ 2021-07-24 07:35:00 EDT,22.5,59.1,1.5,31,218
22
+ 2021-07-24 07:40:00 EDT,22.7,58.6,0.7,42,230
23
+ 2021-07-24 07:45:00 EDT,22.8,56.7,0.8,57,243
24
+ 2021-07-24 07:50:00 EDT,22.7,57.9,1.2,17,256
25
+ 2021-07-24 07:55:00 EDT,22.8,58.5,1.6,37,269
26
+ 2021-07-24 08:00:00 EDT,22.9,58.8,1.5,28,282
27
+ 2021-07-24 08:05:00 EDT,23.1,57.8,1.3,50,297
28
+ 2021-07-24 08:10:00 EDT,23.1,56.7,1.7,43,311
29
+ 2021-07-24 08:15:00 EDT,23,56,2.4,55,326
30
+ 2021-07-24 08:20:00 EDT,23,56,2.3,53,339
31
+ 2021-07-24 08:25:00 EDT,23.2,54.6,2.5,41,353
32
+ 2021-07-24 08:30:00 EDT,23.3,54.9,2.1,30,366
33
+ 2021-07-24 08:35:00 EDT,23.6,53.3,1.4,50,379
34
+ 2021-07-24 08:40:00 EDT,24,52.4,0.9,69,392
35
+ 2021-07-24 08:45:00 EDT,24.1,51.6,0.8,71,405
36
+ 2021-07-24 08:50:00 EDT,24.1,51.3,0.8,77,419
37
+ 2021-07-24 08:55:00 EDT,23.9,51.5,0.7,139,432
38
+ 2021-07-24 09:00:00 EDT,24.4,49.9,0.6,70,445
39
+ 2021-07-24 09:05:00 EDT,24.3,49.4,1,51,458
40
+ 2021-07-24 09:10:00 EDT,24.3,49.9,1.6,55,470
41
+ 2021-07-24 09:15:00 EDT,24.5,49.7,1.2,52,483
42
+ 2021-07-24 09:20:00 EDT,24.2,49.9,1.7,72,494
43
+ 2021-07-24 09:25:00 EDT,24,52.4,1.7,65,505
44
+ 2021-07-24 09:30:00 EDT,24.2,51.5,1.5,77,518
45
+ 2021-07-24 09:35:00 EDT,24.5,51.1,1.4,121,529
46
+ 2021-07-24 09:40:00 EDT,24.7,51,1.1,95,540
47
+ 2021-07-24 09:45:00 EDT,24.4,51.4,1.5,116,550
48
+ 2021-07-24 09:50:00 EDT,24.3,51.2,1.7,104,561
49
+ 2021-07-24 09:55:00 EDT,24.5,51,1.8,85,573
50
+ 2021-07-24 10:00:00 EDT,24.6,50.3,1.5,90,583
51
+ 2021-07-24 10:05:00 EDT,24.4,50.7,1.7,102,595
52
+ 2021-07-24 10:10:00 EDT,25.3,49,0.9,88,606
53
+ 2021-07-24 10:15:00 EDT,24.8,49.6,2.3,95,614
54
+ 2021-07-24 10:20:00 EDT,24.5,51.5,1.6,99,623
55
+ 2021-07-24 10:25:00 EDT,24.8,50,0.9,91,633
56
+ 2021-07-24 10:30:00 EDT,25.4,48.5,1,93,644
57
+ 2021-07-24 10:35:00 EDT,24.6,47.1,2.4,100,654
58
+ 2021-07-24 10:40:00 EDT,25.2,46.8,1.4,113,669
59
+ 2021-07-24 10:45:00 EDT,24.8,47.4,2.2,53,679
60
+ 2021-07-24 10:50:00 EDT,24.9,48,2.3,87,684
61
+ 2021-07-24 10:55:00 EDT,25.3,48.4,1.6,94,692
62
+ 2021-07-24 11:00:00 EDT,25.2,48.5,2.3,69,704
63
+ 2021-07-24 11:05:00 EDT,24.8,49.3,2.5,62,706
64
+ 2021-07-24 11:10:00 EDT,25.1,49.6,1.7,61,698
65
+ 2021-07-24 11:15:00 EDT,25.3,49.2,2.2,74,721
66
+ 2021-07-24 11:20:00 EDT,25.5,49,1.8,84,730
67
+ 2021-07-24 11:25:00 EDT,25,49.1,1.7,31,737
68
+ 2021-07-24 11:30:00 EDT,25.3,49.7,1.1,355,746
69
+ 2021-07-24 11:35:00 EDT,25.4,48.6,1.1,16,755
70
+ 2021-07-24 11:40:00 EDT,25.3,48,1,328,765
71
+ 2021-07-24 11:45:00 EDT,26.1,45.9,1.5,261,778
72
+ 2021-07-24 11:50:00 EDT,26.3,44.3,0.8,272,771
73
+ 2021-07-24 11:55:00 EDT,26.5,44.5,0.8,109,798
74
+ 2021-07-24 12:00:00 EDT,26.3,44.1,1.3,305,802
75
+ 2021-07-24 12:05:00 EDT,26.2,44.1,1.1,288,815
76
+ 2021-07-24 12:10:00 EDT,26.6,43.8,0.7,243,813
77
+ 2021-07-24 12:15:00 EDT,26.2,44.4,2.3,349,804
78
+ 2021-07-24 12:20:00 EDT,25.9,46,1.9,326,811
79
+ 2021-07-24 12:25:00 EDT,26.5,44.9,0.8,338,807
80
+ 2021-07-24 12:30:00 EDT,26.5,42.9,1.8,339,832
81
+ 2021-07-24 12:35:00 EDT,26.4,43.5,1.5,334,840
82
+ 2021-07-24 12:40:00 EDT,26.7,45.2,2.8,17,596
83
+ 2021-07-24 12:45:00 EDT,26.3,46,2.9,31,638
84
+ 2021-07-24 12:50:00 EDT,26.2,46.7,3,51,759
85
+ 2021-07-24 12:55:00 EDT,26.3,46.2,2.6,47,757
86
+ 2021-07-24 13:00:00 EDT,26.7,44.8,1.9,338,763
87
+ 2021-07-24 13:05:00 EDT,26.5,45.4,2.2,318,805
88
+ 2021-07-24 13:10:00 EDT,26.3,44.9,1.8,347,839
89
+ 2021-07-24 13:15:00 EDT,27.6,42.3,0.7,277,837
90
+ 2021-07-24 13:20:00 EDT,27.4,40.2,1.9,28,834
91
+ 2021-07-24 13:25:00 EDT,27.1,39.2,2.9,50,828
92
+ 2021-07-24 13:30:00 EDT,27.6,40.3,1.6,110,546
93
+ 2021-07-24 13:35:00 EDT,27.4,42.2,0.9,133,195
94
+ 2021-07-24 13:40:00 EDT,27.4,42.3,1.3,184,347
95
+ 2021-07-24 13:45:00 EDT,27.2,41.8,0.8,44,808
96
+ 2021-07-24 13:50:00 EDT,27.8,40.1,0.9,160,679
97
+ 2021-07-24 13:55:00 EDT,27.8,39.7,1.3,136,298
98
+ 2021-07-24 14:00:00 EDT,27.9,39.8,0.7,162,626
99
+ 2021-07-24 14:05:00 EDT,27.5,39.9,1.9,106,273
100
+ 2021-07-24 14:10:00 EDT,27.6,40.4,1.3,134,187
101
+ 2021-07-24 14:15:00 EDT,27.5,39.9,1.9,153,207
102
+ 2021-07-24 14:20:00 EDT,27.4,41.9,2.3,145,294
103
+ 2021-07-24 14:25:00 EDT,27.5,43,1.5,145,369
104
+ 2021-07-24 14:30:00 EDT,27.3,43.5,1.2,93,242
105
+ 2021-07-24 14:35:00 EDT,27.5,44.6,1.3,163,246
106
+ 2021-07-24 14:40:00 EDT,27.2,45.2,1.8,146,464
107
+ 2021-07-24 14:45:00 EDT,26.8,47,3.1,147,300
108
+ 2021-07-24 14:50:00 EDT,27,48,2.3,161,204
109
+ 2021-07-24 14:55:00 EDT,26.5,49.8,4.1,148,158
110
+ 2021-07-24 15:00:00 EDT,26.1,51.1,4.1,139,140
111
+ 2021-07-24 15:05:00 EDT,26.3,51.1,2.5,161,128
112
+ 2021-07-24 15:10:00 EDT,26.3,50.9,3,158,219
113
+ 2021-07-24 15:15:00 EDT,26.6,50.5,3.1,154,584
114
+ 2021-07-24 15:20:00 EDT,26.7,49.7,2,132,448
115
+ 2021-07-24 15:25:00 EDT,27.2,46.4,1.4,175,725
116
+ 2021-07-24 15:30:00 EDT,27.3,45.4,3.8,202,349
117
+ 2021-07-24 15:35:00 EDT,26.8,47.6,2.4,209,511
118
+ 2021-07-24 15:40:00 EDT,27,47.2,3.2,142,658
119
+ 2021-07-24 15:45:00 EDT,27.1,47.6,3.2,163,565
120
+ 2021-07-24 15:50:00 EDT,26.6,48.3,3.5,184,181
121
+ 2021-07-24 15:55:00 EDT,26.8,46.7,3.4,196,605
122
+ 2021-07-24 16:00:00 EDT,27,46.1,2.7,209,620
123
+ 2021-07-24 16:05:00 EDT,27.2,44.6,1.9,208,456
124
+ 2021-07-24 16:10:00 EDT,27,45,2.4,200,439
125
+ 2021-07-24 16:15:00 EDT,26.9,45,2.9,196,498
126
+ 2021-07-24 16:20:00 EDT,27.1,44.3,2.2,202,359
127
+ 2021-07-24 16:25:00 EDT,27,44,2.1,176,303
128
+ 2021-07-24 16:30:00 EDT,27.1,44.5,2.3,168,162
129
+ 2021-07-24 16:35:00 EDT,27,44.8,2.2,156,365
130
+ 2021-07-24 16:40:00 EDT,26.9,45.5,2,176,173
131
+ 2021-07-24 16:45:00 EDT,26.7,46.1,2,137,138
132
+ 2021-07-24 16:50:00 EDT,26.3,46.4,3.6,149,139
133
+ 2021-07-24 16:55:00 EDT,25.9,47.2,4,147,145
134
+ 2021-07-24 17:00:00 EDT,25.9,47.6,2.3,165,170
135
+ 2021-07-24 17:05:00 EDT,26.1,47.3,2.2,154,173
136
+ 2021-07-24 17:10:00 EDT,25.8,47.6,2.3,146,174
137
+ 2021-07-24 17:15:00 EDT,25.5,48.7,4.1,146,161
138
+ 2021-07-24 17:20:00 EDT,25.5,49,2.4,178,154
139
+ 2021-07-24 17:25:00 EDT,25.7,47.5,1.5,159,174
140
+ 2021-07-24 17:30:00 EDT,25.9,46.7,1.9,169,301
141
+ 2021-07-24 17:35:00 EDT,25.9,46.6,2.5,173,283
142
+ 2021-07-24 17:40:00 EDT,25.8,47.7,2.2,164,321
143
+ 2021-07-24 17:45:00 EDT,25.7,48.3,3.2,143,287
144
+ 2021-07-24 17:50:00 EDT,25.5,49.3,2.8,157,224
145
+ 2021-07-24 17:55:00 EDT,25.4,49,2,161,130
146
+ 2021-07-24 18:00:00 EDT,25.2,48.9,3.2,148,109
147
+ 2021-07-24 18:05:00 EDT,25.2,49.7,2.3,144,96
148
+ 2021-07-24 18:10:00 EDT,25.3,49.3,2.3,165,117
149
+ 2021-07-24 18:15:00 EDT,25.4,49.1,1.9,165,131
150
+ 2021-07-24 18:20:00 EDT,25.3,49.2,2.3,155,107
151
+ 2021-07-24 18:25:00 EDT,25.1,49.5,2.7,178,108
152
+ 2021-07-24 18:30:00 EDT,25.1,48.3,3,178,113
153
+ 2021-07-24 18:35:00 EDT,25,46.8,2.4,156,102
154
+ 2021-07-24 18:40:00 EDT,25.2,46.2,2.6,176,99
155
+ 2021-07-24 18:45:00 EDT,25.1,46.2,2.8,163,92
156
+ 2021-07-24 18:50:00 EDT,25.1,46.3,3.1,172,119
157
+ 2021-07-24 18:55:00 EDT,25.2,46.2,1.7,148,138
158
+ 2021-07-24 19:00:00 EDT,25.3,45.8,2,160,119
159
+ 2021-07-24 19:05:00 EDT,25.3,45.9,1.6,161,125
160
+ 2021-07-24 19:10:00 EDT,25.3,45.7,1.5,156,124
161
+ 2021-07-24 19:15:00 EDT,25.3,45.9,2.6,173,103
162
+ 2021-07-24 19:20:00 EDT,25.2,46.3,2.4,171,69
163
+ 2021-07-24 19:25:00 EDT,25.2,46.1,1.3,120,53
164
+ 2021-07-24 19:30:00 EDT,25.1,46.1,2.4,177,38
165
+ 2021-07-24 19:35:00 EDT,25,46.6,2,164,27
166
+ 2021-07-24 19:40:00 EDT,25,46.8,2.2,168,21
167
+ 2021-07-24 19:45:00 EDT,24.9,47.3,3,167,18
168
+ 2021-07-24 19:50:00 EDT,24.8,48,2.4,184,19
169
+ 2021-07-24 19:55:00 EDT,24.8,48,2,182,18
170
+ 2021-07-24 20:00:00 EDT,24.6,48.1,3,169,14