示例#1
0
def run_tool(event):
    try:
        if DOCKER_CONTAINER == "True":
            if not os.path.exists(os.path.join('/data', 'outp')):
                os.makedirs(os.path.join('/data', 'outp'))

            data_regrid_fn, data_coarse = start_tool(inp_var.value, inp_data_type.value,
                                                     os.path.join('/data', div_src_data.value.rsplit('\\',1)[-1]),
                                                     os.path.join('/data', div_dst_topo.value.rsplit('\\',1)[-1]),
                                                     os.path.join('/data', div_src_topo.value.rsplit('\\',1)[-1]),
                                                     os.path.join('/data', 'outp'),
                                                     json.loads(inp_lat.value)[0], json.loads(inp_lat.value)[1],
                                                     json.loads(inp_lon.value)[0], json.loads(inp_lon.value)[1],
                                                     int(inp_start_year.value), int(inp_end_year.value),
                                                     regrid_method = inp_reg_method.value)
        else:
            data_regrid_fn, data_coarse = start_tool(inp_var.value, inp_data_type.value,
                div_src_data.text,
                div_dst_topo.text, div_src_topo.text,
                div_dir_dest.text,
                json.loads(inp_lat.value)[0], json.loads(inp_lat.value)[1],
                json.loads(inp_lon.value)[0], json.loads(inp_lon.value)[1],
                int(inp_start_year.value), int(inp_end_year.value),
                regrid_method = inp_reg_method.value)

        data_regrid = xr.open_dataset(data_regrid_fn)

        # Plot
        renderer = gv.renderer('bokeh')
        dataset_coarse = gv.Dataset(data_coarse[inp_var.value].groupby('time.season').mean('time'),
                                    kdims=['season', 'lon', 'lat'],
                                    crs=crs.PlateCarree())
        dataset_regrid = gv.Dataset(data_regrid[inp_var.value].groupby('time.season').mean('time'),
                                    kdims=['season', 'lon', 'lat'],
                                    crs=crs.PlateCarree())

        gv_plot = renderer.get_plot(
            (dataset_coarse.to(gv.Image, ['lon','lat']).options(width=350, colorbar=True, alpha=0.6, title="Coarse data") * gv.WMTS(tiles['Wikipedia'])) + \
            (dataset_regrid.to(gv.Image, ['lon','lat']).options(width=350, colorbar=True, alpha=0.6, title="Downscaled data") * gv.WMTS(tiles['Wikipedia']))
        )

        inp_sel_season = bmo.widgets.Select(title="Season:",
                                value="DJF",
                                options=["DJF","JJA","MAM","SON"])
        inp_sel_season.on_change('value', lambda attrname, old, new: gv_plot.update((new,)))
        l.children[-1] = bo.layouts.layout(bo.layouts.row([inp_sel_season]),
                                            bo.layouts.row([gv_plot.state]))

        div_spinner.text = done_text
    except Exception as e:
        div_spinner.text = error_text
        print("------------- ERROR -------------")
        print(e.args)
示例#2
0
def shapeplot(dframe,
              var,
              coords,
              raxis,
              cm='Jet_r',
              extralayers=[],
              lcolor='black'):
    lcoords = len(coords)
    xly = len(extralayers)
    if lcoords == 2 and xly > 0:
        gvdata = gv.Dataset(dframe,
                            kdims=[coords[0], coords[1], raxis],
                            vdims=var)
        back = gvdata.to(gv.Image, [coords[0], coords[1]], var)
        back = back.opts(colorbar=True,
                         backend='bokeh',
                         cmap=cm,
                         width=600,
                         height=400)
        for layer in extralayers:
            ss = gv.Shape.from_shapefile(layer).opts(line_color=lcolor)
            back *= ss
        return gv.output(back.opts(width=600, height=400), backend='bokeh')
    else:
        print("Incomplete coordinates")
示例#3
0
 def to_geoimage(data,
                 dynamic=True,
                 style_opts={'cmap': 'RdBu_r'},
                 plot_opts={
                     'width': 600,
                     'toolbar': 'above',
                     'colorbar': True
                 },
                 hover=False):
     gvd = gv.Dataset(data)
     if len(gvd.dimensions()) < 4:
         gvimg = gvd.to(gv.Image,
                        kdims=['lon',
                               'lat'])(plot=plot_opts)(style=style_opts)
     else:
         gvimg = gvd.to(gv.Image, kdims=['lon', 'lat'],
                        dynamic=dynamic)(plot=plot_opts)(style=style_opts)
     if hover:
         projected = gv.operation.project_image(gvimg)
         gvimg = hv.QuadMesh(
             projected, kdims=gvimg.kdims,
             vdims=gvimg.vdims)(plot=plot_opts)(style=style_opts)
         gvimg = gvimg(plot={'tools': ['hover']})
         #gvimg*=gvd.to(gv.Points,kdims=['lon','lat'])(style={'alpha':0,'marker':'square','size':6})(plot={'tools':['hover']})
     return gvimg  #*gv.feature.coastline
示例#4
0
def index(document):
    # Load some data
    path = "~/cache/highway_ga6_20190315T0000Z.nc"
    air_temperature = xarray.open_dataset(path).air_temperature
    dataset = gv.Dataset(air_temperature[0])
    contours = dataset.to(gv.LineContours, ['longitude_0', 'latitude_0'])

    # Create map
    feature = (gf.land * gf.ocean * gf.lakes * gf.rivers * gf.coastline *
               gf.borders * contours).opts(global_extent=True,
                                           xaxis=None,
                                           yaxis=None,
                                           border=0,
                                           active_tools=["pan", "wheel_zoom"])
    figure = renderer.get_plot(feature).state
    figure.sizing_mode = "stretch_both"
    figure.aspect_ratio = 1
    figure.axis.visible = False
    figure.toolbar.logo = None
    figure.toolbar_location = None
    figure.title.text = ""

    contours.data = air_temperature[-1]

    document.add_root(
        bokeh.layouts.row(figure, name="map", sizing_mode="stretch_both"))
    document.template = template.INDEX
