def load_data(paths, settings, dtype): M_tt, age_groups = load_age_mixing(paths['age_mixing_matrix_term']) M_hh, _ = load_age_mixing(paths['age_mixing_matrix_hol']) C = collapse_commute_data(paths['mobility_matrix']) la_names = C.index.to_numpy() w_period = [ settings['inference_period'][0], settings['prediction_period'][1] ] W = load_commute_volume(paths['commute_volume'], w_period)['percent'] pop = collapse_pop(paths['population_size']) M_tt = M_tt.astype(DTYPE) M_hh = M_hh.astype(DTYPE) C = C.to_numpy().astype(DTYPE) np.fill_diagonal(C, 0.) W = W.astype(DTYPE) pop['n'] = pop['n'].astype(DTYPE) return { 'M_tt': M_tt, 'M_hh': M_hh, 'C': C, 'la_names': la_names, 'age_groups': age_groups, 'W': W, 'pop': pop }
def load_data(paths, settings, dtype=DTYPE): C = load_mobility_matrix(paths["mobility_matrix"]) la_names = C.index.to_numpy() w_period = [ settings["inference_period"][0], settings["inference_period"][1] ] W = load_commute_volume(paths["commute_volume"], w_period)["percent"] pop = load_population(paths["population_size"]) C = C.to_numpy().astype(DTYPE) np.fill_diagonal(C, 0.0) W = W.to_numpy().astype(DTYPE) pop = pop.to_numpy().astype(DTYPE) return { "C": C, "la_names": la_names, "W": W, "pop": pop, }
help="configuration file") options, args = parser.parse_args() with open(options.config, 'r') as ymlfile: config = yaml.load(ymlfile) param = sanitise_parameter(config['parameter']) settings = sanitise_settings(config['settings']) K_tt, age_groups = load_age_mixing( config['data']['age_mixing_matrix_term']) K_hh, _ = load_age_mixing(config['data']['age_mixing_matrix_hol']) T, la_names = load_mobility_matrix(config['data']['mobility_matrix']) np.fill_diagonal(T, 0.) W = load_commute_volume(config['data']['commute_volume'], settings['inference_period'])['percent'] N, n_names = load_population(config['data']['population_size']) K_tt = K_tt.astype(DTYPE) K_hh = K_hh.astype(DTYPE) W = W.to_numpy().astype(DTYPE) T = T.astype(DTYPE) N = N.astype(DTYPE) case_reports = pd.read_csv(config['data']['reported_cases']) case_reports['DateVal'] = pd.to_datetime(case_reports['DateVal']) case_reports = case_reports[case_reports['DateVal'] >= '2020-02-19'] date_range = [case_reports['DateVal'].min(), case_reports['DateVal'].max()] y = case_reports['CumCases'].to_numpy() y_incr = np.round((y[1:] - y[:-1]) * 0.8)