コード例 #1
0
def display_cases_per_million():

    return [
        html.H1(
            get_translation(
                en="""Cases per million""",
                fr="""Cas par million""",
            )),
        dcc.Markdown(
            get_translation(
                en="""
                The number of reported cases per million is a lower bound on the actual number of infected persons per million inhabitants. Countries have had different testing capabilities and approaches.
                """,
                fr="""
            Le nombre de cas signalés par million est une limite inférieure du nombre réel de personnes infectées par million d'habitants. Les pays ont eu différentes capacités et approches pour réaliser les tests de dépistage.
            """,
            )),
        dbc.Row([
            dbc.Col(dcc.Graph(id='cases per country',
                              figure=lines_cases_per_million_not_log(),
                              config=dict(locale=str(get_locale()))),
                    className="col-12"),
        ]),
        display_source_providers(source_hopkins)
    ]
コード例 #2
0
def display_cases_per_million():

    plot1 = lines_cases_per_million()
    # Save html as a StringIO object in memory
    plot1_html = io.StringIO()
    plot1.save(plot1_html, 'html')

    return [
        html.H1(
            get_translation(
                en="""Cases per million""",
                fr="""Cas par million""",
            )),
        dcc.Markdown(
            get_translation(
                en="""
                The number of reported cases per million is a lower bound on the actual number of infected persons per million inhabitants. Countries have had different testing capabilities and approaches.
                """,
                fr="""
            Le nombre de cas signalés par million est une limite inférieure du nombre réel de personnes infectées par million d'habitants. Les pays ont eu différentes capacités et approches pour réaliser les tests de dépistage.
            """,
            )),
        html.Iframe(
            id='plot',
            height='500',
            width='1000',
            sandbox='allow-scripts',

            # This is where we pass the html
            srcDoc=plot1_html.getvalue(),

            # Get rid of the border box
            style={'border-width': '0px'}),
        display_source_providers(source_hopkins)
    ]
コード例 #3
0
ファイル: region.py プロジェクト: ElNiak/covidbe-opendata
def display_region():
    return [
        html.H2(gettext(
            get_translation(en="Positive cases (avg 7 days)",
                            fr="Numbre de cas positifs (moy 7 jours)"))),
        dbc.Row([
            dbc.Col(display_graphic(id='casesrelregion', figure=cases_relative_region(),
                              config=dict(locale=str(get_locale()))), className="col-12"),
        ]),
        html.H2(gettext(
            get_translation(en="Positive Rate % (avg 7 days)",
                            fr="Taux de positivité % (moy 7 jours)"))),
        dbc.Row([
            dbc.Col(display_graphic(id='positive_rate_region', figure=positive_rate_region(),
                                    config=dict(locale=str(get_locale()))), className="col-12"),
        ]),
        html.H2(gettext(
            get_translation(en="Number of tests/ 100K inhabitants (avg 7 days)",
                            fr="Nombre de tests/ 100K habitant (moy 7 jours)"))),
        dbc.Row([
            dbc.Col(display_graphic(id='number_of_test_per_inhabitant_region', figure=number_of_test_per_inhabitant_region(),
                                    config=dict(locale=str(get_locale()))), className="col-12"),
        ]),
        html.H2(gettext(
            get_translation(en="Ratio New Hospi (avg 7 days) / Cases (avg 7 days)",
                            fr="Ratio New Hospi (moy 7 jours) / Cas (moy 7 jours)"))),
        dbc.Row([
            dbc.Col(display_graphic(id='ratio_case_hospi_region',
                                    figure=ratio_case_hospi_region(),
                                    config=dict(locale=str(get_locale()))), className="col-12"),
        ]),
        display_source_providers(source_sciensano, source_map_provinces)
    ]
コード例 #4
0
def display_deaths_per_million():
    plot1 = lines_deaths_per_million()
    # Save html as a StringIO object in memory
    plot1_html = io.StringIO()
    plot1.save(plot1_html, 'html')

    return [
        html.H1(
            get_translation(
                en="""Deaths per million""",
                fr="""Morts par million""",
            )),
        dcc.Markdown(
            get_translation(
                en="""
                The number of reported deaths per million is a lower bound on the actual number of deaths per million inhabitants. Some countries have likely not reported all cases.
                """,
                fr="""
            Le nombre de décès signalés par million est une limite inférieure du nombre réel de décès par million d'habitants. Certains pays n'ont probablement pas signalé tous les cas.
            """,
            )),
        html.Iframe(
            id='plot',
            height='500',
            width='1000',
            sandbox='allow-scripts',

            # This is where we pass the html
            srcDoc=plot1_html.getvalue(),

            # Get rid of the border box
            style={'border-width': '0px'}),
        display_source_providers(source_hopkins)
    ]
コード例 #5
0
def display_age_groups():
    return [
        html.H2(get_translation(fr = "Nombre de case par groupe d'age",en="Number of cases per age group")),
        html.P(gettext(
            get_translation(
                fr="""C'est le nombre de cas testés positifs rapportés par Sciensano. 
                  Le nombre de cas positifs réel peut être (beaucoup) plus important.
                  Notez que le nombre de tests quotidien augmente également. Voir notre page testing.
            """,
                en="""
            This is the number of positive test cases reported by Sciensano. 
            The number of actual positive cases can be (much) higher.
            Note that the number of daily tests is also increasing. See our testing page."""))),
        dbc.Row([
            dbc.Col(dcc.Graph(id='age-group-cases',
                              figure=age_groups_cases(),
                              config=dict(locale=str(get_locale())))),
        ]),
        dbc.Row([
            dbc.Col(dcc.Graph(id='age-group-cases-pie',
                              figure=age_groups_cases_pie(),
                              config=dict(locale=str(get_locale())))),
        ]),
        display_source_providers(source_sciensano)
    ]
