Files
windfarm/generate_template.py
dmy b924f75add docs: 完善项目文档和使用说明
- 更新README.md,补充GUI特性说明和参数配置文档
- 新增使用说明目录,包含完整的操作手册和界面截图
- 优化generate_template.py,支持自定义模板输出路径
- 改进GUI界面布局,优化文件上传和模板导出功能
- 添加系统参数配置说明(电压、功率因数等)
2026-01-05 23:30:29 +08:00

68 lines
2.4 KiB
Python

import pandas as pd
import numpy as np
def create_template(output_file='windfarm_template.xlsx'):
# Create sample data similar to the internal generator
data = []
# Add Substation
data.append({
'Type': 'Substation',
'ID': 'Sub1',
'X': 4000,
'Y': -800,
'Power': 0,
'PlatformHeight': 0
})
# Add Turbines (Grid layout)
n_turbines = 30
spacing = 800
n_cols = 6
for i in range(n_turbines):
row = i // n_cols
col = i % n_cols
x = col * spacing
y = row * spacing
data.append({
'Type': 'Turbine',
'ID': i,
'X': x,
'Y': y,
'Power': np.random.uniform(6.0, 10.0),
'PlatformHeight': 0
})
df = pd.DataFrame(data)
# Create Cable data
cable_data = [
{'CrossSection': 35, 'Capacity': 150, 'Resistance': 0.524, 'Cost': 80, 'Optional': ''},
{'CrossSection': 70, 'Capacity': 215, 'Resistance': 0.268, 'Cost': 120, 'Optional': ''},
{'CrossSection': 95, 'Capacity': 260, 'Resistance': 0.193, 'Cost': 150, 'Optional': ''},
{'CrossSection': 120, 'Capacity': 295, 'Resistance': 0.153, 'Cost': 180, 'Optional': ''},
{'CrossSection': 150, 'Capacity': 330, 'Resistance': 0.124, 'Cost': 220, 'Optional': ''},
{'CrossSection': 185, 'Capacity': 370, 'Resistance': 0.0991, 'Cost': 270, 'Optional': ''},
{'CrossSection': 240, 'Capacity': 425, 'Resistance': 0.0754, 'Cost': 350, 'Optional': ''},
{'CrossSection': 300, 'Capacity': 500, 'Resistance': 0.0601, 'Cost': 450, 'Optional': ''},
{'CrossSection': 400, 'Capacity': 580, 'Resistance': 0.0470, 'Cost': 600, 'Optional': ''}
]
df_cables = pd.DataFrame(cable_data)
# Create System Parameters data
param_data = [
{'Parameter': 'Voltage (kV) / 电压 (kV)', 'Value': 66},
{'Parameter': 'Power Factor / 功率因数', 'Value': 0.95}
]
df_params = pd.DataFrame(param_data)
# Save to Excel
with pd.ExcelWriter(output_file) as writer:
df.to_excel(writer, sheet_name='Coordinates', index=False)
df_cables.to_excel(writer, sheet_name='Cables', index=False)
df_params.to_excel(writer, sheet_name='Parameters', index=False)
print(f"Created sample file: {output_file} with sheets 'Coordinates', 'Cables', and 'Parameters'")
if __name__ == "__main__":
create_template()