示例#5
0
    def variable_update(event):
        global path, fram_data, curr_var, min_range, max_range, control_path, control_data, global_data, global_path, gv_geo_plot, curr_dataset, curr_intervention, DATA_DICT
        path = './iceClinic/data/f09_g16.B.cobalt.FRAM.MAY.{}.200005-208106.nc'.format(event.item)
        control_path = './iceClinic/data/f09_g16.B.cobalt.CONTROL.MAY.{}.200005-208106.nc'.format(event.item)
        global_path = './iceClinic/data/f09_g16.B.cobalt.GLOBAL.MAY.{}.200005-208106.nc'.format(event.item)
        curr_var = event.item
        fram_data = xr.open_dataset(path)
        control_data = xr.open_dataset(control_path)
        global_data = xr.open_dataset(global_path)
        DATA_DICT = {'CONTROL': control_data, 'FRAM' : fram_data, 'GLOBAL' : global_data}
        curr_dataset = DATA_DICT[curr_intervention]
       
        dataset = gv.Dataset(curr_dataset)
        stateBasemap = gv.Feature(feature.STATES)
        gv_geo_plot = dataset.to(gv.Image, ['lon', 'lat'], curr_var, dynamic=True).opts(title = '{} Intervention, {} data'.format(curr_intervention, curr_var), cmap=CMAP_DICT[curr_var], colorbar=True, backend='bokeh', projection = crs.PlateCarree()) *gf.coastline() * gf.borders() * stateBasemap.opts(fill_alpha=0,line_width=0.5)

        #control_min_range, control_max_range = getMinMax(control_data, curr_var)
        #print(control_min_range, control_max_range)
        fram_min_range, fram_max_range = getMinMax(fram_data, curr_var)
        global_min_range, global_max_range = getMinMax(global_data, curr_var)
        min_range = min(fram_min_range, global_min_range)
        max_range = max(fram_max_range,global_max_range)
        
        gv_geo_plot = gv_geo_plot.redim(**{curr_var:hv.Dimension(curr_var, range=(min_range, max_range))})
        var_stream.event(var=event.item)
示例#6
0
 def plotMap(self,
             dArray,
             name,
             width=500,
             height=250,
             cmap="gist_earth_r",
             dataShader=True,
             alpha=0.5):
     """
     plot the DataArray onto the map.
     
     Args:
         dArray (xarray.DataArray): DataArray of your output.
         name (str): name of your data
         width (int): width of the output image
         height (int): height of the output image
         cmap (str): colormap
         alpha (float): alpha value
     
     Returns:
         bokeh image object
     """
     dataset = gv.Dataset(dArray)
     img = dataset.to(gv.Image, ["lon", "lat"], name)
     if dataShader:
         img = datashader.regrid(img)
     img_out = img.opts(width=width,
                        height=height,
                        alpha=alpha,
                        colorbar=True,
                        cmap=cmap,
                        tools=["hover"]) * self.mapTiles
     return img_out
def plot_polling_place_vote(df,
                            backend,
                            year,
                            electorate=None,
                            color_range=None):
    """Setup for plotting the vote at each polling place."""

    assert backend in ['bokeh', 'matplotlib']

    if electorate:
        plot_df = df[df['DivisionNm'] == electorate]
    else:
        plot_df = df

    votes = gv.Dataset(plot_df, kdims=['GreensPercentage', 'TotalVotes'])
    points = votes.to(
        gv.Points, ['Longitude', 'Latitude'],
        ['PollingPlaceNm', 'GreensVotes', 'TotalVotes', 'GreensPercentage'])

    title = 'Greens senate primary vote, %s Federal Election' % (str(year))
    if electorate:
        title = title + ' (' + electorate + ')'

    if backend == 'bokeh':
        points = points.opts(color='GreensPercentage',
                             cmap='Greens',
                             size=10,
                             tools=['hover'],
                             width=600,
                             height=600,
                             padding=0.1,
                             colorbar=True,
                             line_color='black',
                             title=title,
                             clabel='%',
                             xaxis=None,
                             yaxis=None)
        #size=dim('TotalVotes')*0.015,
        background = gv.tile_sources.Wikipedia

    else:
        points = points.opts(color='GreensPercentage',
                             cmap='Greens',
                             s=30,
                             padding=0.1,
                             colorbar=True,
                             title=title,
                             clabel='%',
                             xaxis=None,
                             yaxis=None)
        #background = gvts.CartoEco
        #background = background.opts(zoom=7, projection=ccrs.PlateCarree())

        background = gv.tile_sources.Wikipedia
        #background = background.opts(zoom=10)

    if color_range:
        points = points.redim.range(GreensPercentage=color_range)

    return points * background
示例#8
0
def geoview_flat_plot(region_da, time_sel=0, level_sel=False, wide_chile=True):
    
    if type(level_sel) is int:
        da = region_da.isel(level=level_sel)
    else:
        da = region_da
    
    gv_ds = gv.Dataset(da.isel(time=time_sel))
    plot = gv_ds.to(gv.Image,  ['lon', 'lat'], 't', 'time').opts(cmap='viridis', 
                                                                colorbar=True)
    extras = []
    if wide_chile:
        easter_island_text = gv.Text(-104.360481, -24.104671, 'Easter Island').opts(color='white')
        easter_island_point = gv.Points([(-109.360481, -27.104671)]).opts(color='red')

        easter = easter_island_point * easter_island_text

        falkland_islands_text = gv.Text(-49.563412, -56.820557, 'Falklands').opts(color='white')
        falkland_islands_point = gv.Points([(-51.563412, -59.820557)]).opts(color='red')

        falkland = falkland_islands_point * falkland_islands_text
        
        extras.append(easter * falkland)
    
    plot = contours(plot, filled=True, overlaid=True)
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        
        final_plot = plot * gf.coastline
        for extra in extras:
            final_plot *= extra
        gv.output(final_plot)
 def to_geoimage(data,
                 dynamic=True,
                 style_opts={'cmap': 'RdBu_r'},
                 plot_opts={
                     'width': 600,
                     'xaxis': None,
                     'yaxis': None,
                     'toolbar': 'above',
                     'colorbar': True
                 },
                 hover=False):
     gvd = gv.Dataset(data)
     if len(gvd.dimensions()) < 4:
         gvimg = gvd.to(gv.Image, kdims=['lon', 'lat'])(plot=plot_opts)(
             style=style_opts) * gv.feature.coastline
     else:
         gvimg = gvd.to(gv.Image, kdims=['lon', 'lat'], dynamic=dynamic)(
             plot=plot_opts)(style=style_opts) * gv.feature.coastline
     if hover:
         gvimg *= gvd.to(gv.Points, kdims=['lon', 'lat'])(style={
             'alpha': 0,
             'marker': 'square',
             'size': 6
         })(plot={
             'tools': ['hover']
         })
     return gvimg
