Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- #
- import plotly.graph_objs as go
- import pandas as pd
- import dash
- import dash_core_components as dcc
- import dash_html_components as html
- from dash.dependencies import Input, Output
- import os
- import numpy as np
- temps=[]
- for name in os.listdir():
- if name.find('tempdatalog')!=-1:
- temps.append(name)
- #temps=sorted(temps)
- temps.sort()
- with open(temps[0]) as f:
- header = f.readline()
- dflist=[]
- for name in temps:
- dflist.append(pd.read_csv(name, sep = '\t', skiprows=4,
- usecols=["Date", "Time", "RTD", "TC1", "TC2", "TC3", "TC4", "TC6", "TC7", "TC9", "TC10"],
- dtype={"RDT": np.float64, "TC1": np.float64, "TC2": np.float64, "TC3": np.float64,"TC4": np.float64, "TC6": np.float64, "TC7": np.float64, "TC9": np.float64, "TC10": np.float64}))
- for frame in dflist:
- frame.set_index(pd.to_datetime(frame['Date']+' '+frame['Time'], format= '%m/%d/%Y %H:%M:%S'), inplace=True)
- #frame.set_index(pd.to_datetime(frame['Date']+' '+frame['Time']), inplace=True)
- for frame in dflist:
- frame.drop(['Date','Time'], axis=1, inplace=True)
- for frame in dflist:
- frame.rename(columns={'RTD':'RTD', 'TC1':'1 st suction', 'TC2':'condenser air inlet', 'TC3':'Evap in',
- 'TC4':'Evap out', 'TC6':'2 stage suction', 'TC7':'Liquid line', 'TC9':'2 stage sump', 'TC10':'HX'}, inplace=True)
- print(enumerate(dflist))
- for i, frame in enumerate(dflist):
- print(dflist[i].info())
- print(len(dflist))
- print(len(temps))
- app = dash.Dash()
- app.layout = html.Div([
- html.Div([
- html.Label(header)
- ], style={'padding':'15','border':'2px black solid'}),
- html.Div([
- dcc.Graph(id='feature-graphic')
- ], style={'padding':'100','border':'2px blue solid','height':'800','float':'bottom'}),
- html.Div([
- dcc.Dropdown(
- id = 'month',
- options = [{'label': i, 'value': temps.index(i)} for i in temps],
- value=0
- )
- ], style={'padding':'15','border':'2px red solid'})
- ])
- @app.callback(
- Output('feature-graphic', 'figure'),
- [Input('month', 'value')])
- def update_graph(month):
- print(dflist[month].index)
- return {
- 'data' : [
- go.Scatter(
- x=dflist[month].index,
- y=dflist[month][name],
- name=name,
- mode = 'lines'
- ) for name in dflist[month].columns
- ],
- 'layout': go.Layout(
- xaxis={'title': 'Time', 'type':'date'},
- yaxis={'title': 'Temperature'},
- title=header,
- hovermode='closest',
- )
- }
- if __name__ == '__main__':
- app.run_server()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement