-
Notifications
You must be signed in to change notification settings - Fork 0
/
value_flow_basis_vis.py
97 lines (78 loc) · 2.74 KB
/
value_flow_basis_vis.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
import numpy as np
import numpy.ma as ma
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from utils.archiver import *
from utils import make_points
from utils.neighbours import *
import os,re
if __name__ == '__main__':
# Make sure that
filedir = "/home/epz/data/minop/vf_bumpy_free/"
summary_file = filedir + "summary.npy"
if os.path.isfile(summary_file):
print "Loading summary file"
data = np.load(summary_file)
else:
print "Reading data from instance files"
filenames = os.listdir(filedir)
pattern = re.compile("vf_(\d+)\.exp_res")
data = []
for filename in filenames:
res = pattern.match(filename)
if res is None:
continue
i = int(res.group(1))
unarch = Unarchiver(filedir+filename)
data.append(unarch.data)
data = np.array(data)
np.save(filedir + "summary",data)
grid = [np.linspace(np.min(data[:,i]),np.max(data[:,i]),128)
for i in xrange(2)]
(P,(X,Y)) = make_points(grid,True)
#Z = smooth(P,data[:,:2],data[:,2],3)
fig = plt.figure()
for (i,p) in enumerate([5,50,95]):
plt.subplot(2,2,i+1)
fn = lambda x: np.percentile(x,p)
# 2 is residual, 3 is iter count
Q = local_fn(fn,P,data[:,:2],data[:,2],1.5)
Q = np.reshape(Q,X.shape)
Qm = ma.masked_where(np.isnan(Q),Q)
plt.pcolormesh(X,Y,Qm)
plt.colorbar()
plt.title("Percentile " + str(p))
plt.xlabel('# Value Basis')
plt.ylabel('# Flow Basis')
plt.suptitle('Basis number vs. Residual')
fig = plt.figure()
for (i,p) in enumerate([5,50,95]):
plt.subplot(2,2,i+1)
fn = lambda x: np.percentile(x,p)
# 2 is residual, 3 is iter count
Q = local_fn(fn,P,data[:,:2],data[:,3],1.5)
Q = np.reshape(Q,X.shape)
Qm = ma.masked_where(np.isnan(Q),Q)
plt.pcolormesh(X,Y,Qm)
plt.colorbar()
plt.title("Percentile " + str(p))
plt.xlabel('# Value Basis')
plt.ylabel('# Flow Basis')
plt.suptitle('Basis number vs. Iteration')
"""
fig = plt.figure()
ax = fig.add_subplot(111,projection="3d")
for (i,p) in enumerate([5,50,95]):
fn = lambda x: np.percentile(x,p)
# 2 is residual, 3 is iter count
Q = local_fn(fn,P,data[:,:2],np.log(data[:,2]),1.5)
Q = np.reshape(Q,X.shape)
Qm = ma.masked_where(np.isnan(Q),Q)
if p != 50:
ax.plot_surface(X,Y,Qm,alpha=0.25,
cstride=2,rstride=2,lw=0)
else:
ax.plot_surface(X,Y,Qm,alpha=0.5,
cstride=2,rstride=2,lw=0)
"""
plt.show()