|
|
@@ -114,9 +114,10 @@ def data_analyse(path: List[str]):
|
|
|
measure_file = path[1]
|
|
|
angle_cone = float(path[2]) # 锥角
|
|
|
axial_inclination = float(path[3]) # 轴向倾角
|
|
|
+ skew_angle = 5 # 偏航角
|
|
|
noise_reduction = 0.000001 # 如果一个距离值的所有样本量小于总样本量的noise_reduction,则被去掉
|
|
|
- min_difference = 1.5 # 如果相邻2个点的距离差大于min_difference,则被注意是否是周期节点
|
|
|
- group_length = [10000, 30000, 5000] # 计算叶片轮廓时每个小切片的长度,三个数分别为叶中、叶根、叶尖切片长度
|
|
|
+ min_difference = 1 # 如果相邻2个点的距离差大于min_difference,则被注意是否是周期节点
|
|
|
+ group_length = [10000, 10000, 5000] # 计算叶片轮廓时每个小切片的长度,三个数分别为叶中、叶根、叶尖切片长度
|
|
|
return_list = []
|
|
|
|
|
|
# 读取文件信息,包括风场名、风机编号、时间、采样频率、2个通道俯仰角
|
|
|
@@ -135,9 +136,11 @@ def data_analyse(path: List[str]):
|
|
|
start_tip, end_tip, filtered_data_tip = cycle_calculate(data_tip, noise_reduction, min_difference)
|
|
|
start_root, end_root, filtered_data_root = cycle_calculate(data_root, noise_reduction, min_difference)
|
|
|
start_nan, end_nan, filtered_data_nan = cycle_calculate(data_nan, noise_reduction, min_difference)
|
|
|
+
|
|
|
+ # 轮毂中心数据降噪,并求均值得到塔筒中心距离,再把降噪后的数据根据俯仰角转换为水平方向的振动
|
|
|
filtered_data_cen = tower_filter(data_cen, noise_reduction)
|
|
|
dist_cen = np.mean(filtered_data_cen.iloc[:, 1].tolist())
|
|
|
- filtered_data_cen.iloc[:, 1] = filtered_data_cen.iloc[:, 1] * np.cos(np.deg2rad(angle_cen))
|
|
|
+ filtered_data_cen.iloc[:, 1] = filtered_data_cen.iloc[:, 1] * np.cos(np.deg2rad(angle_cen + axial_inclination))
|
|
|
|
|
|
# 检查起始结束点顺序,确保叶根叶尖测点同步开始、结束
|
|
|
if end_tip.iloc[0, 0] < start_root.iloc[0, 0]:
|
|
|
@@ -148,7 +151,7 @@ def data_analyse(path: List[str]):
|
|
|
else:
|
|
|
raise ValueError("The elements are not in the expected order.")
|
|
|
|
|
|
- # 计算叶根、叶尖处的塔筒距离,对轮毂中心做FFT分析
|
|
|
+ # 计算叶根、叶中、叶尖处的塔筒距离,对轮毂中心做FFT分析
|
|
|
tower_dist_tip = ff.tower_cal(filtered_data_tip, start_tip, end_tip, sampling_fq_1)
|
|
|
tower_dist_root = ff.tower_cal(filtered_data_root, start_root, end_root, sampling_fq_1)
|
|
|
tower_dist_nan = ff.tower_cal(filtered_data_nan, start_nan, end_nan, sampling_fq)
|
|
|
@@ -188,12 +191,14 @@ def data_analyse(path: List[str]):
|
|
|
cen_blade_nan_array = np.array(cen_blade_nan)
|
|
|
min_tip_array = np.array(min_tip)
|
|
|
min_nan_array = np.array(min_nan)
|
|
|
- abs_diff = np.abs(cen_blade_tip_array - min_tip_array) # 计算差值的绝对值
|
|
|
- abs_diff_nan = np.abs(cen_blade_nan_array - min_nan_array) # 计算差值的绝对值
|
|
|
+
|
|
|
+ # 计算叶片内部中心点距离与叶片最小值之间的差值
|
|
|
+ abs_diff = np.abs(cen_blade_tip_array - min_tip_array)
|
|
|
+ abs_diff_nan = np.abs(cen_blade_nan_array - min_nan_array)
|
|
|
blade_dist_tip = abs_diff * np.cos(np.deg2rad(angle_tip_new))
|
|
|
blade_dist_nan = abs_diff_nan * np.cos(np.deg2rad(angle_nan_new))
|
|
|
- blade_dist_tip.tolist() # 如果需要将结果转换回列表
|
|
|
- blade_dist_nan.tolist() # 如果需要将结果转换回列表
|
|
|
+ blade_dist_tip.tolist()
|
|
|
+ blade_dist_nan.tolist()
|
|
|
|
|
|
# 计算叶片转速-净空散点表
|
|
|
dist_distribute = blade_dist_distribute_cal(filtered_data_tip, start_tip, end_tip,
|
|
|
@@ -227,25 +232,25 @@ def data_analyse(path: List[str]):
|
|
|
first_column = df.iloc[:, 0]
|
|
|
sec_column = df.iloc[:, 1]
|
|
|
df.iloc[:, 0] = first_column * v_speed_tip
|
|
|
- df.iloc[:, 1] = sec_column * np.cos(np.deg2rad(angle_tip_new))
|
|
|
+ df.iloc[:, 1] = sec_column * np.cos(np.deg2rad(angle_tip_new + angle_cone + axial_inclination))
|
|
|
|
|
|
for df in result_line_root:
|
|
|
first_column = df.iloc[:, 0]
|
|
|
sec_column = df.iloc[:, 1]
|
|
|
df.iloc[:, 0] = first_column * v_speed_root
|
|
|
- df.iloc[:, 1] = sec_column * np.cos(np.deg2rad(angle_root))
|
|
|
+ df.iloc[:, 1] = sec_column * np.cos(np.deg2rad(angle_root + angle_cone + axial_inclination))
|
|
|
|
|
|
for df in result_scatter_tip:
|
|
|
first_column = df.iloc[:, 0]
|
|
|
sec_column = df.iloc[:, 1]
|
|
|
df.iloc[:, 0] = first_column * v_speed_tip
|
|
|
- df.iloc[:, 1] = sec_column * np.cos(np.deg2rad(angle_tip_new))
|
|
|
+ df.iloc[:, 1] = sec_column * np.cos(np.deg2rad(angle_tip_new + angle_cone + axial_inclination))
|
|
|
|
|
|
for df in result_scatter_root:
|
|
|
first_column = df.iloc[:, 0]
|
|
|
sec_column = df.iloc[:, 1]
|
|
|
df.iloc[:, 0] = first_column * v_speed_root
|
|
|
- df.iloc[:, 1] = sec_column * np.cos(np.deg2rad(angle_root))
|
|
|
+ df.iloc[:, 1] = sec_column * np.cos(np.deg2rad(angle_root + angle_cone + axial_inclination))
|
|
|
|
|
|
# 将叶片平均轮廓数据乘以线速度,得到实际叶片长度
|
|
|
avg_tip = result_avg_tip.iloc[:, 0]
|
|
|
@@ -253,6 +258,7 @@ def data_analyse(path: List[str]):
|
|
|
avg_root = result_avg_root.iloc[:, 0]
|
|
|
result_avg_root.iloc[:, 0] = avg_root * v_speed_root
|
|
|
|
|
|
+ # 计算叶片扭转角度
|
|
|
twist_1 = round(np.abs(pitch_angle_root[0] - pitch_angle_tip[0]), 2)
|
|
|
twist_2 = round(np.abs(pitch_angle_root[1] - pitch_angle_tip[1]), 2)
|
|
|
twist_3 = round(np.abs(pitch_angle_root[2] - pitch_angle_tip[2]), 2)
|
|
|
@@ -451,21 +457,23 @@ def data_analyse(path: List[str]):
|
|
|
# print(result_line_root[0].iloc[:, 0])
|
|
|
print('振动主频' + str(tower_freq))
|
|
|
print('振动幅值' + str(tower_max))
|
|
|
- print('最小值', min_values)
|
|
|
+ print('净空最小值', min_values)
|
|
|
print('最小值对应的键', min_keys)
|
|
|
- print('最大值', max_values)
|
|
|
+ print('净空最大值', max_values)
|
|
|
print('最大值对应的键', max_keys)
|
|
|
print('叶尖速度' + str(v_speed_tip), '叶根速度' + str(v_speed_root))
|
|
|
print('新俯仰角' + str(angle_tip_new))
|
|
|
print('轮毂中心距离' + str(dist_cen))
|
|
|
print('叶根原始数据采样时间长度' + str(data_root.iloc[-1, 0]))
|
|
|
+ print('-' * 50)
|
|
|
+ print(json.dumps(json_output, indent=4, ensure_ascii=False))
|
|
|
|
|
|
# plot_data(result_line_tip, 'line', 'data1')
|
|
|
# plot_data(result_diff_tip, 'line', 'data_diff_1')
|
|
|
# plot_data(result_scatter_tip, 'scatter', 'data1')
|
|
|
- # plot_data(result_line_root, 'line', 'data2')
|
|
|
+ plot_data(result_line_root, 'line', 'data2')
|
|
|
# plot_data(result_diff_root, 'line', 'data_diff_2')
|
|
|
- # plot_data(result_scatter_root, 'scatter', 'data2')
|
|
|
+ plot_data(result_scatter_root, 'scatter', 'data2')
|
|
|
# plot_data(dist_distribute, 'scatter', 'dist_distribute')
|
|
|
|
|
|
return json_output
|
|
|
@@ -478,7 +486,7 @@ def process_data(file_path):
|
|
|
"""
|
|
|
|
|
|
# 读取第2、4、9列的数据
|
|
|
- data = pd.read_csv(file_path, usecols=[1, 3, 8], header=None, engine='c')
|
|
|
+ data = pd.read_csv(file_path, usecols=[1, 3, 4, 8, 9], header=None, engine='c')
|
|
|
data = data.head(int(len(data) * 0.95))
|
|
|
print('原始数据长度' + str(len(data)))
|
|
|
|
|
|
@@ -525,12 +533,12 @@ def process_data(file_path):
|
|
|
data.iloc[:, 0] -= min_time
|
|
|
|
|
|
# 分为两组数据
|
|
|
- data_1 = data.iloc[:, [0, 1]]
|
|
|
- data_2 = data.iloc[:, [0, 2]]
|
|
|
+ data_1 = data.iloc[:, [0, 1, 2]]
|
|
|
+ data_2 = data.iloc[:, [0, 3, 4]]
|
|
|
|
|
|
# 分别命名列
|
|
|
- data_1.columns = ['time', 'distance']
|
|
|
- data_2.columns = ['time', 'distance']
|
|
|
+ data_1.columns = ['time', 'distance', 'grey']
|
|
|
+ data_2.columns = ['time', 'distance', 'grey']
|
|
|
|
|
|
|
|
|
return data_1, data_2
|
|
|
@@ -722,6 +730,12 @@ def data_normalize(data_group: pd.DataFrame, start_points: pd.DataFrame, end_poi
|
|
|
# 按时间排序
|
|
|
turbine_sorted = turbine.sort_values(by='time').reset_index(drop=True)
|
|
|
|
|
|
+ grey_start_index = int(len(turbine_sorted) * 0.1)
|
|
|
+ grey_end_index = int(len(turbine_sorted) * 0.9)
|
|
|
+ subset_grey = turbine_sorted[grey_start_index:grey_end_index]
|
|
|
+ mean_grey = subset_grey['grey'].mean() * 0.8 # 0.8
|
|
|
+ turbine_sorted = turbine_sorted[turbine_sorted['grey'] > mean_grey]
|
|
|
+
|
|
|
# 找到time列的第一个值
|
|
|
first_time = turbine_sorted['time'].iloc[0]
|
|
|
|
|
|
@@ -756,7 +770,7 @@ def data_normalize(data_group: pd.DataFrame, start_points: pd.DataFrame, end_poi
|
|
|
start_index = int(len(diff_points) * 0.05)
|
|
|
end_index = int(len(diff_points) * 0.95)
|
|
|
subset1 = diff_points[start_index:end_index]
|
|
|
- sdr_diff = np.max(subset1) * 1.1
|
|
|
+ sdr_diff = np.max(subset1) * 1.1 # 1.1
|
|
|
min_list.append(min(mean_points))
|
|
|
|
|
|
# 找到第一个和最后一个小于 sdr_diff 的序号
|
|
|
@@ -801,16 +815,33 @@ def data_normalize(data_group: pd.DataFrame, start_points: pd.DataFrame, end_poi
|
|
|
turbines_scattered.append(scattered_df)
|
|
|
|
|
|
"""# 创建一个总图中有3个分图的形式
|
|
|
- fig, axs = plt.subplots(1, 1, figsize=(15, 9))
|
|
|
- plt.subplots_adjust(hspace=2)
|
|
|
+ fig, axs = plt.subplots(1, 3, figsize=(15, 9))
|
|
|
+ plt.subplots_adjust(wspace=0.3) # 调整子图之间的水平间距
|
|
|
+
|
|
|
+ # 绘制第一张图
|
|
|
+ axs[0].plot(plot_points[0], label='Diff Points', color='blue', marker='x', markersize=5)
|
|
|
+ axs[0].axhline(y=diff_line[0], color='red', linestyle='--')
|
|
|
+ axs[0].legend()
|
|
|
+ axs[0].set_title('Diff Points (Index 1)')
|
|
|
+ axs[0].set_xlabel('Index')
|
|
|
+ axs[0].set_ylabel('Value')
|
|
|
+
|
|
|
+ # 绘制第二张图
|
|
|
+ axs[1].plot(plot_points[1], label='Diff Points', color='blue', marker='x', markersize=5)
|
|
|
+ axs[1].axhline(y=diff_line[1], color='red', linestyle='--')
|
|
|
+ axs[1].legend()
|
|
|
+ axs[1].set_title('Diff Points (Index 2)')
|
|
|
+ axs[1].set_xlabel('Index')
|
|
|
+ axs[1].set_ylabel('Value')
|
|
|
+
|
|
|
+ # 绘制第三张图
|
|
|
+ axs[2].plot(plot_points[2], label='Diff Points', color='blue', marker='x', markersize=5)
|
|
|
+ axs[2].axhline(y=diff_line[2], color='red', linestyle='--')
|
|
|
+ axs[2].legend()
|
|
|
+ axs[2].set_title('Diff Points (Index 3)')
|
|
|
+ axs[2].set_xlabel('Index')
|
|
|
+ axs[2].set_ylabel('Value')
|
|
|
|
|
|
- # 绘制 diff_points 的折线图
|
|
|
- axs.plot(plot_points[1], label='Diff Points', color='blue', marker='x', markersize=5)
|
|
|
- axs.axhline(y=diff_line[1], color='red', linestyle='--')
|
|
|
- axs.legend()
|
|
|
- axs.set_title('Diff Points')
|
|
|
- axs.set_xlabel('Index')
|
|
|
- axs.set_ylabel('Value')
|
|
|
|
|
|
# 显示图形
|
|
|
plt.tight_layout()
|
|
|
@@ -976,13 +1007,6 @@ def blade_angle_aero_dist(border_rows: List[pd.DataFrame], radius: float, full_c
|
|
|
pitch_angle_list = [round(num, 2) for num in pitch_angle_list]
|
|
|
aero_dist_list = [round(num, 2) for num in aero_dist_list]
|
|
|
|
|
|
- print('叶片相对角度偏差:' + '\n' + '叶片1:' + str(pitch_angle_list[0]) + '\n'
|
|
|
- + '叶片2:' + str(pitch_angle_list[1]) + '\n' + '叶片3:' + str(pitch_angle_list[2])
|
|
|
- + '\n' + '相对偏差范围:' + str(pitch_angle_list[3]))
|
|
|
- print('叶片净空距离:' + '\n' + '叶片1:' + str(aero_dist_list[0]) + '\n'
|
|
|
- + '叶片2:' + str(aero_dist_list[1]) + '\n' + '叶片3:' + str(aero_dist_list[2])
|
|
|
- + '\n' + '平均净空距离:' + str(aero_dist_list[3]))
|
|
|
-
|
|
|
return pitch_angle_list, aero_dist_list, v_speed, cen_blade
|
|
|
|
|
|
|
|
|
@@ -1004,7 +1028,7 @@ def plot_data(data, plot_type: str, data_name: str):
|
|
|
|
|
|
if plot_type == 'line':
|
|
|
for df, color in zip(data, ['blue', 'green', 'red']):
|
|
|
- sns.lineplot(data=df, x=df.iloc[:, 0], y=df.iloc[:, 1], color=color)
|
|
|
+ sns.lineplot(data=df, x=df.iloc[:, 0], y=df.iloc[:, 1], color=color, linewidth=8)
|
|
|
elif plot_type == 'scatter':
|
|
|
for df, (size, color) in zip(data, [(50, 'blue'), (25, 'green'), (10, 'red')]):
|
|
|
sns.scatterplot(data=df, x=df.iloc[:, 0], y=df.iloc[:, 1], s=size, color=color)
|