Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
finesse
pykat
Commits
4681357e
Commit
4681357e
authored
Jan 23, 2015
by
Daniel Brown
Browse files
changing ROMHOM output file
parent
426c99be
Changes
2
Show whitespace changes
Inline
Side-by-side
pykat/optics/maps.py
View file @
4681357e
...
...
@@ -143,28 +143,30 @@ class surfacemap(object):
raise
BasePyKatException
(
"Map type needs handling"
)
def
generateROMWeights
(
self
,
isModeMatched
=
True
,
verbose
=
False
,
interpolate
=
False
,
tolerance
=
1e-12
,
sigma
=
1
,
sort
=
False
,
greedyfile
=
None
):
def
generateROMWeights
(
self
,
isModeMatched
=
True
,
verbose
=
False
,
interpolate
=
False
,
interpolate_N
=
None
,
tolerance
=
1e-12
,
sigma
=
1
,
sort
=
False
,
greedyfile
=
None
):
if
interpolate
:
from
scipy.interpolate
import
interp2d
import
numpy
as
np
D
=
interp2d
(
self
.
x
,
self
.
y
,
self
.
data
,
fill_value
=
0
)
if
interpolate_N
is
None
:
interpolate_N
=
(
self
.
size
[
0
],
self
.
size
[
1
])
# only want even number of data points spread equally
# about the axes
if
self
.
size
[
0
]
%
2
==
0
:
Nx
=
self
.
size
[
0
]
if
interpolate_N
[
0
]
%
2
==
0
:
Nx
=
interpolate_N
[
0
]
else
:
Nx
=
self
.
size
[
0
]
-
1
Nx
=
interpolate_N
[
0
]
-
1
if
self
.
size
[
1
]
%
2
==
0
:
Ny
=
self
.
size
[
1
]
if
interpolate_N
[
1
]
%
2
==
0
:
Ny
=
interpolate_N
[
1
]
else
:
Ny
=
self
.
size
[
1
]
-
1
Ny
=
interpolate_N
[
1
]
-
1
nx
=
np
.
linspace
(
min
(
self
.
x
),
max
(
self
.
x
),
Nx
)
ny
=
np
.
linspace
(
min
(
self
.
y
),
max
(
self
.
y
),
Ny
)
nx
=
np
.
linspace
(
min
(
self
.
x
),
max
(
self
.
x
),
interpolate_N
[
0
]
)
ny
=
np
.
linspace
(
min
(
self
.
y
),
max
(
self
.
y
),
interpolate_N
[
1
]
)
data
=
D
(
nx
-
self
.
offset
[
0
],
ny
-
self
.
offset
[
0
])
...
...
pykat/optics/romhom.py
View file @
4681357e
...
...
@@ -28,37 +28,48 @@ class ROMWeights:
self
.
limits
=
limits
def
writeToFile
(
self
,
filename
):
f
=
open
(
filename
,
'w+'
)
"""
Writes this map's ROM weights to a file
that can be used with Finesse. The filename
is appended with '.rom' internally.
"""
f
=
open
(
filename
+
".rom"
,
'w+'
)
f
.
write
(
"zmin=%16.16e
\n
"
%
self
.
limits
.
zmin
)
f
.
write
(
"zmax=%16.16e
\n
"
%
self
.
limits
.
zmax
)
f
.
write
(
"w0min=%16.16e
\n
"
%
self
.
limits
.
w0min
)
f
.
write
(
"w0max=%16.16e
\n
"
%
self
.
limits
.
w0max
)
f
.
write
(
"maxorder=%i
\n
"
%
self
.
limits
.
max_order
)
f
.
write
(
"xnodes=%i
\n
"
%
len
(
self
.
EI
[
"xm"
].
nodes
))
for
v
in
self
.
EI
[
"xm"
].
nodes
.
flatten
():
f
.
write
(
"%s
\n
"
%
repr
(
float
(
v
)))
f
.
write
(
repr
(
self
.
limits
)
+
"
\n
"
)
f
.
write
(
"ynodes=%i
\n
"
%
len
(
self
.
EI
[
"ym"
].
nodes
))
for
v
in
self
.
EI
[
"ym"
].
nodes
.
flatten
():
f
.
write
(
"%s
\n
"
%
repr
(
float
(
v
)))
f
.
write
(
repr
(
self
.
w_ij_Q1
.
shape
)
+
"
\n
"
)
for
v
in
self
.
w_ij_Q1
.
flatten
():
f
.
write
(
"%s "
%
repr
(
complex
(
v
))[
1
:
-
1
])
f
.
write
(
"
\n
"
)
f
.
write
(
"%s
\n
"
%
repr
(
complex
(
v
))[
1
:
-
1
])
f
.
write
(
repr
(
self
.
w_ij_Q2
.
shape
)
+
"
\n
"
)
for
v
in
self
.
w_ij_Q2
.
flatten
():
f
.
write
(
"%s "
%
repr
(
complex
(
v
))[
1
:
-
1
])
f
.
write
(
"
\n
"
)
f
.
write
(
"%s
\n
"
%
repr
(
complex
(
v
))[
1
:
-
1
])
f
.
write
(
repr
(
self
.
w_ij_Q3
.
shape
)
+
"
\n
"
)
for
v
in
self
.
w_ij_Q3
.
flatten
():
f
.
write
(
"%s "
%
repr
(
complex
(
v
))[
1
:
-
1
])
f
.
write
(
"
\n
"
)
f
.
write
(
"%s
\n
"
%
repr
(
complex
(
v
))[
1
:
-
1
])
f
.
write
(
repr
(
self
.
w_ij_Q4
.
shape
)
+
"
\n
"
)
for
v
in
self
.
w_ij_Q4
.
flatten
():
f
.
write
(
"%s "
%
repr
(
complex
(
v
))[
1
:
-
1
])
f
.
write
(
"
\n
"
)
f
.
write
(
"%s
\n
"
%
repr
(
complex
(
v
))[
1
:
-
1
])
f
.
close
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment