nakas Claude commited on
Commit
142fe36
·
1 Parent(s): 4ca4a7d

Add missing precipitation_percentage and intensity_levels to analysis

Browse files

Fix KeyError by ensuring all expected fields are included in the
analyze_radar_pixels return dictionary.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

Files changed (1) hide show
  1. radar_analyzer.py +8 -2
radar_analyzer.py CHANGED
@@ -189,12 +189,18 @@ class CanadianRadarAnalyzer:
189
  color_map[y, x] = match.rgb
190
  pixel_stats[match.name] += 1
191
 
 
 
 
 
192
  return {
193
  'precipitation_map': precipitation_map,
194
  'color_map': color_map,
195
  'pixel_statistics': pixel_stats,
196
- 'total_pixels': height * width,
197
- 'precipitation_pixels': sum(pixel_stats.values())
 
 
198
  }
199
 
200
  def find_color_regions(self, radar_image: np.ndarray, min_region_size: int = 100) -> List[Dict]:
 
189
  color_map[y, x] = match.rgb
190
  pixel_stats[match.name] += 1
191
 
192
+ total_pixels = height * width
193
+ precipitation_pixels = sum(pixel_stats.values())
194
+ precipitation_percentage = (precipitation_pixels / total_pixels) * 100 if total_pixels > 0 else 0
195
+
196
  return {
197
  'precipitation_map': precipitation_map,
198
  'color_map': color_map,
199
  'pixel_statistics': pixel_stats,
200
+ 'total_pixels': total_pixels,
201
+ 'precipitation_pixels': precipitation_pixels,
202
+ 'precipitation_percentage': precipitation_percentage,
203
+ 'intensity_levels': pixel_stats
204
  }
205
 
206
  def find_color_regions(self, radar_image: np.ndarray, min_region_size: int = 100) -> List[Dict]: