import pandas as pd
import matplotlib.pyplot as plt
import datetime
import numpy as np

#normal_datafiles_list=['2025-01-08_5_','2025-01-09_5_','2025-01-10_5_','2025-01-11_5_']
normal_datafiles_list=['2025-01-09_5_','2025-01-10_5_','2025-01-11_5_']
anormal_datafiles_list=['2025-01-04_5_','2025-01-05_5_','2025-01-06_5_','2025-01-07_5_']

cols=['r1 s1','r1 s4','r1 s5','pa1 apiii']

df_list=[]
for f in normal_datafiles_list:
    #df1 = pd.read_csv('./data/'+f+'.csv', parse_dates=['datetime'], dayfirst=True, index_col='datetime')
    df1 = pd.read_csv('./data/'+f+'.csv')
    df_list.append(df1)

df=pd.concat(df_list)
datalength=df.shape[0]
# subsampled to 5'  =  30 * 10"
normaldataframe=df.iloc[range(0,datalength,30)][cols]
normaldataframe.reset_index(inplace=True,drop=True)
normaldata=normaldataframe.values


df_list=[]
for f in anormal_datafiles_list:
    #df1 = pd.read_csv('./data/'+f+'.csv', parse_dates=['datetime'], dayfirst=True, index_col='datetime')
    df1 = pd.read_csv('./data/'+f+'.csv')
    df_list.append(df1)

df=pd.concat(df_list)
datalength=df.shape[0]
# subsampled to 5'  =  30 * 10"
anormaldataframe=df.iloc[range(0,datalength,30)][cols]
anormaldataframe.reset_index(inplace=True,drop=True)
anormaldata=anormaldataframe.values


nplots=len(cols)

plt.rcParams.update({'font.size': 10})
f,ax = plt.subplots(int(np.ceil(nplots/2)),2,figsize=(24,17), dpi=80, facecolor='white', edgecolor='k')    
for i in range(int(np.ceil(nplots/2))):
    for j in range(2):
        r=i*2+j
        if r<nplots:
            ax[i][j].plot(normaldata[:,r],label='normal')
            ax[i][j].plot(anormaldata[:,r],label='abnormal')
            ax[i][j].set_title(anormaldataframe.columns[r])
            ax[i][j].legend()
plt.show()
