コード例 #1
0
def gen_acceleration_graph(count):
    acc_end = len(db.rawdata.index)
    acc_start = int(acc_end - DISPLAY_RANGE*SAMPLING_RATE)

    if acc_start < 0:
        acc_start = 0

    acc_data = db.rawdata[acc_start:acc_end]

    acc_fig = Visualizer.acc_grapher(acc_data,return_fig=True)

    feature_end = len(db.featuredata.index)
    feature_start = int(feature_end - DISPLAY_RANGE/FEATURE_TIME) - 1

    if feature_start < 0:
        feature_start = 0
    if feature_end < 0:
        feature_end = 0

    feature_data = db.featuredata.iloc[feature_start:feature_end,:]
    feature_fig = Visualizer.feature_grapher(feature_data, return_fig=True, feature_index=values)
    
    for label in db.annotationdata.iloc[:,3].unique():
        if label not in annotation_colors:
            annotation_colors[label] = Visualizer.generate_color(1)[0]
    
    annotation_end = len(db.annotationdata.index)
    annotation_start = int(annotation_end - DISPLAY_RANGE/FEATURE_TIME) - 1

    if annotation_start < 0:
        annotation_start = 0
    if annotation_end < 0:
        annotation_end = 0

    annotation_data = db.annotationdata.iloc[annotation_start:annotation_end,:]
    annotation_fig = Visualizer.annotation_feature_grapher(annotation_data.iloc[:,[0,1,3]], colors=annotation_colors, return_fig=True)
    
    
    acc_fig['data'] += feature_fig['data']
    acc_fig['data'] += annotation_fig['data']

    acc_fig['layout'].update(feature_fig['layout'])

    acc_fig['layout'].update(annotation_fig['layout'])
    acc_fig['layout']['yaxis']['domain'] = [0,0.3]
    acc_fig['layout']['yaxis2']['domain'] = [0.31,0.6]
    acc_fig['layout']['yaxis3']['domain'] = [0.61, 1]

    range_end = pd.to_datetime(acc_data.iloc[acc_data.shape[0]-1,0])
    range_start = range_end - datetime.timedelta(seconds=DISPLAY_RANGE)
    acc_fig['layout']['xaxis'].update(dict(fixedrange=True, range=[range_start,range_end]))
    acc_fig['layout']['width'] = 1200

    return acc_fig
コード例 #2
0
    def plot_feature_and_raw(
            features,
            acc_data,
            path_out='/Users/zhangzhanming/Desktop/mHealth/Test/'):
        acc_fig = Visualizer.acc_grapher(acc_data,
                                         return_fig=True,
                                         showlegend=True)
        feature_fig = Visualizer.feature_grapher(features,
                                                 return_fig=True,
                                                 showlegend=True,
                                                 hide_traces=True)
        acc_fig['data'] += feature_fig['data']
        acc_fig['layout'].update(feature_fig['layout'])
        acc_fig['layout']['yaxis2']['domain'] = [0, 0.5]
        acc_fig['layout']['yaxis2']['fixedrange'] = False
        acc_fig['layout']['height'] = 600
        acc_fig['layout']['yaxis3'] = dict(domain=[0.51, 1])

        py.plot(acc_fig, filename=path_out + 'feature_acc_graph.html')
コード例 #3
0
def acc_grapher(data, path_out):
    Visualizer.acc_grapher(data=data, path_out=path_out, showlegend=True)