Exemplo n.º 1
0
def update_ts_graph(zipcode,
                    radius,
                    date_window_option='ALL',
                    region_of_interest=[]):
    print('zipcode: {}'.format(zipcode))
    if len(zipcode) == 5:
        radius = float(radius)
        recs = geoSvr.search_by_zipcode('Confirmed', zipcode,
                                        radius)  # list of (county,state)
        region_options = ['{}, {}'.format(r[0], r[1]) for r in recs]
        # region_defaults = ['{}, {}'.format(r[0],r[1]) for r in recs]
        ds = CSBS()
        dt_range = ds.date_range_str(date_window_option)

        if region_of_interest is None:
            region_of_interest = []
        # print('len of region_options:{}, of region_of_interest:{}'.format(region_options is None, region_of_interest is None))
        if set(region_of_interest).isdisjoint(region_options):
            region_of_interest = region_options

        confirmed = ds.refresh_county_state_category('Confirmed',
                                                     date_window_option,
                                                     region_of_interest)
        deaths = ds.refresh_county_state_category('Deaths', date_window_option,
                                                  region_of_interest)

        return plot_ts_figure(confirmed, 'Confirmed', dt_range), \
            plot_ts_figure(deaths, 'Deaths', dt_range), \
            plot_inc_number(confirmed, 'Confirmed', dt_range), \
            plot_inc_number(deaths, 'Deaths', dt_range), \
            plot_increase(confirmed, 'Confirmed', dt_range), \
            plot_increase(deaths, 'Deaths', dt_range), \
            'Time Window:{}'.format(dt_range), \
            [{'label': x, 'value': x} for x in region_options]
Exemplo n.º 2
0
def load_region_options():
    ds = CSBS()
    ds.dataSet['Confirmed'] = ds.dataSet['Confirmed'].fillna(0)
    ds.dataSet['Deaths'] = ds.dataSet['Deaths'].fillna(0)
    # data_list_confirmed, data_list_deaths, data_list_recovered, date_list, region_of_interest = utl.load_data_2()
    region_of_interest = ds.regions()
    region_options = [{'label': x, 'value': x} for x in region_of_interest]

    return region_options
Exemplo n.º 3
0
def load_options():
    ds = CSBS()

    # data_list_confirmed, data_list_deaths, data_list_recovered, date_list, region_of_interest = utl.load_data_2()
    region_of_interest = ds.regions()
    options = [{'label': x, 'value': x} for x in region_of_interest]
    defaults = region_of_interest[:7]

    return options, defaults
Exemplo n.º 4
0
    def __init__(self):

        search = SearchEngine()

        self.defaultZipcodeInfo = search.by_zipcode('22030')

        self.defaultRadius = 70

        self.ds = CSBS()
        print('.... geoClass Initialized, id(self.ds):{}'.format(id(self.ds)))
Exemplo n.º 5
0
def update_graph(date_window_option, region_of_interest):
    ds = CSBS()
    dt_range = ds.date_range_str(date_window_option)

    confirmed = ds.refresh_category('Confirmed', date_window_option,
                                    region_of_interest)
    deaths = ds.refresh_category('Deaths', date_window_option,
                                 region_of_interest)

    return plot_figure(confirmed, 'Confirmed', dt_range), \
        plot_figure(deaths, 'Deaths', dt_range), \
        plot_inc_number(confirmed, 'Confirmed', dt_range), \
        plot_inc_number(deaths, 'Deaths', dt_range), \
        plot_increase(ds, 'Confirmed', region_of_interest), \
        plot_increase(ds, 'Deaths', region_of_interest), \
        'Time Window:{}'.format(dt_range)
Exemplo n.º 6
0
#         tmp_y = us_cases[i:i+window_size]
#         xs = np.array(tmp_x, dtype=np.float64)
#         ys = np.array(tmp_y, dtype=np.float64)
#         mean_y = np.average(ys)
#         slopes.append(best_fit_slope(xs,ys)/mean_y if mean_y>0 else 0)
#         five_days.append(xs[-1])
#         values.append(ys)
#     # df_5d = pd.DataFrame({'fivedate':five_days,'slope':slopes})

#     country_slopes.append({'Country':country, 'five-date':five_days,'slope':slopes,'value':values})

ax = sns.lineplot(x=country_slopes[0]['five-date'],
                  y=country_slopes[0]['slope'])
plt.show()

ds = CSBS()
df_ds = ds.dataSet['Confirmed']
df_ds['county_state'] = df_ds['County_Name'] + ', ' + df_ds['State_Name']
county_list = df_ds['county_state'].unique().tolist()
county_slopes = get_slopes(df_ds,
                           column_name='county_state',
                           patten='2020-',
                           strp='%Y-%m-%d')
s = 2
ax = sns.lineplot(x=county_slopes[s]['five-date'], y=county_slopes[s]['slope'])

####################################
N = 100000
G = nx.fast_gnp_random_graph(N, 25. / (N - 1))

# they will vary in the rate of leaving exposed class.