-
Notifications
You must be signed in to change notification settings - Fork 0
/
phaseDiagram.py
210 lines (139 loc) · 6.12 KB
/
phaseDiagram.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# To run: name.py [inputDir]
import numpy as np
import sys
from os import listdir
from os.path import isfile, join
import matplotlib.pyplot as plt
import distFit
import scipy.stats as spStat
np.set_printoptions(threshold=10000,linewidth=2000,precision=4,suppress=False)
alphaCI = 0.05
inputDir = sys.argv[1]
inputFiles = [ f for f in listdir(inputDir) if (isfile(join(inputDir,f)) and f!="._.DS_Store" and f!=".DS_Store") ]
infoList = []
distArrayList = []
binEdgesArrayList = []
SValsArrayList = []
bDistArrayList = []
#Get info from each datafile
for datafileName in inputFiles:
print "Reading: {0}".format(datafileName)
# datafile = open(datafileName, 'r')
dataDict = np.load(join(inputDir,datafileName))
infoList.append(dataDict['infoArray'])
# np.vstack((dist2DArray,dataDict['binnedDataGBNE']))
distArrayList.append(dataDict['binnedDataGBNE'])
binEdgesArrayList.append(dataDict['bin_edgesGBNE'])
# SValsArrayList.append(dataDict['Svals'])
# bDistArrayList.append(dataDict['brodyDistArray'])
#print infoList
distArrayArray = np.array(distArrayList)
binEdgesArrayArray = np.array(binEdgesArrayList)
#SValsArrayArray = np.array(SValsArrayList)
#bDistArrayArray = np.array(bDistArrayList)
Nlist = []
qList = []
wList = []
bValList = []
for infoArray in infoList:
Nlist.append(int(infoArray[0]))
qList.append(float(infoArray[1]))
wList.append(float(infoArray[2]))
bValList.append(float(infoArray[8]))
NArray = np.array(Nlist)
qArray = np.array(qList)
wArray = np.array(wList)
bValArray = np.array(bValList)
data2DArray = np.vstack((NArray,qArray,wArray,bValArray))
#print data2DArray
#Sort according to size and then disorder strength
#data2DArray_N_srtd_indices = np.argsort(data2DArray[2])
data2DArray_Nqw_srtd_indices = np.lexsort(np.vstack((wArray,qArray,NArray)))
data2DArray_Nqw_srtd = data2DArray[:,data2DArray_Nqw_srtd_indices]
#print data2DArray_Nqw_srtd
# Sort according to disorder strength
#data2DArray_q_srtd_indices = np.argsort(data2DArray[1])
#
#data2DArray_q_srtd = np.copy(data2DArray[:,data2DArray_q_srtd_indices])
#print data2DArray_q_srtd
#########################
#########################
#Plot
#########################
#########################
figNum = 0
#######
#b vs w
#######
figNum += 1
fig = plt.figure(figNum,facecolor="white")
ax = plt.subplot()
cm = plt.cm.get_cmap('RdYlBu')
colourList = ["red","blue","black"]
markerList = ["D","s","."]
markerSizeList = [5,5,15]
typeIndex = 0
newNIndex = 0
while newNIndex < data2DArray_Nqw_srtd[0].size:
oldNIndex = newNIndex
NvalueCurrent = data2DArray_Nqw_srtd[0,oldNIndex]
newNIndex = np.sum(data2DArray_Nqw_srtd[0] <= data2DArray_Nqw_srtd[0,newNIndex])
# print newNIndex
relevant_data2DArray_Nqw_srtd = data2DArray_Nqw_srtd[:, oldNIndex:newNIndex]
# print relevant_data2DArray_Nqw_srtd
newQIndex = 0
wPlotList = []
qPlotList = []
bPlotList = []
errorBarList = []
while newQIndex < relevant_data2DArray_Nqw_srtd[1].size:
oldQIndex = newQIndex
# qPlotList.append(relevant_data2DArray_Nqw_srtd[1,oldQIndex])
newQIndex += np.sum(np.abs(relevant_data2DArray_Nqw_srtd[1] - relevant_data2DArray_Nqw_srtd[1,newQIndex]) < 1E-10)
w_relevant_data2DArray_Nqw_srtd = relevant_data2DArray_Nqw_srtd[:, oldQIndex:newQIndex]
newWIndex = 0
while newWIndex < w_relevant_data2DArray_Nqw_srtd[2].size:
oldWIndex = newWIndex
wPlotList.append(w_relevant_data2DArray_Nqw_srtd[2,oldWIndex])
qPlotList.append(relevant_data2DArray_Nqw_srtd[1,oldQIndex])
newWIndex += np.sum(np.abs(w_relevant_data2DArray_Nqw_srtd[2] - w_relevant_data2DArray_Nqw_srtd[2,newWIndex]) < 1E-10)
relevant_bArray = w_relevant_data2DArray_Nqw_srtd[3,oldWIndex:newWIndex]
meanB = np.mean(relevant_bArray)
bPlotList.append(meanB)
numDataValues = relevant_bArray.size
stdDevB = np.sqrt(np.sum((relevant_bArray - meanB)**2) / (numDataValues - 1))
stdError = stdDevB/np.sqrt(numDataValues)
tDistFactor = spStat.t.ppf(1. - (alphaCI/2.), numDataValues-1)
errorBarHalf = tDistFactor * stdError
errorBarList.append(errorBarHalf)
# print wPlotList
# print qPlotList
# print bPlotList
# print errorBarList
wPlotArray = np.array(wPlotList)
qPlotArray = np.array(qPlotList)
bPlotArray = np.array(bPlotList)
errorBarArray = np.array(errorBarList)
#print data2DArray_Nqw_srtd[0] <= data2DArray_Nqw_srtd[0,0]
#print np.sum(data2DArray_Nqw_srtd[0] <= data2DArray_Nqw_srtd[0,0]) #This gives next index after first value
#print data2DArray_Nqw_srtd[:,data2DArray_Nqw_srtd[0] <= data2DArray_Nqw_srtd[0,0]]
#yerr=errorBarArray
sc = plt.scatter(1.-qPlotArray, wPlotArray, c=bPlotArray, vmin=0, vmax=1, s=1296, cmap=cm, clip_on=False)
# line = ax.errorbar(qPlotArray, bPlotArray, yerr=errorBarArray, marker=markerList[typeIndex], markersize=markerSizeList[typeIndex], label="N={0}".format(NvalueCurrent), clip_on=False, linewidth=1.0, color=colourList[typeIndex])#linewidth=3.0, ls=''
typeIndex += 1
# line[-1][0].set_linestyle('--')
# line, = ax.errorbar(qPlotList, bPlotList, yerr=errorBarList, 'k-',marker=".", markersize=20,linewidth=3.0, label="Diffusive Regime", clip_on=False)
#line, = ax.plot(data2DArray_q_srtd[1], data2DArray_q_srtd[3],'k-',marker=".", markersize=20,linewidth=3.0, label="Diffusive Regime", clip_on=False)
#line2, = ax.plot(second_q_NArray, second_q_bValArray,'k-',marker=".",markersize=20,linewidth=2.0, label="Localized Regime", clip_on=False)
#line, = ax.plot(NArray_srtd, bValArray_srtd,'k-',marker=".",markersize=20,linewidth=2.0)#, label="Local Level Density")
#line2, = ax.plot(eigvals, rhoGauss, color='red', marker="o", label="Gaussian Broadening Method")
#ax.legend()
# Remove plot frame
#ax.set_frame_on(False)
plt.ylim(0.,np.max(wPlotArray)*1.1)
plt.xlim(0.,1.)
plt.xlabel("Probability of Occupation, p", fontsize=16)
plt.ylabel("Disorder Strength, w", fontsize=16)
#plt.title("Local Level Density", fontsize=18)
plt.colorbar(sc)
plt.show()