# calc eigenvalues from R matrix # should return in descending order (largest will be first) evals, matrix_v = np.linalg.eig(R) # matrix_v --> normalized eigenvectors # largest eigenvalue is R0 R0 = max(evals) return R0 ################################################### if __name__ == "__main__": # READ POPULATION DATA FROM FILE popdata = csv.reader(open('Dropbox/Anne_Bansal_lab/SDI_Data/totalpop_age.csv', 'r'),delimiter = ',') dict_popdata, ages, years = func.import_popdata(popdata, 0, 1, 2) dict_childpop, dict_adultpop = func.pop_child_adult (dict_popdata, years) # READ GERMAN CONTACT DATA FROM FILE filename_germ_contact_data = 'Dropbox/Anne_Bansal_lab/Contact_Data/polymod_germany_contact_matrix_Mossong_2008.csv' filename_germ_pop_data = 'Dropbox/Anne_Bansal_lab/UNdata_Export_2008_Germany_Population.csv' # DEFINE DISEASE PARAMETERS beta = 0.0165 gamma = 0.2 # CALCULATE ALPHA year = 2010 alpha = func.calc_alpha(year, dict_childpop, dict_adultpop) # CALCULATE R MATRIX R = calc_R_matrix (beta, gamma, alpha)
# AGE SPLIT # # POLYMOD contact study (Ref 22 in Apollini 2013) ## Children: (5 - 19) ## Adults: (20 - 69) #popdata #totalpop_age.csv # 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]