-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_surf.py
101 lines (68 loc) · 2.47 KB
/
test_surf.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import numpy as np
import time
import h5py
import matplotlib.pyplot as plt
from tqdm import tqdm
from matplotlib.colors import LinearSegmentedColormap # allows the creation of a custom cmap
from scipy.stats import linregress
import os
from datetime import datetime
from _norm_color import MidpointNormalize
# # Target Dir
save_dir = 'Results/2022_05_17/16_59_07_PKs_surf_s9_'
save_dir = 'Results/2022_05_17/17_00_00_PKs_surf_s9_'
save_dir = 'Results/2022_05_17/17_00_29_PKs_surf_s9_'
# # load data
res = {}
location = "%s/data.hdf5" % (save_dir)
with h5py.File(location, 'r') as hdf:
# Vcs = list(hdf.keys())
IO = hdf.get('IO')
Vcs = []
for k, v in IO.items():
print(k)
if k == 'extent':
res['extent'] = np.array(v)
else:
res[k] = {}
Vc = float(k)
Vcs.append(Vc)
res['%.3f' % Vc]['Vo'] = np.array(IO.get('%s/Vo' % (k)))
res['%.3f' % Vc]['Bo'] = np.array(IO.get('%s/Bo' % (k)))
res['%.3f' % Vc]['Io'] = np.array(IO.get('%s/Io' % (k)))
res['num_op'] = np.shape(res['%.3f' % Vc]['Vo'])[-1]
Vo2 = np.array(hdf.get('IO/0.000/Vo'))
#
print(np.shape(res['%.3f' % Vc]['Vo']))
print(np.shape(Vo2))
# exit()
basic_cols = ['#009cff', '#6d55ff', '#ffffff', '#ff6d55','#ff8800'] # pastal orange/red/white/purle/blue
my_cmap = LinearSegmentedColormap.from_list('mycmap', basic_cols)
# fig, ax = plt.subplots(nrows=1, ncols=len(Vcs), sharey='row')
for op in range(res['num_op']):
fig = plt.figure()
for c, Vc in enumerate(Vcs):
min = np.min(res['%.3f' % Vc]['Vo'])
max = np.max(res['%.3f' % Vc]['Vo'])
# ax = fig.add_subplot(1, len(Vcs), c+1)
fig, ax = plt.subplots(int(1), int(len(Vcs)), sharex='col', sharey='row', squeeze=False)
im = ax[0,c].imshow(res['%.3f' % Vc]['Vo'][:,:,op], origin="lower", extent=res['extent'],
# vmin=min, vmax=max,
#clim=(min, max),
norm=MidpointNormalize(midpoint=0.,vmin=min, vmax=max),
cmap=my_cmap)
ax[0,c].set_title("Vc=%.3f" % (Vc))
if c == 0:
ax[0,c].set_ylabel("Vin2")
ax[0,c].set_xlabel("Vin1")
cbar = fig.colorbar(im, orientation='horizontal')
cbar.set_label('Vo', fontsize=10)
fig_path = "%s/FIG_surf_OP%d.png" % (save_dir, op)
fig.savefig(fig_path, dpi=250)
plt.close(fig)
# plt.show()
# plt.close('all')
#
#
#
# fin