def gapminder_case_death_admin_region_overtime():
    fig = px.scatter(df, x="DEATH_PER_1000HABITANT", y='CASES_PER_1000HABITANT',
                     animation_frame="WEEK", animation_group="NIS3",
                     size="POP", color="name", hover_name="name", range_x=[0, 0.35], range_y=[0, 1],height=1000,)
    fig.update_layout(title_text="GapMinder Plot: Weekly CASES vs Deaths / 1000 Inhabitants / Admin Region",
                      xaxis_title=get_translation(en="Cases / 1000 Inhabitants",fr="Cas / 1000 habitants"),
                      yaxis_title=get_translation(en="Death / 1000 Inhabitants",fr="Décès / 1000 habitants"))
    return fig
コード例 #7
0
def death_age_groups(barmode="group"):
    """
    bar plot age group death in belgium
    """

    age_groups = ['0-24', '25-44', '45-64', '65-74', '75-84', '85+']
    bars_age_groups_deaths = []

    for ag in age_groups:
        df_ag = df_week.loc[df_week['age'] == ag]
        bars_age_groups_deaths.append(go.Bar(
            x=df_ag.week,
            y=df_ag['tot'],
            name=ag
        ))

    maxw = df_week.loc[df_week['week'].idxmax()]['week']
    fig_age_groups_deaths = go.Figure(data=bars_age_groups_deaths,
                                      layout=go.Layout(barmode=barmode), )

    # Set x-axis title
    fig_age_groups_deaths.update_xaxes(title_text="Week")

    # Set y-axes titles
    fig_age_groups_deaths.update_yaxes(title_text=get_translation(en="Total Deaths",fr="Nombre de morts"))

    # Add shape regions
    fig_age_groups_deaths.update_layout(
        shapes=[
            # 1st highlight during Feb 4 - Feb 6
            dict(
                type="rect",
                # x-reference is assigned to the x-values
                xref="x",
                # y-reference is assigned to the plot paper [0,1]
                yref="paper",
                x0=10.5,
                y0=0,
                x1=int(maxw) + 0.5,
                y1=100,
                fillcolor="LightBlue",
                opacity=0.5,
                layer="below",
                line_width=0,
            ),
        ]
    )

    fig_age_groups_deaths.update_layout(template="plotly_white", height=500, margin=dict(l=0, r=0, t=30, b=0),
                                        title=get_translation(en="Weekly Total deaths per age group in Belgium 2020",fr="Nombre de morts dans chaque groupe d'age en Belgique 2020 "))
    return fig_age_groups_deaths
コード例 #8
0
    def update_graph(region, interval):
        df = df_all.loc[df_all.end_name == region]
        df = df.loc[df.date_time.str.contains(interval)]

        df1 = pd.DataFrame({'start_name': df.start_name.unique()})
        df2 = pd.DataFrame({'end_name': df.end_name.unique()})
        df3 = pd.DataFrame({'date_time': df.date_time.unique()})

        df1['n_crisis'] = 0
        df2['n_crisis'] = 0
        df3['n_crisis'] = 0

        df_combinations = df1.merge(df2, how='outer').merge(df3, how='outer')

        df = pd.concat([df, df_combinations])
        df = df.groupby(['date_time', 'start_name', 'end_name']).agg({
            'n_crisis':
            'sum'
        }).reset_index()

        df.date_time = pd.to_datetime(df.date_time)
        if df.empty:
            fig = go.Figure()
            fig.add_trace(
                go.Scatter(
                    x=[0],
                    y=[0],
                    mode="lines+markers+text",
                    text=["No Data"],
                    textfont_size=40,
                ))
        else:
            fig = px.area(x=df.date_time, y=df.n_crisis, color=df.start_name)

        fig.update_layout(title=gettext(
            get_translation(fr='Utilisateurs entrant à ',
                            en='Incoming users in ')) + region,
                          xaxis_title="date",
                          yaxis_title=gettext(
                              get_translation(fr="nombre d'utilisateurs",
                                              en="number of users")),
                          legend_title_text=gettext(
                              get_translation(fr="Venant de",
                                              en="Coming from")))

        fig.update_layout(template="plotly_white",
                          margin=dict(l=0, r=0, t=30, b=0))

        return fig
コード例 #9
0
def staying_put():
    fig = px.line(df_movement_range_short,
                  x='date_time',
                  y='all_day_ratio_single_tile_users',
                  color='name')
    fig.update_layout(xaxis_title="date",
                      yaxis_title=gettext(
                          get_translation(
                              fr="proportion d'utilisateurs immobiles",
                              en="fraction of users staying put")))
    top = 0.8
    bottom = 0
    split = 0.74
    add_text(fig, "2020-04-11", top, "Confinement")
    add_text(fig, "2020-06-09", top, "Deconfinement phases")
    add_text(fig, "2020-05-07", split, "1A")
    add_text(fig, "2020-05-14", split, "1B")
    add_text(fig, "2020-05-29", split, "2")
    add_text(fig, "2020-06-20", split, "3")
    add_text(fig, "2020-07-07", split, "4")
    add_rectangle(fig, "2020-03-18", bottom, "2020-05-04", top, "lightsalmon")
    add_rectangle(fig, "2020-05-04", split, df_movement_range.date_time.max(),
                  top, "darkgreen")
    add_rectangle(fig, "2020-05-04", bottom, "2020-05-11", split, "khaki")
    add_rectangle(fig, "2020-05-11", bottom, "2020-05-18", split, "lightgreen")
    add_rectangle(fig, "2020-05-18", bottom, "2020-06-08", split,
                  "mediumseagreen")
    add_rectangle(fig, "2020-06-08", bottom, "2020-07-01", split, "seagreen")
    add_rectangle(fig, "2020-07-01", bottom, df_movement_range.date_time.max(),
                  split, "green")
    return fig
コード例 #10
0
def movement():
    fig = px.line(df_movement_range_short,
                  x='date_time',
                  y='all_day_bing_tiles_visited_relative_change',
                  color='name')
    fig.update_layout(xaxis_title="date",
                      yaxis_title=gettext(
                          get_translation(
                              fr="changement du nombre de tuiles visités",
                              en="change in number of tiles visited")))
    top = 0.5
    bottom = -0.8
    split = 0.4
    add_text(fig, "2020-04-11", top, "Confinement")
    add_text(fig, "2020-06-09", top, "Deconfinement phases")
    add_text(fig, "2020-05-07", split, "1A")
    add_text(fig, "2020-05-14", split, "1B")
    add_text(fig, "2020-05-29", split, "2")
    add_text(fig, "2020-06-20", split, "3")
    add_text(fig, "2020-07-07", split, "4")
    add_rectangle(fig, "2020-03-18", bottom, "2020-05-04", top, "lightsalmon")
    add_rectangle(fig, "2020-05-04", split, df_movement_range.date_time.max(),
                  top, "darkgreen")
    add_rectangle(fig, "2020-05-04", bottom, "2020-05-11", split, "khaki")
    add_rectangle(fig, "2020-05-11", bottom, "2020-05-18", split, "lightgreen")
    add_rectangle(fig, "2020-05-18", bottom, "2020-06-08", split,
                  "mediumseagreen")
    add_rectangle(fig, "2020-06-08", bottom, "2020-07-01", split, "seagreen")
    add_rectangle(fig, "2020-07-01", bottom, df_movement_range.date_time.max(),
                  split, "green")
    return fig
コード例 #11
0
ファイル: facebook.py プロジェクト: ElNiak/covidbe-opendata
def staying_put():
    admin_regions = df_movement_range_short.name.unique()
    plots = []
    for a in admin_regions:
        dfa = df_movement_range_short[df_movement_range_short.name == a]
        plot = go.Scatter(
            x=dfa['date_time'],
            y=dfa['all_day_ratio_single_tile_users'].rolling(7).mean(),
            name=a)
        plots.append(plot)
    fig = go.Figure(data=plots, layout=go.Layout(barmode='group'))

    fig.update_layout(height=600,
                      xaxis_title="date",
                      yaxis_title=gettext(
                          get_translation(
                              fr="proportion d'utilisateurs immobiles",
                              en="fraction of users staying put")))
    top = 0.6
    bottom = 0
    split = 0.6
    add_text(fig, "2020-04-11", top, "Confinement")
    add_rectangle(fig, "2020-03-18", bottom, "2020-05-04", top, "lightsalmon")
    add_rectangle(fig, "2020-10-18", split, df_movement_range.date_time.max(),
                  top, "lightsalmon")
    add_text(fig, "2020-10-18", top, "Confinement")
    add_rectangle(fig, "2020-10-18", bottom, "2020-10-31", split, "yellow")
    add_rectangle(fig, "2020-11-01", bottom, df_movement_range.date_time.max(),
                  split, "lightsalmon")
    fig.update_layout(template="plotly_white")
    #fig.update_layout(hovermode='x unified')
    return fig
コード例 #12
0
ファイル: facebook.py プロジェクト: ElNiak/covidbe-opendata
def movement():
    admin_regions = df_movement_range_short.name.unique()
    plots = []
    for a in admin_regions:
        dfa = df_movement_range_short[df_movement_range_short.name == a]
        plot = go.Scatter(
            x=dfa['date_time'],
            y=dfa['all_day_bing_tiles_visited_relative_change'].rolling(
                7).mean(),
            name=a)
        plots.append(plot)
    fig = go.Figure(data=plots, layout=go.Layout(barmode='group'))

    fig.update_layout(height=600,
                      xaxis_title="date",
                      yaxis_title=gettext(
                          get_translation(
                              fr="changement du nombre de tuiles visités",
                              en="change in number of tiles visited")))
    top = 0.2
    bottom = -0.6
    split = 0.2
    add_text(fig, "2020-04-11", top, "Confinement")
    add_rectangle(fig, "2020-03-18", bottom, "2020-05-04", top, "lightsalmon")
    add_rectangle(fig, "2020-10-18", split, df_movement_range.date_time.max(),
                  top, "lightsalmon")
    add_text(fig, "2020-10-18", top, "Confinement")
    add_rectangle(fig, "2020-10-18", bottom, "2020-10-31", split, "yellow")
    add_rectangle(fig, "2020-11-01", bottom, df_movement_range.date_time.max(),
                  split, "lightsalmon")

    fig.update_layout(template="plotly_white")
    #fig.update_layout(hovermode='x unified')

    return fig
コード例 #13
0
ファイル: obituary.py プロジェクト: ElNiak/covidbe-opendata
def display_obituary():
    return [
        html.H2(
            gettext(
                "Evolution of the number of deaths published on obituary websites"
            )),
        dcc.Markdown(
            get_translation(
                fr="""
            Les données rapportées sont téléchargées des sites mortuaires belges (necro.sudpress.be, dansnospensees.be). 
            Au total, nous capturons environ 1/3 des décès en Belgique. 
            Nous pensons que cela est suffisamment représentatif de la situation de surmortalité due au COVID19. 
            La Flandre et Bruxelles semblent sous représentés dans les sites belges et reflète dès lors davantage la situation en Wallonie.
            """,
                en="""
            The reported data are crawled from the Belgian (necro.sudpress.be, dansnospensees.be) mortuary sites daily.
            In total, we capture around 1/3 of the daily deaths in Belgium with these data.
            We believe that this is sufficiently representative of the excess mortality situation due to COVID19.
            Flanders and Brussels seem underrepresented in Belgian sites and therefore more closely reflect the situation in Wallonia.
            """,
            )),
        dbc.Row([
            dbc.Col(
                display_graphic(id='sud_presse',
                                figure=sud_presse(),
                                config=dict(locale=str(get_locale())))),
        ]),
        dbc.Row([
            dbc.Col(
                display_graphic(id='dans_nos_pensees',
                                figure=dans_nos_pensees(),
                                config=dict(locale=str(get_locale())))),
        ]),
        display_source_providers(source_inmemoriam, source_necro_sudpress)
    ]
