Create scripts for plotting
This commit is contained in:
parent
f1a4cf4a24
commit
2b68e98dd1
26
python_scripts/colormap.py
Normal file
26
python_scripts/colormap.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import ast
|
||||||
|
import seaborn as sns
|
||||||
|
|
||||||
|
sns.set_theme()
|
||||||
|
|
||||||
|
def plot():
|
||||||
|
with open("data/color_map.txt") as f:
|
||||||
|
lines = f.readlines();
|
||||||
|
size = int(lines[0])
|
||||||
|
for i, line in enumerate(lines[1:]):
|
||||||
|
fig, ax = plt.subplots()
|
||||||
|
arr = line.strip().split("\t")
|
||||||
|
arr = np.asarray(list(map(lambda x: ((a := complex(*ast.literal_eval(x)))*a.conjugate()).real, arr)))
|
||||||
|
|
||||||
|
arr = arr.reshape(size,size)
|
||||||
|
|
||||||
|
ax.imshow(arr.T, interpolation="nearest")
|
||||||
|
plt.savefig(f"latex/images/color_map_{i}.pdf")
|
||||||
|
plt.close(fig)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
plot()
|
||||||
|
|
||||||
41
python_scripts/detector.py
Normal file
41
python_scripts/detector.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import ast
|
||||||
|
import seaborn as sns
|
||||||
|
|
||||||
|
sns.set_theme()
|
||||||
|
|
||||||
|
def plot():
|
||||||
|
files = [
|
||||||
|
"data/screen/single_slit.txt",
|
||||||
|
"data/screen/double_slit.txt",
|
||||||
|
"data/screen/triple_slit.txt",
|
||||||
|
]
|
||||||
|
outputs = [
|
||||||
|
"latex/images/single_slit_detector.pdf",
|
||||||
|
"latex/images/double_slit_detector.pdf",
|
||||||
|
"latex/images/triple_slit_detector.pdf",
|
||||||
|
]
|
||||||
|
for file, output in zip(files, outputs):
|
||||||
|
with open(file) as f:
|
||||||
|
lines = f.readlines();
|
||||||
|
size = int(lines[0])
|
||||||
|
column = int(.8 * size)
|
||||||
|
fig, ax = plt.subplots()
|
||||||
|
arr = lines[1].strip().split("\t")
|
||||||
|
arr = np.asarray(list(map(lambda x: complex(*ast.literal_eval(x)), arr)))
|
||||||
|
|
||||||
|
arr = arr.reshape(size,size)
|
||||||
|
x = np.linspace(0,1, size)
|
||||||
|
slice = arr[column, :]
|
||||||
|
norm = 1. / np.sqrt(sum([(i*i.conjugate()).real for i in slice]))
|
||||||
|
slice *= norm
|
||||||
|
slice = np.asarray([i * i.conjugate() for i in slice])
|
||||||
|
|
||||||
|
ax.plot(x, slice)
|
||||||
|
plt.savefig(output)
|
||||||
|
plt.close(fig)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
plot()
|
||||||
25
python_scripts/normalization.py
Normal file
25
python_scripts/normalization.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import matplotlib
|
||||||
|
from matplotlib.animation import FuncAnimation
|
||||||
|
import ast
|
||||||
|
|
||||||
|
def plot():
|
||||||
|
with open("data/probability_deviation.txt") as f:
|
||||||
|
lines = f.readlines();
|
||||||
|
x = []
|
||||||
|
arr_narrow = []
|
||||||
|
arr_wide = []
|
||||||
|
for line in lines:
|
||||||
|
tmp = line.strip().split(",")
|
||||||
|
x.append(float(tmp[0]))
|
||||||
|
arr_narrow.append(float(tmp[1]))
|
||||||
|
arr_wide.append(float(tmp[2]))
|
||||||
|
|
||||||
|
plt.plot(x,arr_narrow)
|
||||||
|
plt.plot(x,arr_wide)
|
||||||
|
plt.savefig("latex/images/probability_deviation.pdf")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
plot()
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user