|
@@ -4,12 +4,13 @@ import numpy as np
|
|
|
import plotly.graph_objects as go
|
|
|
from algorithmContract.confBusiness import *
|
|
|
from algorithmContract.contract import Contract
|
|
|
-from behavior.analystWithGoodPoint import AnalystWithGoodPoint
|
|
|
+from behavior.analystWithGoodBadLimitPoint import AnalystWithGoodBadLimitPoint
|
|
|
from scipy.stats import binned_statistic_2d
|
|
|
from scipy.stats import skew, kurtosis
|
|
|
from utils.jsonUtil import JsonUtil
|
|
|
+from scipy.stats import norm, gaussian_kde
|
|
|
|
|
|
-class YawErrorDensityAnalyst(AnalystWithGoodPoint):
|
|
|
+class YawErrorDensityAnalyst(AnalystWithGoodBadLimitPoint):
|
|
|
"""
|
|
|
风电机组动态偏航策略分析
|
|
|
"""
|
|
@@ -67,7 +68,9 @@ class YawErrorDensityAnalyst(AnalystWithGoodPoint):
|
|
|
]
|
|
|
|
|
|
for name, group in grouped:
|
|
|
-
|
|
|
+ dataFrame=group[Field_YawError].abs() <= 45
|
|
|
+ yawerror=np.mean(dataFrame[Field_YawError])
|
|
|
+
|
|
|
df = self.calculateYawError(group)
|
|
|
df.dropna(inplace=True)
|
|
|
counts = df['density'].value_counts()
|
|
@@ -145,7 +148,29 @@ class YawErrorDensityAnalyst(AnalystWithGoodPoint):
|
|
|
}]
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ # 使用 gaussian_kde 估计数据的概率密度函数
|
|
|
+ kde = gaussian_kde(df["x"])
|
|
|
+ x = np.linspace(-30, 30, 1000) # 生成 x 轴数据
|
|
|
+ pdf_data = kde(x) # 数据的概率密度函数
|
|
|
+
|
|
|
+ # 构建最终的JSON对象2
|
|
|
+ json_output2 = {
|
|
|
+ "analysisTypeCode": "动态偏航误差",
|
|
|
+ "engineCode": engineTypeCode,
|
|
|
+ "engineTypeName": engineTypeName,
|
|
|
+ "xaixs": "对风角度(度)",
|
|
|
+ "yaixs": "概率密度函数",
|
|
|
+ "data": [{
|
|
|
+ "engineName": name[0],
|
|
|
+ "engineCode": name[1],
|
|
|
+ "title":f'概率密度函数-{name[0]}',
|
|
|
+ "xData": x .tolist(),
|
|
|
+ "yData": pdf_data.tolist(),
|
|
|
+ "xrange":[-30,30]
|
|
|
+
|
|
|
+ }]
|
|
|
+ }
|
|
|
+
|
|
|
# Save to file
|
|
|
filePathOfImage = os.path.join(outputAnalysisDir, f"{name[0]}.png")
|
|
|
fig.write_image(filePathOfImage, scale=3)
|
|
@@ -159,6 +184,12 @@ class YawErrorDensityAnalyst(AnalystWithGoodPoint):
|
|
|
import json
|
|
|
json.dump(json_output, f, ensure_ascii=False, indent=4)
|
|
|
|
|
|
+ # 将JSON对象2保存到文件
|
|
|
+ output_json_path2 = os.path.join(outputAnalysisDir, f"PDF-{name[0]}.json")
|
|
|
+ with open(output_json_path2, 'w', encoding='utf-8') as f:
|
|
|
+ import json
|
|
|
+ json.dump(json_output2, f, ensure_ascii=False, indent=4)
|
|
|
+
|
|
|
# 如果需要返回DataFrame,可以包含文件路径
|
|
|
result_rows.append({
|
|
|
Field_Return_TypeAnalyst: self.typeAnalyst(),
|
|
@@ -168,6 +199,14 @@ class YawErrorDensityAnalyst(AnalystWithGoodPoint):
|
|
|
Field_Return_FilePath: output_json_path,
|
|
|
Field_Return_IsSaveDatabase: True
|
|
|
})
|
|
|
+ result_rows.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: output_json_path2,
|
|
|
+ Field_Return_IsSaveDatabase: True
|
|
|
+ })
|
|
|
|
|
|
result_rows.append({
|
|
|
Field_Return_TypeAnalyst: self.typeAnalyst(),
|