Exemple #1
0
 def _set_style(self, feature, map_type):
     fname = feature.name.capitalize()
     style_path = ('Image', fname + map_type.capitalize())
     options = Store.options(backend='matplotlib')
     if style_path not in options.data:
         cyclic = True if feature.cyclic and not map_type == 'selectivity' else False
         options[style_path] = Options('style', **(dict(cmap='hsv') if cyclic else dict()))
Exemple #2
0
def option_intersections(backend):
    intersections = []
    options = Store.options(backend)
    for k, opts in sorted(options.items()):
        if len(k) > 1: continue
        valid_options = {k: set(o.allowed_keywords)
                         for k, o in opts.groups.items()}
        for g1, g2 in combinations(Options._option_groups, 2):
            intersection = valid_options[g1] & valid_options[g2]
            if intersection:
                intersections.append((k, intersection))
    return intersections
Exemple #3
0
def option_intersections(backend):
    intersections = []
    options = Store.options(backend)
    for k, opts in sorted(options.items()):
        if len(k) > 1: continue
        valid_options = {
            k: set(o.allowed_keywords)
            for k, o in opts.groups.items()
        }
        for g1, g2 in combinations(Options._option_groups, 2):
            intersection = valid_options[g1] & valid_options[g2]
            if intersection:
                intersections.append((k, intersection))
    return intersections
Exemple #4
0
        meta = quest.api.get_data(
            collection_name='examples',
            service_uri='svc://wmts:seamless_imagery',
            search_filters=None,
            download_options=options,
            as_open_datasets=False,
            expand=True,
        )[0]

        file_path = meta.get('file_path', None)
        if not os.path.isfile(file_path):
            print('Error: No TIFF downloaded')
        return file_path

    def view(self):
        return (gv.DynamicMap(self.callback) * self.boxes).options(active_tools=['wheel_zoom'])

    @param.output(image=hv.Image)
    def output(self):
        return self.get_tiff()

    def panel(self):
        return pn.Row(self.param, self.view())


options = Store.options('bokeh')

options.Points = Options('plot', padding=0.1)
options.Path = Options('plot', padding=0.1)
options.Polygons = Options('plot', padding=0.1)
Exemple #5
0
        for (in_label, out_label), view in grids.items():
            results.set_path(('%s_Reverse_Correlation' % in_label, out_label), view)
            if p.store_responses:
                info = (p.pattern_generator.__class__.__name__,
                        pattern_dim_label, 'Response')
                results.set_path(('%s_%s_%s' % info, in_label),
                                 responses[in_label])
                results.set_path(('%s_%s_%s' % info, out_label),
                                 responses[out_label])
        return results

from holoviews.core.options import Compositor
from .analysis import toHCS

#Default styles
options = Store.options(backend='matplotlib')
options.Image.Preference = Options('style', cmap='hsv')
options.Image.Selectivity = Options('style', cmap='gray')
options.Image.Activity = Options('style', cmap='gray')
options.Image.Response = Options('style', cmap='gray')
options.Image.FFT_Power = Options('style', cmap='gray')

# Default channel definitions
Compositor.register(
    Compositor('Image.Orientation_Preference * Image.Orientation_Selectivity',
               toHCS, 'OR PrefSel', mode='display', flipSC=True))

Compositor.register(
    Compositor('Image.Direction_Preference * Image.Direction_Selectivity',
               toHCS, 'DR PrefSel', mode='display', flipSC=True))