示例#10
0
 def intervention_update(event):
     global curr_var, DATA_DICT, control_data, curr_intervention, gv_geo_plot, min_range, max_range
     curr_intervention = event.item
     curr_ds = DATA_DICT[event.item]
     dataset = gv.Dataset(curr_ds)
     gv_geo_plot = dataset.to(gv.Image, ['lon', 'lat'], curr_var, dynamic=True).opts(title = '{} Intervention, {} data'.format(curr_intervention, curr_var), cmap=CMAP_DICT[curr_var], colorbar=True, backend='bokeh', projection = crs.PlateCarree()) *gf.coastline() * gf.borders() * stateBasemap.opts(fill_alpha=0,line_width=0.5)        
     gv_geo_plot = gv_geo_plot.redim(**{curr_var:hv.Dimension(curr_var, range=(min_range, max_range))})
     intervention_stream.event(intervention=event.item)
示例#11
0
 def make_view(self):
     dfc = stations[stations['contractName'] == self.city_name]
     gv_df = gv.Dataset(
         dfc[['longitude', 'latitude', 'name', 'bikes_available_total']])
     points = gv_df.to(gv.Points, ['longitude', 'latitude'],
                       ['name', 'bikes_available_total'])
     return (tiles * points).opts(
         opts.Points(tools=['hover'],
                     size=dim('bikes_available_total'),
                     color='bikes_available_total',
                     cmap='viridis'))
示例#12
0
 def view_map(self):
     sample_map = arr_temp.where(
         (arr_temp.omega == self.omega) & (arr_temp.C_11 == self.c11) &
         (arr_temp.delta_phi == self.delta_phi),
         drop=True)
     dataset = gv.Dataset(sample_map,
                          ['longitude', 'latitude', 'omega', 'C_11'],
                          'surface_temperature')
     images = dataset.to(gv.Image, ['longitude', 'latitude'],
                         'surface_temperature')
     images.opts(cmap='viridis', colorbar=True, width=400, height=250)
     return images
示例#13
0
def update_map(attr, old, new):
    global selection, vizual, gvplot, hvplot, heatmap, feats, points, world_map, range_slider, controls3, max_cur_feature, min_cur_feature, temp_feats
    max_cur_feature = temp_feats[choice.value].max()
    min_cur_feature = temp_feats[choice.value].min()
    range_slider = RangeSlider(start=min_cur_feature,
                               end=max_cur_feature,
                               value=(min_cur_feature, max_cur_feature),
                               step=(max_cur_feature - min_cur_feature) / 20,
                               title="Feature_range")
    range_slider.on_change('value', update_map_val)
    controls3 = widgetbox([range_slider], width=250)
    new_loc_feats = temp_feats.loc[
        (temp_feats[choice.value] < range_slider.value[1])
        & (temp_feats[choice.value] > range_slider.value[0])]
    feats = gv.Dataset(new_loc_feats, kdims=['Longitude', 'Latitude', new])
    points = feats.to(gv.Points, ['Longitude', 'Latitude'], [new])
    if len(new_loc_feats) <= 20000:
        world_map = gv.Overlay(tiles * points).options(
            'Points',
            size=5,
            cmap='viridis',
            colorbar=True,
            tools=TOOLS,
            color_index=2,
            width=900,
            height=800,
            global_extent=True,
            colorbar_opts={'scale_alpha': 0.5},
            fill_alpha=0.5,
            line_alpha=0.5)
    else:
        world_map = decimate(gv.Points(points), max_samples=20000).options(
            'Points',
            size=5,
            cmap='viridis',
            colorbar=True,
            tools=TOOLS,
            color_index=2,
            width=900,
            height=800,
            global_extent=True,
            colorbar_opts={'scale_alpha': 0.5},
            fill_alpha=0.5,
            line_alpha=0.5)
    selection = hv.streams.Selection1D(source=world_map)
    heatmap = hv.DynamicMap(selected_points, streams=[selection])
    zoom = hv.DynamicMap(test_bounds, streams=[box])
    hvplot = renderer.get_plot(heatmap, curdoc())
    gvplot = renderer.get_plot(world_map, curdoc())
    bvplot = renderer.get_plot(zoom, curdoc())
    vizual.children[1].children = [gvplot.state, hvplot.state, bvplot.state]
示例#14
0
    def __init__(self, **kwargs):
        super(LayoutDashBoard, self).__init__()
        ds = xr.open_dataset(os.path.join(dataDir, kwargs['filename']))
        long=np.linspace(-180, 180, 900, dtype='float32') 
        
        ds['longitude'] = long
        ds_out = ds.sel(latitude=slice(-22, -27), longitude=slice(-46, -41))

        dataset = gv.Dataset(ds_out, ['longitude', 'latitude', 'time'],'u10',crs=crs.PlateCarree())
        images = dataset.to(gv.Image) 
        
        im = images.opts(cmap='viridis', alpha=0.4, colorbar=True, width=600, height=500)

        self.app = im * gvts.EsriImagery
示例#15
0
def graph(cube):
    title = cube.standard_name.title().replace('_', ' ')

    dataset = gv.Dataset(cube)
    plot = dataset.to(hv.Curve, label=title, group='')

    renderer = hv.Store.renderers['matplotlib']
    renderer.size = 200
    img_data = io.BytesIO()
    renderer.save(plot, img_data)
    img_data.seek(0)

    s3_url = upload_image(img_data)
    return s3_url
示例#16
0
def plot_polling_place_swing(df,
                             backend,
                             year,
                             electorate=None,
                             color_range=None):
    """Setup for plotting the swing at each polling place.
    
    This will remove all polling places that don't exist 
    in both the current and previous election.
    
    """

    assert backend in ['bokeh']

    if electorate:
        plot_df = df[df['DivisionNm'] == electorate].dropna()
    else:
        plot_df = df.dropna()

    votes = gv.Dataset(plot_df, kdims=['Swing', 'GreensVotes'])
    points = votes.to(gv.Points, ['Longitude', 'Latitude'],
                      ['PollingPlaceNm', 'TotalVotes', 'GreensVotes', 'Swing'])

    title = 'Greens senate swing, %s Federal Election' % (str(year))
    if electorate:
        title = title + ' (' + electorate + ')'

    if backend == 'bokeh':
        points = points.opts(color='Swing',
                             cmap='RdBu_r',
                             size=10,
                             tools=['hover'],
                             width=600,
                             height=600,
                             padding=0.1,
                             colorbar=True,
                             line_color='black',
                             title=title,
                             clabel='%',
                             xaxis=None,
                             yaxis=None)
        # size=dim('GreensVotes')*0.1

    if color_range:
        points = points.redim.range(Swing=color_range)

    background = gv.tile_sources.Wikipedia

    return points * background
