当前位置:   article > 正文

西储大学轴承监测数据集及数据集分类_西储大学轴承数据集

西储大学轴承数据集

1.数据集简介

        振动数据来源于美国凯斯西储大学的开发数据集。轴承试验装置的示意图如图1-1所示。平台组成:

        一个1.5KW(2马力)的电动机(图左侧);

        一个扭矩传感器/ 译码器(图中间连接处);

        一个功率测试计(图右侧);

        驱动端轴承为SKF6205 ,采样频率为12Khz和48Khz;

        电子控制器(图中没显示) 。

DE - drive end accelerometer data 驱动端加速度数据;

FE - fan end accelerometer data 风扇端加速度数据;

BA - base accelerometer data 基座加速度数据(正常);

time - time series data 时间序列数据;

RPM- rpm during testing 转每分钟,除以60为旋转频率;

B -滚动体故障;IR – 内圈故障;OR –外圈故障;

驱动端和风扇端轴承外圈的损伤点分别放置在3点钟、6点钟、12点钟三个不同位置。

数据文件为Matlab格式。每个文件包含风扇和驱动端振动数据,以及电机转速。

 例子:12k_Fan_End_OR007@6_3_297.mat

        12k:12KHZ采样频率

        Fan_End_OR:风扇端外圈故障

        007:直径

        @6:外圈的损伤点在6点钟位置

        3:表电机载荷模式

         297:编号。

数据集由

        12kHz采样率下电机端轴承的故障数据(DE)60个、

        12kHz采样率下风扇端轴承的故障数据(FE)45个、

        48kHz采样率下电机端轴承的故障数据(DE)52个,

        还有正常运转的轴承数据4个组成。

图1-2  12k驱动端故障数据列表

2.数据集下载

