Add Mol multi-zone operational validation

This commit is contained in:
Codex
2026-07-13 18:12:48 +02:00
parent 4539e92bcf
commit 2c16ff2bc0
16 changed files with 605 additions and 12 deletions
@@ -118,7 +118,15 @@ with output_path.open("w", encoding="utf-8") as handle:
reference_count = int(sample.get("reference_feature_count") or 0)
if reference_count < 1:
raise SystemExit(f"Operator sample has no reference features: {sample_slug}")
handle.write(f"{sample_slug}\t{raster_path}\t{reference_path}\t{reference_count}\n")
bbox = sample.get("wgs84_bbox") or []
if len(bbox) != 4:
raise SystemExit(f"Operator sample has no valid wgs84_bbox: {sample_slug}")
bbox_csv = ",".join(str(float(value)) for value in bbox)
municipality = str(sample.get("municipality") or "")
handle.write(
f"{sample_slug}\t{raster_path}\t{reference_path}\t{reference_count}\t"
f"{bbox_csv}\t{municipality}\n"
)
selected += 1
if selected == 0:
@@ -131,13 +139,20 @@ echo "Manifest: ${OPERATOR_SAMPLE_MANIFEST_PATH}"
echo "Sample filter: ${OPERATOR_SAMPLE_SLUGS:-all}"
echo "Output: ${MULTI_SAMPLE_OUTPUT_DIR}"
while IFS=$'\t' read -r sample_slug raster_path reference_path reference_feature_count; do
while IFS=$'\t' read -r sample_slug raster_path reference_path reference_feature_count wgs84_bbox municipality; do
sample_output_dir="${MULTI_SAMPLE_OUTPUT_DIR}/${sample_slug}"
mkdir -p "${sample_output_dir}"
echo "-- Sample ${sample_slug}: reference_features=${reference_feature_count} --"
project_region="Kempen"
if [ "${municipality,,}" = "mol" ]; then
project_region="Mol, Kempen"
fi
REAL_RASTER_PATH="${raster_path}" \
REAL_REFERENCE_VECTOR_PATH="${reference_path}" \
QUALITY_SAMPLE_SLUG="${sample_slug}" \
REAL_PROJECT_REGION="${project_region}" \
REAL_AREA_NAME="${sample_slug} AOI" \
REAL_AREA_BBOX="${wgs84_bbox}" \
QUALITY_OUTPUT_DIR="${sample_output_dir}" \
bash scripts/run_detection_quality_matrix.sh "${BASE_URL}"
done < "${sample_manifest_tsv}"
@@ -153,11 +168,17 @@ from pathlib import Path
output_dir = Path(sys.argv[1])
base_url = sys.argv[2]
manifest_path = sys.argv[3]
manifest_payload = json.loads(manifest_path.read_text(encoding="utf-8-sig"))
manifest_samples = {
str(sample.get("sample_slug") or "").lower(): sample
for sample in manifest_payload.get("samples") or []
}
sample_summaries = []
flat_items = []
for summary_path in sorted(glob.glob(str(output_dir / "*" / "quality_matrix_summary.json"))):
sample_slug = Path(summary_path).parent.name
sample_metadata = manifest_samples.get(sample_slug, {})
summary = json.loads(Path(summary_path).read_text(encoding="utf-8"))
items = summary.get("items") or []
for item in items:
@@ -167,6 +188,11 @@ for summary_path in sorted(glob.glob(str(output_dir / "*" / "quality_matrix_summ
sample_summaries.append(
{
"sample_slug": sample_slug,
"display_name": sample_metadata.get("display_name"),
"municipality": sample_metadata.get("municipality"),
"operational_zone": sample_metadata.get("operational_zone"),
"wgs84_bbox": sample_metadata.get("wgs84_bbox"),
"recommended_split": sample_metadata.get("recommended_split"),
"summary_path": summary_path,
"run_count": len(items),
"best_by_score": summary.get("best_by_score"),