-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamples.py
125 lines (106 loc) · 5.26 KB
/
examples.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
from polarization import *
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.animation as animation
# # Define the vector with Ex and Ey
# print("\n\nDefine horizontal polarization with JonesVector(Ex=1, Ey=0)")
# print("===========================================================")
# v = JonesVector(Ex=1, Ey=0) # horizontal
# print("Components are {0}".format(v))
# print("Orientation is {0:.2f} rad or {1:.1f}°".format(v.orientation,v.orientation*degPerRad))
# v.show()
# #v.show("horizontal.mp4") #to save movie
# print("\n\nDefine other polarizations with JonesVector(Ex, Ey),\ncan be normalized with .normalize()")
# print("====================================================")
# v = JonesVector(Ex=1, Ey=1).normalize() # +45°
# print("Components are {0}".format(v))
# print("Orientation is {0:.2f} rad or {1:.1f}°".format(v.orientation,v.orientation*degPerRad))
# v.show()
# #v.show("plus45.mp4") #to save movie
# print("\n\nMany predefined vectors exist")
# print("=============================")
# # Many predefined vectors:
# # JonesVector.vertical()
# # JonesVector.horizontal()
# # JonesVector.plus45()
# # JonesVector.minus45()
# # JonesVector.rightCircular()
# # JonesVector.leftCircular()
# print("\nJonesVector.rightCircular()")
# print("-----------------------------")
# v = JonesVector.rightCircular()
# print("Components are {0}".format(v))
# print("Orientation is {0:.2f} rad or {1:.1f}°".format(v.orientation,v.orientation*degPerRad))
# v.show()
# print("\nJonesVector.leftCircular()")
# print("-----------------------------")
# v = JonesVector.leftCircular() # Many predefined vectors
# print("Components are {0}".format(v))
# print("Orientation is {0:.2f} rad or {1:.1f}°".format(v.orientation,v.orientation*degPerRad))
# v.show()
# # Arbitrary polarization
# print("\n\nArbitrary polarization JonesVector(Ex=1*exp(1j*0.3), Ey=0.5).normalize()")
# print("========================================================================")
# v = JonesVector(Ex=1*exp(1j*0.3), Ey=0.5).normalize()
# print("Components are {0}".format(v))
# print("Orientation is {0:.2f} rad or {1:.1f}°".format(v.orientation,v.orientation*degPerRad))
# v.show("arbitrary.mp4")
# # Many properties are defined:
# print("\n\nMany properties to access polarization state")
# print("============================================")
# print("For vector {0}".format(v))
# print("v.orientation (0=horizontal) = {0}".format(v.orientation))
# print("v.isLinearlyPolarized = {0}".format(v.isLinearlyPolarized))
# print("v.isEllipticallyPolarized = {0}".format(v.isEllipticallyPolarized))
# print("v.isCircularlyPolarized = {0}".format(v.isCircularlyPolarized))
# print("v.isRightCircularlyPolarized = {0}".format(v.isRightCircularlyPolarized))
# print("v.isLeftCircularlyPolarized = {0}".format(v.isLeftCircularlyPolarized))
# # Vectors can be transformed by JonesMatrices
# # Any matrix can be created with JonesMatrix(A,B,C,D)
# # but there are many predefined matrices:
# #
# # HorizontalPolarizer(): polarizer at theta=0°
# # VerticalPolarizer(): polarizer at theta=90°
# # Plus45Polarizer(): polarizer at theta=45°
# # Minus45Polarizer(): polarizer at theta=-45°
# # HWP(theta=pi/4) : halfwave plate at 45°
# # QWP(theta=pi/4) : quarterwave plate at 45°
# # RightCircularPolarizer(): right circular polarizer
# # LeftCircularPolarizer(): left circular polarizer
# # PhaseRetarder(): arbitrary retarder
# print("\n\nTransform the JonesVector with JonesMatrices")
# print("============================================")
# print("horizontal vector going through quarter waveplate")
# vIn = JonesVector.horizontal()
# v = QWP(theta=pi/4)*vIn
# print("Input components are {0}".format(vIn))
# print("Output components are {0}".format(v))
# print("Orientation is {0:.2f} rad or {1:.1f}°".format(v.orientation,v.orientation*degPerRad))
# print("isCircular {0}".format(v.isCircularlyPolarized))
# v.show()
# print("\n\nApply several JonesMatrices sequentially")
# print("============================================")
# vIn = JonesVector.horizontal()
# v = HWP(theta=pi/2)*QWP(theta=pi/3)*vIn
# print("Input components are {0}".format(vIn))
# print("Output components are {0}".format(v))
# print("Orientation is {0:.2f} rad or {1:.1f}°".format(v.orientation,v.orientation*degPerRad))
# print("v.isLinearlyPolarized = {0}".format(v.isLinearlyPolarized))
# print("v.isEllipticallyPolarized = {0}".format(v.isEllipticallyPolarized))
# print("v.isCircularlyPolarized = {0}".format(v.isCircularlyPolarized))
# print("v.isRightCircularlyPolarized = {0}".format(v.isRightCircularlyPolarized))
# print("v.isLeftCircularlyPolarized = {0}".format(v.isLeftCircularlyPolarized))
# v.show()
# HorizontalPolarizer().showOrientationPlot(input=JonesVector.horizontal())
# QWP(theta=45*degPerRad).showPolarizationPlot()
vIn = JonesVector.horizontal()
pockels = PockelsCell(halfwaveVoltage=300, length=20)
pockels.orientation = 45*radPerDeg
pockels.showVoltagePlot()
pockels.show(input=JonesVector.horizontal(),
xObj=pockels, xProperty='voltage',
yObj=pockels, yProperty='retardance',
xRange=range(0,300,10))
# system.plot(y="input.polarization", x="pockels.voltage")
# system.plot(xObject=vIn, "orientation", x=pockel, xProperty="voltage")
# system.plot(x=(pockels, "voltage"), (vIn, "orientation"))