realtime_fire.py¶
Real-time fire detection simulation. Processes one sweep at a time, incrementally building a mosaic and outputting per-frame PNGs with fire zone labels and area statistics.
realtime_fire.py - Simulate real-time fire detection as the plane sweeps.
Processes each flight line one at a time, incrementally building a mosaic and applying multi-pass fire detection. Outputs one PNG per sweep so the evolution of fire detection can be animated as a GIF.
Day/night is auto-detected per sweep from VNIR radiance levels: if NIR has meaningful signal, there’s sunlight and NDVI vegetation is shown. This is more robust than Solar Zenith Angle because it also handles cloud cover (no solar signal even when geometrically daytime).
- The operator view shows:
Green: vegetation (NDVI, when sunlight detected)
T4 thermal background (when no sunlight)
Red: predicted fire locations
Fire zone labels with area in m² or hectares
Running statistics (fire count, total area, zone breakdown)
- Usage:
python realtime_fire.py # all flights, threshold detector python realtime_fire.py –detector ml # all flights, ML detector python realtime_fire.py –detector simple # all flights, threshold detector
- realtime_fire.render_frame(gs, fire_mask, frame_num, n_total, flight_num, comment, outdir, cell_area_m2, detector_name='simple')[source]¶
Render one frame of the real-time simulation as a PNG.
Background layer is chosen by checking if the grid has accumulated usable VNIR data (any finite NIR pixels), not by the last sweep’s day/night flag. This way, daytime VNIR data persists even after nighttime sweeps are processed.
- realtime_fire.simulate_flight(flight_num, files, comment, gs, ml_model=None, detector_name='simple')[source]¶
Simulate real-time fire detection for one flight.
Day/night is auto-detected per sweep from VNIR radiance.
- Parameters:
flight_num (str) – flight identifier (e.g. ‘24-801-04’).
comment (str) – flight comment from HDF metadata.
gs (Dict[str, Any]) – Dictionary of data that is updated by process_sweep.
ml_model (Any) – optional MLFireDetector. When provided, overrides the threshold-based fire mask with ML predictions from accumulated aggregate features.
detector_name (str) – ‘simple’ or ‘ml’, used in output filenames.
- Return type:
None