measurepoint.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # -*- coding: utf-8 -*-
  2. """
  3. Spyder 编辑器
  4. 这是一个临时脚本文件。
  5. """
  6. import os
  7. import pandas as pd
  8. pd.set_option('chained_assignment', None)
  9. select_cols = ['遥测名称', '遥测别名', '风场', '组件', '风机号', '测点']
  10. origin_col_map = {
  11. 'wind_turbine_number': '风机编号', 'wind_turbine_name': '风机原始名称', 'time_stamp': '时间戳',
  12. 'active_power': '有功功率', 'rotor_speed': '风轮转速', 'generator_speed': '发电机转速', 'wind_velocity': '风速',
  13. 'pitch_angle_blade_1': '桨距角1', 'pitch_angle_blade_2': '桨距角2', 'pitch_angle_blade_3': '桨距角3',
  14. 'cabin_position': '机舱位置', 'true_wind_direction': '绝对风向', 'yaw_error1': '对风角度',
  15. 'set_value_of_active_power': '有功功率设定值', 'gearbox_oil_temperature': '齿轮箱油温',
  16. 'generatordrive_end_bearing_temperature': '发电机驱动端轴承温度',
  17. 'generatornon_drive_end_bearing_temperature': '发电机非驱动端轴承温度', 'cabin_temperature': '机舱内温度',
  18. 'twisted_cable_angle': '扭缆角度', 'front_back_vibration_of_the_cabin': '机舱前后振动',
  19. 'side_to_side_vibration_of_the_cabin': '机舱左右振动', 'actual_torque': '实际力矩', 'given_torque': '给定力矩',
  20. 'clockwise_yaw_count': '顺时针偏航次数', 'counterclockwise_yaw_count': '逆时针偏航次数', 'unusable': '不可利用',
  21. 'power_curve_available': '功率曲线可用', 'required_gearbox_speed': '齿轮箱转速',
  22. 'inverter_speed_master_control': '变频器转速(主控)', 'outside_cabin_temperature': '环境温度',
  23. 'main_bearing_temperature': '主轴承轴承温度',
  24. 'gearbox_high_speed_shaft_bearing_temperature': '齿轮箱高速轴轴承温度',
  25. 'gearboxmedium_speed_shaftbearing_temperature': '齿轮箱中速轴轴承温度',
  26. 'gearbox_low_speed_shaft_bearing_temperature': '齿轮箱低速轴轴承温度',
  27. 'generator_winding1_temperature': '发电机绕组1温度', 'generator_winding2_temperature': '发电机绕组2温度',
  28. 'generator_winding3_temperature': '发电机绕组3温度', 'wind_turbine_status': '风机状态1',
  29. 'wind_turbine_status2': '风机状态2', 'turbulence_intensity': '湍流强度'
  30. }
  31. def save_df(df, name):
  32. df.to_excel(r'C:\Users\wzl\Desktop\中广核104测点\total' + os.sep + str(name) + '.xlsx', columns=select_cols,
  33. index=False)
  34. def common_measurepoint(df, name):
  35. df['风场'] = df['遥测别名'].apply(lambda x: x.split('.')[0])
  36. df['组件'] = df['遥测别名'].apply(lambda x: x.split('.')[3])
  37. df['风机号'] = df['遥测别名'].apply(lambda x: x.split('.')[2])
  38. df['测点'] = df['遥测别名'].apply(lambda x: '.'.join(x.split('.')[4:]))
  39. save_df(df, name + '测点')
  40. return df
  41. if __name__ == '__main__':
  42. df = pd.read_csv(r"D:\data\tmp\12CZYC.csv", encoding='gbk')
  43. df = df[~ df['遥测别名'].str.contains('Farm')]
  44. df = df[~ df['遥测别名'].str.contains('Statistics')]
  45. # 添加右玉处理
  46. name = '右玉'
  47. youyu_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name)
  48. # 添加平陆处理
  49. name = '平陆'
  50. pinglu_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name)
  51. # 添加芮城处理
  52. name = '芮城'
  53. ruicheng_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name)
  54. # 添加盂县处理
  55. name = '盂县'
  56. yuxian_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name)
  57. # 添加古交处理
  58. name = '古交'
  59. gujiao_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name)
  60. # 添加石楼处理
  61. name = '石楼'
  62. shilou_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name)
  63. # 添加阳曲处理
  64. name = '阳曲'
  65. yangqu_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name)
  66. # 添加西潘处理
  67. name = '西潘'
  68. xipan_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name)
  69. # 添加马家梁处理
  70. name = '马家梁'
  71. majialiang_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name)
  72. # 添加富风处理
  73. name = '富风'
  74. fufeng_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name)
  75. # 添加坡底处理
  76. name = '坡底'
  77. podi_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name)
  78. # 添加贺家沟处理
  79. name = '贺家沟'
  80. hejiagou_df = common_measurepoint(df[df['遥测名称'].str.contains(name)], name)
  81. # result_df = pd.concat([youyu_df, pinglu_df, ruicheng_df, yuxian_df, gujiao_df, shilou_df])