data_standardization.py 5.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import pandas as pd
  2. class DataStandardization(object):
  3. def __init__(self, data_dict):
  4. self.data_dict = data_dict
  5. def null_judge(self):
  6. Num = 0
  7. for k in self.data_dict:
  8. if self.data_dict[k] == ' ' or not self.data_dict[k]:
  9. Num += 1
  10. return Num
  11. def dict_standard(self):
  12. dict_chiller_cooling = self.data_dict['chillerConfigInfo']
  13. dict_chiller_outer = {}
  14. dict_code = self.data_dict['controlConfigInfo']
  15. all_chillers_info = self.data_dict['stationInfo']['allChillersInfo']
  16. all_chiller_water_temp_set = []
  17. all_water_temp_control_mode = []
  18. for i in range(len(all_chillers_info['chillerId'])):
  19. if all_chillers_info['runStatus'][i] == 1 and all_chillers_info['isInControl'][i] == 1:
  20. all_chiller_water_temp_set.append(all_chillers_info['chillerWaterTempSet'][i])
  21. if all_chillers_info['isInControl'][i] == 1:
  22. all_water_temp_control_mode.append(all_chillers_info['waterTempControlMode'][i])
  23. dict_chiller_cooling.update({
  24. 'triggerTime': self.data_dict['stationInfo']['triggerTime'],
  25. 'runMode': self.data_dict['stationInfo']['runMode'],
  26. 'runStatus': self.data_dict['chillerInfo']['runStatus'],
  27. 'chillerOffTimeLatest': self.data_dict['chillerInfo']['chillerOffTimeLatest'],
  28. 'offSetTempLatestCooling': self.data_dict['chillerInfo']['offSetTempLatestCooling'],
  29. # 'offSetTempInLatestCooling': 12,
  30. 'allChillerWaterTempSetOn': all_chiller_water_temp_set,
  31. # 'allChillerWaterTempInSetOn': [],
  32. 'allChillerControlSelect': all_water_temp_control_mode,
  33. # 'allChillerPowerRatio': [],
  34. 'chillerPowerRatio': self.data_dict['chillerInfo']['chillerPowerRatio'],
  35. 'chillerWaterTempOut': self.data_dict['chillerInfo']['chillerWaterTempOut'],
  36. 'chillerWaterTempIn': self.data_dict['chillerInfo']['chillerWaterTempIn'],
  37. 'chillerWaterTempSet': self.data_dict['chillerInfo']['chillerWaterTempSet'],
  38. 'chillerWaterTempSetInitial': self.data_dict['controlConfigInfo']['chillerWaterTempSetInitial'],
  39. 'chillerWaterTempSetUpper': self.data_dict['controlConfigInfo']['chillerWaterTempSetUpper'],
  40. # 'chillerWaterTempInSetUpper': self.data_dict,
  41. 'chillerWaterTempSetDown': self.data_dict['controlConfigInfo']['chillerWaterTempSetLower'],
  42. })
  43. dict_chiller_outer.update({
  44. 'triggerTime': self.data_dict['stationInfo']['triggerTime'],
  45. 'userName': self.data_dict['stationInfo']['userName'],
  46. 'coolingStationName': self.data_dict['stationInfo']['coolingStationName'],
  47. 'orgId': self.data_dict['stationInfo']['orgId'],
  48. 'chillerName': self.data_dict['chillerInfo']['chillerName'],
  49. 'chillerId': self.data_dict['chillerInfo']['chillerId'],
  50. 'stationId': self.data_dict['stationInfo']['stationId'],
  51. 'controllerId': self.data_dict['stationInfo']['controllerId'],
  52. 'allChillersInfo': self.data_dict['stationInfo']['allChillersInfo']})
  53. dict_code.update({'upControlTimeLatest': self.data_dict['chillerInfo']['upControlTimeLatest'],
  54. 'downControlTimeLatest': self.data_dict['chillerInfo']['downControlTimeLatest'],
  55. 'triggerTime': self.data_dict['stationInfo']['triggerTime'],
  56. 'runMode': self.data_dict['stationInfo']['runMode'],
  57. 'calMode': 0, # 监测点计算模式默认值为0
  58. 'allChillerControlSelect': all_water_temp_control_mode})
  59. return dict_chiller_cooling, dict_chiller_outer, dict_code
  60. def dict_safety(self):
  61. dict_upper_correct = {'refriType': self.data_dict['chillerInfo']['refriType'],
  62. 'chillerParameter': self.data_dict['chillerSafetyPara']}
  63. # dict_upper_correct.update({'refriType': self.data_dict['chillerInfo']['refriType'],
  64. # 'chillerParameter': self.data_dict['chillerSafetyPara']})
  65. return dict_upper_correct
  66. def data_multi_comp(self):
  67. dict_chiller_inner, dict_chiller_outer, dict_code = self.dict_standard()
  68. dict_upper_correct = self.dict_safety()
  69. data_temp_humi = pd.DataFrame(self.data_dict['terminalInfo'])
  70. return dict_chiller_inner, dict_chiller_outer, dict_code, dict_upper_correct, data_temp_humi