Beispiel #1
0
def power(filename):
    """Return filename of plot of the damped_vibration function."""

    df = read_file(filename)

    labels = df.columns.tolist()

    data = serialize(df, render_to='power', title='',
                       output_type='dict')

    # data['subtitle'] = {'text': 'a subtitle here...'}
    data['plotOptions'] = {'spline': {
         'lineWidth': 2,
         'states': {
         'hover': {
         'lineWidth': 3}
         }}}
    data['chart']['type'] = 'line'
    data['chart']['zoomType'] = 'x'
    data['chart']['panning'] = True
    data['chart']['panKey'] = 'shift'

    result = 'new Highcharts.StockChart({});'.format(json_encode(data))

    return result
Beispiel #2
0
def datarate(filename):
    """Return filename of plot of the damped_vibration function."""

    df = read_file(filename)

    # add data volume columns
    for column in df.columns.values.tolist():
        if 'Accum' in column:
            instr = column[0]
            df[instr, 'Volume', 'Gbits'] = df[instr, 'Accum', 'Gbits'].sub(
                df[instr, 'Accum', 'Gbits'].shift(), fill_value=0)
    df = df.sort_index(axis=1)

    insts = ['BELA','ISA','MERMAG','MERTIS','MGNS','MIXS_SIXS',
             'PHEBUS','SERENA','SIMBIOSYS']

    # slice out a few specific dataframes
    df_insts_accum_gbits = {
        'data': df[insts].filter(like='Accum'),
        'title': ''}
    df_insts_volume_gbits = {
        'data': df[insts].filter(like='Volume'),
        'title': 'Data Rate [Gbit/s]'}
    df_insts_upload_kbitsps = {
        'data': df[insts].filter(like='Upload'),
        'title': ''}
    df_ssmm_accum_gbits = {
        'data': df.filter(like='SSMM').filter(like='Accum'),
        'title': ''}
    df_ssmm_volume_gbits = {
        'data': df.filter(like='SSMM').filter(like='Volume'),
        'title': ''}

    # select dataframe to use
    df = df_insts_volume_gbits

    labels = insts # df.columns.tolist()

    data = serialize(df['data'], render_to='datarate', title='',
                       output_type='dict')

    for x in data['series']:
        x['name'] = x['name'][0]

    # data['subtitle'] = {'text': 'a subtitle here...'}
    data['plotOptions'] = {'spline': {
         'lineWidth': 2,
         'states': {
         'hover': {
         'lineWidth': 3}
         }}}
    data['chart']['type'] = 'line'
    data['chart']['zoomType'] = 'x'
    data['chart']['panning'] = True
    data['chart']['panKey'] = 'shift'
    data['title']['text'] = df['title']

    result = 'new Highcharts.StockChart({});'.format(json_encode(data))

    return result
Beispiel #3
0
def compute_highcharts(A, b, w, T, resolution=10000):
    """Return filename of plot of the damped_vibration function."""
    t = linspace(0, T, resolution+1)
    u = damped_vibrations(t, A, b, T)
    d = {'t': t, 'u': u}
    df = pd.DataFrame(d)
    df.set_index('t', inplace=True)

    data = serialize(df, output_type='dict', chart_type='stock',
                      render_to='my-chart',
                      )

    data['chart']['type'] = 'line'
    data['chart']['zoomType'] = 'x'
    data['chart']['panning'] = True
    data['chart']['panKey'] = 'shift'
    data['chart']['plotBackgroundColor'] = '#FCFFC5'

    data["plotOptions"] = {
                "spline": {
                    "color": "#FF0000",
                    "lineWidth": 1,
                    "states": { "hover": { "lineWidth": 1 } },
                    "marker": {"enabled": True }
                }
            }

    chart = 'new Highcharts.Chart({});'.format(json_encode(data))

    return chart
Beispiel #4
0
def timeline_pandas_highcharts():
    """Return filename of plot of the damped_vibration function."""

    data = defaultdict(lambda: defaultdict(dict))

    timeline_data = pd.read_csv('timeline.txt')

    data['chart']['type'] = 'columnrange'
    data['chart']['inverted'] = True
    data['chart']['zoomType'] = 'y'
    data['chart']['panning'] = True
    data['chart']['panKey'] = 'shift'
    data['chart']['renderTo'] = 'my-chart'

    data['title']['text'] = 'BepiTimeline Test'

    data['scrollbar']['enable'] = True

    data['xAxis']['categories'] = list(set(timeline_data['Instrument'].values.tolist()))

    data['yAxis']['type'] = 'datetime'

    data['yAxis']['title']['text'] = 'Timespan'

    data['plotOptions']['columnrange']['grouping'] =  False

    data['legend']['enabled'] = True

    data['tooltip']['headerFormat'] = '<b>{series.name}</b><br/>'
    data['tooltip']['pointFormat'] = '{point.low} - {point.high}'

    data['series'] = []

    grouped = timeline_data.groupby('Instrument')
    grouped = [grouped.get_group(x) for x in grouped.groups]

    for level, frame in enumerate(grouped):
        df = {}
        df['name'] = frame['Instrument'].values[0]
        df['data'] = []

        for row in frame.itertuples():
            block = {}
            block['x'] = level
            st = dt.strptime(row[2], '%Y-%m-%d %H:%M')
            st = int((st-dt(1970,1,1)).total_seconds()*1000)
            en = dt.strptime(row[3], '%Y-%m-%d %H:%M')
            en = int((en-dt(1970,1,1)).total_seconds()*1000)
            block['low'] = st
            block['high'] = en
            block['mode'] = row[4]
            block['power'] = row[5]
            block['data_rate'] = row[6]
            df['data'].append(block)

        data['series'].append(df)

    chart = 'new Highcharts.Chart({});'.format(json_encode(data))

    print( data['title']['text'] )

    return [data['series'], data['xAxis']['categories'], data['title']['text']]