示例#17
0
def fastplot(dframe, var, coords, raxis, cm='Jet'):
    lcoords = len(coords)
    if lcoords == 2:
        gvdata = gv.Dataset(dframe,
                            kdims=[coords[0], coords[1], raxis],
                            vdims=var)
        back = gvdata.to(gv.Image, [coords[0], coords[1]], var)
        return gv.output(back.opts(colorbar=True,
                                   backend='bokeh',
                                   cmap=cm,
                                   width=600,
                                   height=400),
                         backend='bokeh')
    else:
        print("Incomplete coordinates")
示例#18
0
def make_spatio_temporal_vel_point_obj(date):
    opts = dict(color='w', marker='v', size=3, line_color="r", tools=["hover"])
    idx = spatio_temporal_vel_data_tab_df["starttime"] == date
    emax_avg_df = spatio_temporal_vel_data_tab_df[idx]
    ds = gv.Dataset((emax_avg_df["longitude"], emax_avg_df["latitude"],
                     emax_avg_df["e_max"], emax_avg_df["station"]),
                    ["Longitude", "Latitude"],
                    ["Velocity Changes (%)", "Station"],
                    crs=crs.PlateCarree())
    vdims = [("e_max", "Velocity Changes (%)"), "Station"]
    spatio_temporal_vel_point_obj = ds.to(gv.Points, ["Longitude", "Latitude"],
                                          crs=ccrs.PlateCarree())
    spatio_temporal_vel_point_obj = spatio_temporal_vel_point_obj.opts(**opts)
    print("make_spatio_temporal_vel_point_obj {}".format(date))
    return (spatio_temporal_vel_point_obj)
示例#19
0
def quick_map(da, dims=["lon", "lat"], redim_range=None, **user_options):
    options = dict(
        cmap="viridis",
        colorbar=True,
        fig_size=300,
        projection=crs.Robinson(central_longitude=180),
    )
    options.update(user_options)
    name = da.name
    dataset = gv.Dataset(da)
    image = dataset.to(gv.Image, dims, dynamic=True).options(**options)
    if redim_range is not None:
        image = image.redim.range(**{name: redim_range})

    return gv.output(image * gf.coastline(), backend="matplotlib")
def _make_heatmap(final_grid, density, fname, target):
    logger.info('Drawing the heatmap')

    lat = np.linspace(-90, 90, num=180 * density + 1)
    lon = np.linspace(-179.75, 180, num=360 * density)

    d = {
        'coords': {
            'latitude': {
                'dims': ('latitude', ),
                'data': lat
            },
            'longitude': {
                'dims': ('longitude', ),
                'data': lon
            }
        },
        'attrs': {
            'title': '%s latency heatmap' % target
        },
        'dims': ['latitude', 'longitude'],
        'data_vars': {
            'latency': {
                'dims': ('latitude', 'longitude'),
                'data': final_grid
            }
        }
    }

    xr_set = xr.Dataset.from_dict(d)
    xr_dataset = gv.Dataset(xr_set,
                            kdims=['latitude', 'longitude'],
                            vdims=['latency'],
                            crs=crs.PlateCarree())

    hv.output(dpi=200, size=500)
    hv.opts("Image [colorbar=True clipping_colors={'min': 'lightgrey'}]")

    main_layer = xr_dataset.redim(latency=dict(range=(30, 90))).to(
        gv.Image, ['longitude', 'latitude'])

    img = gf.land * main_layer * gf.ocean * gf.borders

    if fname.endswith('.png'):
        fname = fname[:-4]

    renderer = hv.renderer('matplotlib').instance(fig='png')
    renderer.save(img, fname, style=dict(Image={'cmap': 'RdYlGn_r'}))
示例#21
0
def view_time_series(filename, cmap='jet'):
    """
    Visualize and interact with time series netcdf files.
    """

    # Open geoviews interactive session.
    gv.extension('bokeh', 'matplotlib')
    with xr.open_dataset(filename, decode_times=False) as da:
        dataset = gv.Dataset(da)
        ensemble = dataset.to(gv.Image, ['x', 'y'])
        gv.output(ensemble.opts(cmap=cmap,
                                colorbar=True,
                                fig_size=200,
                                backend='matplotlib'),
                  backend='matplotlib')
    return
示例#22
0
def plot_map(data, label, agg_data, agg_name, cmap):
    url = "http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/{Z}/{Y}/{X}.png"
    geomap = gv.WMTS(url)
    points = hv.Points(gv.Dataset(data, kdims=['x', 'y'], vdims=[agg_name]))
    agg = datashade(points,
                    element_type=gv.Image,
                    aggregator=agg_data,
                    cmap=cmap)
    zip_codes = dynspread(agg, threshold=T, max_px=PX)
    hover = hv.util.Dynamic(rasterize(points,
                                      aggregator=agg_data,
                                      width=50,
                                      height=25,
                                      streams=[RangeXY]),
                            operation=hv.QuadMesh)
    hover = hover.options(cmap=cmap)
    img = geomap * zip_codes * hover
    img = img.relabel(label)
    return img
示例#23
0
def update_map_val(attr, old, new):
    global selection, vizual, gvplot, hvplot, heatmap, feats, points, world_map, temp_feats
    max_cur_feature = loc_feats[choice.value].max()
    min_cur_feature = loc_feats[choice.value].min()
    new_loc_feats = temp_feats.loc[(temp_feats[choice.value] <= new[1])
                                   & (temp_feats[choice.value] >= new[0])]
    feats = gv.Dataset(new_loc_feats,
                       kdims=['Longitude', 'Latitude', choice.value])
    points = feats.to(gv.Points, ['Longitude', 'Latitude'], [choice.value])
    if len(new_loc_feats) <= 20000:
        world_map = gv.Points(points).options(
            'Points',
            size=5,
            cmap='viridis',
            colorbar=True,
            tools=TOOLS,
            color_index=2,
            width=900,
            height=800,
            colorbar_opts={'scale_alpha': 0.5},
            fill_alpha=0.5,
            line_alpha=0.5)
    else:
        world_map = decimate(gv.Points(points), max_samples=20000).options(
            'Points',
            size=5,
            cmap='viridis',
            colorbar=True,
            tools=TOOLS,
            color_index=2,
            width=900,
            height=800,
            colorbar_opts={'scale_alpha': 0.5},
            fill_alpha=0.5,
            line_alpha=0.5)
    selection = hv.streams.Selection1D(source=world_map)
    heatmap = hv.DynamicMap(selected_points, streams=[selection])
    box = hv.streams.BoundsXY(source=world_map)
    zoom = hv.DynamicMap(test_bounds, streams=[box])
    hvplot = renderer.get_plot(heatmap, curdoc())
    gvplot = renderer.get_plot(world_map, curdoc())
    bvplot = renderer.get_plot(zoom, curdoc())
    vizual.children[1].children = [gvplot.state, hvplot.state, bvplot.state]
