Skip to content

Commit bab58c1

Browse files
committed
Update learn.py
1 parent a050eeb commit bab58c1

1 file changed

Lines changed: 48 additions & 53 deletions

File tree

ratc/learn.py

Lines changed: 48 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numpy as np
33
import matplotlib.pyplot as plt
44
import time
5-
print("plot u")
5+
GENERATE_PLOT = 1
66

77
concore.delay = 0.005
88
concore.default_maxtime(150)
@@ -25,59 +25,54 @@
2525
ymt[int(concore.simtime)] = np.array(ym).T
2626
oldsimtime = concore.simtime
2727
print("retry="+str(concore.retrycount))
28-
#print(ut)
29-
#print(ymt)
30-
#################
31-
# plot inputs and outputs
32-
u1 = [x[0].item() for x in ut]
33-
u2 = [x[1].item() for x in ut]
34-
u3 = [x[2].item() for x in ut]
35-
u4 = [x[3].item() for x in ut]
36-
u5 = [x[4].item() for x in ut]
37-
u6 = [x[5].item() for x in ut]
38-
39-
Nsim = len(u1)
40-
plt.figure()
41-
plt.subplot(321)
42-
plt.plot(range(Nsim), u1)
43-
plt.ylabel('Pw1 (s)')
44-
plt.subplot(322)
45-
plt.plot(range(Nsim), u2)
46-
plt.ylabel('Pf1 (Hz)')
47-
plt.subplot(323)
48-
plt.plot(range(Nsim), u3)
49-
plt.xlabel('Learn Cycles')
50-
plt.ylabel('Pw2 (s)')
51-
plt.subplot(324)
52-
plt.plot(range(Nsim), u4)
53-
plt.ylabel('Pf2 (Hz)')
54-
plt.subplot(325)
55-
plt.plot(range(Nsim), u5)
56-
plt.ylabel('Pw3 (s)')
57-
plt.subplot(326)
58-
plt.plot(range(Nsim), u6)
59-
plt.xlabel('Learn Cycles')
60-
plt.ylabel('Pf3 (Hz)')
61-
plt.savefig("stim.pdf")
62-
plt.tight_layout()
63-
6428

6529
#################
66-
6730
# plot inputs and outputs
68-
ym1 = [x[0].item() for x in ymt]
69-
ym2 = [x[1].item() for x in ymt]
70-
Nsim = len(ym1)
7131

72-
plt.figure()
73-
plt.subplot(211)
74-
plt.plot(range(Nsim), ym1)
75-
plt.ylabel('MAP (mmHg)')
76-
plt.legend(['Learn MAP'], loc=0)
77-
plt.subplot(212)
78-
plt.plot(range(Nsim), ym2)
79-
plt.xlabel('Cycles')
80-
plt.ylabel('HR (bpm)')
81-
plt.legend(['Learn HR'], loc=0)
82-
plt.savefig("hrmap.pdf")
83-
plt.show()
32+
if GENERATE_PLOT == 1:
33+
u1 = [x[0].item() for x in ut]
34+
u2 = [x[1].item() for x in ut]
35+
u3 = [x[2].item() for x in ut]
36+
u4 = [x[3].item() for x in ut]
37+
u5 = [x[4].item() for x in ut]
38+
u6 = [x[5].item() for x in ut]
39+
Nsim = len(u1)
40+
plt.figure()
41+
plt.subplot(321)
42+
plt.plot(range(Nsim), u1)
43+
plt.ylabel('Pw1 (s)')
44+
plt.subplot(322)
45+
plt.plot(range(Nsim), u2)
46+
plt.ylabel('Pf1 (Hz)')
47+
plt.subplot(323)
48+
plt.plot(range(Nsim), u3)
49+
plt.xlabel('Learn Cycles')
50+
plt.ylabel('Pw2 (s)')
51+
plt.subplot(324)
52+
plt.plot(range(Nsim), u4)
53+
plt.ylabel('Pf2 (Hz)')
54+
plt.subplot(325)
55+
plt.plot(range(Nsim), u5)
56+
plt.ylabel('Pw3 (s)')
57+
plt.subplot(326)
58+
plt.plot(range(Nsim), u6)
59+
plt.xlabel('Learn Cycles')
60+
plt.ylabel('Pf3 (Hz)')
61+
plt.savefig("stim.pdf")
62+
plt.tight_layout()
63+
64+
ym1 = [x[0].item() for x in ymt]
65+
ym2 = [x[1].item() for x in ymt]
66+
Nsim = len(ym1)
67+
plt.figure()
68+
plt.subplot(211)
69+
plt.plot(range(Nsim), ym1)
70+
plt.ylabel('MAP (mmHg)')
71+
plt.legend(['Learn MAP'], loc=0)
72+
plt.subplot(212)
73+
plt.plot(range(Nsim), ym2)
74+
plt.xlabel('Cycles')
75+
plt.ylabel('HR (bpm)')
76+
plt.legend(['Learn HR'], loc=0)
77+
plt.savefig("hrmap.pdf")
78+
plt.show()

0 commit comments

Comments
 (0)