|
2 | 2 | import numpy as np |
3 | 3 | import matplotlib.pyplot as plt |
4 | 4 | import time |
5 | | -print("plot u") |
| 5 | +GENERATE_PLOT = 1 |
6 | 6 |
|
7 | 7 | concore.delay = 0.005 |
8 | 8 | concore.default_maxtime(150) |
|
25 | 25 | ymt[int(concore.simtime)] = np.array(ym).T |
26 | 26 | oldsimtime = concore.simtime |
27 | 27 | 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 | | - |
64 | 28 |
|
65 | 29 | ################# |
66 | | - |
67 | 30 | # 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) |
71 | 31 |
|
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