def interactive_plot(cube,
                     cmap='viridis',
                     kdims=['longitude', 'latitude'],
                     coastlines=False,
                     coastline_color='white',
                     projection=ccrs.PlateCarree,
                     tools=['hover'],
                     min_height=600,
                     **opts):
    # Generate an interactive Bokeh image of a cube with various plotting options

    # Convert cube to GeoViews dataset
    dataset = gv.Dataset(cube, [coord.name() for coord in cube.dim_coords],
                         label=cube.name())

    # Generate an image object which will dynamically render as the interactive view changes
    image = regrid(dataset.to(gv.Image, kdims, dynamic=True))

    # Options for plotting
    options = {
        'cmap': cmap,
        'responsive': True,
        'projection': projection(),
        'colorbar': True,
        'min_height': min_height,
        'aspect': 2,
        'tools': tools
    }

    # Include coastlines if needed
    if coastlines:
        return gv.feature.ocean * gv.feature.land * image.opts(
            **options, **
            opts) * gv.feature.coastline.opts(line_color=coastline_color)
    else:
        return image.opts(**options, **opts)
def interactive_map(v1, options):
    # print(options)
    import cartopy.crs as ccrs
    import holoviews as hv
    from holoviews import opts, dim
    import geoviews as gv
    import geoviews.feature as gf
    import simplekml

    hv.extension("bokeh", "matplotlib")

    vname = v1.columns.tolist()[0]

    stretch = [0, 100]

    tres = np.median(np.diff(v1.index.tolist()))
    tres = 1 * int(tres.total_seconds() / 60)
    # vf1 = dataset.ts_aggregate_timebins(v1.to_frame(), time_bin=tres, operations={'': np.nanmean}, index_position='middle')

    #  come up with leg coloring
    leg_series = dataset.add_legs_index(v1)["leg"]

    vcol = dataset.ts_aggregate_timebins(
        v1,
        time_bin=tres,
        operations={"": options["resampling_operation"]},
        index_position="initial",
    )

    vcol.columns = ["color"]
    min_ = np.percentile(vcol.dropna(), stretch[0])
    max_ = np.percentile(vcol.dropna(), stretch[1])
    # print(min_,max_)
    vcol[vcol < min_] = min_
    vcol[vcol > max_] = max_

    coordinates_raw = dataset.read_standard_dataframe(
        options["gps_file"])[["latitude", "longitude"]]

    # mode_ = lambda x : stats.mode(x)[0]
    #  Deal with coordinates
    coordinates = dataset.ts_aggregate_timebins(
        coordinates_raw,
        time_bin=int(np.floor(options["map_temporal_aggregation"] * 60)),
        operations={"": np.nanmedian},
        index_position="initial",
    )

    #  Resample and merge coordinates + data
    to_plot = pd.merge(coordinates, v1, left_index=True, right_index=True)
    to_plot = pd.merge(
        to_plot,
        pd.DataFrame(data=to_plot.index.tolist(),
                     columns=["date"],
                     index=to_plot.index),
        left_index=True,
        right_index=True,
    )
    to_plot = to_plot.dropna()

    if options["kml_file"]:
        kml_ = simplekml.Kml()
        fol = kml_.newfolder(name="LV_KML")

        colz = (to_plot.loc[:, vname] - to_plot.loc[:, vname].min()) / (
            to_plot.loc[:, vname].max() - to_plot.loc[:, vname].min())
        colz = np.floor(255 * plt.cm.Spectral_r(colz.values)).astype(int)
        c = 0
        for lat, lon, val, date in to_plot.values:
            #     print(lat, lon, val, date)
            #     print(row[1].loc['LV#11'])
            pnt = fol.newpoint(name=str(date), coords=[(lon, lat)])
            pnt.style.iconstyle.icon.href = (
                "http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png")
            pnt.style.iconstyle.scale = 1  # Icon thrice as big
            pnt.style.iconstyle.color = simplekml.Color.rgb(
                colz[c, 0], colz[c, 1], colz[c, 2], 255)
            pnt.style.labelstyle.scale = 0.5
            c += 1

        kml_.save(options["kml_file"])

    #  colorbar limits
    min_v1 = min_  # np.percentile(to_plot.loc[:,vname].dropna(), stretch[0])
    max_v1 = max_  # np.percentile(to_plot.loc[:,vname].dropna(), stretch[1])

    #  Create geoviews datasets
    v1_tomap = hv.Dataset(
        to_plot.loc[:, ["longitude", "latitude", "date", vname]],
        kdims=["longitude", "latitude"],
        vdims=[hv.Dimension(vname, range=(min_v1, max_v1))],
        group=vname,
    )

    points_v1 = v1_tomap.to(gv.Points, kdims=["longitude", "latitude"])

    gps_track = gv.Dataset(coordinates_raw)
    track = gv.Path(gps_track, kdims=["longitude", "latitude"])
    # land_ = gf.land#.options(facecolor='red')

    point_map_v1 = points_v1.opts(
        projection=ccrs.SouthPolarStereo(),
        cmap=options["colormap"],
        size=5,
        tools=["hover"],  #  ['hover'],
        width=500,
        height=400,
        color_index=2,
        colorbar=True,
    )

    track_map = track.opts(projection=ccrs.SouthPolarStereo()).opts(
        color="black")

    return (gf.land * gf.coastline * track_map * point_map_v1).opts(
        title=vname, width=options["figsize"][0], height=options["figsize"][1])
