|
|
@@ -147,6 +147,8 @@ class WindDirectionFrequencyAnalyst(AnalystNotFilter):
|
|
|
return result_df
|
|
|
'''
|
|
|
def windRoseAnalysis(self, dataFrameMerge: pd.DataFrame, outputAnalysisDir, conf: Contract):
|
|
|
+ # 提前初始化,保证即使数据缺失提前返回,后续 outputJsonData 也能安全访问
|
|
|
+ self.frequency_data = {}
|
|
|
# 检查所需列是否存在
|
|
|
required_columns = {Field_WindDirection, Field_WindSpeed}
|
|
|
if not required_columns.issubset(dataFrameMerge.columns) or dataFrameMerge[Field_WindDirection].isna().all() or dataFrameMerge[Field_WindSpeed].isna().all():
|
|
|
@@ -154,9 +156,6 @@ class WindDirectionFrequencyAnalyst(AnalystNotFilter):
|
|
|
self.logger.warning(msg)
|
|
|
return pd.DataFrame()
|
|
|
|
|
|
- # 定义类属性 self.frequency_data
|
|
|
- self.frequency_data = {}
|
|
|
-
|
|
|
# 风速区间
|
|
|
bins = [0, 3, 6, 9, np.inf]
|
|
|
speed_labels = ['[0,3)', '[3,6)', '[6,9)', '>=9']
|
|
|
@@ -275,6 +274,9 @@ class WindDirectionFrequencyAnalyst(AnalystNotFilter):
|
|
|
# return returnDatas
|
|
|
|
|
|
def outputJsonData(self, conf: Contract, outputAnalysisDir: str, turbineModelInfo: pd.Series, dataFrameMerge: pd.DataFrame) -> pd.DataFrame:
|
|
|
+ # 兼容 windRoseAnalysis 因数据缺失提前返回的情况
|
|
|
+ if not hasattr(self, "frequency_data"):
|
|
|
+ self.frequency_data = {}
|
|
|
turbineCodes = dataFrameMerge[Field_CodeOfTurbine].unique()
|
|
|
|
|
|
result_rows = []
|