Spaces:
Sleeping
fix: Coordinate dimension mismatch for Combined Smoke HRRR data
Browse files🔧 CRITICAL FIX: Coordinate System Alignment
## Problem Identified:
- Real HRRR data: shape (1059, 1799) - actual HRRR grid
- Synthetic coordinates: shape (50, 60) - demo grid
- Error: "conflicting sizes for dimension 'lat': length 50 vs 1059"
## Solution Implemented:
- Use proper HRRR CONUS coordinate ranges for real data:
- Latitude: 20.192° to 52.863° (1059 points)
- Longitude: -134.096° to -60.917° (1799 points)
- Keep synthetic coordinates (25°-50°, -125°--70°) for demo data
- Apply fix to all Combined Smoke functions:
- quick_kmz_generation()
- create_smoke_map() main forecast
- quick_kmz_wrapper() Folium maps
## Result:
- Eliminates xarray dimension conflicts
- Enables proper KMZ generation with real HRRR data
- Maintains demo mode compatibility
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
Binary files a/.DS_Store and b/.DS_Store differ
|
|
|
|
@@ -1385,9 +1385,10 @@ class HRRRSmokeApp:
|
|
| 1385 |
if datasets:
|
| 1386 |
combined_smoke = self.polygon_generator.combine_smoke_parameters(datasets)
|
| 1387 |
|
| 1388 |
-
# Create combined xarray dataset
|
| 1389 |
-
|
| 1390 |
-
|
|
|
|
| 1391 |
ds = xr.Dataset({
|
| 1392 |
'combined_smoke': (['lat', 'lon'], combined_smoke)
|
| 1393 |
}, coords={'lat': lats, 'lon': lons})
|
|
@@ -1735,9 +1736,10 @@ class HRRRSmokeApp:
|
|
| 1735 |
print(f"Quick KMZ: Successfully fetched {len(datasets)} parameters: {list(datasets.keys())}")
|
| 1736 |
combined_smoke = self.polygon_generator.combine_smoke_parameters(datasets)
|
| 1737 |
|
| 1738 |
-
#
|
| 1739 |
-
|
| 1740 |
-
|
|
|
|
| 1741 |
ds = xr.Dataset({
|
| 1742 |
'combined_smoke': (['lat', 'lon'], combined_smoke)
|
| 1743 |
}, coords={'lat': lats, 'lon': lons})
|
|
@@ -2106,8 +2108,9 @@ with gr.Blocks(title="HRRR Smoke Forecast", theme=gr.themes.Soft()) as app:
|
|
| 2106 |
|
| 2107 |
if datasets:
|
| 2108 |
combined_smoke = smoke_app.polygon_generator.combine_smoke_parameters(datasets)
|
| 2109 |
-
|
| 2110 |
-
|
|
|
|
| 2111 |
ds = xr.Dataset({
|
| 2112 |
'combined_smoke': (['lat', 'lon'], combined_smoke)
|
| 2113 |
}, coords={'lat': lats, 'lon': lons})
|
|
@@ -2116,8 +2119,9 @@ with gr.Blocks(title="HRRR Smoke Forecast", theme=gr.themes.Soft()) as app:
|
|
| 2116 |
['MASSDEN', 'PM25', 'VIS', 'COLMD', 'FRPAVG'], forecast_hour
|
| 2117 |
)
|
| 2118 |
combined_smoke = smoke_app.polygon_generator.combine_smoke_parameters(datasets)
|
| 2119 |
-
|
| 2120 |
-
|
|
|
|
| 2121 |
ds = xr.Dataset({
|
| 2122 |
'combined_smoke': (['lat', 'lon'], combined_smoke)
|
| 2123 |
}, coords={'lat': lats, 'lon': lons})
|
|
|
|
| 1385 |
if datasets:
|
| 1386 |
combined_smoke = self.polygon_generator.combine_smoke_parameters(datasets)
|
| 1387 |
|
| 1388 |
+
# Create combined xarray dataset with proper HRRR grid coordinates
|
| 1389 |
+
print(f"Main forecast: Creating coordinates for HRRR grid: {combined_smoke.shape}")
|
| 1390 |
+
lats = np.linspace(20.192, 52.863, combined_smoke.shape[0]) # HRRR CONUS lat range
|
| 1391 |
+
lons = np.linspace(-134.096, -60.917, combined_smoke.shape[1]) # HRRR CONUS lon range
|
| 1392 |
ds = xr.Dataset({
|
| 1393 |
'combined_smoke': (['lat', 'lon'], combined_smoke)
|
| 1394 |
}, coords={'lat': lats, 'lon': lons})
|
|
|
|
| 1736 |
print(f"Quick KMZ: Successfully fetched {len(datasets)} parameters: {list(datasets.keys())}")
|
| 1737 |
combined_smoke = self.polygon_generator.combine_smoke_parameters(datasets)
|
| 1738 |
|
| 1739 |
+
# Create coordinates matching the actual HRRR grid dimensions
|
| 1740 |
+
print(f"Creating coordinates for HRRR grid: {combined_smoke.shape}")
|
| 1741 |
+
lats = np.linspace(20.192, 52.863, combined_smoke.shape[0]) # HRRR CONUS lat range
|
| 1742 |
+
lons = np.linspace(-134.096, -60.917, combined_smoke.shape[1]) # HRRR CONUS lon range
|
| 1743 |
ds = xr.Dataset({
|
| 1744 |
'combined_smoke': (['lat', 'lon'], combined_smoke)
|
| 1745 |
}, coords={'lat': lats, 'lon': lons})
|
|
|
|
| 2108 |
|
| 2109 |
if datasets:
|
| 2110 |
combined_smoke = smoke_app.polygon_generator.combine_smoke_parameters(datasets)
|
| 2111 |
+
# Use HRRR grid coordinates for Folium wrapper too
|
| 2112 |
+
lats = np.linspace(20.192, 52.863, combined_smoke.shape[0])
|
| 2113 |
+
lons = np.linspace(-134.096, -60.917, combined_smoke.shape[1])
|
| 2114 |
ds = xr.Dataset({
|
| 2115 |
'combined_smoke': (['lat', 'lon'], combined_smoke)
|
| 2116 |
}, coords={'lat': lats, 'lon': lons})
|
|
|
|
| 2119 |
['MASSDEN', 'PM25', 'VIS', 'COLMD', 'FRPAVG'], forecast_hour
|
| 2120 |
)
|
| 2121 |
combined_smoke = smoke_app.polygon_generator.combine_smoke_parameters(datasets)
|
| 2122 |
+
# Use demo coordinates for synthetic data (50x60 grid)
|
| 2123 |
+
lats = np.linspace(25, 50, combined_smoke.shape[0])
|
| 2124 |
+
lons = np.linspace(-125, -70, combined_smoke.shape[1])
|
| 2125 |
ds = xr.Dataset({
|
| 2126 |
'combined_smoke': (['lat', 'lon'], combined_smoke)
|
| 2127 |
}, coords={'lat': lats, 'lon': lons})
|