pitchPowerAnalyst.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. import os
  2. from datetime import datetime
  3. import numpy as np
  4. import pandas as pd
  5. import plotly.express as px
  6. import plotly.graph_objects as go
  7. from algorithmContract.confBusiness import *
  8. from algorithmContract.contract import Contract
  9. from behavior.analystWithGoodBadPoint import AnalystWithGoodBadPoint
  10. class PitchPowerAnalyst(AnalystWithGoodBadPoint):
  11. """
  12. 风电机组变桨-功率分析
  13. """
  14. def typeAnalyst(self):
  15. return "pitch_power"
  16. def selectColumns(self):
  17. return [Field_DeviceCode, Field_Time,Field_WindSpeed, Field_ActiverPower, Field_PitchAngel1]
  18. def turbinesAnalysis(self, outputAnalysisDir, conf: Contract, turbineCodes):
  19. dictionary = self.processTurbineData(turbineCodes, conf,self.selectColumns())
  20. dataFrame = self.userDataFrame(dictionary,conf.dataContract.configAnalysis,self)
  21. turbineInfos = self.common.getTurbineInfos(conf.dataContract.dataFilter.powerFarmID, turbineCodes,
  22. self.turbineInfo)
  23. result_df1 = self.plot_power_pitch_angle(dataFrame, turbineInfos, outputAnalysisDir, conf)
  24. result_df2 = self.drawScatterGraph(dataFrame, turbineInfos, outputAnalysisDir, conf)
  25. result_df = pd.concat([result_df1, result_df2], ignore_index=True)
  26. return result_df
  27. def plot_power_pitch_angle(self, dataFrame:pd.DataFrame, turbineModelInfo: pd.Series, outputAnalysisDir:str, conf: Contract):
  28. # 按设备名分组数据
  29. dataFrameMerge = dataFrame[(dataFrame[Field_ActiverPower] > 0)].sort_values(by=Field_YearMonth)
  30. grouped = dataFrameMerge.groupby([Field_NameOfTurbine, Field_CodeOfTurbine])
  31. # 定义固定的颜色映射列表
  32. fixed_colors = [
  33. "#3E409C",
  34. "#476CB9",
  35. "#3586BF",
  36. "#4FA4B5",
  37. "#52A3AE",
  38. "#60C5A3",
  39. "#85D0AE",
  40. "#A8DCA2",
  41. "#CFEE9E",
  42. "#E4F39E",
  43. "#EEF9A7",
  44. "#FBFFBE",
  45. "#FDF1A9",
  46. "#FFE286",
  47. "#FFC475",
  48. "#FCB06C",
  49. "#F78F4F",
  50. "#F96F4A",
  51. "#E4574C",
  52. "#CA3756",
  53. "#AF254F"
  54. ]
  55. # 将 fixed_colors 转换为 Plotly 的 colorscale 格式
  56. fixed_colorscale = [
  57. [i / (len(fixed_colors) - 1), color] for i, color in enumerate(fixed_colors)
  58. ]
  59. # 遍历每个设备并绘制散点图
  60. result_rows1 = []
  61. for name, group in grouped:
  62. # 创建图形
  63. fig = go.Figure()
  64. # 添加散点图
  65. fig.add_trace(go.Scatter(
  66. x=group[Field_ActiverPower],
  67. y=group[Field_PitchAngel1],
  68. mode='markers',
  69. # marker=dict(color='blue', size=3.5)
  70. marker=dict(
  71. color=group[Field_UnixYearMonth],
  72. colorscale=fixed_colorscale,
  73. size=3,
  74. opacity=0.7,
  75. colorbar=dict(
  76. tickvals=np.linspace(
  77. group[Field_UnixYearMonth].min(), group[Field_UnixYearMonth].max(), 6),
  78. ticktext=[datetime.fromtimestamp(ts).strftime('%Y-%m') for ts in np.linspace(
  79. group[Field_UnixYearMonth].min(), group[Field_UnixYearMonth].max(), 6)],
  80. thickness=18,
  81. len=1, # 设置颜色条的长度,使其占据整个图的高度
  82. outlinecolor='rgba(255,255,255,0)'
  83. ),
  84. showscale=True
  85. ),
  86. showlegend=False
  87. ))
  88. # 设置图形布局
  89. fig.update_layout(
  90. title=f'机组: {name[0]}',
  91. xaxis=dict(
  92. title='功率',
  93. range=[self.axisLowerLimitActivePower,
  94. self.axisUpperLimitActivePower],
  95. dtick=self.axisStepActivePower,
  96. tickangle=-45 # 设置x轴刻度值旋转角度为45度,如果需要
  97. ),
  98. yaxis=dict(
  99. title='桨距角',
  100. range=[self.axisLowerLimitPitchAngle,
  101. self.axisUpperLimitPitchAngle],
  102. dtick=self.axisStepPitchAngle
  103. ),
  104. coloraxis=dict(
  105. colorbar=dict(
  106. title="时间",
  107. ticks="outside",
  108. len=1, # 设置颜色条的长度,使其占据整个图的高度
  109. thickness=20, # 调整颜色条的宽度
  110. orientation='v', # 设置颜色条为垂直方向
  111. tickmode='array', # 确保刻度按顺序排列
  112. tickvals=dataFrameMerge[Field_YearMonth].unique(
  113. ).tolist(), # 确保刻度为唯一的年月
  114. ticktext=dataFrameMerge[Field_YearMonth].unique(
  115. ).tolist() # 以%Y-%m格式显示标签
  116. )
  117. )
  118. )
  119. # 确保从 Series 中提取的是具体的值
  120. engineTypeCode = turbineModelInfo.get(Field_MillTypeCode, "")
  121. if isinstance(engineTypeCode, pd.Series):
  122. engineTypeCode = engineTypeCode.iloc[0]
  123. engineTypeName = turbineModelInfo.get(Field_MachineTypeCode, "")
  124. if isinstance(engineTypeName, pd.Series):
  125. engineTypeName = engineTypeName.iloc[0]
  126. group[Field_UnixYearMonth] = pd.to_datetime(group[Field_UnixYearMonth], unit='s').dt.strftime(
  127. '%Y-%m-%d %H:%M:%S')
  128. # 构建最终的JSON对象
  129. json_output = {
  130. "analysisTypeCode": "变桨和有功功率协调性分析",
  131. "engineCode": engineTypeCode,
  132. "engineTypeName": engineTypeName,
  133. "xaixs": "功率(kW)",
  134. "yaixs": "桨距角(°)",
  135. "data": [{
  136. "engineName": name[0],
  137. "engineCode": name[1],
  138. "title": f' 机组: {name[0]}',
  139. "xData": group[Field_ActiverPower].tolist(),
  140. "yData": group[Field_PitchAngel1].tolist(),
  141. "timeData": group[Field_UnixYearMonth].tolist(),
  142. # "colorbar": dataFrameMerge[Field_YearMonth].unique().tolist(),
  143. "colorbar": group[Field_YearMonth].tolist(),
  144. }]
  145. }
  146. # 保存图像
  147. # filePathOfImage = os.path.join(outputAnalysisDir, f"{name[0]}.png")
  148. # fig.write_image(filePathOfImage, width=800, height=600, scale=3)
  149. # filePathOfHtml = os.path.join(outputAnalysisDir, f"{name[0]}.html")
  150. # fig.write_html(filePathOfHtml)
  151. # 将JSON对象保存到文件
  152. output_json_path = os.path.join(outputAnalysisDir, f"pitch_Power_Analyst{name[0]}.json")
  153. with open(output_json_path, 'w', encoding='utf-8') as f:
  154. import json
  155. json.dump(json_output, f, ensure_ascii=False, indent=4)
  156. # result_rows1.append({
  157. # Field_Return_TypeAnalyst: self.typeAnalyst(),
  158. # Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
  159. # Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
  160. # Field_CodeOfTurbine: name[1],
  161. # Field_Return_FilePath: filePathOfImage,
  162. # Field_Return_IsSaveDatabase: False
  163. # })
  164. result_rows1.append({
  165. Field_Return_TypeAnalyst: self.typeAnalyst(),
  166. Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
  167. Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
  168. Field_CodeOfTurbine: name[1],
  169. Field_MillTypeCode: 'total',
  170. Field_Return_FilePath: output_json_path,
  171. Field_Return_IsSaveDatabase: True
  172. })
  173. result_df1 = pd.DataFrame(result_rows1)
  174. return result_df1
  175. def drawScatterGraph(self, dataFrame: pd.DataFrame, turbineModelInfo: pd.Series, outputAnalysisDir: str, conf: Contract):
  176. dataFrame = dataFrame[(dataFrame[Field_ActiverPower] > 0)].sort_values(
  177. by=Field_YearMonth)
  178. grouped = dataFrame.groupby([Field_NameOfTurbine, Field_CodeOfTurbine])
  179. '''
  180. # 遍历每个设备的数据
  181. result_rows2 = []
  182. for name, group in grouped:
  183. if len(group[Field_YearMonth].unique()) > 1:
  184. fig = px.scatter_3d(dataFrame,
  185. x=Field_PitchAngel1,
  186. y=Field_YearMonth,
  187. z=Field_ActiverPower,
  188. color=Field_YearMonth,
  189. labels={Field_PitchAngel1: '桨距角',
  190. Field_YearMonth: '时间', Field_ActiverPower: '功率'},
  191. )
  192. # 设置固定散点大小
  193. fig.update_traces(marker=dict(size=1.5))
  194. # 更新图形的布局
  195. fig.update_layout(
  196. title={
  197. "text": f'月度桨距角功率3D散点图: {name[0]}',
  198. "x": 0.5
  199. },
  200. scene=dict(
  201. xaxis=dict(
  202. title='桨距角',
  203. dtick=self.axisStepPitchAngle,
  204. range=[self.axisLowerLimitPitchAngle,
  205. self.axisUpperLimitPitchAngle],
  206. ),
  207. yaxis=dict(
  208. title='时间',
  209. tickformat='%Y-%m', # 日期格式,
  210. dtick='M1', # 每月一个刻度
  211. showgrid=True, # 显示网格线
  212. ),
  213. zaxis=dict(
  214. title='功率',
  215. dtick=self.axisStepActivePower,
  216. range=[self.axisLowerLimitActivePower,
  217. self.axisUpperLimitActivePower],
  218. showgrid=True, # 显示网格线
  219. )
  220. ),
  221. scene_camera=dict(
  222. up=dict(x=0, y=0, z=1), # 保持相机向上方向不变
  223. center=dict(x=0, y=0, z=0), # 保持相机中心位置不变
  224. eye=dict(x=-1.8, y=-1.8, z=1.2) # 调整eye属性以实现水平旋转180°
  225. ),
  226. # 设置图例标题
  227. # legend_title_text='Time',
  228. legend=dict(
  229. orientation="h",
  230. itemsizing="constant", # Use constant size for legend items
  231. itemwidth=80 # Set the width of legend items to 50 pixels
  232. )
  233. )
  234. '''
  235. # 假设 colorsList 已经在代码的其他部分定义
  236. colorsList = [
  237. "#3E409C",
  238. "#3586BF",
  239. "#52A3AE",
  240. "#85D0AE",
  241. "#A8DCA2",
  242. "#FBFFBE",
  243. "#FDF1A9",
  244. "#FFE286",
  245. "#FCB06C",
  246. "#F96F4A",
  247. "#E4574C",
  248. "#AF254F"
  249. ]
  250. # 遍历每个设备的数据
  251. result_rows2 = []
  252. for name, group in grouped:
  253. if len(group[Field_YearMonth].unique()) > 1:
  254. fig = px.scatter_3d(
  255. group,
  256. x=Field_PitchAngel1,
  257. y=Field_YearMonth,
  258. z=Field_ActiverPower,
  259. color=Field_YearMonth,
  260. color_discrete_sequence=colorsList, # 使用 colorsList 作为颜色映射
  261. labels={
  262. Field_PitchAngel1: '桨距角',
  263. Field_YearMonth: '时间',
  264. Field_ActiverPower: '功率'
  265. },
  266. )
  267. # 设置固定散点大小
  268. fig.update_traces(marker=dict(size=1.5))
  269. # 更新图形的布局
  270. fig.update_layout(
  271. title={
  272. "text": f'月度桨距角功率3D散点图: {name[0]}',
  273. "x": 0.5
  274. },
  275. scene=dict(
  276. xaxis=dict(
  277. title='桨距角',
  278. dtick=self.axisStepPitchAngle,
  279. range=[self.axisLowerLimitPitchAngle, self.axisUpperLimitPitchAngle],
  280. ),
  281. yaxis=dict(
  282. title='时间',
  283. tickformat='%Y-%m', # 日期格式,
  284. dtick='M1', # 每月一个刻度
  285. showgrid=True, # 显示网格线
  286. ),
  287. zaxis=dict(
  288. title='功率',
  289. dtick=self.axisStepActivePower,
  290. range=[self.axisLowerLimitActivePower, self.axisUpperLimitActivePower],
  291. showgrid=True, # 显示网格线
  292. )
  293. ),
  294. scene_camera=dict(
  295. up=dict(x=0, y=0, z=1), # 保持相机向上方向不变
  296. center=dict(x=0, y=0, z=0), # 保持相机中心位置不变
  297. eye=dict(x=-1.8, y=-1.8, z=1.2) # 调整eye属性以实现水平旋转180°
  298. ),
  299. legend=dict(
  300. orientation="h",
  301. itemsizing="constant", # Use constant size for legend items
  302. itemwidth=80 # Set the width of legend items to 50 pixels
  303. )
  304. )
  305. # 确保从 Series 中提取的是具体的值
  306. engineTypeCode = turbineModelInfo.get(Field_MillTypeCode, "")
  307. if isinstance(engineTypeCode, pd.Series):
  308. engineTypeCode = engineTypeCode.iloc[0]
  309. engineTypeName = turbineModelInfo.get(Field_MachineTypeCode, "")
  310. if isinstance(engineTypeName, pd.Series):
  311. engineTypeName = engineTypeName.iloc[0]
  312. # 构建最终的JSON对象
  313. json_output = {
  314. "analysisTypeCode": "变桨和有功功率协调性分析",
  315. "engineCode": engineTypeCode,
  316. "engineTypeName": engineTypeName,
  317. "xaixs": "桨距角(°)",
  318. "yaixs": "时间",
  319. "zaixs": "有功功率(kW)",
  320. "data": [{
  321. "engineName": name[0],
  322. "engineCode": name[1],
  323. "title": f' 月度桨距角功率3D散点图: {name[0]}',
  324. "xData": group[Field_PitchAngel1].tolist(),
  325. "yData": group[Field_YearMonth].tolist(),
  326. "zData": group[Field_ActiverPower].tolist(),
  327. "color":group[Field_YearMonth].tolist()
  328. }]
  329. }
  330. # 保存图像
  331. # filePathOfImage = os.path.join(outputAnalysisDir, f"{name[0]}_3D.png")
  332. # fig.write_image(filePathOfImage, width=800, height=600, scale=3)
  333. # filePathOfHtml = os.path.join(outputAnalysisDir, f"{name[0]}_3D.html")
  334. # fig.write_html(filePathOfHtml)
  335. # 将JSON对象保存到文件
  336. output_json_path = os.path.join(outputAnalysisDir, f"pitch_Power_Analyst{name[0]}_3D.json")
  337. with open(output_json_path, 'w', encoding='utf-8') as f:
  338. import json
  339. json.dump(json_output, f, ensure_ascii=False, indent=4)
  340. # result_rows2.append({
  341. # Field_Return_TypeAnalyst: self.typeAnalyst(),
  342. # Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
  343. # Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
  344. # Field_CodeOfTurbine: name[1],
  345. # Field_Return_FilePath: filePathOfImage,
  346. # Field_Return_IsSaveDatabase: False
  347. # })
  348. result_rows2.append({
  349. Field_Return_TypeAnalyst: self.typeAnalyst(),
  350. Field_PowerFarmCode: conf.dataContract.dataFilter.powerFarmID,
  351. Field_Return_BatchCode: conf.dataContract.dataFilter.dataBatchNum,
  352. Field_CodeOfTurbine: name[1],
  353. Field_MillTypeCode: 'total',
  354. Field_Return_FilePath: output_json_path,
  355. Field_Return_IsSaveDatabase: True
  356. })
  357. result_df2 = pd.DataFrame(result_rows2)
  358. return result_df2
  359. # self.drawScatterGraphOfTurbine(
  360. # group, outputAnalysisDir, conf, name)
  361. # def drawScatterGraphOfTurbine(self, dataFrame: pd.DataFrame, outputAnalysisDir: str, conf: Contract, turbineName: str):
  362. # # 创建3D散点图
  363. # fig = px.scatter_3d(dataFrame,
  364. # x=Field_PitchAngel1,
  365. # y=Field_YearMonth,
  366. # z=Field_ActiverPower,
  367. # color=Field_YearMonth,
  368. # labels={Field_PitchAngel1: 'Pitch Angle',
  369. # Field_YearMonth: 'Time', Field_ActiverPower: 'Power'},
  370. # )
  371. # # 设置固定散点大小
  372. # fig.update_traces(marker=dict(size=1.5))
  373. # # 更新图形的布局
  374. # fig.update_layout(
  375. # title={
  376. # "text": f'Monthly Pitch-Power 3D Scatter Plot: {turbineName}',
  377. # "x": 0.5
  378. # },
  379. # scene=dict(
  380. # xaxis=dict(
  381. # title='Pitch Angle',
  382. # range=[conf.dataContract.graphSets["pitchAngle"]["min"] if not self.common.isNone(conf.dataContract.graphSets["pitchAngle"]["min"]) else -2,
  383. # conf.dataContract.graphSets["pitchAngle"]["max"] if not self.common.isNone(conf.dataContract.graphSets["pitchAngle"]["max"]) else 28],
  384. # dtick=conf.dataContract.graphSets["pitchAngle"]["step"] if not self.common.isNone(conf.dataContract.graphSets["pitchAngle"]["step"]) else 2,
  385. # ),
  386. # yaxis=dict(
  387. # title='Time',
  388. # tickformat='%Y-%m', # 日期格式,
  389. # dtick='M1', # 每月一个刻度
  390. # showgrid=True, # 显示网格线
  391. # ),
  392. # zaxis=dict(
  393. # title='Power',
  394. # dtick=conf.dataContract.graphSets["activePower"]["step"] if not self.common.isNone(
  395. # conf.dataContract.graphSets["activePower"]) and not self.common.isNone(
  396. # conf.dataContract.graphSets["activePower"]["step"]) else 250,
  397. # range=[conf.dataContract.graphSets["activePower"]["min"] if not self.common.isNone(
  398. # conf.dataContract.graphSets["activePower"]["min"]) else 0, conf.dataContract.graphSets["activePower"]["max"] if not self.common.isNone(conf.dataContract.graphSets["activePower"]["max"]) else conf.rated_power*1.2],
  399. # showgrid=True, # 显示网格线
  400. # )
  401. # ),
  402. # scene_camera=dict(
  403. # up=dict(x=0, y=0, z=1), # 保持相机向上方向不变
  404. # center=dict(x=0, y=0, z=0), # 保持相机中心位置不变
  405. # eye=dict(x=-1.8, y=-1.8, z=1.2) # 调整eye属性以实现水平旋转180°
  406. # ),
  407. # # 设置图例标题
  408. # legend_title_text='Time'
  409. # )
  410. # # 保存图像
  411. # outputFileHtml = os.path.join(
  412. # outputAnalysisDir, "{}_3D.html".format(turbineName))
  413. # fig.write_html(outputFileHtml)
  414. """"
  415. def drawScatterGraph(self, dataFrame: pd.DataFrame, outputAnalysisDir, conf: Contract):
  416. ## 绘制变桨-功率分布图并保存为文件。
  417. ## 参数:
  418. ## dataFrameMerge (pd.DataFrame): 包含数据的DataFrame,需要包含设备名、风速和功率列。
  419. ## outputAnalysisDir (str): 分析输出目录。
  420. ## conf (ConfBusiness): 配置
  421. ## 按设备名分组数据
  422. colorsList = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd',
  423. '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf', '#aec7e8', '#ffbb78']
  424. grouped = dataFrame.groupby(Field_NameOfTurbine)
  425. # 遍历每个设备的数据
  426. for name, group in grouped:
  427. # 创建颜色映射,将每个年月映射到一个唯一的颜色
  428. unique_months = group[Field_YearMonth].unique()
  429. colors = [
  430. colorsList[i % 12] for i in range(len(unique_months))]
  431. color_map = dict(zip(unique_months, colors))
  432. # 使用go.Scatter3d创建3D散点图
  433. trace = go.Scatter3d(
  434. x=group[Field_PitchAngel1],
  435. y=group[Field_YearMonth],
  436. z=group[Field_ActiverPower],
  437. mode='markers',
  438. marker=dict(
  439. color=[color_map[month]
  440. for month in group[Field_YearMonth]],
  441. size=1.5,
  442. line=dict(
  443. color='rgba(0, 0, 0, 0)', # 设置边框颜色为透明,以去掉白色边框
  444. width=0 # 设置边框宽度为0,进一步确保没有边框
  445. ),
  446. opacity=0.8 # 调整散点的透明度,增加透视效果
  447. )
  448. )
  449. # 创建图形
  450. fig = go.Figure(data=[trace])
  451. # 更新图形的布局
  452. fig.update_layout(
  453. title={
  454. "text": f'三维散点图{name}',
  455. "x": 0.5
  456. },
  457. scene=dict(
  458. xaxis=dict(
  459. title='桨距角',
  460. dtick=conf.dataContract.graphSets["pitchAngle"]["step"] if not self.common.isNone(
  461. conf.dataContract.graphSets["pitchAngle"]["step"]) else 2, # 设置y轴刻度间隔为0.1
  462. range=[conf.dataContract.graphSets["pitchAngle"]["min"] if not self.common.isNone(
  463. conf.dataContract.graphSets["pitchAngle"]["min"]) else -2, conf.dataContract.graphSets["pitchAngle"]["max"] if not self.common.isNone(conf.dataContract.graphSets["pitchAngle"]["max"]) else 28], # 设置y轴的范围从0到1
  464. showgrid=True, # 显示网格线
  465. ),
  466. yaxis=dict(
  467. title='时间',
  468. tickmode='array',
  469. tickvals=unique_months,
  470. ticktext=unique_months,
  471. showgrid=True, # 显示网格线
  472. categoryorder='category ascending'
  473. ),
  474. zaxis=dict(
  475. title='功率',
  476. dtick=conf.dataContract.graphSets["activePower"]["step"] if not self.common.isNone(
  477. conf.dataContract.graphSets["activePower"]) and not self.common.isNone(
  478. conf.dataContract.graphSets["activePower"]["step"]) else 250,
  479. range=[conf.dataContract.graphSets["activePower"]["min"] if not self.common.isNone(
  480. conf.dataContract.graphSets["activePower"]["min"]) else 0, conf.dataContract.graphSets["activePower"]["max"] if not self.common.isNone(conf.dataContract.graphSets["activePower"]["max"]) else conf.rated_power*1.2],
  481. )
  482. ),
  483. scene_camera=dict(
  484. up=dict(x=0, y=0, z=1), # 保持相机向上方向不变
  485. center=dict(x=0, y=0, z=0), # 保持相机中心位置不变
  486. eye=dict(x=-1.8, y=-1.8, z=1.2) # 调整eye属性以实现水平旋转180°
  487. ),
  488. margin=dict(t=50, b=10) # t为顶部(top)间距,b为底部(bottom)间距
  489. )
  490. # 保存图像
  491. outputFileHtml = os.path.join(
  492. outputAnalysisDir, "{}.html".format(name))
  493. fig.write_html(outputFileHtml)
  494. """