Exemple #6
0
    def __init__(self,
                 data,
                 x,
                 y,
                 kind=None,
                 by=None,
                 use_index=True,
                 group_label='Variable',
                 value_label='value',
                 backlog=1000,
                 persist=False,
                 use_dask=False,
                 crs=None,
                 fields={},
                 groupby=None,
                 dynamic=True,
                 width=700,
                 height=300,
                 shared_axes=True,
                 grid=False,
                 legend=True,
                 rot=None,
                 title=None,
                 xlim=None,
                 ylim=None,
                 clim=None,
                 xticks=None,
                 yticks=None,
                 logx=False,
                 logy=False,
                 loglog=False,
                 hover=True,
                 subplots=False,
                 label=None,
                 invert=False,
                 stacked=False,
                 colorbar=None,
                 fontsize=None,
                 colormap=None,
                 datashade=False,
                 rasterize=False,
                 row=None,
                 col=None,
                 figsize=None,
                 debug=False,
                 xaxis=True,
                 yaxis=True,
                 framewise=True,
                 aggregator=None,
                 projection=None,
                 global_extent=False,
                 geo=False,
                 precompute=False,
                 flip_xaxis=False,
                 flip_yaxis=False,
                 dynspread=False,
                 hover_cols=[],
                 x_sampling=None,
                 y_sampling=None,
                 **kwds):

        # Process data and related options
        self._process_data(kind, data, x, y, by, groupby, row, col, use_dask,
                           persist, backlog, label, value_label, hover_cols,
                           kwds)
        self.use_index = use_index
        self.value_label = value_label
        self.group_label = group_label
        self.dynamic = dynamic
        self.geo = geo or crs or global_extent or projection
        self.crs = process_crs(crs) if self.geo else None
        self.row = row
        self.col = col

        # Operations
        self.datashade = datashade
        self.rasterize = rasterize
        self.dynspread = dynspread
        self.aggregator = aggregator
        self.precompute = precompute
        self.x_sampling = x_sampling
        self.y_sampling = y_sampling

        # By type
        self.subplots = subplots
        self._by_type = NdLayout if subplots else NdOverlay

        # Process options
        style_opts, plot_opts, kwds = self._process_style(colormap, kwds)
        self.stacked = stacked
        self.invert = invert
        plot_opts['logx'] = logx or loglog
        plot_opts['logy'] = logy or loglog
        plot_opts['show_grid'] = grid
        plot_opts['shared_axes'] = shared_axes
        plot_opts['show_legend'] = legend
        if xticks:
            plot_opts['xticks'] = xticks
        if yticks:
            plot_opts['yticks'] = yticks
        if not xaxis:
            plot_opts['xaxis'] = None
        if not yaxis:
            plot_opts['yaxis'] = None
        if flip_xaxis:
            plot_opts['invert_xaxis'] = True
        if flip_yaxis:
            plot_opts['invert_yaxis'] = True
        if width:
            plot_opts['width'] = width
        if height:
            plot_opts['height'] = height
        if fontsize:
            plot_opts['fontsize'] = fontsize
        if isinstance(colorbar, bool):
            plot_opts['colorbar'] = colorbar
        elif self.kind in self._colorbar_types:
            plot_opts['colorbar'] = True
        if invert:
            plot_opts['invert_axes'] = kind != 'barh'
        if rot:
            axis = 'yrotation' if invert else 'xrotation'
            plot_opts[axis] = rot
        if hover:
            plot_opts['tools'] = ['hover']

        if self.crs and global_extent:
            plot_opts['global_extent'] = global_extent
        if projection:
            plot_opts['projection'] = process_crs(projection)
        plot_opts['legend_position'] = 'right'
        if title is not None:
            plot_opts['title_format'] = title
        self._plot_opts = plot_opts
        options = Store.options(backend='bokeh')
        el_type = self._kind_mapping[self.kind].__name__
        style = options[el_type].groups['style']
        cycled_opts = [
            k for k, v in style.kwargs.items() if isinstance(v, Cycle)
        ]
        for opt in cycled_opts:
            color = style_opts.get('color', None)
            if color is None:
                color = process_cmap(colormap or 'Category10',
                                     categorical=True)
            style_opts[opt] = Cycle(
                values=color) if isinstance(color, list) else color
        self._style_opts = style_opts
        self._norm_opts = {'framewise': framewise, 'axiswise': not shared_axes}
        self.kwds = kwds

        # Process dimensions and labels
        self.label = label
        self._relabel = {'label': label} if label else {}
        self._dim_ranges = {
            'x': xlim or (None, None),
            'y': ylim or (None, None),
            'c': clim or (None, None)
        }
        self._redim = fields

        # High-level options
        self._validate_kwds(kwds)
        if debug:
            kwds = dict(x=self.x,
                        y=self.y,
                        by=self.by,
                        kind=self.kind,
                        groupby=self.groupby)
            self.warning('Plotting {kind} plot with parameters x: {x}, '
                         'y: {y}, by: {by}, groupby: {groupby}'.format(**kwds))
Exemple #7
0
        for vind in range(vlines)[:: p.stride]:
            lines.append(np.vstack([xsv.data[:, vind].T, ysv.data[:, vind]]).T)
        cogmesh = Contours(lines, extents=sheet.bounds.lbrt(), label=proj.name, group="Center of Gravity")

        xcog_map = HoloMap((timestamp, xsv), kdims=[features.Time])
        xcog_map.metadata = metadata
        ycog_map = HoloMap((timestamp, ysv), kdims=[features.Time])
        ycog_map.metadata = metadata

        contour_map = HoloMap((timestamp, cogmesh), kdims=[features.Time])
        contour_map.metadata = metadata

        return {"XCoG": xcog_map, "YCoG": ycog_map, "CoG": contour_map}


options = Store.options(backend="matplotlib")
options.Contours.Gravity = Options("style", linewidth=1.0)
options.Image.X_CoG = Options("style", cmap="gray")
options.Image.Y_CoG = Options("style", cmap="gray")
options.CFView.OnOff_CFs = Options("style", cmap="RdYlBu_r", interpolation="nearest")

import types

__all__ = list(
    set(
        [
            k
            for k, v in locals().items()
            if isinstance(v, types.FunctionType)
            or (isinstance(v, type) and issubclass(v, ParameterizedFunction))
            and not v.__name__.startswith("_")
Exemple #8
0
                           extents=sheet.bounds.lbrt(),
                           label=proj.name,
                           group='Center of Gravity')

        xcog_map = HoloMap((timestamp, xsv), kdims=[features.Time])
        xcog_map.metadata = metadata
        ycog_map = HoloMap((timestamp, ysv), kdims=[features.Time])
        ycog_map.metadata = metadata

        contour_map = HoloMap((timestamp, cogmesh), kdims=[features.Time])
        contour_map.metadata = metadata

        return {'XCoG': xcog_map, 'YCoG': ycog_map, 'CoG': contour_map}


options = Store.options(backend='matplotlib')
options.Contours.Gravity = Options('style', linewidth=1.0)
options.Image.X_CoG = Options('style', cmap='gray')
options.Image.Y_CoG = Options('style', cmap='gray')
options.CFView.OnOff_CFs = Options('style',
                                   cmap='RdYlBu_r',
                                   interpolation='nearest')

import types

__all__ = list(
    set([
        k for k, v in locals().items() if isinstance(v, types.FunctionType) or
        (isinstance(v, type) and issubclass(v, ParameterizedFunction))
        and not v.__name__.startswith('_')
    ]))