From 7563f22236332e30276cce2bcd8041d5636daff1 Mon Sep 17 00:00:00 2001
From: Laurent Mercadier <laurent.mercadier@xfel.eu>
Date: Thu, 26 Sep 2019 13:56:54 +0200
Subject: [PATCH] Adds HWP angle to power conversion

---
 Laser_utils.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/Laser_utils.py b/Laser_utils.py
index 0af4c88..157f387 100644
--- a/Laser_utils.py
+++ b/Laser_utils.py
@@ -12,4 +12,16 @@ def positionToDelay(data, key, origin=0, invert = False, reflections=1):
     '''
     c_ = 299792458 *1e-9 # speed of light in mm/ps
     x = -1 if invert else 1
-    return 2*reflections*(data[key]-origin)*x/c_
\ No newline at end of file
+    return 2*reflections*(data[key]-origin)*x/c_
+    
+def degToRelPower(x, theta0=0):
+    ''' converts a half-wave plate position in degrees into relative power
+        between 0 and 1.
+        Inputs:
+            x: array-like positions of half-wave plate, in degrees
+            theta0: position for which relative power is zero
+            
+        Output:
+            array-like relative power
+    '''
+    return np.sin(2*(x-theta0)*np.pi/180)**2
-- 
GitLab