Brak opisu

v1.py 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import pandas as pd
  2. import matplotlib.pyplot as plt
  3. import datetime
  4. import numpy as np
  5. #normal_datafiles_list=['2025-01-08_5_','2025-01-09_5_','2025-01-10_5_','2025-01-11_5_']
  6. normal_datafiles_list=['2025-01-09_5_','2025-01-10_5_','2025-01-11_5_']
  7. anormal_datafiles_list=['2025-01-04_5_','2025-01-05_5_','2025-01-06_5_','2025-01-07_5_']
  8. cols=['r1 s1','r1 s4','r1 s5','pa1 apiii']
  9. df_list=[]
  10. for f in normal_datafiles_list:
  11. #df1 = pd.read_csv('./data/'+f+'.csv', parse_dates=['datetime'], dayfirst=True, index_col='datetime')
  12. df1 = pd.read_csv('./data/'+f+'.csv')
  13. df_list.append(df1)
  14. df=pd.concat(df_list)
  15. datalength=df.shape[0]
  16. # subsampled to 5' = 30 * 10"
  17. normaldataframe=df.iloc[range(0,datalength,30)][cols]
  18. normaldataframe.reset_index(inplace=True,drop=True)
  19. normaldata=normaldataframe.values
  20. df_list=[]
  21. for f in anormal_datafiles_list:
  22. #df1 = pd.read_csv('./data/'+f+'.csv', parse_dates=['datetime'], dayfirst=True, index_col='datetime')
  23. df1 = pd.read_csv('./data/'+f+'.csv')
  24. df_list.append(df1)
  25. df=pd.concat(df_list)
  26. datalength=df.shape[0]
  27. # subsampled to 5' = 30 * 10"
  28. anormaldataframe=df.iloc[range(0,datalength,30)][cols]
  29. anormaldataframe.reset_index(inplace=True,drop=True)
  30. anormaldata=anormaldataframe.values
  31. nplots=len(cols)
  32. plt.rcParams.update({'font.size': 10})
  33. f,ax = plt.subplots(int(np.ceil(nplots/2)),2,figsize=(24,17), dpi=80, facecolor='white', edgecolor='k')
  34. for i in range(int(np.ceil(nplots/2))):
  35. for j in range(2):
  36. r=i*2+j
  37. if r<nplots:
  38. ax[i][j].plot(normaldata[:,r],label='normal')
  39. ax[i][j].plot(anormaldata[:,r],label='abnormal')
  40. ax[i][j].set_title(anormaldataframe.columns[r])
  41. ax[i][j].legend()
  42. plt.show()

Powered by TurnKey Linux.