|
@@ -19,27 +19,9 @@ class RatedPowerWindSpeedAnalyst(AnalystWithGoodBadPoint):
|
|
|
|
|
|
def turbinesAnalysis(self, outputAnalysisDir, conf: Contract, turbineCodes):
|
|
|
dictionary=self.processTurbineData(turbineCodes,conf,[Field_DeviceCode,Field_Time,Field_EnvTemp,Field_WindSpeed,Field_ActiverPower])
|
|
|
- # dataFrameMerge=self.userDataFrame(dictionary,conf.dataContract.configAnalysis,self)
|
|
|
- dataFrameOfTurbines = self.userDataFrame(
|
|
|
- dictionary, conf.dataContract.configAnalysis, self)
|
|
|
-
|
|
|
- turbrineInfos = self.common.getTurbineInfos(
|
|
|
- conf.dataContract.dataFilter.powerFarmID, turbineCodes, self.turbineInfo)
|
|
|
-
|
|
|
- groupedOfTurbineModel = turbrineInfos.groupby(Field_MillTypeCode)
|
|
|
-
|
|
|
- returnDatas = []
|
|
|
- for turbineModelCode, group in groupedOfTurbineModel:
|
|
|
- currTurbineCodes = group[Field_CodeOfTurbine].unique().tolist()
|
|
|
- currTurbineModeInfo = self.common.getTurbineModelByCode(
|
|
|
- turbineModelCode, self.turbineModelInfo)
|
|
|
- currDataFrameOfTurbines = dataFrameOfTurbines[dataFrameOfTurbines[Field_CodeOfTurbine].isin(
|
|
|
- currTurbineCodes)]
|
|
|
- returnData= self.draw(currDataFrameOfTurbines, outputAnalysisDir, conf,currTurbineModeInfo)
|
|
|
- returnDatas.append(returnData)
|
|
|
-
|
|
|
- returnResult = pd.concat(returnDatas, ignore_index=True)
|
|
|
- return returnResult
|
|
|
+ dataFrameMerge=self.userDataFrame(dictionary,conf.dataContract.configAnalysis,self)
|
|
|
+ turbineInfos = self.common.getTurbineInfos(conf.dataContract.dataFilter.powerFarmID, turbineCodes, self.turbineInfo)
|
|
|
+ return self.draw(dataFrameMerge, outputAnalysisDir, conf,turbineInfos)
|
|
|
|
|
|
def draw(self, dataFrameMerge: pd.DataFrame, outputAnalysisDir, conf: Contract,turbineModelInfo: pd.Series):
|
|
|
"""
|
|
@@ -98,37 +80,73 @@ class RatedPowerWindSpeedAnalyst(AnalystWithGoodBadPoint):
|
|
|
fig.update_xaxes(title_text='机组', type='category',
|
|
|
tickangle=-45, tickfont=dict(size=10))
|
|
|
fig.update_layout(title={
|
|
|
- 'text': f'额定功率分布(环境温度>=25摄氏度)-{turbineModelInfo[Field_MachineTypeCode]}', 'x': 0.5}, boxmode='group')
|
|
|
-
|
|
|
+ 'text': f'额定功率分布(环境温度>=25摄氏度)', 'x': 0.5}, boxmode='group')
|
|
|
+ # 确保从 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": "功率(kw)",
|
|
|
+ "data": [{
|
|
|
+ "title":f'额定功率分布(环境温度>=25摄氏度)',
|
|
|
+ "xData": over_temp[Field_NameOfTurbine].tolist(),
|
|
|
+ "yData": over_temp[Field_ActiverPower].tolist(),
|
|
|
+ "linecolor":'black',
|
|
|
+ "linewidth":1,
|
|
|
+ "fillcolor":'dodgerblue'
|
|
|
+ }]
|
|
|
+ }
|
|
|
result_rows = []
|
|
|
# 保存图像
|
|
|
pngFileName = "额定满发风速功率分布(10min)(环境温度大于25度).png"
|
|
|
pngFilePath = os.path.join(outputAnalysisDir, pngFileName)
|
|
|
fig.write_image(pngFilePath, scale=3)
|
|
|
-
|
|
|
- # 保存HTML
|
|
|
- htmlFileName = "额定满发风速功率分布(10min)(环境温度大于25度).html"
|
|
|
- htmlFilePath = os.path.join(outputAnalysisDir, htmlFileName)
|
|
|
- fig.write_html(htmlFilePath)
|
|
|
-
|
|
|
+
|
|
|
+ # # 保存HTML
|
|
|
+ # htmlFileName = "额定满发风速功率分布(10min)(环境温度大于25度).html"
|
|
|
+ # htmlFilePath = os.path.join(outputAnalysisDir, htmlFileName)
|
|
|
+ # fig.write_html(htmlFilePath)
|
|
|
+ # 保存Json
|
|
|
+ # 将JSON对象保存到文件
|
|
|
+ output_json_path = os.path.join(outputAnalysisDir, "额定满发风速功率分布(10min)(环境温度大于25度).json")
|
|
|
+ with open(output_json_path, 'w', encoding='utf-8') as f:
|
|
|
+ import json
|
|
|
+ json.dump(json_output, f, ensure_ascii=False, indent=4)
|
|
|
+ # 如果需要返回DataFrame,可以包含文件路径
|
|
|
result_rows.append({
|
|
|
Field_Return_TypeAnalyst: self.typeAnalyst(),
|
|
|
Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
|
|
|
Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
|
|
|
Field_CodeOfTurbine: 'total',
|
|
|
- Field_Return_FilePath: pngFilePath,
|
|
|
- Field_Return_IsSaveDatabase: False
|
|
|
+ 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: 'total',
|
|
|
- Field_Return_FilePath: htmlFilePath,
|
|
|
- Field_Return_IsSaveDatabase: True
|
|
|
+ Field_Return_FilePath: pngFilePath,
|
|
|
+ Field_Return_IsSaveDatabase: False
|
|
|
})
|
|
|
|
|
|
+ # result_rows.append({
|
|
|
+ # Field_Return_TypeAnalyst: self.typeAnalyst(),
|
|
|
+ # Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
|
|
|
+ # Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
|
|
|
+ # Field_CodeOfTurbine: 'total',
|
|
|
+ # Field_Return_FilePath: htmlFilePath,
|
|
|
+ # Field_Return_IsSaveDatabase: True
|
|
|
+ # })
|
|
|
+
|
|
|
# 绘制环境温度小于25℃的功率分布图
|
|
|
fig = make_subplots(rows=1, cols=1)
|
|
|
fig.add_trace(go.Box(y=below_temp[Field_ActiverPower], x=below_temp[Field_NameOfTurbine],
|
|
@@ -160,36 +178,65 @@ class RatedPowerWindSpeedAnalyst(AnalystWithGoodBadPoint):
|
|
|
fig.update_xaxes(title_text='机组', type='category',
|
|
|
tickangle=-45, tickfont=dict(size=10))
|
|
|
fig.update_layout(title={
|
|
|
- 'text': f'额定功率分布(环境温度<25摄氏度)-{turbineModelInfo[Field_MachineTypeCode]}', 'x': 0.5}, boxmode='group')
|
|
|
-
|
|
|
+ 'text': f'额定功率分布(环境温度<25摄氏度)', 'x': 0.5}, boxmode='group')
|
|
|
+ # 构建最终的JSON对象2
|
|
|
+ json_output2 = {
|
|
|
+ "analysisTypeCode": "额定功率和风速分析",
|
|
|
+ "engineCode": engineTypeCode,
|
|
|
+ "engineTypeName": engineTypeName,
|
|
|
+ "xaixs": "机组",
|
|
|
+ "yaixs": "功率(kw)",
|
|
|
+ "data": [{
|
|
|
+ "title":f'额定功率分布(环境温度<25摄氏度)',
|
|
|
+ "xData": below_temp[Field_NameOfTurbine].tolist(),
|
|
|
+ "yData": below_temp[Field_ActiverPower].tolist(),
|
|
|
+ "linecolor":'black',
|
|
|
+ "linewidth":1,
|
|
|
+ "fillcolor":'dodgerblue'
|
|
|
+ }]
|
|
|
+ }
|
|
|
# 保存图像
|
|
|
pngFileName = "额定满发风速功率分布(10min)(环境温度小于25度).png"
|
|
|
pngFilePath = os.path.join(outputAnalysisDir, pngFileName)
|
|
|
fig.write_image(pngFilePath, scale=3)
|
|
|
|
|
|
- # 保存HTML
|
|
|
- htmlFileName = "额定满发风速功率分布(10min)(环境温度小于25度).html"
|
|
|
- htmlFilePath = os.path.join(outputAnalysisDir, htmlFileName)
|
|
|
- fig.write_html(htmlFilePath)
|
|
|
-
|
|
|
+ # # 保存HTML
|
|
|
+ # htmlFileName = "额定满发风速功率分布(10min)(环境温度小于25度).html"
|
|
|
+ # htmlFilePath = os.path.join(outputAnalysisDir, htmlFileName)
|
|
|
+ # fig.write_html(htmlFilePath)
|
|
|
+ # 保存Json
|
|
|
+ # 将JSON对象保存到文件
|
|
|
+ output_json_path2 = os.path.join(outputAnalysisDir, "额定满发风速功率分布(10min)(环境温度小于25度).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(),
|
|
|
Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
|
|
|
Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
|
|
|
Field_CodeOfTurbine: 'total',
|
|
|
- Field_Return_FilePath: pngFilePath,
|
|
|
- Field_Return_IsSaveDatabase: False
|
|
|
+ Field_Return_FilePath: output_json_path2,
|
|
|
+ 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: 'total',
|
|
|
- Field_Return_FilePath: htmlFilePath,
|
|
|
- Field_Return_IsSaveDatabase: True
|
|
|
+ Field_Return_FilePath: pngFilePath,
|
|
|
+ Field_Return_IsSaveDatabase: False
|
|
|
})
|
|
|
|
|
|
+ # result_rows.append({
|
|
|
+ # Field_Return_TypeAnalyst: self.typeAnalyst(),
|
|
|
+ # Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
|
|
|
+ # Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
|
|
|
+ # Field_CodeOfTurbine: 'total',
|
|
|
+ # Field_Return_FilePath: htmlFilePath,
|
|
|
+ # Field_Return_IsSaveDatabase: True
|
|
|
+ # })
|
|
|
+
|
|
|
result_df = pd.DataFrame(result_rows)
|
|
|
|
|
|
return result_df
|