-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_individual_graphs.sce
More file actions
80 lines (69 loc) · 3.19 KB
/
Copy pathrun_individual_graphs.sce
File metadata and controls
80 lines (69 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// run_individual_graphs.sce - Generates 4 individual PNGs
funcprot(0);
disp('=== Initializing All Modules ===');
exec('phm_project/data_loader/load_data.sci', -1);
exec('phm_project/interpolation/interpolation.sci', -1);
exec('phm_project/differentiation/differentiation.sci', -1);
exec('phm_project/integration/integration.sci', -1);
exec('phm_project/user_interface/health_dashboard.sci', -1);
THRESHOLD = 9.5;
[pressure, voltage, hours, vibration] = load_data('pump_health_data.csv');
// --- Calculations ---
coeff_poly = poly_fit(voltage, pressure, 3);
press_poly = eval_poly(coeff_poly, voltage);
v_smooth = linspace(min(voltage), max(voltage), 200)';
p_smooth = eval_poly(coeff_poly, v_smooth);
resid_A = pressure - press_poly;
[a_exp, b_exp] = linearize_vib(hours, vibration);
vib_exp = predict_vibration(a_exp, b_exp, hours);
h_star = find_threshold_hour(hours, vib_exp, THRESHOLD);
HI = compute_health_index(vibration, THRESHOLD);
n = length(hours);
h_known = ~isinf(h_star) & ~isnan(h_star);
disp('=== Generating Individual Graphs ===');
// --- Graph 1: Calibration ---
fig1 = scf(1); clf(); fig1.figure_size = [800, 600];
scatter(voltage, pressure, 18, [0.15 0.40 0.75]);
plot(v_smooth, p_smooth, 'r-');
xlabel('Sensor Voltage (mV)'); ylabel('Differential Pressure (bar)');
title('[Student A] Pressure-Voltage Calibration');
legend(['Measured data'; 'Cubic fit (k=3)'], 4);
xgrid(1);
xs2png(fig1, 'graph_1_calibration.png');
disp('Saved: graph_1_calibration.png');
// --- Graph 2: Residuals ---
fig2 = scf(2); clf(); fig2.figure_size = [800, 600];
scatter(voltage, resid_A, 18, [0.15 0.40 0.75]);
plot([min(voltage), max(voltage)], [0, 0], 'k-');
xlabel('Sensor Voltage (mV)'); ylabel('Residual (bar)');
title('[Student A] Calibration Residuals');
xgrid(1);
xs2png(fig2, 'graph_2_residuals.png');
disp('Saved: graph_2_residuals.png');
// --- Graph 3: Degradation ---
fig3 = scf(3); clf(); fig3.figure_size = [800, 600];
scatter(hours, vibration, 18, [1.0 0.55 0.15]);
plot(hours, vib_exp, 'g-');
plot(hours, THRESHOLD .* ones(n, 1), 'k--');
if h_known then plot([h_star, h_star], [0, THRESHOLD * 1.35], 'm-.'); end
xlabel('Operational Hours (h)'); ylabel('Vibration (mm/s rms)');
title('[Student B] Vibration Degradation Model');
if h_known then legend(['Measured vibration'; 'Exponential fit'; 'Failure threshold'; 'Predicted failure h*'], 4);
else legend(['Measured vibration'; 'Exponential fit'; 'Failure threshold'], 4); end
xgrid(1);
xs2png(fig3, 'graph_3_degradation.png');
disp('Saved: graph_3_degradation.png');
// --- Graph 4: Health Index ---
fig4 = scf(4); clf(); fig4.figure_size = [800, 600];
plot(hours, 0.75 .* ones(n, 1), 'g--');
plot(hours, 0.90 .* ones(n, 1), 'y--');
plot(hours, ones(n, 1), 'r--');
plot(hours, HI, 'b-');
if h_known then plot([h_star, h_star], [0, 1.05], 'm-.'); end
xlabel('Operational Hours (h)'); ylabel('Health Index (HI)');
title('[Students C+D] Health Index and Failure Prediction');
if h_known then legend(['GOOD/WARN (0.75)'; 'WARN/CRIT (0.90)'; 'Failure (1.0)'; 'Health Index'; 'Predicted h*'], 2);
else legend(['GOOD/WARN (0.75)'; 'WARN/CRIT (0.90)'; 'Failure (1.0)'; 'Health Index'], 2); end
xgrid(1);
xs2png(fig4, 'graph_4_health_index.png');
disp('Saved: graph_4_health_index.png');