Skip to content
Snippets Groups Projects
Commit 934e8e10 authored by Leah Tacke genannt Unterberg's avatar Leah Tacke genannt Unterberg
Browse files

initial

parent b3236d41
No related branches found
No related tags found
No related merge requests found
########################################################################
# Python - https://github.com/github/gitignore/blob/master/Python.gitignore
########################################################################
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# Distribution / packaging
build/
dist/
eggs/
.eggs/
*.egg-info/
*.egg
.prerelease-version
# Autogenerated Protobufs
lib/streamlit/proto/*_pb2.py
lib/streamlit/proto/*_pb2.pyi
frontend/src/lib/proto.js
frontend/src/lib/proto.d.ts
########################################################################
# Streamlit
########################################################################
#.streamlit/
lib/streamlit/static
streamlit-storage
# Data Files
uploads
########################################################################
# JetBrains
########################################################################
.idea
\ No newline at end of file
[server]
maxUploadSize = 4096
\ No newline at end of file
This is the official machine data visualization app package.
It is built atop the base mdata package and makes conversion and visualization tools contained therein interactively accessible.
\ No newline at end of file
import numpy as np
import pandas as pd
import streamlit as st
from mdata.visualization import plotting
from plotly import graph_objects as go
from plotly.subplots import make_subplots
available_widgets = ['Specifications', 'Raw Data', 'Overview', 'Inspector']
def generate_page(md, widget):
c = st.columns(3)
c[0].metric('#Observations', len(md.index_frame))
c[1].metric('#Event Types', len(md.event_series_types))
c[2].metric('#Measurement Types', len(md.measurement_series_types))
c = st.columns(2)
cont = c[0].container()
cont.text(md.index_frame['time'].min())
cont.caption('First Observation')
cont = c[1].container()
cont.text(md.index_frame['time'].max())
cont.caption('Last Observation')
if widget not in available_widgets:
return
if widget == 'Specifications':
st.markdown('## Events')
st.table(make_spec_df(md.event_series_types))
st.markdown('## Measurements')
st.table(make_spec_df(md.measurement_series_types))
if widget == 'Raw Data':
st.write(md.index_frame)
if widget == 'Overview':
f = plotting.create_overview_plot(md, downsample_to=5_000)
st.plotly_chart(f, use_container_width=True)
if widget == 'Inspector':
c1, c2, c3 = st.columns(3)
object_list = list(md.get_unique_objects())
event_type_list = list(md.event_series_types.keys())
measurement_type_list = list(md.measurement_series_types.keys())
selected_measurement_type = c1.selectbox('Measurement Type', measurement_type_list)
fs = md.measurement_series_types[selected_measurement_type].features
measurement_feature_selection = c1.multiselect('Feature Selection', fs)
event_selection = c2.multiselect('Event Type Selection', event_type_list)
object_selection = c3.selectbox('Object Selection', object_list)
df = md.measurement_series[selected_measurement_type].df
downsample_to = 15_000
should_downsample = False
if len(df) > downsample_to:
st.text('will have to downsample ☹️')
should_downsample = True
from tsdownsample import MinMaxLTTBDownsampler
sampler = MinMaxLTTBDownsampler()
df = df.loc[df.object == object_selection, ['time'] + measurement_feature_selection]
fig = make_subplots(rows=2, cols=1, row_heights=[0.9, 0.1], shared_xaxes=True, vertical_spacing=0.05)
for f in measurement_feature_selection:
# go.scatter.Line()
x, y = df.time, df[f]
if should_downsample:
x = x.values
y = y.values
sidx = sampler.downsample(x, y, n_out=downsample_to)
x = x[sidx] # .iloc[sidx, 'time']
y = y[sidx] # .iloc[sidx, f]
fig.add_trace(go.Scattergl(name=f, x=x, y=y, mode='lines'), row=1, col=1)
for e in event_selection:
edf = md.event_series[e].df
edf = edf.loc[edf.object == object_selection]
fig.add_trace(
go.Scatter(name=e, x=edf.time, y=np.zeros_like(edf.time), mode='markers',
marker=dict(size=10, line_width=4, symbol='line-ns-open')), row=2, col=1)
fig.update_yaxes(row=2, col=1, visible=False)
fig.update_layout(title_text='Timeseries', showlegend=True,
legend=dict(x=0, y=-0.2, orientation='h'))
st.plotly_chart(fig, use_container_width=True)
def make_spec_df(spec_types):
df = pd.DataFrame.from_dict({l: list(t.features) for l, t in spec_types.items()},
orient='index').replace(pd.NA, '')
df.columns = [f'f_{i}' for i in range(1, len(df.columns) + 1)]
return df
import mdata.file_formats.csv
import streamlit as st
from logic.page_logic import generate_page, available_widgets
@st.cache_data
def load_data():
return mdata.file_formats.csv.read_machine_data('resources/mock_header.csv', 'resources/mock_data.csv')
md = load_data()
selected_widget = st.sidebar.selectbox('Widget', available_widgets)
generate_page(md, selected_widget)
poetry.lock 0 → 100644
Source diff could not be displayed: it is too large. Options to address this: view the blob.
[tool.poetry]
name = "mdata-app"
version = "0.1.0"
description = ""
authors = ["Leah Tacke genannt Unterberg <leah.tgu@pads.rwth-aachen.de>"]
packages = [{ include = "mdata_app" }]
readme = "README.md"
license = "MIT"
[tool.poetry.dependencies]
python = "^3.9,!=3.9.7"
# flask = "^2.2.3"
streamlit = "^1.21"
mdata = { path = "C:/Users/Leah/PycharmProjects/mdata", develop = true }
# mdata = { git = "git@git-ce.rwth-aachen.de:leah.tgu/mdata.git", branch = "master" }
seaborn = "^0.12.2"
plotly = "^5.14.1"
tsdownsample = "^0.1.2"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
time,object,type,label,f_1,f_2,f_3
2023-04-24T09:57:10.0,m_1,E,on
2023-04-24T09:57:15.0,m_1,M,source_A,50,6.9,4
2023-04-24T09:58:00.0,m_1,M,source_B,2,-3.5,90
2023-04-24T09:59:45.0,m_1,E,error,"exceptional behavior"
2023-04-24T10:00:00.0,m_1,M,source_B,1,-4,80
2023-04-24T10:00:15.0,m_1,M,source_A,50,7,-4
2023-04-24T10:01:10.0,m_1,E,error,"cascading exceptional behavior"
2023-04-24T10:02:00.0,m_1,M,source_B,.5,-4.5,75
2023-04-24T10:03:15.0,m_1,M,source_A,20,7.2,-40
2023-04-24T10:03:55.0,m_1,E,rapid_unplanned_disassembly,200
2023-04-24T10:04:00.0,m_1,M,source_B,NaN,NaN,NaN
2023-04-24T10:05:00.0,m_1,E,off
E,on
E,off
E,error,code
E,rapid_unplanned_disassembly,explosion_size
M,source_A,x,y,z
M,source_B,f,r,phi
import streamlit as st
from logic.switch_page import switch_page
st.set_page_config(layout="wide")
st.title('Welcome to the Machine Data Demo Website')
got_to_demo = st.button('Got to Demo')
go_to_file_viewer = st.button('Got to File Viewer')
if got_to_demo:
switch_page('demo_page')
elif go_to_file_viewer:
switch_page('upload_page')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment