def main(): """Main function executed at the bottom.""" # Get all US surge data including states. us_surge = Surge() # Set parameters us_surge.end_date = '4/20/20' # set end date wanted us_surge.end_date = None # get all the data available us_surge.ignore_last_n_days = 2 # allow for data repo to be updated # ************************************************************************* # Combine all states into a country # ************************************************************************* print('******************************************************************') print('* US *') print('******************************************************************') print('# of states/distric: ', len(us_surge.names)) print('# of days: ', us_surge.dates.shape[0]) # Plot the data us_surge.plot_covid_data(save=True) n_last_days = 7 print('') print('Last %i days'%n_last_days, ' # of cumulative cases = ', np.sum(us_surge.cases, axis=1)[-n_last_days:]) print('Last %i days'%n_last_days, ' # of added cases =', [b-a for (b, a) in zip(np.sum(us_surge.cases, axis=1)[-(n_last_days-1):], np.sum(us_surge.cases, axis=1)[-n_last_days:-1])]) print('') # Fit data to model function param_vec = us_surge.fit_data() print('') # Plot the fit data to model function of combined US data us_surge.plot_covid_nlfit(param_vec, save=True, plot_prime=True, plot_double_prime=True) # Report critical times (tcc, dtc) = us_surge.report_critical_times(param_vec, verbose=True) # Report errors us_surge.report_error_analysis(param_vec, tcc, dtc) # 60-day look-ahead n_prediction_days = 60 last_day = us_surge.dates.size total_deaths_predicted = int(us_surge.sigmoid_func(n_prediction_days + last_day, param_vec)) print('') print('Estimated cumulative deaths in %s days from %s = %6i'% (n_prediction_days, us_surge.dates[-1], total_deaths_predicted)) print('# of cumulative deaths today, %s = %6i'% (us_surge.dates[-1], int(np.sum(us_surge.cases[-1, :])))) print('')
def main(): """Main function executed at the bottom.""" # Get global surge data g_surge = Surge(locale='global') print('# of countries: ', g_surge.cases.shape[1]) print('# of days: ', g_surge.cases.shape[0]) # Set parameters g_surge.end_date = '4/20/20' # set end date wanted g_surge.end_date = None # get all the data available g_surge.ignore_last_n_days = 0 # allow for data repo to be updated print('******************************************************************') print('* Single Country *') print('******************************************************************') name = 'Brazil' print(name) print('') # Plot the data g_surge.plot_covid_data(name, save=True) n_last_days = 7 country_id = g_surge.names.index(name) print('') print('Last %i days' % n_last_days, ' # of cumulative cases = ', g_surge.cases[-n_last_days:, country_id]) print('Last %i days' % n_last_days, ' # of added cases =', [ b - a for (b, a) in zip(g_surge.cases[-(n_last_days - 1):, country_id], g_surge.cases[-n_last_days:-1, country_id]) ]) print('') # Fit data to model function param_vec = g_surge.fit_data(name) print('') # Plot the fit data to model function g_surge.plot_covid_nlfit(param_vec, name, save=True, plot_prime=True, plot_double_prime=True) # Report critical times (tcc, dtc) = g_surge.report_critical_times(param_vec, name, verbose=True) # Report errors g_surge.report_error_analysis(param_vec, tcc, dtc, name) # 60-day look-ahead n_prediction_days = 60 last_day = g_surge.dates.size total_deaths_predicted = int( g_surge.sigmoid_func(n_prediction_days + last_day, param_vec)) print('') print('Estimated cumulative deaths in %s days from %s = %6i'%\ (n_prediction_days, g_surge.dates[-1], total_deaths_predicted)) print('# of cumulative deaths today, %s = %6i'%\ (g_surge.dates[-1], g_surge.cases[-1, g_surge.names.index(name)])) print('')
def main(): """Main function executed at the bottom.""" # Get US surge data us_surge = Surge() # Set parameters us_surge.end_date = '4/20/20' # set end date wanted us_surge.end_date = None # get all the data available us_surge.ignore_last_n_days = 0 # allow for data repo to be updated #************************************************************************** # Single State Case #************************************************************************** print('******************************************************************') print('* Single State *') print('******************************************************************') name = 'New Mexico' print(name) print('') # Plot the data us_surge.plot_covid_data(name, save=True) n_last_days = 7 state_id = us_surge.names.index(name) print('') print('Last %i days' % n_last_days, ' # of cumulative cases = ', us_surge.cases[-n_last_days:, state_id]) print('Last %i days' % n_last_days, ' # of added cases =', [ b - a for (b, a) in zip(us_surge.cases[-(n_last_days - 1):, state_id], us_surge.cases[-n_last_days:-1, state_id]) ]) print('') # Fit data to model function param_vec = us_surge.fit_data(name) print('') # Plot the fit data to model function us_surge.plot_covid_nlfit(param_vec, name, save=True, plot_prime=True, plot_double_prime=True) # Report critical times (tcc, dtc) = us_surge.report_critical_times(param_vec, name, verbose=True) # Report errors us_surge.report_error_analysis(param_vec, tcc, dtc, name) # 60-day look-ahead n_prediction_days = 60 last_day = us_surge.dates.size total_deaths_predicted = int( us_surge.sigmoid_func(n_prediction_days + last_day, param_vec)) print('') print('Estimated cumulative deaths in %s days from %s = %6i'%\ (n_prediction_days, us_surge.dates[-1], total_deaths_predicted)) print('# of cumulative deaths today, %s = %6i'%\ (us_surge.dates[-1], us_surge.cases[-1, us_surge.names.index(name)])) print('')