# import csv file of pop data
popdata = csv.reader(open('Dropbox/Anne_Bansal_lab/SDI_Data/totalpop_age.csv', 'r'),delimiter = ',')

# import data into dicts
d_pop_for_yr_age, ages, years = func.import_popdata(popdata, 0, 1, 2)

#group ages into children and adults

d_childpop, d_adultpop = func.pop_child_adult(d_pop_for_yr_age, years)

# set value of alpha from U.S. pop data
year = 2010 # decided to use pop from 2010 bc most recent
a = func.pop_child_frac(year, d_childpop, d_adultpop)
#print a # = 0.239 for 2010 with 60-69; was 0.27 without 60-69

metro, ages = func.assign_metro(a)

print metro

#totpop of metros = 10817
# ids of ppl = [0 - 10816]



# 3b
## contact btwn children and adults
## 'C' = equation 3 in Apollini 2014
### alpha (a) = fraction of ch  --> calc in 3a
### (n) = ratio of ad/ch avg # contacts (q_a/q_c)
### (E) = avg fraction of contacts across age groups
#### --> from Euro data in Table 2 in Apollini 2013 + Ref 22
# import csv file of pop data
popdata = csv.reader(open('Dropbox/Anne_Bansal_lab/SDI_Data/totalpop_age.csv', 'r'),delimiter = ',')

# import data into dicts
d_pop_for_yr_age, ages, years = func.import_popdata(popdata, 0, 1, 2)

#group ages into children and adults

d_childpop, d_adultpop = func.pop_child_adult(d_pop_for_yr_age, years)

# set value of alpha from U.S. pop data
year = 2010 # decided to use pop from 2010 bc most recent
a = func.pop_child_frac(year, d_childpop, d_adultpop)
#print a # = 0.239 for 2010 with 60-69; was 0.27 without 60-69

metro = func.assign_metro(a)

print metro

# 3b
## contact btwn children and adults
## 'C' = equation 3 in Apollini 2014
### alpha (a) = fraction of ch  --> calc in 3a
### (n) = ratio of ad/ch avg # contacts (q_a/q_c)
### (E) = avg fraction of contacts across age groups
#### --> from Euro data in Table 2 in Apollini 2013 + Ref 22

#Apollini 2013, Table 2, "Europe (average values)"
#n = 0.79
E = 0.097 #avg fraction of contacts across age groups