示例#26
0
def test_bounds(bounds):
    global selection, vizual, gvplot, hvplot, heatmap, feats, points, world_map, range_slider, controls3, max_cur_feature, min_cur_feature, temp_feats
    if bounds != None:
        min_long = min(bounds[0], bounds[2])
        max_long = max(bounds[0], bounds[2])
        min_lat = min(bounds[1], bounds[3])
        max_lat = max(bounds[1], bounds[3])
        downscale_feats = loc_feats.loc[(loc_feats['Longitude'] >= min_long)
                                        & (loc_feats['Longitude'] <= max_long)
                                        & (loc_feats['Latitude'] >= min_lat) &
                                        (loc_feats['Latitude'] <= max_lat)]
        temp_feats = downscale_feats
        max_cur_feature = temp_feats[choice.value].max()
        min_cur_feature = temp_feats[choice.value].min()
        range_slider = RangeSlider(start=min_cur_feature,
                                   end=max_cur_feature,
                                   value=(min_cur_feature, max_cur_feature),
                                   step=(max_cur_feature - min_cur_feature) /
                                   20,
                                   title="Feature_range")
        range_slider.on_change('value', update_map_val)
        controls3 = widgetbox([range_slider], width=250)
        new_loc_feats = temp_feats.loc[
            (temp_feats[choice.value] <= range_slider.value[1])
            & (temp_feats[choice.value] >= range_slider.value[0])]
        feats = gv.Dataset(new_loc_feats,
                           kdims=['Longitude', 'Latitude', choice.value])
        points = feats.to(gv.Points, ['Longitude', 'Latitude'], [choice.value])
        if len(new_loc_feats <= 20000):
            world_map = gv.Points(points).options(
                'Points',
                size=5,
                cmap='viridis',
                colorbar=True,
                tools=TOOLS,
                color_index=2,
                width=900,
                height=800,
                colorbar_opts={'scale_alpha': 0.5},
                fill_alpha=0.5,
                line_alpha=0.5)
        else:
            world_map = decimate(gv.Points(points), max_samples=20000).options(
                'Points',
                size=5,
                cmap='viridis',
                colorbar=True,
                tools=TOOLS,
                color_index=2,
                width=900,
                height=800,
                colorbar_opts={'scale_alpha': 0.5},
                fill_alpha=0.5,
                line_alpha=0.5)
        selection = hv.streams.Selection1D(source=world_map)
        heatmap = hv.DynamicMap(selected_points, streams=[selection])
        box = hv.streams.BoundsXY(source=world_map)
        zoom = hv.DynamicMap(test_bounds, streams=[box])
        hvplot = renderer.get_plot(heatmap, curdoc())
        gvplot = renderer.get_plot(world_map, curdoc())
        bvplot = renderer.get_plot(zoom, curdoc())
        vizual.children[1].children = [
            gvplot.state, hvplot.state, bvplot.state
        ]
        vizual.children[0].children[2] = controls3
    else:
        bounds = (0, 0, 0, 0)
    return hv.Bounds(bounds).options(show_grid=False,
                                     height=0,
                                     width=0,
                                     xaxis=None,
                                     yaxis=None,
                                     default_tools=[],
                                     show_frame=False,
                                     toolbar=None)
示例#27
0
    plot = fram_plot * control_plot * global_plot
    labels = {'TS':'Temperature (C)',
              'PRECT' : "Precipitation (mm/day)",
              "SPI" : "Standardized Precipitation Index",
              "FWI" : "Fosberg Fire Weather Index"}
    return plot.opts(width=500, framewise=True, 
                     title='{} timeseries data'.format(curr_var), ylabel=labels[var])

stream = hv.streams.Stream.define('time_step', time_step=cftime.DatetimeNoLeap(2000, 6, 1))()
var_stream = hv.streams.Stream.define('Var', var="TS")()
lat_stream = hv.streams.Stream.define('Lat', lat=45)()
lon_stream = hv.streams.Stream.define('Lon', lon=122)()
intervention_stream = hv.streams.Stream.define('intervention', intervention="FRAM")()

dmap = hv.DynamicMap(geo_plot, streams=[stream, var_stream, intervention_stream]).opts(width=600)
dataset = gv.Dataset(curr_dataset)
stateBasemap = gv.Feature(feature.STATES)
gv_geo_plot = dataset.to(gv.Image, ['lon', 'lat'], 'TS', dynamic=True).opts(
    title = '{} Intervention, {} data'.format(curr_intervention, curr_var),
    cmap='coolwarm', colorbar=True, backend='bokeh', projection = crs.PlateCarree()) * gf.coastline() * gf.borders() * stateBasemap.opts(fill_alpha=0,line_width=0.5)
gv_geo_plot = gv_geo_plot.redim(TS=hv.Dimension(curr_var, range=(min_range, max_range)))

dmap_time_series = hv.DynamicMap(timeseries, streams=[var_stream, lat_stream, lon_stream]).opts(width=500, framewise=True)
#Main function that processes incoming events and defines the current layout
def modify_doc(doc):
    # Bokeh renderers that hold current viz as its state
    hvplot = renderer.get_plot(dmap, doc)
    timeseriesPlot = renderer.get_plot(dmap_time_series, doc)

    def animate_update():
        year = slider.value + 1