コード例 #14
0
def map_totcases_admin_region_():
    fig = px.choropleth_mapbox(df3,
                               geojson=geojson,
                               locations="NIS3",
                               color='CASES',
                               color_continuous_scale="magma_r",
                               featureidkey="properties.NIS3",
                               center={
                                   "lat": 50.641111,
                                   "lon": 4.668889
                               },
                               hover_name="CASES",
                               hover_data=["CASES", "name"],
                               height=600,
                               mapbox_style="carto-positron",
                               zoom=6)
    fig.update_geos(fitbounds="locations")
    fig.layout.coloraxis.colorbar.title = get_translation(fr="Nombres de cas",
                                                          en="Number of cases")
    fig.layout.coloraxis.colorbar.titleside = "right"
    fig.layout.coloraxis.colorbar.ticks = "outside"
    fig.layout.coloraxis.colorbar.tickmode = "array"
    fig.update_traces(hovertemplate=gettext(
        gettext("<b>%{customdata[0]}<br><b>%{customdata[1]}")))
    fig.update_layout(template="plotly_white", margin=dict(l=0, r=0, t=5, b=0))
    return fig
コード例 #15
0
def map_communes_per_inhabitant():
    fig = px.choropleth_mapbox(
        df_communes_tot,
        geojson=geojson_communes,
        locations="NIS5",
        color='CASES_PER_100_POP',
        color_continuous_scale="magma_r",
        #range_color=(3, 10),
        featureidkey="properties.NIS5",
        center={
            "lat": 50.641111,
            "lon": 4.668889
        },
        hover_name="name",
        hover_data=["name", "CASES_PER_100_POP", "NIS5"],
        height=500,
        mapbox_style="carto-positron",
        zoom=6)
    fig.update_geos(fitbounds="locations")
    fig.layout.coloraxis.colorbar.title = get_translation(
        fr="Pourcentage de cas dans la population depuis mars",
        en="Pourcentage de cas dans la population depuis mars")
    fig.layout.coloraxis.colorbar.titleside = "right"
    fig.layout.coloraxis.colorbar.ticks = "outside"
    fig.layout.coloraxis.colorbar.tickmode = "array"
    fig.update_layout(template="plotly_white", margin=dict(l=0, r=0, t=5, b=0))

    return fig
コード例 #16
0
def map_cases_incidence_provinces():
    div = 250
    fig = px.choropleth_mapbox(
        df3d,
        geojson=geojson_provinces,
        locations="PROV",
        color='CASES_PER_100KHABITANT',
        range_color=(0, 300),
        color_continuous_scale="magma_r",
        #color_continuous_scale=[(0, "green"), (15/150, "green"), (15/150, "yellow"),
        #                        (30/150, "yellow"), (30/150, "orange"), (50/150, "orange"),
        #                        (50/150, "red"), (100/150, "red"),(100/150, "black"),(150/150, "black")],
        featureidkey="properties.proviso",
        center={
            "lat": 50.641111,
            "lon": 4.668889
        },
        hover_name="CASES_PER_100KHABITANT",
        hover_data=["CASES_PER_100KHABITANT", "POP", "PROVINCE"],
        height=600,
        mapbox_style="carto-positron",
        zoom=6)
    fig.update_geos(fitbounds="locations")
    fig.layout.coloraxis.colorbar.title = get_translation(
        fr="Nombres de cas/100K past [d-17,d-4] days",
        en="Number of cases/100K past [d-17,d-4] days")
    fig.layout.coloraxis.colorbar.titleside = "right"
    fig.layout.coloraxis.colorbar.ticks = "outside"
    fig.layout.coloraxis.colorbar.tickmode = "array"
    fig.update_traces(hovertemplate=gettext(
        gettext(
            "incidence:<b>%{customdata[0]}<br>pop:<b>%{customdata[1]}<br><b>%{customdata[2]}"
        )))
    fig.update_layout(template="plotly_white", margin=dict(l=0, r=0, t=5, b=0))
    return fig
コード例 #17
0
def display_provinces():
    return [
        html.H2(gettext("Number of cases / 1000 inhabitants")),
        html.P(
            gettext(
                get_translation(
                    fr=
                    """C'est le nombre de cas testés positifs rapportés par Sciensano. 
              Le nombre de cas positifs réel peut être (beaucoup) plus important.
              Notez que le nombre de tests quotidien augmente également. Voir notre page testing.
        """,
                    en="""
        This is the number of positive test cases reported by Sciensano. 
        The number of actual positive cases can be (much) higher.
        Note that the number of daily tests is also increasing. See our testing page.
        """))),
        dbc.Row([
            dbc.Col(dcc.Graph(id='cases-province-map',
                              figure=map_provinces(),
                              config=dict(locale=str(get_locale()))),
                    className="col-12"),
            dbc.Col(dcc.Graph(id='cases-province-barplot',
                              figure=barplot_provinces_cases(),
                              config=dict(locale=str(get_locale()))),
                    className="col-12"),
        ]),
        display_source_providers(source_sciensano, source_map_provinces)
    ]
