From 3dc1013ed233a8b79bffcb086e533e88c2a7bb8b Mon Sep 17 00:00:00 2001 From: "Roberts, Simon" Date: Sat, 18 May 2024 09:34:04 +1000 Subject: [PATCH] Add check_tech_change_status_upgrade to check upgrade->tech tallies --- code/adhoc_tools.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/code/adhoc_tools.py b/code/adhoc_tools.py index ba21480b23..9455ac9884 100755 --- a/code/adhoc_tools.py +++ b/code/adhoc_tools.py @@ -4,6 +4,7 @@ import glob import logging import os +import pprint import re import subprocess from collections import Counter, OrderedDict @@ -350,6 +351,24 @@ def fix_tech_breakdown(tech): # breakdown-state.json and breakdown.STATE.csv (uses breakdown-suburbs.json) generate_state_breakdown() +def check_tech_change_status_upgrade(): + """Emit tally on the upgrade field for all locations with tech_change_status.""" + tallies = {} + filenames = glob.glob("results/**/*.geojson") + for n, file in enumerate(filenames): + if n % 100 == 0: + utils.print_progress_bar(n, len(filenames), prefix="Progress:", suffix="Complete", length=50) + geojson = utils.read_json_file(file) + for feature in geojson["features"]: + tech_change = feature["properties"].get("tech_change_status") + if tech_change: + if tech_change not in tallies: + tallies[tech_change] = Counter() + tallies[tech_change][feature["properties"].get('upgrade')] += 1 + + print() + pprint.pprint(tallies) + if __name__ == "__main__": LOGLEVEL = os.environ.get("LOGLEVEL", "INFO").upper()