コード例 #1
0
 def update_data(attrib,old,new):
     g = gliders.value
     #depth   = load_sensor(g, 'm_depth')
     #celcius = load_sensor(g, 'sci_water_temp')
     t = 1000*util.time()
     ego = dict(x=[t-4*60*1000,t-3*60*1000,t-2*60*1000,t-1*60*1000],
                     y=[1,1,2,2], values=[1,2,3,4])
     fig1.pprint_props()
コード例 #2
0
    def update_plot(attrib, old, new):
        sensorname = select_sensor.value
        print('UPDATE!')

        if attrib == 'button_click':
            chunk_index = button_next_chunk.clicks - button_prev_chunk.clicks
            label_chunk_index.value = str( chunk_index )
        else:
            chunk_index = int(label_chunk_index.value)
            button_prev_chunk.clicks = 0
            button_next_chunk.clicks = chunk_index

        try:
            sensor = mongoman.mongo_fetch(util.DB,
                                          select_platformID.value,
                                          {'name':sensorname})[0]
        except IndexError:
            print('{} does not exist for {} in this range'.format(sensorname, select_platformID.value))
            return
        except Exception as e:
            print(e)
            return
        #sensor = Sensor(sensorname,'arbit',[(0,0),(1,1),(2,2),(3,3)],'noparse',['fake'])

        select_sensor.options = get_sensornames(select_platformID.value)

        x,y = sensor.xylist()
        times = [s*10**3 for s in x] #seconds to milliseconds
        source.data = dict(x=times, y=y)

        if select_chunkation.value == 'file':
            tstart,tend,chunk_ID = truncate_filechunk(chunk_index, select_platformID.value)
        elif select_chunkation.value == '24hr':
            hr = 86400
            c = abs(chunk_index)
            t = util.time()
            tstart = t-(c+1)*hr
            tend = t-c*hr
            chunk_ID = '{} {} {}'.format(select_platformID.value, util.e2ts(min(x)), sensorname)
        else:
            tstart, tend = None,None

        fig.x_range.start = tstart*1000
        fig.x_range.end   = tend*1000   #converts to s to ms

        fig.yaxis.axis_label = '{} ({})'.format(sensorname,sensor.units)
        if sensorname == 'm_depth':
            fig.y_range.start = 1000
            fig.y_range.end   = 0
        else:
            fig.y_range.start = None
            fig.y_range.end   = None


        fig.title = '{} {} '.format(chunk_ID, sensorname)
コード例 #3
0
def plot():

    # INPUT WIDGETS
    collection_list = ['bugaboo']
    #collection_list = util.CONN[util.DB].collection_names(include_system_collections=False)
    gliders = sorted([platformID for platformID in collection_list if len(platformID)>2])
    gliders = Select(title = 'PlatformID', value = gliders[0], options = gliders)
    prev_glider = Button(label = '<')
    next_glider = Button(label = '>')
    glider_controlbox = HBox(children = [gliders, prev_glider, next_glider])

    control_box = HBox(glider_controlbox)

    # DATA VARS
    heatdata = dict(x=[1.5,2],y=[2,1.5],values=[0,10])
    t = 1000*util.time()
    heatdata = dict(x=[t-4*60*1000,t-3*60*1000,t-2*60*1000,t-1*60*1000],
                    y=[1,1,2,2], values=[1,2,3,4])

    # FIGURES AND AXIS
    fig1 = HeatMap(data=heatdata, x='x', y='y', values='values', title = 'SUPERHOT')

    # LEGEND
    #TODO
    """
    legend = Figure(tools=None)
    legend.toolbar_location=None
    legend.rect(x=0.5, y='value', fill_color='color', width=1, height=1, source=heatdata)
    layout = hplot(main, legend)
    """

    # CALLBACK FUNCS
    def update_data(attrib,old,new):
        g = gliders.value
        #depth   = load_sensor(g, 'm_depth')
        #celcius = load_sensor(g, 'sci_water_temp')
        t = 1000*util.time()
        ego = dict(x=[t-4*60*1000,t-3*60*1000,t-2*60*1000,t-1*60*1000],
                        y=[1,1,2,2], values=[1,2,3,4])
        fig1.pprint_props()


    #GLIDER SELECTS
    def glider_buttons(increment):
        ops = gliders.options
        new_index = ops.index(gliders.value) + increment
        if new_index >= len(ops):
            new_index = 0
        elif new_index < 0:
            new_index = len(ops)-1
        gliders.value = ops[new_index]
    def next_glider_func():
        glider_buttons(1)
    def prev_glider_func():
        glider_buttons(-1)

    gliders.on_change('value', update_data)
    next_glider.on_click(next_glider_func)
    prev_glider.on_click(prev_glider_func)

    update_data(None,None,None)

    return vplot(control_box, fig1)