Commit 7362e302 authored by Jonathan Mattingly's avatar Jonathan Mattingly
Browse files

edits. add large atlas

parent 2f44fc36
Loading
Loading
Loading
Loading
+3.7 KiB

File added.

No diff preview for this file type.

+4.24 KiB

File added.

No diff preview for this file type.

+113 MiB

File added.

No diff preview for this file type.

+48 −0
Original line number Diff line number Diff line
## This script reads in one of the multiscale map assignments
## CURRENTLY CODE DOES NOTHING WITH THE MAPS


import Atlas
import helper_functions as hf
import json
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns

pctDataF = open("pct21_20cen_wMCD.json")
pctData = json.load(pctDataF)
dataElection = pctData['nodes']

atlas = Atlas.openAtlas("./truncated_nc_multiscale.jsonl")
print(atlas)
map = []

electionName = "G16_USS"

pctToDistVotes = {}
for node in pctData["nodes"]:
    pctToDistVotes[node["id"]] = {}

while map is not None:  # This loops through all of the map in the atlas
    try:
        map = Atlas.nextMap(atlas)  # Get the next map in the atlas 
        print(map.name)
        # The maps are multi scale in the sense that if a county is kept whole
        # the following fuction makes a map from precicts to districts out of 
        # the multiscale assignement 
        node_to_dist = hf.get_node_to_district(map.districting, 
                                               pctData["nodes"]) 
        # The next fuction  sums up the election for this districting (defined 
        # by the map)
        distVoteR, distVoteD, distVoteT = hf.sumElection(electionName, 
                                                         node_to_dist, 
                                                         dataElection)
        print(distVoteR, distVoteD, distVoteT,"\n")

        # DO SOMETHING WITH THE MAP !!
        # Right Now the code does nothing

    except Exception:
        break

Loading