summaryrefslogtreecommitdiff
path: root/src/phys.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/phys.py')
-rw-r--r--src/phys.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/phys.py b/src/phys.py
index 4e78fe2..c47a497 100644
--- a/src/phys.py
+++ b/src/phys.py
@@ -7,6 +7,16 @@ from PyQt5.QtCore import *
from ui import *
+
+
+def jones_to_stokes(E):
+ I = np.abs(E[0] ** 2) + np.abs(E[1] ** 2)
+ Q = np.abs(E[0] ** 2) - np.abs(E[1] ** 2)
+ U = 2 * np.real(E[0] * np.conjugate(E[1]))
+ V = 2 * np.imag(E[0] * np.conjugate(E[1]))
+ return np.array([I, Q, U, V])
+
+
def R(theta):
return np.array([[np.cos(theta), np.sin(theta)],
[-np.sin(theta), np.cos(theta)]])
@@ -14,7 +24,6 @@ def R(theta):
class Ellipse:
def __init__(self, state):
- # FIXME: a less brute-force way of doing this
if state is None:
self.alpha = np.nan
self.theta = np.nan
@@ -44,12 +53,14 @@ class Ellipse:
bounds=[0, np.pi], method="bounded")
self.a = r(opt.x)
- self.alpha = angle(x(opt.x))
+ V = jones_to_stokes(state)
+
+ self.alpha = np.arctan2(V[2], V[1]) / 2
+ if self.alpha < 0:
+ self.alpha += np.pi
- self.e = self.b / self.a
- self.theta = np.arctan(self.e)
- if self.alpha > angle(x(opt.x + 0.001)):
- self.theta *= -1
+ R = np.sqrt(V[1] ** 2 + V[2] ** 2 + V[3] ** 2)
+ self.theta = np.arcsin(V[3] / R) / 2
class Polarizer:
def __init__(self, type, delta=0):
@@ -98,6 +109,7 @@ class System:
def recalculate(system):
system.states = [None] * len(system.elements)
+ system.Vs = [None] * len(system.elements)
system.ellipses = list()
state = None