3.python 训练及验证数据集制作代码.

  1. from scipy.io import loadmat
  2. import numpy as np
  3. import os
  4. from sklearn import preprocessing # 0-1编码
  5. from sklearn.model_selection import StratifiedShuffleSplit # 随机划分,保证每一类比例相同
  6. def prepro(d_path, length=864, number=1000, normal=True, rate=[0.5, 0.25, 0.25], enc=True, enc_step=28):
  7. """对数据进行预处理,返回train_X, train_Y, valid_X, valid_Y, test_X, test_Y样本.
  8. :param d_path: 源数据地址
  9. :param length: 信号长度,默认2个信号周期,864
  10. :param number: 每种信号个数,总共10类,默认每个类别1000个数据
  11. :param normal: 是否标准化.True,Fales.默认True
  12. :param rate: 训练集/验证集/测试集比例.默认[0.5,0.25,0.25],相加要等于1
  13. :param enc: 训练集、验证集是否采用数据增强.Bool,默认True
  14. :param enc_step: 增强数据集采样顺延间隔
  15. :return: Train_X, Train_Y, Valid_X, Valid_Y, Test_X, Test_Y
  16. ```
  17. import preprocess.preprocess_nonoise as pre
  18. train_X, train_Y, valid_X, valid_Y, test_X, test_Y = pre.prepro(d_path=path,
  19. length=864,
  20. number=1000,
  21. normal=False,
  22. rate=[0.5, 0.25, 0.25],
  23. enc=True,
  24. enc_step=28)
  25. ```
  26. """
  27. # 获得该文件夹下所有.mat文件名
  28. filenames = os.listdir(d_path)
  29. def capture(original_path):
  30. """读取mat文件,返回字典
  31. :param original_path: 读取路径
  32. :return: 数据字典
  33. """
  34. files = {}
  35. for i in filenames:
  36. # 文件路径
  37. file_path = os.path.join(d_path, i)
  38. file = loadmat(file_path)
  39. file_keys = file.keys()
  40. for key in file_keys:
  41. if 'DE' in key:
  42. files[i] = file[key].ravel()
  43. return files
  44. def slice_enc(data, slice_rate=rate[1] + rate[2]):
  45. """将数据切分为前面多少比例,后面多少比例.
  46. :param data: 单挑数据
  47. :param slice_rate: 验证集以及测试集所占的比例
  48. :return: 切分好的数据
  49. """
  50. keys = data.keys()
  51. Train_Samples = {}
  52. Test_Samples = {}
  53. for i in keys:
  54. slice_data = data[i]
  55. all_lenght = len(slice_data)
  56. end_index = int(all_lenght * (1 - slice_rate))
  57. samp_train = int(number * (1 - slice_rate)) # 700
  58. Train_sample = []
  59. Test_Sample = []
  60. if enc:
  61. enc_time = length // enc_step
  62. samp_step = 0 # 用来计数Train采样次数
  63. for j in range(samp_train):
  64. random_start = np.random.randint(low=0, high=(end_index - 2 * length))
  65. label = 0
  66. for h in range(enc_time):
  67. samp_step += 1
  68. random_start += enc_step
  69. sample = slice_data[random_start: random_start + length]
  70. Train_sample.append(sample)
  71. if samp_step == samp_train:
  72. label = 1
  73. break
  74. if label:
  75. break
  76. else:
  77. for j in range(samp_train):
  78. random_start = np.random.randint(low=0, high=(end_index - length))
  79. sample = slice_data[random_start:random_start + length]
  80. Train_sample.append(sample)
  81. # 抓取测试数据
  82. for h in range(number - samp_train):
  83. random_start = np.random.randint(low=end_index, high=(all_lenght - length))
  84. sample = slice_data[random_start:random_start + length]
  85. Test_Sample.append(sample)
  86. Train_Samples[i] = Train_sample
  87. Test_Samples[i] = Test_Sample
  88. return Train_Samples, Test_Samples
  89. # 仅抽样完成,打标签
  90. def add_labels(train_test):
  91. X = []
  92. Y = []
  93. label = 0
  94. for i in filenames:
  95. x = train_test[i]
  96. X += x
  97. lenx = len(x)
  98. Y += [label] * lenx
  99. label += 1
  100. return X, Y
  101. # one-hot编码
  102. def one_hot(Train_Y, Test_Y):
  103. Train_Y = np.array(Train_Y).reshape([-1, 1])
  104. Test_Y = np.array(Test_Y).reshape([-1, 1])
  105. Encoder = preprocessing.OneHotEncoder()
  106. Encoder.fit(Train_Y)
  107. Train_Y = Encoder.transform(Train_Y).toarray()
  108. Test_Y = Encoder.transform(Test_Y).toarray()
  109. Train_Y = np.asarray(Train_Y, dtype=np.int32)
  110. Test_Y = np.asarray(Test_Y, dtype=np.int32)
  111. return Train_Y, Test_Y
  112. def scalar_stand(Train_X, Test_X):
  113. # 用训练集标准差标准化训练集以及测试集
  114. scalar = preprocessing.StandardScaler().fit(Train_X)
  115. Train_X = scalar.transform(Train_X)
  116. Test_X = scalar.transform(Test_X)
  117. return Train_X, Test_X
  118. def valid_test_slice(Test_X, Test_Y):
  119. test_size = rate[2] / (rate[1] + rate[2])
  120. ss = StratifiedShuffleSplit(n_splits=1, test_size=test_size)
  121. for train_index, test_index in ss.split(Test_X, Test_Y):
  122. X_valid, X_test = Test_X[train_index], Test_X[test_index]
  123. Y_valid, Y_test = Test_Y[train_index], Test_Y[test_index]
  124. return X_valid, Y_valid, X_test, Y_test
  125. # 从所有.mat文件中读取出数据的字典
  126. data = capture(original_path=d_path)
  127. # 将数据切分为训练集、测试集
  128. train, test = slice_enc(data)
  129. # 为训练集制作标签,返回X,Y
  130. Train_X, Train_Y = add_labels(train)
  131. # 为测试集制作标签,返回X,Y
  132. Test_X, Test_Y = add_labels(test)
  133. # 为训练集Y/测试集One-hot标签
  134. Train_Y, Test_Y = one_hot(Train_Y, Test_Y)
  135. # 训练数据/测试数据 是否标准化.
  136. if normal:
  137. Train_X, Test_X = scalar_stand(Train_X, Test_X)
  138. else:
  139. # 需要做一个数据转换,转换成np格式.
  140. Train_X = np.asarray(Train_X)
  141. Test_X = np.asarray(Test_X)
  142. # 将测试集切分为验证集合和测试集.
  143. Valid_X, Valid_Y, Test_X, Test_Y = valid_test_slice(Test_X, Test_Y)
  144. return Train_X, Train_Y, Valid_X, Valid_Y, Test_X, Test_Y
  145. if __name__ == "__main__":
  146. path = r'D:\360安全浏览器下载\轴承故障检测\数据源\西储大学\CWRU轴承数据\cwru_data\0'
  147. train_X, train_Y, valid_X, valid_Y, test_X, test_Y = prepro(d_path=path,
  148. length=864,
  149. number=1000,
  150. normal=False,
  151. rate=[0.5, 0.25, 0.25],
  152. enc=False,
  153. enc_step=28)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/202612
推荐阅读
相关标签
  

闽ICP备14008679号