Add NASA FIRMS active-fire ingest + /api/fires; API keys management page
Coherent merge of two coordinated features on the shared working tree: FIRMS fire heatmap (backend, t_6e404c14): - app/fire_sources.py: fetch FIRMS VIIRS area CSV (free MAP_KEY) -> NATS events.fire - fires hypertable (TimescaleDB, 1-day chunks) with natural-key PK (latitude, longitude, acq_time, satellite); idempotent ON CONFLICT DO NOTHING - alembic/versions/002_fires.py; GET /api/fires?bbox=&since= (JSON only) - POST /api/ingest/fires; ~15 min poll loop (FIRMS_INTERVAL=900) in ingester - env-driven config (FIRMS_MAP_KEY/DATASET/BBOX/INTERVAL); docs/firms.md covers the zero-cost GIBS VIIRS_SNPP_Thermal_Anomalies_375m_All tile alternative - 18 tests (parser, mapping, idempotency, API contract) verified vs real TimescaleDB+PostGIS (localhost/osint-dashboard-pg image) API keys page (frontend, t_4433cff2): - app/keystore.py: api_keys table (self-creating), FIRMS/GEMINI/TELEGRAM registry with format validation, ****last4 masking, get_api_key() - GET/POST/DELETE /api/keys (never returns full values); Keys tab in index.html DB_NULL_POOL env switch in app/database.py enables a NullPool for tests / short-lived processes that open a fresh event loop per unit.
This commit is contained in:
parent
bce2d5c3bd
commit
627990efde
19 changed files with 1428 additions and 10 deletions
|
|
@ -5,7 +5,7 @@ from uuid import uuid4
|
|||
|
||||
from sqlalchemy import (
|
||||
Column, Enum, Float, Index, Integer, String, Text,
|
||||
DateTime, JSON, func, Table,
|
||||
DateTime, JSON, func, Table, PrimaryKeyConstraint,
|
||||
)
|
||||
from sqlalchemy.dialects.postgresql import UUID, TSVECTOR
|
||||
|
||||
|
|
@ -145,3 +145,40 @@ documents = Table(
|
|||
Column("event_id", UUID(as_uuid=True)),
|
||||
Column("uploaded_at", DateTime(timezone=True), server_default=func.now()),
|
||||
)
|
||||
|
||||
|
||||
# ── Active Fires / Hotspots (NASA FIRMS) ──────────────────────────────────
|
||||
|
||||
# VIIRS active fire/hotspot detections from NASA FIRMS. The primary key IS the
|
||||
# natural key (latitude, longitude, acq_time, satellite) so repeated 15-minute
|
||||
# polls of the same detection are idempotent (INSERT ... ON CONFLICT DO NOTHING
|
||||
# silently ignores duplicates). acq_time is the partitioning column of the
|
||||
# TimescaleDB hypertable, and since it is part of the PK, TimescaleDB's
|
||||
# "all unique indexes must include the partitioning column" rule is satisfied.
|
||||
# No surrogate id is needed — the natural key is the identity of a detection.
|
||||
fires = Table(
|
||||
"fires",
|
||||
metadata,
|
||||
Column("latitude", Float, nullable=False),
|
||||
Column("longitude", Float, nullable=False),
|
||||
Column("brightness", Float, nullable=False), # bright_ti4, Kelvin
|
||||
Column("confidence", String(10), nullable=False), # VIIRS: n/l/h, MODIS: %
|
||||
Column("acq_time", DateTime(timezone=True), nullable=False), # UTC acquisition
|
||||
Column("satellite", String(16), nullable=False), # e.g. N (S-NPP), N20, N21
|
||||
Column("instrument", String(16)),
|
||||
Column("bright_ti5", Float), # 12µm brightness, Kelvin
|
||||
Column("frp", Float), # fire radiative power, MW
|
||||
Column("daynight", String(1)), # D / N
|
||||
Column("scan", Float),
|
||||
Column("track", Float),
|
||||
Column("version", String(32)), # e.g. 2.0NRT / 2.0URT
|
||||
Column("raw", JSON),
|
||||
Column("ingested_at", DateTime(timezone=True), server_default=func.now(), nullable=False),
|
||||
PrimaryKeyConstraint(
|
||||
"latitude", "longitude", "acq_time", "satellite",
|
||||
name="pk_fires_natural_key",
|
||||
),
|
||||
)
|
||||
|
||||
# Bounding-box index for `bbox=` filtering (lon first for max/min-lon scans).
|
||||
Index("ix_fires_bbox", fires.c.longitude, fires.c.latitude)
|
||||
|
|
|
|||
Loading…
Reference in a new issue