Ejemplo n.º 1
0
def test_filter_colormaps():
    cmap = "Accent"

    for example in get_examples():
        properties = {}
        _ = filter_colormap(example, cmap=cmap, properties=properties)
        properties["nan_color"]
        properties["inf_color"]
        properties["flat_color"]
Ejemplo n.º 2
0
def test_filter_colormaps():
    cmap = 'Accent'

    for example in get_examples():
        properties = {}
        _ = filter_colormap(example, cmap=cmap, properties=properties)
        properties['nan_color']
        properties['inf_color']
        properties['flat_color']
Ejemplo n.º 3
0
def demo_colormaps(r):
    x = get_test_bar()
    cmaps = ['Reds', 'jet', 'Accent']
    for cmap in cmaps:
        f = r.figure(cmap)
        properties = {}
        rgba = filter_colormap(x, cmap, properties=properties)
        f.data_rgb('result', diagflip(rgba))
        f.data_rgb('colorbar', diagflip(properties['color_bar']))
        f.data_rgb('nan_color', get_solid((20, 20), properties['nan_color']))
        f.data_rgb('inf_color', get_solid((20, 20), properties['inf_color']))
        f.data_rgb('flat_color', get_solid((20, 20), properties['flat_color']))
Ejemplo n.º 4
0
def demo_colormaps(r):
    x = get_test_bar()
    cmaps = ["Reds", "jet", "Accent"]
    for cmap in cmaps:
        f = r.figure(cmap)
        properties = {}
        rgba = filter_colormap(x, cmap, properties=properties)
        f.data_rgb("result", diagflip(rgba))
        f.data_rgb("colorbar", diagflip(properties["color_bar"]))
        f.data_rgb("nan_color", get_solid((20, 20), properties["nan_color"]))
        f.data_rgb("inf_color", get_solid((20, 20), properties["inf_color"]))
        f.data_rgb("flat_color", get_solid((20, 20), properties["flat_color"]))
Ejemplo n.º 5
0
def report_nmap_distances(nmap, nmap_distances):
    r = Report()
    timestamps = []
    alldists = []
    allobs = []
    poses = []
    for i, (timestamp, (y, distances, pose)) in enumerate(nmap_distances):
        timestamps.append(timestamp)
        alldists.append(distances)
        allobs.append(y)
        poses.append(pose)

    timestamp = np.array(timestamps)    
    alldists = np.vstack(alldists).T
        
    print ('ntimestamps: %s' % len(timestamps))
    nwaypoints, nmoments = alldists.shape
    print('nmoments: %s' % nmoments)
    print('nwaypoints: %s' % nwaypoints)
    
    assert len(timestamps) == nmoments
    
    f = r.figure(cols=1)
    GREEN = [0, 1, 0]
    RED = [1, 0, 0]
    
    alldists_rgb1 = scale(alldists, min_color=GREEN, max_color=RED)
    f.data_rgb('alldists', alldists_rgb1)
    alldists_rgb2 = filter_colormap(alldists,
                   cmap='jet',
                   min_value=None, max_value=None,
                   nan_color=[1, 0.6, 0.6],
                   inf_color=[0.6, 1, 0.6],
                   flat_color=[0.5, 0.5, 0.5])
    
    f.data_rgb('alldists2', alldists_rgb2)
    
    f.data_rgb('observations', _nmapobslist_to_rgb(allobs))
    
    waypoints = range(0, nwaypoints, 5)
    with f.plot('distances') as pylab:
        for a, i in enumerate(waypoints): 
            d = alldists[i, :]        
            d = d - np.min(d)
            d = d / np.max(d)
            x = timestamps
            y = d + a * 1.1
            pylab.plot(x, y, 'k-')
            
    return r
Ejemplo n.º 6
0
def get_rgb(field, colors, **kwargs):
    ''' Returns a dict with values 'rgb' (rgb in [0,1]), 'colorbar', etc.. '''
    properties = {}
    if colors == 'posneg':
        rgb = posneg(field, properties=properties, **kwargs) / 255.0
    elif colors == 'scale':
        rgb = scale(field, properties=properties, **kwargs) / 255.0
    elif colors == 'cmap':
        rgb = filter_colormap(field,
                              properties=properties, **kwargs) / 255.0
    else:
        raise ValueError('No known colors %r. ' % colors)
    
    properties['rgb'] = rgb
    return properties