Skip to content

Commit

Permalink
Add check_tech_change_status_upgrade to check upgrade->tech tallies
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-anz committed May 17, 2024
1 parent 1888a03 commit 3dc1013
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions code/adhoc_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import glob
import logging
import os
import pprint
import re
import subprocess
from collections import Counter, OrderedDict
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 3dc1013

Please sign in to comment.