To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 06bf1c3e authored by Bastian Telgen's avatar Bastian Telgen
Browse files

update plotting

parent 854452fc
......@@ -2,142 +2,119 @@ import numpy as np
from matplotlib import pyplot as plt
import sys
for i in range(100):
try:
name = "UC_" + str(i)
print(name)
def plot_dispersion(kpath, eigfreq):
# name = sys.argv[1]
from matplotlib import pyplot as plt
import numpy as np
# name = "UC_1"
path = "/mnt/io/structures/"
# path = "/home/bastian/Workspace/cppPNCOpt/build/Applications/"
fkpath = path + name + ".kpath"
fdpath = path + name + ".dispersion"
plt.rc("text", usetex=True)
plt.rc("font", family="serif")
plt.rc("text", usetex=True)
plt.rc("font", family="serif")
# klabel = np.array(kpath[1])
# idx = np.where(klabel <> u'')[0]
#
il = range(0, len(kpath))
# for i in range(len(idx) - 1):
#
# if idx[i + 1] == idx[i] + 1:
#
# il[idx[i] + 1:] = [l - 1 for l in il[idx[i] + 1:]]
#
# if klabel[idx[i]] <> klabel[idx[i + 1]]:
# klabel[idx[i]] = klabel[idx[i]] + klabel[idx[i + 1]]
# klabel[idx[i + 1]] = klabel[idx[i]]
dispersion = np.loadtxt(fdpath, delimiter=",")
plt.plot(il, eigfreq)
with open(fkpath, "r") as f:
kpath = [x.split(",") for x in f.readlines()]
# for i in [il[j] for j in idx]:
# plt.axvline(x=i, color='black')
klabel = []
il = []
for i, k in enumerate(kpath):
if len(k) > 3:
klabel.append(k[3].rstrip())
il.append(i)
plt.xlim(0, np.max(il))
np.set_printoptions(precision=8, edgeitems=50, linewidth=2)
eigfreq = dispersion[:, 3:]
kpath = dispersion[:, :3]
# plt.xticks([il[j] for j in idx], klabel[idx])
plt.show()
# plt.rc('text', usetex=True)
from matplotlib.patches import Rectangle
name = sys.argv[1]
# name = "UC_1"
path = "/mnt/io/tools/temp/"
# path = "/home/bastian/Workspace/cppPNCOpt/build/Applications/"
fkpath = path + name + ".kpath"
fdpath = path + name + ".dispersion"
currentAxis = plt.gca()
i_klabel = []
for i in range(0, len(il), 2):
plt.rc("text", usetex=True)
plt.rc("font", family="serif")
idb = il[i]
idu = il[i + 1]
dispersion = np.loadtxt(fdpath, delimiter=",")
with open(fkpath, "r") as f:
kpath = [x.split(",") for x in f.readlines()]
klabel = []
il = []
for i, k in enumerate(kpath):
if len(k) > 3:
klabel.append(k[3].rstrip())
il.append(i)
np.set_printoptions(precision=8, edgeitems=50, linewidth=2)
eigfreq = dispersion[:, 3:]
kpath = dispersion[:, :3]
# plt.rc('text', usetex=True)
from matplotlib.patches import Rectangle
currentAxis = plt.gca()
i_klabel = []
for i in range(0, len(il), 2):
idb = il[i]
idu = il[i + 1]
plt.axvline(x=idb - i, color="black", linestyle="--", linewidth=0.8)
plt.plot(
range(idb - i, idu - i),
eigfreq[range(idb, idu)],
color="black",
marker=",",
linestyle="None",
)
# plt.gca().set_prop_cycle(None)
i_klabel.append(idb - i)
fu = np.nanmin(eigfreq[idb:idu], axis=0)[1:]
fl = np.nanmax(eigfreq[idb:idu], axis=0)[:-1]
pb = fu - fl
# print pb
#
for j, b in enumerate(pb):
if b > 2e-2:
w = idu - idb - 1
h = fu[j] - fl[j]
currentAxis.add_patch(
Rectangle((idb - i, fl[j]), w, h, alpha=1, color="#98FB98")
plt.axvline(x=idb - i, color="black", linestyle="--", linewidth=0.8)
plt.plot(
range(idb - i, idu - i),
eigfreq[range(idb, idu)],
color="black",
marker=",",
linestyle="None",
)
i_klabel.append(idu - i - 1)
fu = np.nanmin(eigfreq, axis=0)[1:]
fl = np.nanmax(eigfreq, axis=0)[:-1]
full_bandgap = fu - fl
for j, b in enumerate(full_bandgap):
if b > 2e-2:
w = i_klabel[-1]
h = fu[j] - fl[j]
currentAxis.add_patch(Rectangle((0, fl[j]), w, h, alpha=1, color="#6B8E23"))
# # k-path labelling
klabel2 = []
double = False
for i in range(len(klabel) - 1):
idb = i
idu = i + 1
if il[idb] == il[idu] - 1:
if klabel[idb] != klabel[idu]:
klabel2.append("$" + klabel[idb] + r"\vert " + klabel[idb + 1] + "$")
double = True
else:
if not double:
klabel2.append("$" + klabel[idb] + "$")
else:
double = False
klabel2.append("$" + klabel[idu] + "$")
plt.xticks(i_klabel, klabel2)
plt.xlim(0, len(kpath) - len(klabel))
plt.ylim(bottom=0)
# plt.title('dispersion curve')
plt.xlabel("k-space position")
plt.ylabel("frequency $[Hz]$")
plt.savefig(name + ".svg")
# plt.gca().set_prop_cycle(None)
i_klabel.append(idb - i)
fu = np.nanmin(eigfreq[idb:idu], axis=0)[1:]
fl = np.nanmax(eigfreq[idb:idu], axis=0)[:-1]
pb = fu - fl
for j, b in enumerate(pb):
if b > 2e-2:
w = idu - idb - 1
h = fu[j] - fl[j]
# print(h)
currentAxis.add_patch(
Rectangle((idb - i, fl[j]), w, h, alpha=1, color="#98FB98")
)
i_klabel.append(idu - i - 1)
fu = np.nanmin(eigfreq, axis=0)[1:]
fl = np.nanmax(eigfreq, axis=0)[:-1]
full_bandgap = fu - fl
for j, b in enumerate(full_bandgap):
if b > 2e-2:
w = i_klabel[-1]
h = fu[j] - fl[j]
print(h)
currentAxis.add_patch(
Rectangle((0, fl[j]), w, h, alpha=1, color="#6B8E23")
)
# # k-path labelling
klabel2 = []
double = False
for i in range(len(klabel) - 1):
idb = i
idu = i + 1
if il[idb] == il[idu] - 1:
if klabel[idb] != klabel[idu]:
klabel2.append(
"$" + klabel[idb] + r"\vert " + klabel[idb + 1] + "$"
)
double = True
else:
if not double:
klabel2.append("$" + klabel[idb] + "$")
else:
double = False
klabel2.append("$" + klabel[idu] + "$")
plt.xticks(i_klabel, klabel2)
plt.xlim(0, len(kpath) - len(klabel))
plt.ylim(bottom=0)
# plt.title('dispersion curve')
plt.xlabel("k-space position")
plt.ylabel("frequency $[Hz]$")
plt.savefig(name + ".png")
plt.close()
except:
pass
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment