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
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
finesse
pykat
Commits
8c85bcc5
Commit
8c85bcc5
authored
9 years ago
by
Daniel Toyra
Browse files
Options
Downloads
Patches
Plain Diff
Now creates an aperture map as well, when preparing a phase map for finesse.
parent
5f755e9f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pykat/optics/maps.py
+50
-18
50 additions, 18 deletions
pykat/optics/maps.py
with
50 additions
and
18 deletions
pykat/optics/maps.py
+
50
−
18
View file @
8c85bcc5
...
@@ -41,8 +41,13 @@ class MirrorROQWeights:
...
@@ -41,8 +41,13 @@ class MirrorROQWeights:
if
self
.
tBack
is
not
None
:
self
.
tBack
.
writeToFile
(
f
=
f
)
if
self
.
tBack
is
not
None
:
self
.
tBack
.
writeToFile
(
f
=
f
)
class
surfacemap
(
object
):
class
surfacemap
(
object
):
def
__init__
(
self
,
name
,
maptype
,
size
,
center
,
step_size
,
scaling
,
data
=
None
,
def
__init__
(
self
,
name
,
maptype
,
size
,
center
,
step_size
,
scaling
,
data
=
None
,
notNan
=
None
,
Rc
=
None
,
zOffset
=
None
,
xyOffset
=
(.
0
,.
0
)):
notNan
=
None
,
Rc
=
None
,
zOffset
=
None
,
xyOffset
=
(.
0
,.
0
)):
'''
size, center, step_size, xyOffset are all tuples of the form (x, y),
i.e., (col, row).
'''
self
.
name
=
name
self
.
name
=
name
self
.
type
=
maptype
self
.
type
=
maptype
...
@@ -60,12 +65,12 @@ class surfacemap(object):
...
@@ -60,12 +65,12 @@ class surfacemap(object):
self
.
_xyOffset
=
xyOffset
self
.
_xyOffset
=
xyOffset
if
data
is
None
:
if
data
is
None
:
self
.
data
=
np
.
zeros
(
size
)
self
.
data
=
np
.
zeros
(
size
[::
-
1
]
)
else
:
else
:
self
.
data
=
data
self
.
data
=
data
if
notNan
is
None
:
if
notNan
is
None
:
self
.
notNan
=
np
.
ones
(
size
)
self
.
notNan
=
np
.
ones
(
size
[::
-
1
],
dtype
=
bool
)
else
:
else
:
self
.
notNan
=
notNan
self
.
notNan
=
notNan
...
@@ -1088,9 +1093,24 @@ class surfacemap(object):
...
@@ -1088,9 +1093,24 @@ class surfacemap(object):
rho
=
np
.
sqrt
(
X
**
2
+
Y
**
2
)
rho
=
np
.
sqrt
(
X
**
2
+
Y
**
2
)
return
rho
,
phi
return
rho
,
phi
def
preparePhaseMap
(
self
,
xyOffset
=
None
,
w
=
None
,
verbose
=
False
):
def
preparePhaseMap
(
self
,
w
=
None
,
xyOffset
=
None
,
verbose
=
False
):
'''
'''
Based on Simtools function
'
FT_prepare_phase_map_for_finesse.m
'
by Charlotte Bond.
Prepares the phase mirror map for being used in Finesse. The map is cropped, and
the curvature, offset and tilt are removed, in that order.
Input: w, xyOffset, verbose
w - radius of Gaussian weights [m]. If specified, surfaces are fitted
to the mirror map when removing curvature and tilt. Otherise, the
whole mirror map is treated the same, thus covolutions with Zernike
polynomials are used instead.
xyOffset - Beam center offset compared to the mirror center.
verbose - True makes a chatty method, while False only prints the end results.
Output: amap
amap - Aperture map (absorption map), i.e. zeros within the map surface and
ones outside it.
Based on Charlotte Bond
'
s Simtools function
'
FT_prepare_phase_map_for_finesse.m
'
.
'''
'''
if
verbose
:
if
verbose
:
print
(
'
--------------------------------------------------
'
)
print
(
'
--------------------------------------------------
'
)
...
@@ -1195,6 +1215,14 @@ class surfacemap(object):
...
@@ -1195,6 +1215,14 @@ class surfacemap(object):
if
verbose
:
if
verbose
:
print
(
'
Equivalent Z00 amplitude from accumulated z-offsets, A00 = {:.2f}
'
.
format
(
A0
))
print
(
'
Equivalent Z00 amplitude from accumulated z-offsets, A00 = {:.2f}
'
.
format
(
A0
))
if
verbose
:
print
(
'
Creating aperture map...
'
)
# --------------------------------------------------------
amap
=
aperturemap
(
self
.
name
,
self
.
size
,
self
.
step_size
,
self
.
find_radius
(
method
=
'
min
'
,
unit
=
'
meters
'
),
self
.
center
)
if
verbose
:
print
(
'
Aperture map created.
'
)
if
xyOffset
is
not
None
:
if
xyOffset
is
not
None
:
if
verbose
:
if
verbose
:
print
(
'
Offsetting mirror center in the xy-plane...
'
)
print
(
'
Offsetting mirror center in the xy-plane...
'
)
...
@@ -1208,13 +1236,16 @@ class surfacemap(object):
...
@@ -1208,13 +1236,16 @@ class surfacemap(object):
self
.
xyOffset
=
(
0
,
0
)
self
.
xyOffset
=
(
0
,
0
)
if
verbose
:
if
verbose
:
print
(
'
Writing
phase
map to file...
'
)
print
(
'
Writing map
s
to file...
'
)
# --------------------------------------------------------
# --------------------------------------------------------
filename
=
self
.
name
+
'
_finesse.txt
'
filename
=
self
.
name
+
'
_finesse.txt
'
self
.
write_map
(
filename
)
self
.
write_map
(
filename
)
if
verbose
:
if
verbose
:
print
(
'
Phase map written to file {:s}
'
.
format
(
filename
))
print
(
'
Phase map written to file {:s}
'
.
format
(
filename
))
filename
=
amap
.
name
+
'
_aperture.txt
'
amap
.
write_map
(
filename
)
if
verbose
:
print
(
'
Aperture map written to file {:s}
'
.
format
(
filename
))
if
verbose
:
if
verbose
:
print
(
'
Writing result information to file...
'
)
print
(
'
Writing result information to file...
'
)
# --------------------------------------------------------
# --------------------------------------------------------
...
@@ -1223,6 +1254,7 @@ class surfacemap(object):
...
@@ -1223,6 +1254,7 @@ class surfacemap(object):
if
verbose
:
if
verbose
:
print
(
'
Result written to file {:s}
'
.
format
(
filename
))
print
(
'
Result written to file {:s}
'
.
format
(
filename
))
# Printing results to terminal
# Printing results to terminal
print
(
'
--------------------------------------------------
'
)
print
(
'
--------------------------------------------------
'
)
print
(
'
Phase map prepared!
'
)
print
(
'
Phase map prepared!
'
)
...
@@ -1249,14 +1281,12 @@ class surfacemap(object):
...
@@ -1249,14 +1281,12 @@ class surfacemap(object):
print
(
'
--------------------------------------------------
'
)
print
(
'
--------------------------------------------------
'
)
print
()
print
()
return
amap
# Todo:
# Add "create aperture map"
def
writeMapPrepResults
(
self
,
filename
,
w
):
def
writeMapPrepResults
(
self
,
filename
,
w
):
'''
'''
Writing results to file. Not yet finished.
Writing result information to file. The same info that is written to the
terminal.
'''
'''
import
time
import
time
with
open
(
filename
,
'
w
'
)
as
mapfile
:
with
open
(
filename
,
'
w
'
)
as
mapfile
:
...
@@ -1568,8 +1598,10 @@ class mergedmap:
...
@@ -1568,8 +1598,10 @@ class mergedmap:
class
aperturemap
(
surfacemap
):
class
aperturemap
(
surfacemap
):
def
__init__
(
self
,
name
,
size
,
step_size
,
R
):
def
__init__
(
self
,
name
,
size
,
step_size
,
R
,
center
=
None
):
surfacemap
.
__init__
(
self
,
name
,
"
absorption both
"
,
size
,
(
np
.
array
(
size
)
+
1
)
/
2.0
,
step_size
,
1
)
if
center
is
None
:
center
=
(
np
.
array
(
size
)
+
1
)
/
2.0
surfacemap
.
__init__
(
self
,
name
,
"
absorption both
"
,
size
,
center
,
step_size
,
1
)
self
.
R
=
R
self
.
R
=
R
@property
@property
...
@@ -1584,7 +1616,7 @@ class aperturemap(surfacemap):
...
@@ -1584,7 +1616,7 @@ class aperturemap(surfacemap):
radius
=
np
.
sqrt
(
xx
**
2
+
yy
**
2
)
radius
=
np
.
sqrt
(
xx
**
2
+
yy
**
2
)
self
.
data
=
np
.
zeros
(
self
.
size
)
self
.
data
=
np
.
zeros
(
self
.
size
[::
-
1
]
)
self
.
data
[
radius
>
self
.
R
]
=
1.0
self
.
data
[
radius
>
self
.
R
]
=
1.0
...
...
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