コード例 #18
0
def map_hospi(column, title):
    fig = px.choropleth_mapbox(dfl,
                               geojson=geojson_provinces,
                               locations="PROV",
                               color=column,
                               color_continuous_scale="magma_r",
                               featureidkey="properties.proviso",
                               center={
                                   "lat": 50.641111,
                                   "lon": 4.668889
                               },
                               hover_name=column,
                               hover_data=[column, "POP", "PROVINCE"],
                               height=600,
                               mapbox_style="carto-positron",
                               zoom=6)
    fig.update_geos(fitbounds="locations")
    fig.layout.coloraxis.colorbar.title = get_translation(fr=title, en=title)
    fig.layout.coloraxis.colorbar.titleside = "right"
    fig.layout.coloraxis.colorbar.ticks = "outside"
    fig.layout.coloraxis.colorbar.tickmode = "array"
    fig.update_traces(hovertemplate=gettext(
        gettext(
            title +
            ":<b>%{customdata[0]}<br>pop:<b>%{customdata[1]}<br><b>%{customdata[2]}"
        )))
    fig.update_layout(template="plotly_white", margin=dict(l=0, r=0, t=5, b=0))
    return fig
コード例 #19
0
def map_cases_per_habittant_admin_region_overtime():
    fig = px.choropleth_mapbox(
        df3,
        geojson=geojson,
        locations="NIS3",
        color='CASES_PER_1000HABITANT',
        color_continuous_scale="magma_r",
        # range_color=(0.85, 1),
        animation_frame="WEEK",
        animation_group="NIS3",
        featureidkey="properties.NIS3",
        center={
            "lat": 50.641111,
            "lon": 4.668889
        },
        hover_name="CASES",
        hover_data=["CASES", 'CASES_PER_1000HABITANT', "name"],
        height=600,
        mapbox_style="carto-positron",
        zoom=6)
    fig.update_geos(fitbounds="locations")
    fig.layout.coloraxis.colorbar.title = get_translation(
        fr="Nombres de cas / 1000 habitants",
        en="Number of cases / 1000 inhabitants")
    fig.layout.coloraxis.colorbar.titleside = "right"
    fig.layout.coloraxis.colorbar.ticks = "outside"
    fig.layout.coloraxis.colorbar.tickmode = "array"
    fig.update_traces(hovertemplate=gettext(
        gettext(
            "<b>%{customdata[2]}%</b><br>%{customdata[1]}<br>%{customdata[2]}")
    ))
    fig.update_layout(template="plotly_white", margin=dict(l=0, r=0, t=5, b=0))
    return fig
コード例 #20
0
def death_arrondissements_map_yearly():
    fig = px.choropleth_mapbox(
        df3,
        geojson=geojson,
        locations="NIS3",
        color='DEATH_PER_1000HABITANT',
        color_continuous_scale="magma_r",
        range_color=(9, 14),
        animation_frame="YEAR",
        animation_group="NIS3",
        featureidkey="properties.NIS3",
        center={
            "lat": 50.641111,
            "lon": 4.668889
        },
        hover_name='DEATH_PER_1000HABITANT',
        hover_data=["DEATH_PER_1000HABITANT", "TOT", "name"],
        height=600,
        mapbox_style="carto-positron",
        zoom=6)
    fig.update_geos(fitbounds="locations")
    fig.layout.coloraxis.colorbar.title = get_translation(
        en="Number of deaths / 1000 inhabitants",
        fr="Nombre de morts / 1000 habitants")
    fig.layout.coloraxis.colorbar.titleside = "right"
    fig.layout.coloraxis.colorbar.ticks = "outside"
    fig.layout.coloraxis.colorbar.tickmode = "array"
    fig.update_traces(hovertemplate=gettext(
        "<b>%{customdata[0]} /1000</b><br><b>%{customdata[1]}</b><br><b>%{customdata[2]}</b>"
    ))
    fig.update_layout(template="plotly_white", margin=dict(l=0, r=0, t=5, b=0))
    return fig
コード例 #21
0
ファイル: tomtom.py プロジェクト: johnaoga/covidbe-opendata
def display_tomtom():
    return [
        html.H2(gettext("TomTom Traffic")),
        dcc.Markdown(get_translation(
            en="""
    The TomTom traffic index is the additional time needed as compared to a 30-minutes trip in uncongested conditions.
    A 53% congestion level in Brussels, for example, means that a 30-minute trip will take 53% more time than it would during Brussels’s baseline uncongested conditions.
    It thus means that you will need 45.9 minutes total average travel time instead of 30 minutes (in uncongested conditions).

    We record this data daily to measure the release of the lockdown constraints.
        """,
            fr="""
    L'indice de trafic TomTom est le temps supplémentaire nécessaire par rapport à un trajet de 30 minutes dans des conditions non encombrées.
    Un niveau de congestion de 53% à Bruxelles, par exemple, signifie qu’un voyage de 30 minutes prendra 53% de temps de plus qu’un trajet sans encombrement à Bruxelles.
    Cela signifie donc que vous aurez besoin d'un temps de trajet moyen total de 45,9 minutes au lieu de 30 minutes (dans des conditions non encombrées).

    Nous enregistrons ces données quotidiennement depuis le 14 avril pour mesurer le déconfinement.
            """, )),
        html.H2(gettext("TomTom Traffic Index Belgium Cities 07:00-9:00")),
        dbc.Row([
            dbc.Col(dcc.Graph(id='google map usage',
                              figure=plot_tomtom_be_working_days(),
                              config=dict(locale=str(get_locale())))),
        ]),
        display_source_providers(source_tomtom),
    ]
コード例 #22
0
ファイル: traffic.py プロジェクト: ElNiak/covidbe-opendata
def display_traffic():
    return [
        html.H2(gettext("Google Map Usage working days 8:00-8:30")),
        dcc.Markdown(
            get_translation(
                fr="""
Google enregistre le ratio entre le taux de demande (trafic) dans cette région et le taux de demande au niveau mondial pour chacune des applications.
Nous pensons que l'application google map est intéressante à observer, car elle reflète l'impact du confinement.
Afin de comparer les pays, nous normalisons la courbe d'un pays par rapport à la moyenne des 10 premiers jours de mars.
Une valeur de 1 signifie que la proportion du trafic de ce pays et la même que les 10 premiers jours de mars.
Une valeur inférieure à 1 signifie que le pays a perdu des parts de trafic par rapport aux 10 premiers jours de mars.
La mobilité dans ce pays semble comparativement plus réduite que la normale relativement aux autres pays.
Une valeur supérieure à 1 signifie que le pays a gagné du trafic par rapport aux 10 premiers jours de mars.
La mobilité dans ce pays semble comparativement supérieure à la normale relativement aux autres pays.
    """,
                en="""
Google records the ratio between the demand rate (traffic) in this region and the global demand rate for each of the applications.
We think the google map app is interesting to study because it reflects the impact of the lockdown.
In order to compare the countries, we normalize the curve of a country compared to the average of the first 10 days of March.
A value of 1 means that the proportion of traffic from this country is the same as the first 10 days of March.
A value less than 1 means that the country has lost traffic shares compared to the first 10 days of March.
Mobility in this country seems comparatively lower than normal compared to other countries.
A value greater than 1 means that the country has gained traffic compared to the first 10 days of March.
Mobility in this country seems comparatively higher than normal compared to other countries.
        """,
            )),
        dbc.Row([
            dbc.Col(
                display_graphic(id='google map usage',
                                figure=plot_google_traffic_working_days(),
                                config=dict(locale=str(get_locale())))),
        ]),
        display_source_providers(source_google_traffic),
    ]
コード例 #23
0
def facebook_imported_cases():


    df_fb = pd.read_csv('static/csv/facebook/movement_countries.csv')
    countries = sorted(df_fb.end_name.unique())
    df_fb.rename(columns={'ds': 'date'}, inplace=True)

    df_owid = pd.read_csv('static/csv/owid.csv')
    df_owid['location'] = df_owid['location'].str.lower()

    countries = sorted(df_owid.location.unique())

    df_owid = df_owid[['date', 'location', 'new_cases_smoothed_per_million', 'continent', 'population']]

    df = pd.merge(df_fb, df_owid, how='left', left_on=['date', 'start_name'], right_on=['date', 'location']).drop(
        columns=['location', 'population'])
    df.rename(columns={'new_cases_smoothed_per_million': 'start_new_cases_smoothed_per_million'}, inplace=True)

    df = pd.merge(df, df_owid, how='left', left_on=['date', 'end_name', 'continent'],
                  right_on=['date', 'location', 'continent']).drop(columns=['location'])
    df.rename(columns={'new_cases_smoothed_per_million': 'end_new_cases_smoothed_per_million',
                       'population': 'end_population'}, inplace=True)

    df = df[df.continent == 'Europe']

    df['covid_in'] = 7 * df['start_new_cases_smoothed_per_million'] * df['travel_counts'] / 1000000

    df = df.groupby(['date', 'end_name', 'end_population'])['covid_in'].sum().reset_index()

    df['covid_in_per_million'] = 1000000 * df['covid_in'] / df['end_population']

    df = df[df['end_name'].isin(['austria', 'belgium', 'croatia', 'czech republic', 'denmark'
                                                                                    'estonia', 'finland', 'france',
                                 'germany', 'greece', 'iceland', 'ireland',
                                 'italy', 'lithuania', 'luxembourg', 'netherlands', 'norway'
                                                                                    'romania', 'serbia', 'spain',
                                 'sweden', 'switzerland',
                                 'united kingdom', 'portugal', 'slovenia', 'hungary', 'poland',
                                 'bosnia and herzegovina', 'slovakia', 'bulgaria',
                                 'albania'])]

    countries = df.end_name.unique()

    plots = []
    for c in countries:
        dfc = df[df.end_name == c]
        plot = go.Scatter(x=dfc['date'], y=dfc['covid_in_per_million'].rolling(7).mean(), name=c)
        plots.append(plot)
    fig = go.Figure(data=plots, layout=go.Layout(barmode='group'))

    fig.update_layout(template="plotly_white", margin=dict(l=0, r=0, t=30, b=0))

    fig.update_layout(
        height=600,
        xaxis_title="date",
        yaxis_title=gettext(
            get_translation(fr="imported cases per million inhabitants", en="imported cases per million inhabitants"))
    )
    return fig
コード例 #24
0
ファイル: who.py プロジェクト: ElNiak/covidbe-opendata
def display_who():
    return [
        html.H2(gettext("New Hospitalization WHO Indicator")),
        dcc.Markdown(get_translation(
            fr="""
            Cette page utilise des sommes et moyennes *centrées* sur 14 jour. La somme au jour J est donc calculée à partir des jours J-7 jusque J+6.
            
            Taux d’hospitalisation = Nombre de nouvelles hospitalisations dues à la COVID-19 pour 100 000 habitants et par semaine (moyenne sur deux semaines).""",
            en="""
            This page uses centered sums and means, with a 14-days window. The sum at day D is thus computed from the days D-7 until D+6.
            
            Hospitalization rate = Number of new hospitalizations due to COVID-19 per 100,000 inhabitants per week (average over two weeks).""")),
        dbc.Row([
            dbc.Col(display_graphic(id='newinoms',
                              figure=newin_oms(),
                              config=dict(locale=str(get_locale())))),
        ]),
        html.H2(gettext("Positive Rate WHO Indicator")),
        dcc.Markdown(get_translation(
            fr="""Taux de positivité = Proportion de tests positifs (moyenne sur deux semaines)""",
            en="""Positivity rate = Proportion of positive tests (average over two weeks)""")),
        dbc.Row([
            dbc.Col(display_graphic(id='posrate_oms',
                              figure=posrate_oms(),
                              config=dict(locale=str(get_locale())))),
        ]),
        html.H2(gettext("Cases Incidence WHO Indicator")),
        dcc.Markdown(get_translation(
            fr="""Incidence des cas = Nombre de cas confirmés pour 100 000 habitants et par semaine (moyenne sur deux semaines). """,
            en="""Incidence = number of confirmed cases per 100 000 inhabitants per week (averaged over two weeks). """)),
        dbc.Row([
            dbc.Col(display_graphic(id='cases_oms',
                                figure=cases_oms(),
                              config=dict(locale=str(get_locale())))),
        ]),
        html.H2(gettext("COVID Death WHO Indicator")),
        dcc.Markdown(get_translation(
            fr="""Mortalité = Nombre de décès attribués à la COVID-19 pour 100 000 habitants et par semaine (moyenne sur deux semaines)""",
            en="""Mortality = Number of deaths attributed to COVID-19 per 100,000 population per week (two-week average) """)),
        dbc.Row([
            dbc.Col(display_graphic(id='death_oms',
                                    figure=death_oms(),
                                    config=dict(locale=str(get_locale())))),
        ]),
        display_source_providers(source_sciensano),
    ]
コード例 #25
0
ファイル: brussels.py プロジェクト: ElNiak/covidbe-opendata
def display_brussels():
    return [
        html.H3(gettext("Tunnel traffic")),
        html.P(gettext(
            get_translation(
                fr="""Nombre de véhicules passant chaque heure dans les tunnels principaux de Bruxelles.""",
                en="""Number of vehicles passing every hour through the main tunnels of Brussels."""))),
        html.H3(gettext("Brussels tunnels traffic working days 7:00-8:00")),
        dbc.Row([
            dbc.Col(display_graphic(id='brussels-tunnel',
                              figure=brussels_tunnels(),
                              config=dict(locale=str(get_locale())))),
        ]),
        html.H3(gettext("Brussels all tunnels relative traffic working days 7:00-8:00")),
        html.P(gettext(
            get_translation(
                fr="""Divisé par le nombre moyen de véhicules enregistré sur la période 1er Féb - 10 Mars""",
                en="""Divided by the average number of vehicles recorded over the period Feb 1 - March 10"""))),
        dbc.Row([
            dbc.Col(display_graphic(id='brussels-tunnel-ratio',
                              figure=brussels_alltunnels_ratio(),
                              config=dict(locale=str(get_locale())))),
        ]),

        display_source_providers(source_brussels_mobility),
        html.H2(gettext("Apple Mobility Report")),
        dbc.Row([
            dbc.Col(display_graphic(id='eucities-apple',
                              figure=apple_mobility_plot_cities(),
                              config=dict(locale=str(get_locale())))),
        ]),
        display_source_providers(source_apple_mobility),
        html.H2(gettext("Brussels Mobility: bike relative passage count through stations")),
        html.P(gettext(
            get_translation(
                fr="""Relatif signifie divisé par le nombre moyen de passages quotidien avant confinement afin de rendre les sites de comptages comparables""",
                en="""Relative means divided by the average number of daily passages before confinement in order to make the counting sites comparable"""))),
        dbc.Row([
            dbc.Col(display_graphic(id='brussels-bikes-ratio',
                              figure=bike_mobility_plot_stations(),
                              config=dict(locale=str(get_locale())))),
        ]),
        display_source_providers(source_brussels_mobility),

    ]
コード例 #26
0
def display_admin():
    return [
        html.H2(gettext(
            get_translation(en="Number of cases per admin region", fr="Nombre de cas par arrondissement"))),
        html.P(gettext(
            get_translation(
                fr="""C'est le nombre de cas testés positifs rapportés par Sciensano. 
                      Le nombre de cas positifs réel peut être (beaucoup) plus important.
                      Notez que le nombre de tests quotidien augmente également. Voir notre page testing.
                """,
                en="""
                This is the number of positive test cases reported by Sciensano. 
                The number of actual positive cases can be (much) higher.
                Note that the number of daily tests is also increasing. See our testing page."""))),

        html.H3(gettext(
            get_translation(en="Incidence: Number of cases/100K inhabitants over the past 14 days (click to see the evolution)", fr="Incidence: Nombre de cas/100K habitants sur les 14 derniers jours (cliquez pour voir l'évolution)"))),
        html.H4(get_translation(
            en="""click on a region to see the cases barplot""",
            fr="""cliquez sur un arrondissement pour observer l'historique des cas""",
        )),
        dbc.Row([
            dbc.Col(display_graphic(id='map_cases_incidence_nis3', figure=map_cases_incidence_nis3(),
                              config=dict(locale=str(get_locale()))), className="col-12"),
        ]),
        dbc.Row([
            dbc.Col(display_graphic(id='map_cases_incidence_nis3_percentage', figure=map_increase_incidence_admin_region_percentage(),
                                    config=dict(locale=str(get_locale()))), className="col-12"),
        ]),
        dbc.Row([
            dbc.Col(display_graphic(id='barplot_admin', style={"display": "none"}, figure=barplot_admin(),
                                    config=dict(locale=str(get_locale()))))
        ]),
        dbc.Row([
            dbc.Col(display_graphic(id='cases-province-scatter-incidence', figure=scatter_incidence_nis3(),
                              config=dict(locale=str(get_locale()))), className="col-12"),
        ]),
        html.H3(gettext(
            get_translation(en="Plot over time  (double click in the legend to isolate one region)", fr="Evolution dans le temps (double click dans la legende pour isoler une region)"))),
        dbc.Row([
            dbc.Col(display_graphic(id='cases-admin-daily-bar-chart', figure=plot_cases_daily_admin_region_overtime(),
                              config=dict(locale=str(get_locale()))), className="col-12"),
        ]),
        dbc.Row([
            dbc.Col(display_graphic(id='cases-province-daily-bar-chart-perhabittant', figure=plot_cases_per_habittant_admin_region_overtime(),
                              config=dict(locale=str(get_locale()))), className="col-12"),
        ]),
        html.H3(gettext(get_translation(en="Total Number of cases since beginning", fr="Nombre de cas total depuis le début"))),
        dbc.Row([
            dbc.Col(display_graphic(id='tot-cases-province-map', figure=map_totcases_admin_region(),
                              config=dict(locale=str(get_locale()))), className="col-12"),
        ]),
        html.H3(gettext(get_translation(en="Total Number of cases per 1000 inhabitants since the beginning",
                                        fr="Nombre de cas total pour 1000 habitants depuis le début "))),
        dbc.Row([
            dbc.Col(display_graphic(id='perhabittant-cases-province-map', figure=map_cases_per_habittant_admin_region(),
                              config=dict(locale=str(get_locale()))), className="col-12"),
        ]),
        display_source_providers(source_sciensano, source_map_provinces)
    ]
