fires: append FIRMS day-range param; API 400s without it
All checks were successful
build-and-deploy / build (push) Successful in 1m54s
All checks were successful
build-and-deploy / build (push) Successful in 1m54s
FIRMS area-CSV requires an explicit [1..5] day range — requests without it return 'Invalid day range. Expects [1..5].' as a 400. New FIRMS_DAYS env (default 1).
This commit is contained in:
parent
1ce3da4403
commit
1f0b831835
2 changed files with 12 additions and 3 deletions
|
|
@ -54,5 +54,8 @@ FIRMS_DATASET = os.getenv("FIRMS_DATASET", "VIIRS_SNPP_NRT")
|
||||||
FIRMS_BBOX = os.getenv("FIRMS_BBOX", "-180,-60,180,75")
|
FIRMS_BBOX = os.getenv("FIRMS_BBOX", "-180,-60,180,75")
|
||||||
# Poll cadence in seconds. FIRMS NRT updates every ~5-10 min; 900 = 15 min.
|
# Poll cadence in seconds. FIRMS NRT updates every ~5-10 min; 900 = 15 min.
|
||||||
FIRMS_INTERVAL = int(os.getenv("FIRMS_INTERVAL", "900"))
|
FIRMS_INTERVAL = int(os.getenv("FIRMS_INTERVAL", "900"))
|
||||||
|
# Day range for the area-CSV request. FIRMS accepts [1..5] days of NRT
|
||||||
|
# detections; the API 400s when this parameter is omitted.
|
||||||
|
FIRMS_DAYS = int(os.getenv("FIRMS_DAYS", "1"))
|
||||||
# Outbound HTTP timeout for the FIRMS CSV download.
|
# Outbound HTTP timeout for the FIRMS CSV download.
|
||||||
FIRMS_TIMEOUT = float(os.getenv("FIRMS_TIMEOUT", "60"))
|
FIRMS_TIMEOUT = float(os.getenv("FIRMS_TIMEOUT", "60"))
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,13 @@ from datetime import datetime, timezone
|
||||||
import httpx
|
import httpx
|
||||||
import nats
|
import nats
|
||||||
|
|
||||||
from config import FIRMS_DATASET, FIRMS_BBOX, FIRMS_TIMEOUT, NATS_URL
|
from config import (
|
||||||
|
FIRMS_BBOX,
|
||||||
|
FIRMS_DATASET,
|
||||||
|
FIRMS_DAYS,
|
||||||
|
FIRMS_TIMEOUT,
|
||||||
|
NATS_URL,
|
||||||
|
)
|
||||||
from keystore import get_api_key
|
from keystore import get_api_key
|
||||||
|
|
||||||
logger = logging.getLogger("osint.firms")
|
logger = logging.getLogger("osint.firms")
|
||||||
|
|
@ -39,7 +45,7 @@ logger = logging.getLogger("osint.firms")
|
||||||
# ── FIRMS API ─────────────────────────────────────────────────────────────
|
# ── FIRMS API ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
FIRMS_AREA_CSV = (
|
FIRMS_AREA_CSV = (
|
||||||
"https://firms.modaps.eosdis.nasa.gov/api/area/csv/{key}/{dataset}/{bbox}"
|
"https://firms.modaps.eosdis.nasa.gov/api/area/csv/{key}/{dataset}/{bbox}/{days}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# The canonical VIIRS CSV header FIRMS returns. Used to (a) locate the real
|
# The canonical VIIRS CSV header FIRMS returns. Used to (a) locate the real
|
||||||
|
|
@ -175,7 +181,7 @@ async def ingest_fires(bbox: str | None = None) -> int:
|
||||||
|
|
||||||
area = bbox or FIRMS_BBOX
|
area = bbox or FIRMS_BBOX
|
||||||
url = FIRMS_AREA_CSV.format(
|
url = FIRMS_AREA_CSV.format(
|
||||||
key=map_key, dataset=FIRMS_DATASET, bbox=area
|
key=map_key, dataset=FIRMS_DATASET, bbox=area, days=FIRMS_DAYS
|
||||||
)
|
)
|
||||||
|
|
||||||
async with httpx.AsyncClient(timeout=FIRMS_TIMEOUT) as client:
|
async with httpx.AsyncClient(timeout=FIRMS_TIMEOUT) as client:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue