Commit 54aa3914 authored by Orkun Şensebat's avatar Orkun Şensebat
Browse files

Produce desired plot

parent 2bdb32cb
Pipeline #463838 passed with stage
in 52 seconds
import numpy as np
import matplotlib.pyplot as plt
# some initialization
......@@ -53,32 +54,29 @@ for ipsi0 in range(nsteps): # loop over different settings of EOM1
count[j1, j2, 1, ipsi0] = count[j1, j2, 1, ipsi0] + 1 # Malus law model + time window
# data analysis
tot = np.zeros(shape=(2, nsteps), dtype=np.int16)
tot = np.zeros(shape=(2, nsteps), dtype=np.int32)
E12 = np.zeros(shape=(2, nsteps), dtype=np.float64)
E1 = np.zeros(shape=(2, nsteps), dtype=np.float64)
E2 = np.zeros(shape=(2, nsteps), dtype=np.float64)
for j in range(nsteps):
for i in [0, 1]: # i = 0 <==> no time window, i = 1 <=> use time coincidences
tot[i, j] = np.sum(count[:, :, i, j])
for i in [0, 1]:
# i = 0 <==> no time window, i = 1 <=> use time coincidences
#tot[i, j] = np.sum(count[:, :, i, j])
tot[i, j] = count[0, 0, i, j] + count[1, 1, i, j] + count[1, 0, i, j] + count[0, 1, i, j]
E12[i, j] = count[0, 0, i, j] + count[1, 1, i, j] - count[1, 0, i, j] - count[0, 1, i, j]
E1[i, j] = count[0, 0, i, j] + count[0, 1, i, j] - count[1, 1, i, j] - count[1, 0, i, j]
E2[i, j] = count[0, 0, i, j] + count[1, 0, i, j] - count[1, 1, i, j] - count[0, 1, i, j]
if(tot[i, j]>0) :
if(tot[i, j]>0):
E12[i, j] = E12[i, j]/tot[i, j]
E1[i, j] = E1[i, j]/tot[i, j]
E2[i, j] = E2[i, j]/tot[i, j]
# print out to two different files, suitable for plotting by GNUPLOT
for i in [0, 1]:
print('("# ** DLM Demo EPRB **")')
print('("# Input variables: ")')
print('("# Nsamples = ', nsamples, '"')
print('("# theta HWP2 = ', HWP2, '"')
print('("# T0 = ', T0, '"')
print('("# W = ', W, '"')
print('("# seed = ', wxyz, '"')
print('("# Theta <S1.a> <S2.b> <S1.a S2.b> theory S N++ N-+ N+- N-- sum(N..)")')
for j in range(nsteps):
S = 3*E12[i, j] - E12[i, (j*3)%nsteps] # correlation of QT
r0 = -np.cos(2*j*2*np.pi/nsteps)
print(j*360.0/nsteps, E1[i, j], E2[i, j], E12[i, j], r0, S, count[:, :, i, j].flatten(), tot[i, j])
\ No newline at end of file
theta = np.linspace(0, 360, nsteps)
theta_theory = np.linspace(0, 360, nsteps*100)
theory = []
for j in range(nsteps*100):
theory.append(-np.cos(2 * j * 2 * np.pi / nsteps / 100))
plt.plot(theta, E12[0, :], 'o')
plt.plot(theta_theory, theory, '.', markersize=1)
plt.savefig('e12.pdf')
plt.close()
\ 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