forked from kaanaksit/odak
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__init__.py
53 lines (47 loc) · 1.64 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
``odak.jones``
===================
Provides necessary definitions for jones calculus. See "Introduction to Fourier Optics" by Joseph Goodman.
"""
from odak import np
def electricfield(px,py):
"""
Definition to create an electric field vector (polarization vector).
Parameters
----------
px : float
Amplitude of the electric field along X axis.
py : float
Amplitude of the electric field along Y axis.
Returns
----------
field : ndarray
An electric field vector (polarization vector).
"""
field = np.array([[px],[py]])
return field
def linearpolarizer(field,rotation=0):
"""
Definition that represents a linear polarizer.
Parameters
----------
field : ndarray
Polarization vector of an input beam.
rotation : float
Represents rotation of the polarizer along propagation direction in angles (couter-clockwise).
Returns
----------
result : ndarray
Polarization vector of an output beam.
"""
rotation = np.radians(rotation)
rotmat = np.array(
[
[ float(np.cos(rotation)), float(np.sin(rotation))],
[float(-np.sin(rotation)), float(np.cos(rotation))]
]
)
linearpolarizer = np.array([[1,0],[0,0]])
linearpolarizer = np.dot(rotmat.transpose(),np.dot(linearpolarizer,rotmat))
result = np.dot(linearpolarizer,field)
return result