1说明
西交大轴承振动数据集
XJTU-SY滚动轴承加速寿命试验数据集解读预测与健康管理对保障机械装备安全服役、提高生产效率、增加经济效益至关重要。高质量的全寿命周期数据是预测与健康管理领域的基础性资源,这些数据承载着反映装备服役性能完整退化过程与规律的关键信息。然而,由于数据获取成本高、存储与传输技术有待发展等原因,典型的全寿命周期数据极其匮乏,严重制约了机械装备预测与健康管理技术的理论研究与工程应用。为解决上述难题,西安交通大学机械工程学院雷亚国教授团队联合浙江长兴昇阳科技有限公司,选取工业场景中典型的关键部件——滚动轴承为试验对象,开展了历时两年的滚动轴承加速寿命试验,并将获取的试验数据——XJTU-SY滚动轴承加速寿命试验数据集面向全球学者公开发布。该数据集共包含3种工况下15个滚动轴承的全寿命周期振动信号,采样频率高、数据量大、失效类型丰富、记录信息详细,既可为预测与健康管理领域提供新鲜的"数据血液",推动故障诊断与剩余寿命预测等领域的算法研究,又可助力工业界智能化运维的"落地生根"。https://qikan.cmes.org/jxgcxb/CN/10.3901/JME.2019.16.001
如果要在自己的振动解析程序中进行处理,需要能够把振动数据逐帧压入分析程序,这里是一份具备完整功能的python源码,它会检索多个通道数据最终统一采样率后压入一个.bin的数据文件。
2.源码
1.读取数据文件 ReadXjtuDatafile.py
import csv
import numpy as np
file_path = r"D:\git2024\20240304_PushVibrationData\XJTU-SY_Bearing_Datasets\35Hz12kN\Bearing1_1\1.csv"
def ReadOneChannelRecordFromXJBD(file_path):
horizontal_signals = []
vertical_signals = []
with open(file_path, newline='') as csvfile:
reader = csv.reader(csvfile)
next(reader) # 跳过标题行
for row in reader:
horizontal_signals.append(float(row[0]))
vertical_signals.append(float(row[1]))
return (horizontal_signals, vertical_signals)
#将[+-50g的信号归一化为0点在32768处的u16信号]
def double2u16(data_in_array):
data = np.array(data_in_array);
normalized_data = np.clip(np.array(((data - (-50.0)) / 100.0 * 65535), dtype=np.uint16), 0, 65535)
return normalized_data;
def resampleData(data_in_array, target_point):
# 确定抽样点位置的索引值
idx = np.linspace(0, len(data_in_array)-1, target_point, dtype=np.int32)
# 使用interp函数进行抽样
resampled_data = np.interp(idx, np.arange(len(data_in_array)), data_in_array)
return resampled_data;
def getSampledataIn2048U16(file_path, dataType):
(hdata, vdata) = ReadOneChannelRecordFromXJBD(file_path);
if(dataType == "h"):
data = resampleData(hdata, 2048)
else:
data = resampleData(vdata, 2048)
return double2u16(data);
2.配置文件 in json
{
"dataset":{
"root_path":"D:\\git2024\\20240304_PushVibrationData"
},
"ch1":{
"path":".\\XJTU-SY_Bearing_Datasets\\35Hz12kN\\Bearing1_1",
"type":"h",
"range":[1,100]
},
"ch2":{
"path":".\\XJTU-SY_Bearing_Datasets\\35Hz12kN\\Bearing1_1",
"type":"v",
"range":[1,100]
},
"ch3":{
"path":".\\XJTU-SY_Bearing_Datasets\\35Hz12kN\\Bearing1_2",
"type":"h",
"range":[1,100]
},
"default":{
"path":".\\XJTU-SY_Bearing_Datasets\\35Hz12kN\\Bearing1_1",
"type":"h",
"range":[1,100]
}
}
3.读取配置,检索数据集,打包数据 PackXjtuDataByConfig.py
import json
import os
import ReadXjtuDatafile
def getfilecountByExt(dirOfFile, extWithDot):
# 指定目录路径
directory = dirOfFile
# 初始化计数器
csv_count = 0
# 遍历目录下所有文件
for filename in os.listdir(directory):
if filename.endswith(extWithDot): # 判断文件是否以.csv结尾
csv_count += 1
return csv_count;
XJTU_CONFIG_FILE = r"xjtu_dataset.json"
def get_xjtu_dataset_rootpath():
# 读取 JSON 文件
with open(XJTU_CONFIG_FILE) as f:
data = json.load(f)
# 获取 root_path 值
root_path = data['dataset']['root_path']
return root_path
def get_channel_config(ch):
# 读取 JSON 文件
with open(XJTU_CONFIG_FILE) as f:
data = json.load(f)
#读取default配置:
key = str.format("ch%d" %ch)
if not (key in data):
key = "default"
ch_path = data[key]['path']
ch_type = data[key]['type']
ch_range = data[key]['range']
return (ch_path, ch_type, ch_range);
def get_channel_data(ch, idx):
(ch_path, ch_type, ch_range) = get_channel_config(ch);
file_path = get_xjtu_dataset_rootpath() + ch_path[1:];
print(file_path);
totalDataFileSize = getfilecountByExt(file_path, ".csv");
target_idx = idx%totalDataFileSize;
#TODO:range;
fullname = str.format("%s\\%d.csv" %(file_path, target_idx));
sampleDataInU16 = ReadXjtuDatafile.getSampledataIn2048U16(fullname, ch_type);
return (sampleDataInU16, ch, idx, fullname);
def test_PackXjtuDataByConfig():
print(get_xjtu_dataset_rootpath())
print(get_channel_config(1))
print(get_channel_config(2))
print(get_channel_config(3))
(sampleDataInU16, ch, idx, fullname) = get_channel_data(1, 3);
print(len(sampleDataInU16), ch, idx, fullname)
test_PackXjtuDataByConfig()
4. 顶层调用接口 读取多个通道振动数据,写入唯一文件 PushVirbrationData.py
import csv
import numpy as np
import PackXjtuDataByConfig
import array
import struct
import os
import time
vibration_data_file = "d:\\vibration_data_file.bin";
def Gen21ChanelsData(idx):
u16array = array.array('H')
for i in np.arange(1,22):
(sampleDataInU16, ch, idx, fullname) = PackXjtuDataByConfig.get_channel_data(i, idx)
u16array.extend(sampleDataInU16);
return u16array;
def write2file(filename, data):
# 打开文件
with open(filename, "wb") as file:
# 将数组转换为字节流
byte_data = struct.pack(f"{len(data)}H", *data)
# 写入数据到文件
file.write(byte_data)
def TestReadOneRecordFromXJDB():
#raw
idx=1
while(1):
u16array=Gen21ChanelsData(idx)
write2file(vibration_data_file, u16array)
time.sleep(5)
idx=idx+1
TestReadOneRecordFromXJDB();