コード例 #1
0
def event(auth_key, event):
    out = []
    template = open("static_private/picarus_event_explorer_template.html").read()
    chart_count = 0
    chart_values = {}
    rows = EVENT_ROWS[event]
    times = EVENT_ROW_TIMES[event]
    event_sensors, sensor_names = get_event_sensors(rows, ROW_COLUMNS, times[0], times[-1], max_samples=1000)
    out += ['<div class="event">'] + generate_event(auth_key, event)
    chart_id = "chart_%d" % chart_count
    chart_num = 0
    out.append('<h2>%s (%d)</h2><div id="%s"></div>' % ("locomotion", chart_num, chart_id))
    chart_values[chart_id] = [[], []]
    for start_time, stop_time, results in EVENT_CLASSIFICATIONS[event]:
        chart_values[chart_id][0].append(start_time)
        chart_values[chart_id][0].append(stop_time)
        chart_values[chart_id][1].append(results["locomotion"])
        chart_values[chart_id][1].append(results["locomotion"])
    chart_count += 1
    for chart_num in [1, 2, 3, 4, 5, 9, 10, 11]:
        chart_id = "chart_%d" % chart_count
        out.append('<h2>%s (%d)</h2><div id="%s"></div>' % (sensor_names[chart_num], chart_num, chart_id))
        chart_values[chart_id] = [[x[1] for x in event_sensors[chart_num]]] + zip(
            *[x[0] for x in event_sensors[chart_num]]
        )
        chart_count += 1
    out.append("</div>")
    return (
        template.replace("{{events}}", "".join(out))
        .replace("{{chartValues}}", json.dumps(chart_values))
        .replace("{{AUTH_KEY}}", auth_key)
        .replace("{{EVENT}}", event)
        .replace("{{THUMBWIDTH}}", ARGS.thumbwidth)
    )
コード例 #2
0
def classify_slice(rows, row_columns, start_time, stop_time, window_size=10):
    sensors, sensor_names = get_event_sensors(rows, row_columns, start_time,
                                              stop_time)
    sensor_values = {
        k: np.array([[v['timestamp']] + v['values'] for v in vs])
        for k, vs in sensors.items()
    }
    return classify_sensors(sensor_values)
コード例 #3
0
def event(auth_key, event):
    out = []
    template = open('static_private/picarus_event_explorer_template.html').read()
    chart_count = 0
    chart_values = {}
    rows = EVENT_ROWS[event]
    times = EVENT_ROW_TIMES[event]
    event_sensors, sensor_names = get_event_sensors(rows, ROW_COLUMNS, times[0], times[-1], max_samples=1000)
    out += ['<div class="event">'] + generate_event(auth_key, event)
    for chart_num in [1, 2, 3, 4, 5, 9, 10, 11]:
        chart_id = 'chart_%d' % chart_count
        out.append('<h2>%s (%d)</h2><div id="%s"></div>' % (sensor_names[chart_num], chart_num, chart_id))
        chart_values[chart_id] = [[x['timestamp'] for x in event_sensors[chart_num]]] + zip(*[x['values'] for x in event_sensors[chart_num]])
        chart_count += 1
    out.append('</div>')
    return template.replace('{{events}}', ''.join(out)).replace('{{chartValues}}', json.dumps(chart_values)).replace('{{AUTH_KEY}}', auth_key).replace('{{EVENT}}', event).replace('{{THUMBWIDTH}}', ARGS.thumbwidth)
コード例 #4
0
def classify_slice(rows, row_columns, start_time, stop_time, window_size=10):
    sensors, sensor_names = get_event_sensors(rows, row_columns, start_time, stop_time)
    sensor_values = {k: np.array([[v[1]] + v[0] for v in vs]) for k, vs in sensors.items()}
    return classify_sensors(sensor_values)