-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfind_vr_maxima.py
89 lines (65 loc) · 1.66 KB
/
find_vr_maxima.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
#!/usr/bin/env python
from numpy import *
import cPickle as cp
import time
from pylab import *
import sys
time_step = 20
North = 11
East = 11
Down = 3
#=======================
def d_break(locs,*message):
print '\n\n'
print message
print '\n'
doc=""" IPython shell for debugging -- all variables available \n"""
try:
import IPython
IPython.Shell.IPShell(user_ns=locs).mainloop(sys_exit=1, banner=doc)
except:
import code
code.interact(local = locs)
#=======================
FH = file(sys.argv[1],'r')
full_dict = cp.load(FH)
FH.close()
lo_results = []
lo_vrs = []
maxvr = 0
mvg = zeros((North, East))
update = Down + 1
for time_step in arange(len(full_dict.keys())):
sol_dict = full_dict[str(time_step)]
lo_results.append(sol_dict)
VR_total = sol_dict['VR_array']
VR_grid = zeros((North, East, Down))
#d_break(locals(),'')
for idx,vr in enumerate(VR_total):
d = int(idx/(North*East))
horz_idx = idx%(North*East)
e = int(horz_idx/North)
n = horz_idx%North
VR_grid[n,e,d] = vr
if vr > maxvr:
maxvr = vr
update = d
if update == 1:
mvg = VR_grid[:,:,d]
lo_vrs.append(VR_grid)
#d_break(locals(),'')
ion()
aa = contourf(mvg)
aa.set_clim(vmin=0,vmax=maxvr)
cb = colorbar(aa)
cb.set_clim(vmin=0, vmax=maxvr)
hold(False)
dinx = int(sys.argv[2])-1
for idx, vr in enumerate(lo_vrs):
aa = contourf(vr[:,:,dinx])
#lo_vrs[idx][:,:,1]
clim(0,maxvr)
#draw()
print idx
time.sleep(0.5)
#raw_input()