|
@@ -24,13 +24,15 @@ class PitchPowerAnalyst(AnalystWithGoodBadPoint):
|
|
|
def turbinesAnalysis(self, outputAnalysisDir, conf: Contract, turbineCodes):
|
|
|
dictionary = self.processTurbineData(turbineCodes, conf,self.selectColumns())
|
|
|
dataFrame = self.userDataFrame(dictionary,conf.dataContract.configAnalysis,self)
|
|
|
- result_df1 = self.plot_power_pitch_angle(dataFrame, outputAnalysisDir, conf)
|
|
|
- result_df2 = self.drawScatterGraph(dataFrame, outputAnalysisDir, conf)
|
|
|
+ turbineInfos = self.common.getTurbineInfos(conf.dataContract.dataFilter.powerFarmID, turbineCodes,
|
|
|
+ self.turbineInfo)
|
|
|
+ result_df1 = self.plot_power_pitch_angle(dataFrame, turbineInfos, outputAnalysisDir, conf)
|
|
|
+ result_df2 = self.drawScatterGraph(dataFrame, turbineInfos, outputAnalysisDir, conf)
|
|
|
result_df = pd.concat([result_df1, result_df2], ignore_index=True)
|
|
|
|
|
|
return result_df
|
|
|
|
|
|
- def plot_power_pitch_angle(self, dataFrame:pd.DataFrame, outputAnalysisDir:str, conf: Contract):
|
|
|
+ def plot_power_pitch_angle(self, dataFrame:pd.DataFrame, turbineModelInfo: pd.Series, outputAnalysisDir:str, conf: Contract):
|
|
|
# 按设备名分组数据
|
|
|
|
|
|
dataFrameMerge = dataFrame[(dataFrame[Field_ActiverPower] > 0)].sort_values(by=Field_YearMonth)
|
|
@@ -127,11 +129,42 @@ class PitchPowerAnalyst(AnalystWithGoodBadPoint):
|
|
|
)
|
|
|
)
|
|
|
|
|
|
+ # 确保从 Series 中提取的是具体的值
|
|
|
+ engineTypeCode = turbineModelInfo.get(Field_MillTypeCode, "")
|
|
|
+ if isinstance(engineTypeCode, pd.Series):
|
|
|
+ engineTypeCode = engineTypeCode.iloc[0]
|
|
|
+
|
|
|
+ engineTypeName = turbineModelInfo.get(Field_MachineTypeCode, "")
|
|
|
+ if isinstance(engineTypeName, pd.Series):
|
|
|
+ engineTypeName = engineTypeName.iloc[0]
|
|
|
+ # 构建最终的JSON对象
|
|
|
+ json_output = {
|
|
|
+ "analysisTypeCode": "变桨和有功功率协调性分析",
|
|
|
+ "engineCode": engineTypeCode,
|
|
|
+ "engineTypeName": engineTypeName,
|
|
|
+ "xaixs": "功率(kW)",
|
|
|
+ "yaixs": "桨距角(°)",
|
|
|
+ "data": [{
|
|
|
+ "engineName": name[0],
|
|
|
+ "engineCode": name[1],
|
|
|
+ "title": f' 机组: {name[0]}',
|
|
|
+ "xData": group[Field_ActiverPower].tolist(),
|
|
|
+ "yData": group[Field_PitchAngel1].tolist(),
|
|
|
+ "colorbar": dataFrameMerge[Field_YearMonth].unique().tolist(),
|
|
|
+ }]
|
|
|
+ }
|
|
|
+
|
|
|
# 保存图像
|
|
|
filePathOfImage = os.path.join(outputAnalysisDir, f"{name[0]}.png")
|
|
|
fig.write_image(filePathOfImage, width=800, height=600, scale=3)
|
|
|
- filePathOfHtml = os.path.join(outputAnalysisDir, f"{name[0]}.html")
|
|
|
- fig.write_html(filePathOfHtml)
|
|
|
+ # filePathOfHtml = os.path.join(outputAnalysisDir, f"{name[0]}.html")
|
|
|
+ # fig.write_html(filePathOfHtml)
|
|
|
+
|
|
|
+ # 将JSON对象保存到文件
|
|
|
+ output_json_path = os.path.join(outputAnalysisDir, f"pitch_Power_Analyst{name[0]}.json")
|
|
|
+ with open(output_json_path, 'w', encoding='utf-8') as f:
|
|
|
+ import json
|
|
|
+ json.dump(json_output, f, ensure_ascii=False, indent=4)
|
|
|
|
|
|
result_rows1.append({
|
|
|
Field_Return_TypeAnalyst: self.typeAnalyst(),
|
|
@@ -147,7 +180,8 @@ class PitchPowerAnalyst(AnalystWithGoodBadPoint):
|
|
|
Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
|
|
|
Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
|
|
|
Field_CodeOfTurbine: name[1],
|
|
|
- Field_Return_FilePath: filePathOfHtml,
|
|
|
+ Field_MillTypeCode: 'total',
|
|
|
+ Field_Return_FilePath: output_json_path,
|
|
|
Field_Return_IsSaveDatabase: True
|
|
|
})
|
|
|
|
|
@@ -155,7 +189,7 @@ class PitchPowerAnalyst(AnalystWithGoodBadPoint):
|
|
|
|
|
|
return result_df1
|
|
|
|
|
|
- def drawScatterGraph(self, dataFrame: pd.DataFrame, outputAnalysisDir: str, conf: Contract):
|
|
|
+ def drawScatterGraph(self, dataFrame: pd.DataFrame, turbineModelInfo: pd.Series, outputAnalysisDir: str, conf: Contract):
|
|
|
|
|
|
dataFrame = dataFrame[(dataFrame[Field_ActiverPower] > 0)].sort_values(
|
|
|
by=Field_YearMonth)
|
|
@@ -292,18 +326,58 @@ class PitchPowerAnalyst(AnalystWithGoodBadPoint):
|
|
|
itemwidth=80 # Set the width of legend items to 50 pixels
|
|
|
)
|
|
|
)
|
|
|
-
|
|
|
+ # 确保从 Series 中提取的是具体的值
|
|
|
+ engineTypeCode = turbineModelInfo.get(Field_MillTypeCode, "")
|
|
|
+ if isinstance(engineTypeCode, pd.Series):
|
|
|
+ engineTypeCode = engineTypeCode.iloc[0]
|
|
|
+
|
|
|
+ engineTypeName = turbineModelInfo.get(Field_MachineTypeCode, "")
|
|
|
+ if isinstance(engineTypeName, pd.Series):
|
|
|
+ engineTypeName = engineTypeName.iloc[0]
|
|
|
+ # 构建最终的JSON对象
|
|
|
+ json_output = {
|
|
|
+ "analysisTypeCode": "变桨和有功功率协调性分析",
|
|
|
+ "engineCode": engineTypeCode,
|
|
|
+ "engineTypeName": engineTypeName,
|
|
|
+ "xaixs": "桨距角(°)",
|
|
|
+ "yaixs": "时间",
|
|
|
+ "zaixs": "有功功率(kW)",
|
|
|
+ "data": [{
|
|
|
+ "engineName": name[0],
|
|
|
+ "engineCode": name[1],
|
|
|
+ "title": f' 月度桨距角功率3D散点图: {name[0]}',
|
|
|
+ "xData": group[Field_PitchAngel1].tolist(),
|
|
|
+ "yData": group[Field_YearMonth].tolist(),
|
|
|
+ "zData": group[Field_ActiverPower].tolist(),
|
|
|
+ }]
|
|
|
+ }
|
|
|
# 保存图像
|
|
|
- filePathOfHtml = os.path.join(
|
|
|
- outputAnalysisDir, f"{name[0]}_3D.html")
|
|
|
- fig.write_html(filePathOfHtml)
|
|
|
+ filePathOfImage = os.path.join(outputAnalysisDir, f"{name[0]}_3D.png")
|
|
|
+ fig.write_image(filePathOfImage, width=800, height=600, scale=3)
|
|
|
+ # filePathOfHtml = os.path.join(outputAnalysisDir, f"{name[0]}_3D.html")
|
|
|
+ # fig.write_html(filePathOfHtml)
|
|
|
|
|
|
+ # 将JSON对象保存到文件
|
|
|
+ output_json_path = os.path.join(outputAnalysisDir, f"pitch_Power_Analyst{name[0]}_3D.json")
|
|
|
+ with open(output_json_path, 'w', encoding='utf-8') as f:
|
|
|
+ import json
|
|
|
+ json.dump(json_output, f, ensure_ascii=False, indent=4)
|
|
|
+
|
|
|
+ result_rows2.append({
|
|
|
+ Field_Return_TypeAnalyst: self.typeAnalyst(),
|
|
|
+ Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
|
|
|
+ Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
|
|
|
+ Field_CodeOfTurbine: name[1],
|
|
|
+ Field_Return_FilePath: filePathOfImage,
|
|
|
+ Field_Return_IsSaveDatabase: False
|
|
|
+ })
|
|
|
result_rows2.append({
|
|
|
Field_Return_TypeAnalyst: self.typeAnalyst(),
|
|
|
Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
|
|
|
Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
|
|
|
Field_CodeOfTurbine: name[1],
|
|
|
- Field_Return_FilePath: filePathOfHtml,
|
|
|
+ Field_MillTypeCode: 'total',
|
|
|
+ Field_Return_FilePath: output_json_path,
|
|
|
Field_Return_IsSaveDatabase: True
|
|
|
})
|
|
|
|