import numpy as np
import pandas as pd

# Time vector as (start, end, Hz)
time = np.arange(0.0, 2500, 5)

# Simulate basic responses (steady state + sine oscillation)
rot_speed = 12.140 + 0.100 * np.sin(2 * np.pi * 0.010 * time)
gen_power = 523.00 + 10.00 * np.sin(2 * np.pi * 0.010 * time + 0.5)
root_myc1 = 925.00 + 250.0 * np.sin(2 * np.pi * 0.002 * time)
twr_bsfxt = 45.120 + 2.000 * np.sin(2 * np.pi * 0.005 * time)

# Assemble DataFrame
df = pd.DataFrame({
    'Time': time,
    'RotSpeed': rot_speed,
    'GenPower': gen_power,
    'RootMyc1': root_myc1,
    'TwrBsFxt': twr_bsfxt
})
units = ['(s)', '(rpm)', '(kW)', '(kN m)', '(kN)']

header_line = ",".join([str(col) for col in df.columns])
#header_line = "".join([str(col).ljust(12) for col in df.columns])
units_line = "".join([str(col).ljust(12) for col in units])

# Print OpenFAST-style header and data to file
with open('WT_Sample_Loads.out', 'w') as f:
    #f.write("Sample data to emulate OpenFAST output\n")
    #f.write("Generated via Python\n")

    f.write(header_line + "\n")
    #f.write(units_line + "\n")
    
    for _, row in df.iterrows():
        f.write(f"{row['Time']:8.1f},{row['RotSpeed']:8.3E},{row['GenPower']:9.3E}"
        f",{row['RootMyc1']:9.3E},{row['TwrBsFxt']:9.3E}\n")

