lib.mosaic

Flight mosaic gridding, incremental sweep processing, and multi-pass fire filtering.

Mosaic gridding: build flight mosaics, incremental sweep processing.

lib.mosaic.build_mosaic(files, lat_min, lat_max, lon_min, lon_max, day_night='D')[source]

Build a gridded mosaic from a list of flight line files.

Files are processed in order (chronological), so later lines overwrite earlier ones in overlapping areas. A multi-pass consistency filter requires fire to be detected in >=2 passes for pixels observed multiple times, filtering out angle-dependent false positives (e.g. solar reflection).

Returns dict with keys:

T4, T11, SWIR: gridded brightness temp / radiance arrays Red, NIR: gridded VNIR radiance (NaN for nighttime flights) NDVI: computed from gridded Red/NIR (NaN for nighttime flights) fire: boolean fire mask after multi-pass filter lat_axis, lon_axis: coordinate axes fire_count, obs_count: per-cell detection and observation counts day_night: ‘D’ or ‘N’ flag

Parameters:
Return type:

dict[str, Any]

lib.mosaic.init_grid_state(lat_min=None, lat_max=None, lon_min=None, lon_max=None)[source]

Initialize empty grid state for incremental mosaic building.

When called with no arguments, returns an empty sentinel grid (0x0) that will be populated on the first call to process_sweep().

Parameters:
Return type:

dict[str, Any]

lib.mosaic.process_sweep(filepath, gs, pixel_rows, day_night='auto', flight_num='', fire_fn=None)[source]

Process one sweep file and update grid state in-place.

Also appends per-pixel data to pixel_rows list for DataFrame construction later.

Parameters:
  • filepath (str) – path to HDF file.

  • gs (dict[str, Any]) – grid state dict (modified in-place).

  • pixel_rows (list[dict[str, Any]]) – list to append per-pixel dicts to (modified in-place).

  • day_night (str) – ‘D’, ‘N’, or ‘auto’. When ‘auto’, checks VNIR radiance to determine if the scene has sunlight (robust to cloud).

  • flight_num (str) – flight identifier string.

  • fire_fn (Any) – optional callable(T4, T11, NDVI) -> bool mask. When provided, replaces detect_fire_simple for fire detection.

Returns:

fire pixel count and detected day/night flag.

Return type:

(n_new_fire, day_night)

lib.mosaic.get_fire_mask(gs)[source]

Apply multi-pass consistency filter with vegetation confirmation.

Standard rule: pixels observed >=2 times need fire in >=2 passes. Override: pixels with veg_confirmed=True are treated as fire even with only 1 thermal fire detection (vegetation loss is independent confirmation that the thermal signal was real fire).

Parameters:

gs (dict[str, Any])

Return type:

ndarray