-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kokikwbt
committed
Nov 3, 2021
1 parent
09b7172
commit 88253b7
Showing
82 changed files
with
2,431 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,4 +129,7 @@ dmypy.json | |
.pyre/ | ||
raw | ||
processed | ||
out | ||
out | ||
|
||
*.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from . import alpi | ||
from . import cbm | ||
from . import gdd | ||
from . import gfd | ||
from . import hydsys | ||
from . import mapm | ||
from . import ppd | ||
from . import ufd |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
import datetime | ||
import os | ||
import matplotlib.pyplot as plt | ||
from matplotlib.backends.backend_pdf import PdfPages | ||
import pandas as pd | ||
import seaborn as sns | ||
|
||
|
||
def load_data(index='state'): | ||
|
||
assert index in ['state', 'anomaly', 'normal', 'linear', 'pressure'] | ||
fp = os.path.dirname(__file__) | ||
|
||
if index == 'state': | ||
df = pd.read_csv(fp + '/Genesis_StateMachineLabel.csv.gz') | ||
elif index == 'anomaly': | ||
df = pd.read_csv(fp + '/Genesis_AnomalyLabels.csv.gz') | ||
elif index == 'normal': | ||
df = pd.read_csv(fp + '/Genesis_normal.csv.gz') | ||
df.Timestamp = df.Timestamp / 1000 | ||
elif index == 'linear': | ||
df = pd.read_csv(fp + '/Genesis_lineardrive.csv.gz') | ||
df.Timestamp = df.Timestamp / 1000 | ||
elif index == 'pressure': | ||
df = pd.read_csv(fp + '/Genesis_pressure.csv.gz') | ||
df.Timestamp = df.Timestamp / 1000 | ||
|
||
df.Timestamp = df.Timestamp.apply(datetime.datetime.fromtimestamp) | ||
|
||
return df | ||
|
||
|
||
def plot_genesis_labels(df, figsize=(15, 20), cmap='tab10'): | ||
""" Call this for machine states and anomaly labels """ | ||
|
||
fig, ax = plt.subplots(10, figsize=figsize) | ||
|
||
df['MotorData.ActCurrent'].plot(ax=ax[0], legend=True, cmap=cmap) | ||
df['MotorData.ActPosition'].plot(ax=ax[1], legend=True, cmap=cmap) | ||
df['MotorData.ActSpeed'].plot(ax=ax[2], legend=True, cmap=cmap) | ||
|
||
df['MotorData.IsAcceleration'].plot(ax=ax[3], legend=True, cmap=cmap) | ||
df['MotorData.IsForce'].plot(ax=ax[4], legend=True, cmap=cmap) | ||
|
||
df[['MotorData.Motor_Pos1reached', # binary | ||
'MotorData.Motor_Pos2reached', # binary | ||
'MotorData.Motor_Pos3reached', # binary | ||
'MotorData.Motor_Pos4reached', # binary | ||
]].plot(ax=ax[5], legend=True, cmap=cmap) | ||
|
||
df[['NVL_Recv_Ind.GL_Metall', # binary | ||
'NVL_Recv_Ind.GL_NonMetall', # binary | ||
]].plot(ax=ax[6], legend=True, cmap=cmap) | ||
|
||
df[['NVL_Recv_Storage.GL_I_ProcessStarted', # binary | ||
'NVL_Recv_Storage.GL_I_Slider_IN', # binary | ||
'NVL_Recv_Storage.GL_I_Slider_OUT', # binary | ||
'NVL_Recv_Storage.GL_LightBarrier', # binary | ||
'NVL_Send_Storage.ActivateStorage', # binary | ||
]].plot(ax=ax[7], legend=True, cmap=cmap) | ||
|
||
df[['PLC_PRG.Gripper', # binary | ||
'PLC_PRG.MaterialIsMetal', # binary | ||
]].plot(ax=ax[8], legend=True, cmap=cmap) | ||
|
||
df['Label'].plot(ax=ax[9], legend=True, cmap=cmap) | ||
|
||
for axi in ax: | ||
axi.set_xlim(0, df.shape[0]) | ||
axi.set_ylabel('Value') | ||
|
||
ax[0].set_title('Date: {} to {}'.format( | ||
df.Timestamp.min(), df.Timestamp.max())) | ||
ax[-1].set_xlabel('Time') | ||
fig.tight_layout() | ||
|
||
return fig, ax | ||
|
||
|
||
def plot_genesis_nonlabels(df, figsize=(15, 20), cmap='tab10'): | ||
""" Call this for non-labeled data """ | ||
|
||
fig, ax = plt.subplots(8, figsize=figsize) | ||
|
||
df[['MotorData.SetCurrent', | ||
'MotorData.ActCurrent', | ||
]].plot(ax=ax[0], legend=True, cmap=cmap) | ||
|
||
df[['MotorData.SetSpeed', | ||
'MotorData.ActSpeed', | ||
]].plot(ax=ax[1], legend=True, cmap=cmap) | ||
|
||
df[['MotorData.SetAcceleration', | ||
'MotorData.IsAcceleration', | ||
]].plot(ax=ax[2], legend=True, cmap=cmap) | ||
|
||
df[['MotorData.SetForce', | ||
'MotorData.IsForce' | ||
]].plot(ax=ax[3], legend=True, cmap=cmap) | ||
|
||
df[['MotorData.Motor_Pos1reached', # binary | ||
'MotorData.Motor_Pos2reached', # binary | ||
'MotorData.Motor_Pos3reached', # binary | ||
'MotorData.Motor_Pos4reached', # binary | ||
]].plot(ax=ax[4], legend=True, cmap=cmap) | ||
|
||
df[['NVL_Recv_Ind.GL_Metall', # binary | ||
'NVL_Recv_Ind.GL_NonMetall', # binary | ||
]].plot(ax=ax[5], legend=True, cmap=cmap) | ||
|
||
df[['NVL_Recv_Storage.GL_I_ProcessStarted', # binary | ||
'NVL_Recv_Storage.GL_I_Slider_IN', # binary | ||
'NVL_Recv_Storage.GL_I_Slider_OUT', # binary | ||
'NVL_Recv_Storage.GL_LightBarrier', # binary | ||
'NVL_Send_Storage.ActivateStorage', # binary | ||
]].plot(ax=ax[6], legend=True, cmap=cmap) | ||
|
||
df[['PLC_PRG.Gripper', # binary | ||
'PLC_PRG.MaterialIsMetal', # binary | ||
]].plot(ax=ax[7], legend=True, cmap=cmap) | ||
|
||
for axi in ax: | ||
axi.set_xlim(0, df.shape[0]) | ||
axi.set_ylabel('Value') | ||
|
||
ax[0].set_title('Date: {} to {}'.format(df.Timestamp.min(), df.Timestamp.max())) | ||
ax[-1].set_xlabel('Time') | ||
|
||
fig.tight_layout() | ||
return fig, ax | ||
|
||
|
||
def gen_summary(outdir='../out'): | ||
|
||
os.makedirs(outdir, exist_ok=True) | ||
fp = os.path.dirname(__file__) | ||
sns.set(font_scale=1.1, style='whitegrid') | ||
|
||
with PdfPages(outdir + '/gdd_summary.pdf') as pp: | ||
|
||
print('Plotting Genesis_StateMachineLabel...') | ||
df = load_data(index='state') | ||
fig, _ = plot_genesis_labels(df) | ||
fig.savefig(pp, bbox_inches='tight', format='pdf') | ||
plt.clf() | ||
plt.close() | ||
|
||
print('Plotting Genesis_AnomalyLabels...') | ||
df = load_data(index='anomaly') | ||
fig, _ = plot_genesis_labels(df) | ||
fig.savefig(pp, bbox_inches='tight', format='pdf') | ||
plt.clf() | ||
plt.close() | ||
|
||
print('Plotting Genesis_normal...') | ||
df = load_data(index='normal') | ||
fig, _ = plot_genesis_nonlabels(df) | ||
fig.savefig(pp, bbox_inches='tight', format='pdf') | ||
plt.clf() | ||
plt.close() | ||
|
||
print('Plotting Genesis_lineardrive...') | ||
df = load_data(index='linear') | ||
fig, _ = plot_genesis_nonlabels(df) | ||
fig.savefig(pp, bbox_inches='tight', format='pdf') | ||
plt.clf() | ||
plt.close() | ||
|
||
print('Plotting Genesis_pressure...') | ||
df = load_data(index='pressure') | ||
fig, _ = plot_genesis_nonlabels(df) | ||
fig.savefig(pp, bbox_inches='tight', format='pdf') | ||
plt.clf() | ||
plt.close() | ||
|
||
print("done!") |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import os | ||
import numpy as np | ||
import pandas as pd | ||
|
||
|
||
def make_pressure_dataframe(fp, cycle_id=0): | ||
""" 100 Hz. 6000 samples in each cycle | ||
""" | ||
data = pd.DataFrame(columns=[f'PS{i+1}' for i in range(6)]) | ||
for i in range(6): | ||
data[f'PS{i+1}'] = np.loadtxt(fp + f'/PS{i+1}.txt.gz')[cycle_id] | ||
|
||
return data | ||
|
||
|
||
def make_motor_power_dataframe(fp, cycle_id=0): | ||
""" 100 Hz. 6000 samples in each cycle | ||
""" | ||
return pd.DataFrame(np.loadtxt(fp + '/EPS1.txt.gz')[cycle_id], columns=['EPS1']) | ||
|
||
|
||
def make_volume_flow_dataframe(fp, cycle_id=0): | ||
""" 10 Hz. 600 samples in each cycle | ||
""" | ||
data = pd.DataFrame(columns=['FS1', 'FS2']) | ||
data['FS1'] = np.loadtxt(fp + '/FS1.txt.gz')[cycle_id] | ||
data['FS2'] = np.loadtxt(fp + '/FS2.txt.gz')[cycle_id] | ||
return data | ||
|
||
|
||
def make_temp_dataframe(cycle_id=0): | ||
""" 1 Hz. 60 samples in each cycle | ||
""" | ||
fp = os.path.dirname(__file__) | ||
data = pd.DataFrame(columns=[f'TS{i+1}' for i in range(4)]) | ||
data['TS1'] = np.loadtxt(fp + '/TS1.txt.gz')[cycle_id] | ||
data['TS2'] = np.loadtxt(fp + '/TS2.txt.gz')[cycle_id] | ||
data['TS3'] = np.loadtxt(fp + '/TS3.txt.gz')[cycle_id] | ||
data['TS4'] = np.loadtxt(fp + '/TS4.txt.gz')[cycle_id] | ||
return data | ||
|
||
|
||
def make_vibration_dataframe(cycle_id=0): | ||
fp = os.path.dirname(__file__) | ||
return pd.DataFrame(np.loadtxt(fp + '/VS1.txt.gz')[cycle_id], columns=['VS1']) | ||
|
||
|
||
def make_efficiency_dataframe(cycle_id=0): | ||
fp = os.path.dirname(__file__) | ||
return pd.DataFrame(np.loadtxt(fp + '/SE.txt.gz')[cycle_id], columns=['SE']) | ||
|
||
|
||
def make_cooling_dataframe(cycle_id=0): | ||
fp = os.path.dirname(__file__) | ||
data = pd.DataFrame(columns=['CE', 'CP']) | ||
data['CE'] = np.loadtxt(fp + '/CE.txt.gz')[cycle_id] | ||
data['CP'] = np.loadtxt(fp + '/CP.txt.gz')[cycle_id] | ||
return data | ||
|
||
|
||
def make_condition_dataframe(): | ||
fp = os.path.dirname(__file__) | ||
return pd.DataFrame(np.loadtxt(fp + '/profile.txt'), | ||
columns=[ | ||
'cooler_condition', | ||
'valve_condition', | ||
'internal_pump_leakage', | ||
'hydraulic_accumulator', | ||
'stable_flag']).reset_index().rename( | ||
columns={'index': 'cycle'}) | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import os | ||
import pandas as pd | ||
import numpy as np | ||
|
||
|
||
def load_data(meter_id='A'): | ||
fp = os.path.dirname(__file__) | ||
data = np.loadtxt(fp + '/Meter{}.txt'.format(meter_id)) | ||
|
||
if meter_id == 'A': | ||
columns = ['flatness_ratio', 'symmetry', 'crossflow'] | ||
columns += ['flow_velocity_{}'.format(i+1) for i in range(8)] | ||
columns += ['sound_speed_{}'.format(i+1) for i in range(8)] | ||
columns += ['average_speed'] | ||
columns += ['gain_{}'.format(i+1) for i in range(16)] | ||
columns += ['health_state'] | ||
|
||
if meter_id == 'B': | ||
columns = ['profile_factor', 'symmetry', 'crossflow', 'swirl_angle'] | ||
columns += ['flow_velocity_{}'.format(i+1) for i in range(4)] | ||
columns += ['average_flow'] | ||
columns += ['sound_speed_{}'.format(i+1) for i in range(4)] | ||
columns += ['average_speed'] | ||
columns += ['signal_strength_{}'.format(i+1) for i in range(8)] | ||
columns += ['turbulence_{}'.format(i+1) for i in range(4)] | ||
columns += ['meter_performance'] | ||
columns += ['signal_quality_{}'.format(i+1) for i in range(8)] | ||
columns += ['gain_{}'.format(i+1) for i in range(8)] | ||
columns += ['transit_time_{}'.format(i+1) for i in range(8)] | ||
columns += ['health_state'] | ||
|
||
if meter_id == 'C' or meter_id == 'D': | ||
columns = ['profile_factor', 'symmetry', 'crossflow'] | ||
columns += ['flow_velocity_{}'.format(i+1) for i in range(4)] | ||
columns += ['sound_speed_{}'.format(i+1) for i in range(4)] | ||
columns += ['signal_strength_{}'.format(i+1) for i in range(8)] | ||
columns += ['signal_quality_{}'.format(i+1) for i in range(8)] | ||
columns += ['gain_{}'.format(i+1) for i in range(8)] | ||
columns += ['transit_time_{}'.format(i+1) for i in range(8)] | ||
columns += ['health_state'] | ||
|
||
return pd.DataFrame(data, columns=columns) |
Oops, something went wrong.