Improved single sites metrics calculation.
This commit is contained in:
parent
6b7395b617
commit
d7b18baf2e
2 changed files with 18 additions and 10 deletions
15
5-metrics.py
15
5-metrics.py
|
|
@ -756,8 +756,6 @@ def main() -> None:
|
|||
# Export per-site data for the requested year
|
||||
year_sites = manifest["sites"].get(str(year), {})
|
||||
fusion_sites = {s: m for s, m in year_sites.items() if m["has_fusion"]}
|
||||
if filter_site:
|
||||
fusion_sites = {s: m for s, m in fusion_sites.items() if s == filter_site}
|
||||
|
||||
print(f"Exporting {len(fusion_sites)} site(s) with fusion data for {year}")
|
||||
for site, meta in tqdm(fusion_sites.items(), desc="Sites"):
|
||||
|
|
@ -771,7 +769,18 @@ def main() -> None:
|
|||
print(f" ✗ {site} — no fusion data found")
|
||||
|
||||
manifest_path = out_base / "manifest.json"
|
||||
manifest_path.write_text(json.dumps(manifest, separators=(",", ":")))
|
||||
if filter_site and manifest_path.is_file():
|
||||
# Merge: update only the filtered site(s); preserve all other entries.
|
||||
existing: dict = json.loads(manifest_path.read_text())
|
||||
for year_key, year_sites_new in manifest["sites"].items():
|
||||
existing.setdefault("sites", {}).setdefault(year_key, {}).update(
|
||||
year_sites_new
|
||||
)
|
||||
all_years = sorted(set(existing.get("years", [])) | set(manifest["years"]))
|
||||
existing["years"] = all_years
|
||||
manifest_path.write_text(json.dumps(existing, separators=(",", ":")))
|
||||
else:
|
||||
manifest_path.write_text(json.dumps(manifest, separators=(",", ":")))
|
||||
print(f"Manifest written → {manifest_path}")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue