Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pykat
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sean Leavey
pykat
Commits
7624b78a
Commit
7624b78a
authored
8 years ago
by
Andreas Freise
Browse files
Options
Downloads
Patches
Plain Diff
fixing spatial filter example, ading very simple phaseplate example
parent
ff2041ce
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/fft/phaseplate.py
+108
-0
108 additions, 0 deletions
examples/fft/phaseplate.py
examples/fft/spatial_filter.py
+107
-94
107 additions, 94 deletions
examples/fft/spatial_filter.py
with
215 additions
and
94 deletions
examples/fft/phaseplate.py
0 → 100644
+
108
−
0
View file @
7624b78a
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
matplotlib.pyplot
as
plt
from
pykat.optics.gaussian_beams
import
HG_mode
,
beam_param
from
pykat.optics.fft
import
*
import
numpy
as
np
import
scipy
def
main
():
print
(
"""
--------------------------------------------------------------
Example file for using PyKat http://www.gwoptics.org/pykat
Generate a HG11 mode from a HG00 mode with a simple
phase plate.
Andreas Freise, 18.10.2016
--------------------------------------------------------------
"""
)
plt
.
close
(
'
all
'
)
# wavelength
Lambda
=
1064.0E-9
# distance to propagate/focal length of lens
D
=
4
######## Generate Grid stucture required for FFT propagation ####
xpoints
=
512
ypoints
=
512
xsize
=
0.05
ysize
=
0.05
# Apply offset such that the center of the beam lies in the
# center of a grid tile
xoffset
=
-
0.5
*
xsize
/
xpoints
yoffset
=
-
0.5
*
ysize
/
ypoints
shape
=
grid
(
xpoints
,
ypoints
,
xsize
,
ysize
,
xoffset
,
yoffset
)
x
=
shape
.
xaxis
y
=
shape
.
yaxis
######## Generates input beam ################
gx
=
beam_param
(
w0
=
2e-3
,
z
=
0
)
gy
=
beam_param
(
w0
=
2e-3
,
z
=
0
)
beam
=
HG_mode
(
gx
,
gy
,
0
,
0
)
global
field
,
laser
field
=
beam
.
Unm
(
x
,
y
)
####### Apply phase plate #######################################
plate
=
np
.
ones
([
xpoints
,
ypoints
])
plate
[
0
:
xpoints
//
2
,
0
:
ypoints
//
2
]
=-
1.0
plate
[
xpoints
//
2
:
xpoints
,
ypoints
//
2
:
ypoints
]
=-
1.0
field2
=
field
*
plate
;
####### Propagates the field by FFT ##############################
field2
=
FFT_propagate
(
field2
,
shape
,
Lambda
,
D
,
1
)
# maybe apply a thin lens
f
=
D
field2
=
apply_thin_lens
(
field2
,
shape
,
Lambda
,
f
)
field2
=
FFT_propagate
(
field2
,
shape
,
Lambda
,
D
,
1
)
midx
=
(
xpoints
)
//
2
midy
=
(
ypoints
)
//
2
off1
=
50
off2
=
50
# plot hand tuned for certain ranges and sizes, not automtically scaled
fig
=
plt
.
figure
(
110
)
fig
.
clear
()
plt
.
subplot
(
1
,
3
,
1
)
plt
.
imshow
(
abs
(
field
))
plt
.
xlim
(
midx
-
off1
,
midx
+
off1
)
plt
.
ylim
(
midy
-
off1
,
midy
+
off1
)
plt
.
draw
()
plt
.
subplot
(
1
,
3
,
2
)
plt
.
imshow
(
plate
)
#pl.xlim(midx-off2,midx+off2)
#pl.ylim(midy-off2,midy+off2)
plt
.
draw
()
plt
.
subplot
(
1
,
3
,
3
)
plt
.
imshow
(
abs
(
field2
))
plt
.
xlim
(
midx
-
off2
,
midx
+
off2
)
plt
.
ylim
(
midy
-
off2
,
midy
+
off2
)
plt
.
draw
()
if
in_ipython
():
plt
.
show
(
block
=
0
)
else
:
plt
.
show
(
block
=
1
)
# testing if the script is run from within ipython
def
in_ipython
():
try
:
__IPYTHON__
except
NameError
:
return
False
else
:
return
True
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
examples/fft/spatial_filter.py
+
107
−
94
View file @
7624b78a
...
...
@@ -3,14 +3,26 @@ from __future__ import division
from
__future__
import
print_function
from
__future__
import
unicode_literals
import
pylab
as
pl
import
matplotlib.pyplot
as
pl
t
from
pykat.optics.gaussian_beams
import
HG_
beam
,
beam_param
from
pykat.optics.gaussian_beams
import
HG_
mode
,
beam_param
from
pykat.optics.fft
import
*
import
numpy
as
np
import
scipy
def
main
():
print
(
"""
--------------------------------------------------------------
Example file for using PyKat http://www.gwoptics.org/pykat
Simple spatial filter to measure the mode content in a
Hermite Gauss beam
Andreas Freise, 18.10.2016
--------------------------------------------------------------
"""
)
plt
.
close
(
'
all
'
)
# wavelength
Lambda
=
1064.0E-9
# distance to propagate/focal length of lens
...
...
@@ -34,6 +46,7 @@ def main():
xoffset
=
-
0.5
*
xsize
/
xpoints
yoffset
=
-
0.5
*
ysize
/
ypoints
global
shape
shape
=
grid
(
xpoints
,
ypoints
,
xsize
,
ysize
,
xoffset
,
yoffset
)
x
=
shape
.
xaxis
y
=
shape
.
yaxis
...
...
@@ -41,9 +54,9 @@ def main():
######## Generates a mixture of fields ################
gx
=
beam_param
(
w0
=
2e-3
,
z
=
0
)
gy
=
beam_param
(
w0
=
2e-3
,
z
=
0
)
beam
=
HG_
beam
(
gx
,
gy
,
n1
,
m1
)
beam
=
HG_
mode
(
gx
,
gy
,
n1
,
m1
)
field1
=
beam
.
Unm
(
x
,
y
)
beam2
=
HG_
beam
(
gx
,
gy
,
n2
,
m2
)
beam2
=
HG_
mode
(
gx
,
gy
,
n2
,
m2
)
field2
=
beam2
.
Unm
(
x
,
y
)
global
field
,
laser1
,
laser2
field
=
np
.
sqrt
(
c1
)
*
field1
+
np
.
sqrt
(
c2
)
*
field2
...
...
@@ -80,29 +93,29 @@ def main():
print
(
"
c2 {0}, coef2 {1}, error {3} (raw output {2})
"
.
format
(
c2
,
pc2
,
coef2
,
np
.
abs
(
c2
-
pc2
)))
# plot hand tuned for certain ranges and sizes, not automtically scaled
fig
=
pl
.
figure
(
110
)
fig
=
pl
t
.
figure
(
110
)
fig
.
clear
()
off1
=
xpoints
/
10
off2
=
xpoints
/
6
pl
.
subplot
(
1
,
3
,
1
)
pl
.
imshow
(
abs
(
field
))
pl
.
xlim
(
midx
-
off1
,
midx
+
off1
)
pl
.
ylim
(
midy
-
off1
,
midy
+
off1
)
pl
.
draw
()
pl
.
subplot
(
1
,
3
,
2
)
pl
.
imshow
(
abs
(
laser1
))
pl
.
xlim
(
midx
-
off2
,
midx
+
off2
)
pl
.
ylim
(
midy
-
off2
,
midy
+
off2
)
pl
.
draw
()
pl
.
subplot
(
1
,
3
,
3
)
pl
.
imshow
(
abs
(
laser2
))
pl
.
xlim
(
midx
-
off2
,
midx
+
off2
)
pl
.
ylim
(
midy
-
off2
,
midy
+
off2
)
pl
.
draw
()
pl
t
.
subplot
(
1
,
3
,
1
)
pl
t
.
imshow
(
abs
(
field
))
pl
t
.
xlim
(
midx
-
off1
,
midx
+
off1
)
pl
t
.
ylim
(
midy
-
off1
,
midy
+
off1
)
pl
t
.
draw
()
pl
t
.
subplot
(
1
,
3
,
2
)
pl
t
.
imshow
(
abs
(
laser1
))
pl
t
.
xlim
(
midx
-
off2
,
midx
+
off2
)
pl
t
.
ylim
(
midy
-
off2
,
midy
+
off2
)
pl
t
.
draw
()
pl
t
.
subplot
(
1
,
3
,
3
)
pl
t
.
imshow
(
abs
(
laser2
))
pl
t
.
xlim
(
midx
-
off2
,
midx
+
off2
)
pl
t
.
ylim
(
midy
-
off2
,
midy
+
off2
)
pl
t
.
draw
()
if
in_ipython
():
pl
.
show
(
block
=
0
)
pl
t
.
show
(
block
=
0
)
else
:
pl
.
show
(
block
=
1
)
pl
t
.
show
(
block
=
1
)
# testing if the script is run from within ipython
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment