Ejemplo n.º 1
0
def Site_Week_Summary(site_name, species):
    df = LoadData.get_recent_site_data(site_name, species, days_ago=7)

    plot = [
        go.Scatter(x=df.index,
                   y=df.Concentration.values,
                   mode='lines',
                   name=species)
    ]

    plot_title = '%s at %s between %s and %s' % (
        species, site_name, df.index[0].date(), df.index[-1].date())
    #  Find the unit for the species

    unit = LoadData.Get_Unit('AURN', species)
    ytitle = '%s (%s)' % (species, unit)
    layout = go.Layout(
        title=plot_title,
        xaxis=dict(title='Date'),
        yaxis=dict(title=ytitle),
        images=[
            dict(source="assets/UoE_Geosciences_2_colour.jpg",
                 xref="paper",
                 yref="paper",
                 x=.6,
                 y=0.95,
                 sizex=0.25,
                 sizey=0.25,
                 xanchor="right",
                 yanchor="bottom"),
            dict(source="assets/ukri-nerc-logo-600x160.png",
                 xref="paper",
                 yref="paper",
                 x=0.83,
                 y=0.95,
                 sizex=0.2,
                 sizey=0.2,
                 xanchor="right",
                 yanchor="bottom"),
            dict(source="assets/DEFRA-logo.png",
                 xref="paper",
                 yref="paper",
                 x=1,
                 y=0.95,
                 sizex=0.13,
                 sizey=0.13,
                 xanchor="right",
                 yanchor="bottom"),
        ],
    )

    plot = dcc.Graph(id='map_site_timeseries',
                     figure={
                         'data': plot,
                         'layout': layout
                     })

    return plot
Ejemplo n.º 2
0
def main_site_map(environment, region, species):
    mapbox_access_token = 'pk.eyJ1IjoiZG91Z2ZpbmNoIiwiYSI6ImNqZHhjYnpqeDBteDAyd3FsZXM4ZGdqdTAifQ.xLS22vmqzVYR0SAEDWdLpQ'
    # site_df = LoadData.get_all_site_info(environment, region)

    # random_sizes = np.random.randint(20, size = len(site_df))
    # For the time being lets just set variable and time
    date = datetime(2017, 12, 14, 12)
    variable = species

    vals_df = LoadData.all_sites_one_var_data(date, variable, region,
                                              environment)
    unit = LoadData.Get_Unit('AURN', species)

    size_scale = 1
    variable_vals = vals_df.value * size_scale

    hover_text = [
        '%s: %.3f %s' % (vals_df.index.tolist()[x], variable_vals[x], unit)
        for x in range(len(variable_vals))
    ]

    data = [
        go.Scattermapbox(
            lat=vals_df.latitude.tolist(),
            lon=vals_df.longitude.tolist(),
            mode='markers',
            # customdata = final_df.index.tolist(),
            marker=go.scattermapbox.Marker(
                color=variable_vals.tolist(),
                colorscale='Viridis',
                showscale=True,
                size=14,
                colorbar=dict(title=species + ' ' + unit, titleside='right'),
                # opacity = 0.85,
                # color = chosen_hour,
                # cmax = last_day.max(axis = 1).max(),
                # colorbar = {'title':var_choice}
            ),
            text=hover_text,
        )
    ]

    layout = go.Layout(
        showlegend=False,
        autosize=True,
        # showlegend = True,
        height=750,
        hovermode='closest',
        margin={
            'l': 0.2,
            'r': 0.2,
            't': 0.2,
            'b': 0.2
        },
        mapbox=dict(accesstoken=mapbox_access_token,
                    bearing=0,
                    center=dict(lat=55, lon=-3.2),
                    pitch=0,
                    zoom=4.5),
    )

    fig = dict(data=data, layout=layout)

    return len(vals_df), fig