UPDATE
This commit is contained in:
@@ -6,6 +6,7 @@ from statistics import mean
|
||||
from typing import Any
|
||||
|
||||
from django.apps import apps
|
||||
from location_data.satellite_snapshot import build_location_satellite_snapshot
|
||||
|
||||
from crop_simulation.services import CropSimulationService
|
||||
|
||||
@@ -141,14 +142,15 @@ def _build_weather_records(forecasts: list[Any], *, latitude: float, longitude:
|
||||
|
||||
def _build_soil_parameters(sensor: Any) -> tuple[dict[str, Any], dict[str, Any]]:
|
||||
moisture_pct = _sensor_metric(sensor, "soil_moisture")
|
||||
depths = []
|
||||
center_location = getattr(sensor, "center_location", None)
|
||||
if center_location is not None:
|
||||
depths = list(center_location.depths.all())
|
||||
|
||||
top_depth = depths[0] if depths else None
|
||||
wv0033 = _safe_float(getattr(top_depth, "wv0033", None), 0.34)
|
||||
wv1500 = _safe_float(getattr(top_depth, "wv1500", None), 0.14)
|
||||
satellite_metrics = (
|
||||
build_location_satellite_snapshot(center_location).get("resolved_metrics") or {}
|
||||
if center_location is not None
|
||||
else {}
|
||||
)
|
||||
ndwi = _safe_float(satellite_metrics.get("ndwi"), 0.34)
|
||||
wv0033 = ndwi if ndwi > 0 else 0.34
|
||||
wv1500 = max(round(wv0033 * 0.45, 3), 0.14)
|
||||
|
||||
smfcf = _clamp(wv0033 if wv0033 > 0 else 0.34, 0.2, 0.55)
|
||||
smw = _clamp(wv1500 if wv1500 > 0 else 0.12, 0.05, smfcf - 0.02)
|
||||
|
||||
Reference in New Issue
Block a user