示例#28
0
def plot_grids(data,fields,plot_type):
    if len(data) == 2: 
        ds,grid_ds = data
        
        if fields == 'Sources':
            print('Plotting Sources..')
            event_times_seconds = xr.DataArray(ds.event_time.values.astype('<m8[s]')/86400,dims='number_of_events')
            event_times_seconds.shape,ds.event_time.shape
            dss = ds.copy()
            dss['times'] = event_times_seconds.astype(int)

            xr_dataset = gv.Dataset(hv.Points((dss.event_longitude.values, dss.event_latitude.values,dss.times.values), 
                kdims=[hv.Dimension('x'),hv.Dimension('y')],vdims=['time']))

            fig = gv.tile_sources.Wikipedia.opts(width=900, height=900) * xr_dataset.to.points(['x','y']).opts(opts.Points(color='time'))

        else:
            print(plot_type)
            z = grid_ds.flash_extent_density
            x = grid_ds.grid_longitude.values
            y = grid_ds.grid_latitude.values

            # get xarray dataset, suited for handling raster data in pyviz
            xr_dataset = gv.Dataset(hv.Image((x, y, np.log10(z.mean(axis=0))), bounds=(x.min(),y.min(),x.max(),y.max()), 
                    kdims=[hv.Dimension('x'),  hv.Dimension('y')], datatype=['grid']))

            # create contours from image
            gv.FilledContours(xr_dataset)
            fig = gv.tile_sources.Wikipedia.opts(width=900, height=900) * xr_dataset.to.image(['x', 'y']).opts(cmap='cubehelix', alpha=0.8)#gv.FilledContours(xr_dataset).opts(cmap='viridis', alpha=0.5)


        responsive = pn.pane.HoloViews(fig, config={'responsive': True})
        return(responsive)
    
    else:
        grid_ds = data
        print('No Data Processed')
        if fields == 'Sources':
            xr_dataset = gv.Dataset(hv.Points((np.repeat(-101.1,1), np.repeat(32,2),np.repeat(10,2)), 
                kdims=[hv.Dimension('x'),hv.Dimension('y')],vdims=['time']))

            fig = gv.tile_sources.Wikipedia.opts(width=900, height=900) * xr_dataset.to.points(['x','y']).opts(opts.Points(color='time'))

        elif plot_type == 'Grids':
            z = np.random.randn(10,(100,100))
            x = np.repeat(-101.1,100) 
            y = np.repeat(32,100)
            
           

            # get xarray dataset, suited for handling raster data in pyviz
            xr_dataset = gv.Dataset(hv.Image((x, y, np.log10(z)), bounds=(x.min(),y.min(),x.max(),y.max()), 
                    kdims=[hv.Dimension('x'),  hv.Dimension('y')], datatype=['grid']))

            # create contours from image
            gv.FilledContours(xr_dataset)
            fig = gv.tile_sources.Wikipedia.opts(width=900, height=900) * xr_dataset.to.image(['x', 'y']).opts(cmap='cubehelix', alpha=0.8)#gv.FilledContours(xr_dataset).opts(cmap='viridis', alpha=0.5)


        responsive = pn.pane.HoloViews(fig, config={'responsive': True})
        return(responsive)
示例#29
0
ds_psl = xr.open_mfdataset('/nobackup_3/users/stoop/7A_weather_data/psl_d_ECEarth_2C_s16r09_2064_world.nc')
ds_rsds = xr.open_mfdataset('/nobackup_3/users/stoop/7A_weather_data/rsds_d_ECEarth_2C_s16r09_2064_world.nc')
ds_wind = xr.open_mfdataset('/nobackup_3/users/stoop/7A_weather_data/sfcwind_d_ECEarth_2C_s16r09_2064_world.nc')
ds_temp = xr.open_mfdataset('/nobackup_3/users/stoop/7A_weather_data/tas_d_ECEarth_2C_s16r09_2064_world.nc')


# In[3]:


#%% Asignment of dimensions (GeoViews can use Iris cubes, Xarray data or just Numpy data)

# Set the key dims (coordinates), the ones that are not part of the image will be sliders
kdims = ['time', 'lat', 'lon']

# Load the GeoViews dataset (data, key dimensions, variable dimensions, projection)
gv_psl= gv.Dataset(ds_psl, kdims=kdims, vdims='psl', crs=crs.PlateCarree())
gv_rsds= gv.Dataset(ds_rsds, kdims=kdims, vdims='rsds', crs=crs.PlateCarree())
gv_wind= gv.Dataset(ds_wind, kdims=kdims, vdims='sfcwind', crs=crs.PlateCarree())
gv_temp= gv.Dataset(ds_temp, kdims=kdims, vdims='tas', crs=crs.PlateCarree())


# In[4]:


# Make an image of the data
gv_temp.to.image(['lon','lat'])


# # Changing figure characteristics

