# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3.6.9 64-bit
#     language: python
#     name: python3
# ---

# # Gearbox Fault Diagnosis
#
# - [https://www.kaggle.com/brjapon/gearbox-fault-diagnosis](https://www.kaggle.com/brjapon/gearbox-fault-diagnosis)
# - [https://openei.org/datasets/dataset/gearbox-fault-diagnosis-data](https://openei.org/datasets/dataset/gearbox-fault-diagnosis-data)
#

import pandas as pd
import matplotlib.pyplot as plt


def load_data(label='h', load=0):
    return pd.read_csv(f'{label}30hz{load}.csv.gz')


pd.read_csv('h30hz90.csv.gz').plot()

pd.read_csv('b30hz90.csv.gz').plot()

print("Healthy | BrokenTooth")
for i in range(0, 100, 10):
    print(pd.read_csv(f'h30hz{i}.csv.gz').shape,
          pd.read_csv(f'b30hz{i}.csv.gz').shape)
    

def plot_sequence(df, st=0, ed=None, ax=None, figsize=(10, 3), individual=True):

    if ed is None:
        ed = df.shape[0]

    if individual:
        if not ax is None:
            assert len(ax) == 4
        else:
            fig, ax = plt.subplots(4, figsize=figsize)

        for i in range(4):
            df.iloc[st:ed, i].plot(ax=ax[i], figsize=figsize, legend=True)

    else:
        if ax is None:
            fig, ax = plt.subplots(figsize=figsize)

        df.iloc[st:ed].plot(ax=ax, figsize=figsize, legend=True)


plot_sequence(load_data(), st=100, ed=200, individual=False)

# +
label = 'h'
load = 0
wd = 20
hg = 8
fig, ax = plt.subplots(5)
plot_sequence(load_data(label=label, load=load), st=0, ed=500, ax=ax[:4], figsize=(wd, hg), individual=True)
plot_sequence(load_data(label=label, load=load), st=0, ed=500, ax=ax[-1], figsize=(wd, hg), individual=False)

ax[-1].set_xlabel('Time')
for axi in ax: axi.set_ylabel('Value')
name = 'Healty' if label == 'h' else 'BrokenTooth'
ax[0].set_title(f'{name}: Load= {load}')
# -



StarcoderdataJupyterScriptsDedupFiltered