-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresultsPlot.py
87 lines (71 loc) · 2.73 KB
/
resultsPlot.py
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
80
81
82
83
84
85
86
87
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 12:00:56 2015
@author: Pavel Esir
"""
import matplotlib
matplotlib.rcParams.update({'font.size': 16})
from matplotlib.pylab import *
from numpy import *
SimTime = 2000
C = 5.0
dNread = 20
freq = 4
T = 0.05
N = 200
Mm = 0.5
Nreads = arange(dNread, N + 1, dNread, dtype='int')
Urange = arange(0.05, 0.951, 0.05)
#Ierange = load('U_Iex_Simime_20.0_h_0.0020_D_2.0_N_200_eps_0.010_m_{:.1f}.npy'.format(Mm))
#folderName = 'res_h_0.0020_D_2.0_freq_{:.1f}_T_{:.2f}/'.format(freq, T)
folderName = 'res_h_0.0020_D_2.0_freq_{:.1f}_T_{:.2f}_m_{:.1f}/'.format(freq, T, Mm)
name = folderName + 'U_{:.2f}_C_{:.1f}_N_{:d}_SimTime_{:d}.npy'
nameExactR = folderName + 'U_{:.2f}_C_{:.1f}_N_{:d}_SimTime_{:d}_exactPV.npy'
errR = np.load(name.format(Urange[0], C, N, SimTime))
arrShape = len(Urange), shape(errR)[0], shape(errR)[1], shape(errR)[2]
errR = zeros(arrShape)
arrShape = len(Urange), shape(errR)[1], shape(errR)[3]
errExactR = zeros(arrShape)
for idx, u in enumerate(Urange):
er = load(name.format(u, C, N, SimTime))
errR[idx] = er
er = load(nameExactR.format(u, C, N, SimTime))
errExactR[idx] = er
#%%
meanErrR = mean(errR, axis=3)
minLags = argmin(meanErrR, axis=1)
minLagErr = amin(meanErrR, axis=1)
meanErrExactR = mean(errExactR, axis=2)
minLagsExact = argmin(meanErrExactR, axis=1)
minLagErrExact = amin(meanErrExactR, axis=1)
minErrNread = zeros(len(Nreads))
NreadsForPlot = [20, 40, 80, 200]
for idx, Nread in enumerate(Nreads):
errs = minLagErr[:, int(Nread/dNread - 1)]*360/(4*np.pi)
minErrNread[idx] = Urange[argmin(errs)]
if Nread in NreadsForPlot:
figure(1, figsize=(4*2.5, 3*2.5))
plot(Urange, errs, '-o', label=r'$N_{{read}}={}$'.format(Nread))
figure(2, figsize=(4*2.5, 3*2.5))
plot(Urange, minLags[:, int(Nread/dNread - 1)]*2., '-o', label=r'$N_{{read}}={}$'.format(Nread))
figure(1, figsize=(4*2.5, 3*2.5))
plot(Urange, minLagErrExact*360/(4*pi), '--o', label='exact readout')
title('$C={}$'.format(C))
legend(loc='upper right', fontsize=14.0)
xlabel('U')
ylabel('$Error[degree \; ^{\circ}$]')
#savefig("Freq_{}_C_{}_Tsim_{}_mean_{}_N_{}.png".format(freq, C, SimTime, Mm, N), dpi=260.)
figure(2, figsize=(4*2.5, 3*2.5))
plot(Urange, minLagsExact*2, '--o', label='exact readout')
title('$C={}$'.format(C))
legend(loc='upper right', fontsize=14.0)
xlabel('U')
ylabel('$lag[ms]$')
#savefig("lag_Freq_{}_C_{}_Tsim_{}_mean_{}_N_{}.png".format(freq, C, SimTime, Mm, N), dpi=260.)
#%%
figure(3, figsize=(4*2.5, 3*2.5))
#title(r"$C = {}$".format(C))
plot(Nreads, minErrNread, '-o', label='$C= {}$'.format(C))
xlabel(r'$N_{read}$')
ylabel(r'U for minimal error')
#savefig("U_for_min_Freq_{}_C_{}_Tsim_{}_mean_{}_N_{}.png".format(freq, C, SimTime, Mm, N), dpi=260.)