This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_plots.py
executable file
·105 lines (86 loc) · 3.74 KB
/
make_plots.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
102
103
#!/usr/bin/env python
import plotting
reload(plotting)
import os
import shutil
import numpy
from numpy.linalg import *
os.environ[ 'MPLCONFIGDIR' ] = '/mnt/data/copycat/mplconfig/'
def plot_D(outdir,Dfilename):
#########################################################################
#### input D plotted for comparison to results
#########################################################################
filename=Dfilename
D_answer=plotting.loadmatrix(filename)
plotting.plotcells(D_answer,filename="%s/D_answer.png" % (outdir))
def make_plots(outdir,Dfilename,numclones=0):
numclones=int(numclones)
if os.path.isdir(outdir)==False:
print "Directory does not exist: %s" % outdir
return
print "Dfilename in make_plots.py: %s" % Dfilename
#########################################################################
######## costs
#########################################################################
filename="%s/costs.txt" % outdir
if os.path.isfile(filename):
costs = plotting.loadmatrix(filename)
plotting.cost_value_plot(costs,filename="%s/costs.png" % outdir)
print "Top solutions cost plot done"
#########################################################################
######## input D plotted for comparison to results
#########################################################################
print "Before plotting D"
plot_D(outdir,Dfilename)
print "After plotting D"
#########################################################################
######## grab S and R, calculate D inferred from solutions
#########################################################################
done = False
num=2
if numclones==0:
num=2
else:
num=numclones
while done==False:
directory = "%s/%d_clones" % (outdir,num)
if os.path.isdir(directory):
print "%s is a directory" % directory
list_done=False
soln=0
while list_done==False:
#cost is only one number and doesn't need its own plot
R=0
S=0
#grab R
filename="%s/R_%d" % (directory,soln)
if os.path.exists(filename):
print "%s is a file" % filename
R=plotting.loadmatrix(filename)
plotting.plot_R(R,filename="%s.png" % filename)
else:
#print "%s is not a file" % filename
list_done=True
#grab S
filename="%s/S_%d" % (directory,soln)
if os.path.exists(filename):
print "%s is a file" % filename
S=plotting.loadmatrix(filename)
plotting.plot_S(S, filename="%s.png" % filename)
else:
#print "%s is not a file" % filename
list_done=True
#calculate inferred D
if list_done==False:
#D=R.dot(S)
D=numpy.dot(R,S)
filename="%s/D_%d" % (directory,soln)
plotting.matrixtofile(D,filename,use_float=True)
plotting.plotcells(D,filename="%s.png" % filename)
soln+=1
num+=1
if numclones==0:
done=True
else:
done=True
#print "%s is not a directory" % directory