Exemplo n.º 1
0
def update_graph(selected_dropdown_value):

    fig = viz_map.plot_hospital_severity_slider(
        df, target_days=np.array(NUM_DAYS_LIST),
        df_county=df_county, counties_json=counties_json, dark=True,
        auto_open=False, plot=False,
        county_filter=selected_dropdown_value
    )

    return fig
                           width=900,
                           height=600,
                           scale=2)
    print('successfully updated png of map of deaths')

    # load in hospital data and merge
    df_hospital = load_data.load_hospital_level(
        data_dir=oj(os.path.dirname(parentdir), 'covid-19-private-data'))

    df = merge_data.merge_county_and_hosp(df_county, df_hospital)
    df = severity_index.add_severity_index(df, NUM_DAYS_LIST)

    # load counties geojson
    # counties_json = json.load(open(oj(parentdir, 'data', 'geojson-counties-fips.json'), "r"))

    # create hospital-level severity index plot
    severity_fig = viz_map.plot_hospital_severity_slider(
        df,
        target_days=np.array(NUM_DAYS_LIST),
        plot_choropleth=False,
        dark=True,
        auto_open=False,
        filename=oj(parentdir, 'results', 'severity_map.html'))
    print('successfully updated map of severity index')

    severity_fig.write_image(oj(parentdir, 'results', 'severity_map.png'),
                             width=900,
                             height=600,
                             scale=2)
    print('successfully updated png of map of severity index')
Exemplo n.º 3
0
    )
    county_lat_lon['fips'] = (county_lat_lon['STATEFP'] + county_lat_lon['COUNTYFP'])#.astype(np.int64)
    # add predictions
    NUM_DAYS_LIST = [1, 2, 3, 4, 5]
    df_county = add_preds(df_county, NUM_DAYS_LIST=NUM_DAYS_LIST, cached_dir=data_dir)
    # join lat / lon to df_county
    # This does not seem necessary as lat and lon is already in the df_county
    #df_county = df_county.join(county_lat_lon.set_index('fips'), on='countyFIPS', how='left').rename(
    #    columns={'LATITUDE': 'lat', 'LONGITUDE': 'lon'}
    #)
    # create county-level predictions plot
    viz_map.plot_counties_slider(df_county, auto_open=False,
                         n_past_days=1,
                         target_days=np.array(NUM_DAYS_LIST),
                         filename=oj(parentdir, 'results', 'deaths.html'))

    # load in hospital data and merge
    df_hospital = load_data.load_hospital_level(data_dir=oj(parentdir, 'data_hospital_level'))
    df = merge_data.merge_county_and_hosp(df_county, df_hospital)
    df = severity_index.add_severity_index(df, NUM_DAYS_LIST)

    # load counties geojson
    counties_json = json.load(open(oj(parentdir, 'data', 'geojson-counties-fips.json'), "r"))

    # create hospital-level severity index plot
    viz_map.plot_hospital_severity_slider(
        df, target_days=np.array(NUM_DAYS_LIST),
        df_county=df_county, counties_json=counties_json, dark=True,
        auto_open=False, filename=oj(parentdir, 'results', 'severity_map.html')
    )
Exemplo n.º 4
0
df_county = add_preds(df_county, NUM_DAYS_LIST=NUM_DAYS_LIST, cached_dir=data_dir)

# load in hospital data and merge
df_hospital = load_data.load_hospital_level(
    data_dir=oj(os.path.dirname(rootdir), 'covid-19-private-data')
)
df = merge_data.merge_county_and_hosp(df_county, df_hospital)
df = severity_index.add_severity_index(df, NUM_DAYS_LIST)

# load counties geojson
counties_json = json.load(open(oj(rootdir, 'data', 'geojson-counties-fips.json'), "r"))

# create hospital-level severity index plot
fig = viz_map.plot_hospital_severity_slider(
    df, target_days=np.array(NUM_DAYS_LIST),
    df_county=df_county, counties_json=counties_json, dark=True,
    auto_open=False, plot=False
)

app = dash.Dash('app', server=server)

app.scripts.config.serve_locally = False
dcc._js_dist[0]['external_url'] = 'https://cdn.plot.ly/plotly-basic-latest.min.js'

# county dropdown
app.layout = html.Div([
    html.H1('County'),
    dcc.Dropdown(
        id='my-dropdown',
        options=[
            {'label': 'Queens', 'value': 'Queens'},