| import pandas as pd
|
| import matplotlib.pyplot as plt
|
|
|
|
|
| df = pd.read_csv('flightgear_phm_log.csv')
|
|
|
|
|
| fig, ax1 = plt.subplots(figsize=(10, 5))
|
|
|
|
|
| color1 = '#38BDF8'
|
| ax1.set_xlabel('Frame (10 Hz)')
|
| ax1.set_ylabel('Predicted RUL (cycles)', color=color1, fontweight='bold')
|
| ax1.plot(df['frame'], df['rul_mean'], color=color1, label='RUL (mean)', lw=2)
|
| ax1.fill_between(df['frame'],
|
| df['rul_mean'] - 1.645 * df['rul_std'],
|
| df['rul_mean'] + 1.645 * df['rul_std'],
|
| alpha=0.2, color=color1, label='90% Confidence Interval')
|
| ax1.tick_params(axis='y', labelcolor=color1)
|
|
|
|
|
| ax2 = ax1.twinx()
|
| color2 = '#EF4444'
|
| ax2.set_ylabel('Relative Health (%)', color=color2, fontweight='bold')
|
| ax2.plot(df['frame'], df['health_pct'], color=color2, linestyle='--', lw=2, label='Health %')
|
| ax2.tick_params(axis='y', labelcolor=color2)
|
| ax2.set_ylim(0, 110)
|
|
|
|
|
|
|
| fault_frame = 1800
|
| plt.axvline(x=fault_frame, color='gray', linestyle=':', label='Fault Injection (HPT)')
|
|
|
|
|
| plt.title('Figure 9: Real-time PHM Response to Simulated HPT Blade Degradation', fontweight='bold')
|
| fig.tight_layout()
|
| plt.grid(True, alpha=0.3)
|
|
|
| lines1, labels1 = ax1.get_legend_handles_labels()
|
| lines2, labels2 = ax2.get_legend_handles_labels()
|
| ax1.legend(lines1 + lines2, labels1 + labels2, loc='lower left', frameon=True)
|
|
|
|
|
| plt.savefig('fig9_health_timeseries.pdf', format='pdf')
|
| print("Successfully generated fig9_health_timeseries.pdf")
|
| plt.show() |