コード例 #27
0
 def update_plots(country, state, metrics, n):
     refreshData()
     data = filtered_data(country, state)
     barchart_new = barchart(data,
                             metrics,
                             prefix="New",
                             yaxisTitle=get_translation(
                                 en="New Cases per Day",
                                 fr="Nouveaux Cas par Jour",
                             ))
     barchart_cum = barchart(data,
                             metrics,
                             prefix="Cum",
                             yaxisTitle=get_translation(
                                 en="Cumulated Cases",
                                 fr="Cas Cumulés",
                             ))
     return barchart_new, barchart_cum
コード例 #28
0
def map_cases_incidence_nis3():
    geojson = geopandas.read_file('static/json/admin-units/be-geojson.geojson')
    df_names = pd.DataFrame(geojson.drop(columns='geometry'))
    cutoff1 = (pd.to_datetime('today') - pd.Timedelta('17 days')).date()
    cutoff2 = (pd.to_datetime('today') - pd.Timedelta('4 days')).date()

    df3d = pd.read_csv("static/csv/cases_daily_ins3.csv", encoding='latin1')
    df3d = df3d[df3d.DATE >= str(cutoff1)]
    df3d = df3d[df3d.DATE <= str(cutoff2)]
    df3d = df3d.groupby([df3d.NIS3, df3d.POP]).agg({
        'CASES': ['sum']
    }).reset_index()
    df3d.columns = df3d.columns.get_level_values(0)
    df3d['NIS3'] = df3d['NIS3'].astype(int)
    df3d['CASES_PER_100KHABITANT'] = df3d['CASES'] / df3d['POP'] * 100000
    df3d = pd.merge(df3d,
                    df_names,
                    left_on='NIS3',
                    right_on='NIS3',
                    how='left')
    df3d = df3d.round({'CASES_PER_100KHABITANT': 1})

    fig = px.choropleth_mapbox(
        df3d,
        geojson=geojson,
        locations="NIS3",
        color='CASES_PER_100KHABITANT',
        range_color=(0, 500),
        color_continuous_scale="magma_r",
        #color_continuous_scale=[(0, "green"), (15/150, "green"), (15/150, "yellow"),
        #                        (30/150, "yellow"), (30/150, "orange"), (50/150, "orange"),
        #                        (50/150, "red"), (100/150, "red"),(100/150, "black"),(150/150, "black")],
        featureidkey="properties.NIS3",
        center={
            "lat": 50.641111,
            "lon": 4.668889
        },
        hover_name="CASES_PER_100KHABITANT",
        hover_data=["CASES_PER_100KHABITANT", "POP", "NIS3", "name"],
        custom_data=["CASES_PER_100KHABITANT", "POP", "NIS3", "name"],
        height=600,
        mapbox_style="carto-positron",
        zoom=6)
    fig.update_geos(fitbounds="locations")
    fig.layout.coloraxis.colorbar.title = get_translation(
        fr="Nombres de cas/100K past [d-17,d-4] days",
        en="Number of cases/100K past [d-17,d-4] days")
    fig.layout.coloraxis.colorbar.titleside = "right"
    fig.layout.coloraxis.colorbar.ticks = "outside"
    fig.layout.coloraxis.colorbar.tickmode = "array"
    fig.update_traces(hovertemplate=gettext(
        gettext(
            "incidence:<b>%{customdata[0]}<br>pop:<b>%{customdata[1]}<br><b>%{customdata[3]}"
        )))
    fig.update_layout(template="plotly_white", margin=dict(l=0, r=0, t=5, b=0))
    return fig
コード例 #29
0
def population_evolution():
    fig = px.line(df_population,
                  x='date_time',
                  y='percent_change',
                  color='name')
    fig.update_layout(xaxis_title="date",
                      yaxis_title=gettext(
                          get_translation(
                              fr="changement du nombre d'utilisateurs",
                              en="change in number of users")))
    return fig
コード例 #30
0
ファイル: vaccines.py プロジェクト: ElNiak/covidbe-opendata
def display_vaccines():
    return [
        html.H2(gettext("Vaccines")),
        dcc.Markdown(get_translation(
            fr="""Vaccins COVID Belgiques""",
            en="""Covid Vaccines Belgium""")),
        dbc.Row([
            dbc.Col(display_graphic(id='vaccines',
                              figure=plot_vaccines_cumulated(),
                              config=dict(locale=str(get_locale())))),
        ]),
        display_source_providers(source_sciensano),
    ]