# In[5]:
示例#30
0
def plot_ly(lon, lat, alt, time, power, density, weight, bins, file_path,
            clear_fig, current_time_range, maps):
    '''Plotting routine to view raw data. Select map=False or True to view a 3 panel or single panel 
    plot of the raw lma data. All other kwargs are used to display specific user selected traits of the data,
    e.g. raw source locations, gridded source count densities, etc.
    '''
    fig = make_subplots(
        rows=5,
        cols=4,
        shared_xaxes=True,
        shared_yaxes=True,
        specs=[[{
            'colspan': 3,
            "rowspan": 2
        }, None, {}, {}], [None, None, None, None],
               [{
                   'colspan': 3,
                   "rowspan": 3
               }, {}, {}, {
                   "rowspan": 3
               }], [None, None, None, None], [None, None, None, None]],
        #         print_grid=True
    )

    fig.update_layout(autosize=False, width=1000, height=900)

    if maps == True:

        if clear_fig == 'No Data Found':
            print('Nope')
            if density == 'Points' or density == 'Density':
                if weight is not None:
                    fig.add_trace(go.Scatter(x=[0, 0, 0], y=[0, 0, 0]),
                                  row=1,
                                  col=1)
                    fig.add_trace(go.Scatter(x=[0, 0, 0], y=[0, 0, 0]),
                                  row=3,
                                  col=4)
                    fig.add_trace(go.Scatter(x=[0, 0, 0], y=[0, 0, 0]),
                                  row=3,
                                  col=1)

        else:
            if density == 'Points':
                print('Picked Points')
                fig.add_trace(go.Scatter(x=[0, 0, 0], y=[0, 0, 0]),
                              row=1,
                              col=1)
                fig.add_trace(go.Scatter(x=[0, 0, 0], y=[0, 0, 0]),
                              row=3,
                              col=4)
                fig.add_trace(go.Scatter(x=[0, 0, 0], y=[0, 0, 0]),
                              row=3,
                              col=1)

                if weight == 'None':
                    fig.update_traces(go.Scatter(
                        x=lon,
                        y=alt,
                        mode='markers',
                    ),
                                      row=1,
                                      col=1)

                    fig.update_traces(go.Scatter(
                        x=lon,
                        y=lat,
                        mode='markers',
                    ),
                                      row=3,
                                      col=1)

                    fig.update_traces(go.Scatter(
                        x=alt,
                        y=lat,
                        mode='markers',
                    ),
                                      row=3,
                                      col=4)
                else:
                    if weight == 'alt':
                        weight = alt / 1e4
                        cmap = cm.cm.deep_r
                    elif weight == 'time':
                        weight = time / 1e9
                        cmap = plt.cm.magma
                    elif weight == 'power':
                        weight = power * 3e1
                        cmap = cm.cm.algae_r

                    fig.update_traces(go.Scatter(x=lon,
                                                 y=alt,
                                                 mode='markers',
                                                 marker=dict(size=weight,
                                                             color='black')),
                                      row=1,
                                      col=1)

                    fig.update_traces(go.Scatter(x=lon,
                                                 y=lat,
                                                 mode='markers',
                                                 marker=dict(size=weight,
                                                             color='black')),
                                      row=3,
                                      col=1)

                    fig.update_traces(go.Scatter(x=alt,
                                                 y=lat,
                                                 mode='markers',
                                                 marker=dict(size=weight,
                                                             color='black')),
                                      row=3,
                                      col=4)

            else:
                h0xy, xe1, ye1 = np.histogram2d(lon,
                                                lat,
                                                bins=(int(bins), int(bins)))
                h0xz, xe2, ye2 = np.histogram2d(lon,
                                                alt,
                                                bins=(int(bins), int(bins)))
                h0yz, xe3, ye3 = np.histogram2d(alt,
                                                lat,
                                                bins=(int(bins), int(bins)))

                colors = fig.add_trace(go.Heatmap(z=h0xy.T,
                                                  showscale=True,
                                                  coloraxis='coloraxis'),
                                       row=3,
                                       col=1)
                fig.add_trace(go.Heatmap(z=h0xz.T, coloraxis='coloraxis'),
                              row=1,
                              col=1)
                fig.add_trace(go.Heatmap(z=h0yz.T, coloraxis='coloraxis'),
                              row=3,
                              col=4)

                if weight == 'None':
                    cbar_title = r'LMA Sources per square km'

                    fig.update_traces(go.Heatmap(x=xe1,
                                                 y=ye1,
                                                 z=np.log10(h0xy).T,
                                                 showscale=True,
                                                 coloraxis='coloraxis'),
                                      row=3,
                                      col=1)

                    fig.update_traces(go.Heatmap(x=xe2,
                                                 y=ye2,
                                                 z=np.log10(h0xz).T,
                                                 coloraxis='coloraxis'),
                                      row=1,
                                      col=1)

                    fig.update_traces(go.Heatmap(x=xe3,
                                                 y=ye3,
                                                 z=np.log10(h0yz).T,
                                                 coloraxis='coloraxis'),
                                      row=3,
                                      col=4)

                    color_bar_pref = dict(
                        title=cbar_title,
                        thicknessmode="pixels",
                        thickness=40,
                        lenmode="pixels",
                        len=600,
                        yanchor="bottom",
                        y=0.05,
                    )

                    fig.update_layout(coloraxis_colorbar=color_bar_pref,
                                      coloraxis={'colorscale': 'viridis'})

                else:
                    if weight == 'alt':
                        cbar_title = 'LMA Source Altitude'
                        weight = alt
                        cmap = cm.cm.deep_r
                    elif weight == 'time':
                        cbar_title = 'LMA Source Time'
                        weight = time
                        cmap = plt.cm.magma
                    elif weight == 'power':
                        cbar_title = 'LMA Source Power'
                        weight = power
                        cmap = cm.cm.algae_r

                    h0xy0, xe1, ye1 = np.histogram2d(lon,
                                                     lat,
                                                     bins=(int(bins),
                                                           int(bins)),
                                                     weights=weight)
                    h0xz0, xe2, ye2 = np.histogram2d(lon,
                                                     alt,
                                                     bins=(int(bins),
                                                           int(bins)),
                                                     weights=weight)
                    h0yz0, xe3, ye3 = np.histogram2d(alt,
                                                     lat,
                                                     bins=(int(bins),
                                                           int(bins)),
                                                     weights=weight)

                    fig.update_traces(go.Heatmap(x=xe1,
                                                 y=ye1,
                                                 z=(h0xy0 / h0xy).T,
                                                 showscale=True,
                                                 coloraxis='coloraxis'),
                                      row=3,
                                      col=1)

                    fig.update_traces(go.Heatmap(x=xe2,
                                                 y=ye2,
                                                 z=(h0xz0 / h0xz).T,
                                                 coloraxis='coloraxis'),
                                      row=1,
                                      col=1)

                    fig.update_traces(go.Heatmap(x=xe3,
                                                 y=ye3,
                                                 z=(h0yz0 / h0yz).T,
                                                 coloraxis='coloraxis'),
                                      row=3,
                                      col=4)

                    color_bar_pref = dict(
                        title=cbar_title,
                        thicknessmode="pixels",
                        thickness=40,
                        lenmode="pixels",
                        len=600,
                        yanchor="bottom",
                        y=0.05,
                    )
                    fig.update_layout(coloraxis_colorbar=color_bar_pref,
                                      coloraxis={'colorscale': 'viridis'})

            fig.update_layout(showlegend=False,
                              title_text=r"Date: {0}-{1}-{2} {3}".format(
                                  file_path.year, file_path.month,
                                  file_path.day, current_time_range))
            fig.update_xaxes(matches='x', row=1, col=1)
            fig.update_xaxes(matches='x', row=3, col=1)
            fig.update_yaxes(matches='y2', row=3, col=1)
            fig.update_yaxes(matches='y2', row=3, col=4)
            fig.update_yaxes(matches='y', row=1, col=1)
            fig.update_xaxes(matches='y', row=3, col=4)

        responsive = pn.pane.Plotly(fig, config={'responsive': True})
    else:
        #Original use of Plotl's MapBox
        #fig.add_trace(go.Densitymapbox(lon=lon, lat=lat,
        #                         radius=20))
        #fig.update_layout(mapbox_style="carto-positron",mapbox_center_lon=-101.5,mapbox_center_lat=34,mapbox=dict(zoom=6))
        #fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})

        #Switch to Holoviews for consistency:
        raw_hist, xe, ye = np.histogram2d(lon,
                                          lat,
                                          bins=(int(bins), int(bins)))

        # get xarray dataset, suited for handling raster data in pyviz
        xr_dataset = gv.Dataset(
            hv.Image(
                (xe, ye,
                 np.log10(np.ma.MaskedArray(raw_hist.T, mask=raw_hist.T
                                            == 0))),
                bounds=(xe.min(), ye.min(), xe.max(), ye.max()),
                kdims=[hv.Dimension('x'), hv.Dimension('y')],
                datatype=['grid']))

        # create contours from image
        gv.FilledContours(xr_dataset)
        fig = gv.tile_sources.Wikipedia.opts(
            width=900, height=900) * xr_dataset.to.image(['x', 'y']).opts(
                cmap='cubehelix', alpha=0.8
            )  #gv.FilledContours(xr_dataset).opts(cmap='viridis', alpha=0.5)
        responsive = pn.pane.HoloViews(fig, config={'responsive': True})

    return (responsive)