Skip to content
GitLab
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
489129df
Commit
489129df
authored
Jul 17, 2015
by
Daniel Brown
Browse files
fixing fsig parsing of 'fsig signal frequency'. Adding code to allow surface motions.
parent
449bf621
Changes
4
Hide whitespace changes
Inline
Side-by-side
pykat/components.py
View file @
489129df
...
...
@@ -321,6 +321,11 @@ class AbstractMirrorComponent(Component):
self
.
__Frx
=
Param
(
"Frx"
,
self
,
None
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"Frx"
)
self
.
__Fry
=
Param
(
"Fry"
,
self
,
None
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"Fry"
)
self
.
__Fs0
=
Param
(
"Fs0"
,
self
,
None
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"Fs0"
)
self
.
__Fs1
=
Param
(
"Fs1"
,
self
,
None
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"Fs1"
)
self
.
__Fs0
=
Param
(
"s0"
,
self
,
None
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"s0"
)
self
.
__Fs1
=
Param
(
"s1"
,
self
,
None
,
canFsig
=
True
,
isPutable
=
False
,
isPutter
=
False
,
isTunable
=
False
,
fsig_name
=
"s1"
)
self
.
_default_fsig_param
=
self
.
__phi
@
property
...
...
pykat/finesse.py
View file @
489129df
...
...
@@ -382,6 +382,7 @@ class Signals(object):
return
rtn
@
property
def
name
(
self
):
# if we don't have any signals yet then use a dummy name
...
...
@@ -389,7 +390,7 @@ class Signals(object):
# so need to get the name of at least one of them
# as if you tune one you tune them all
if
len
(
self
.
targets
)
==
0
:
return
"fsignal"
return
self
.
_default_name
else
:
return
self
.
targets
[
0
].
name
...
...
@@ -408,6 +409,7 @@ class Signals(object):
def
f
(
self
,
value
):
self
.
__f
.
value
=
SIfloat
(
value
)
def
__init__
(
self
,
kat
):
self
.
_default_name
=
"fsignal"
self
.
targets
=
[]
self
.
_params
=
[]
self
.
__f
=
Param
(
"f"
,
self
,
1
)
...
...
@@ -429,16 +431,21 @@ class Signals(object):
def
getFinesseText
(
self
):
rtn
=
[]
for
t
in
self
.
targets
:
rtn
.
extend
(
t
.
getFinesseText
())
if
len
(
self
.
targets
)
==
0
and
self
.
f
!=
0
:
rtn
.
append
(
"fsig {name} {frequency}"
.
format
(
name
=
self
.
name
,
frequency
=
str
(
self
.
f
)))
else
:
for
t
in
self
.
targets
:
rtn
.
extend
(
t
.
getFinesseText
())
rtn
.
append
(
"fsig {name} {comp} {target} {frequency} {phase} {amplitude}"
.
format
(
name
=
t
.
name
,
comp
=
t
.
owner
,
target
=
t
.
target
,
frequency
=
str
(
self
.
f
),
phase
=
str
(
t
.
phase
),
amplitude
=
str
(
t
.
amplitude
if
t
.
amplitude
!=
None
else
""
)))
rtn
.
append
(
"fsig {name} {comp} {target} {frequency} {phase} {amplitude}"
.
format
(
name
=
t
.
name
,
comp
=
t
.
owner
,
target
=
t
.
target
,
frequency
=
str
(
self
.
f
),
phase
=
str
(
t
.
phase
),
amplitude
=
str
(
t
.
amplitude
if
t
.
amplitude
!=
None
else
""
)))
for
p
in
self
.
_params
:
rtn
.
extend
(
p
.
getFinesseText
())
...
...
@@ -1003,61 +1010,69 @@ class kat(object):
name
=
str
(
v
[
1
])
if
v
[
2
]
not
in
self
.
__components
:
raise
pkex
.
BasePyKatException
(
"Could not find the component '{0}'. Line: '{1}'"
.
format
(
v
[
2
],
line
))
if
len
(
v
)
==
3
:
self
.
signals
.
_default_name
=
name
self
.
signals
.
f
=
SIfloat
(
v
[
2
])
else
:
if
v
[
2
]
not
in
self
.
__components
:
raise
pkex
.
BasePyKatException
(
"Could not find the component '{0}'. Line: '{1}'"
.
format
(
v
[
2
],
line
))
comp
=
self
.
__components
[
v
[
2
]]
comp
=
self
.
__components
[
v
[
2
]]
if
comp
.
_default_fsig
()
is
None
:
raise
pkex
.
BasePyKatException
(
"Component '{0}' cannot be fsig'd. Line: '{1}'"
.
format
(
comp
.
name
,
line
))
if
comp
.
_default_fsig
()
is
None
:
raise
pkex
.
BasePyKatException
(
"Component '{0}' cannot be fsig'd. Line: '{1}'"
.
format
(
comp
.
name
,
line
))
param_name
=
None
amp
=
None
param_name
=
None
amp
=
None
if
len
(
v
)
==
5
:
#param is None
freq
=
SIfloat
(
v
[
3
])
phase
=
SIfloat
(
v
[
4
])
elif
len
(
v
)
==
6
:
try
:
SIfloat
(
v
[
3
])
isFloat
=
True
except
:
isFloat
=
False
if
isFloat
:
if
len
(
v
)
==
3
:
self
.
signals
.
_default_name
=
name
freq
=
SIfloat
(
v
[
3
])
elif
len
(
v
)
==
5
:
#param is None
freq
=
SIfloat
(
v
[
3
])
phase
=
SIfloat
(
v
[
4
])
amp
=
SIfloat
(
v
[
5
])
else
:
elif
len
(
v
)
==
6
:
try
:
SIfloat
(
v
[
3
])
isFloat
=
True
except
:
isFloat
=
False
if
isFloat
:
freq
=
SIfloat
(
v
[
3
])
phase
=
SIfloat
(
v
[
4
])
amp
=
SIfloat
(
v
[
5
])
else
:
param_name
=
v
[
3
]
freq
=
SIfloat
(
v
[
4
])
phase
=
SIfloat
(
v
[
5
])
elif
len
(
v
)
==
7
:
param_name
=
v
[
3
]
freq
=
SIfloat
(
v
[
4
])
phase
=
SIfloat
(
v
[
5
])
elif
len
(
v
)
==
7
:
param_name
=
v
[
3
]
freq
=
SIfloat
(
v
[
4
])
phase
=
SIfloat
(
v
[
5
])
amp
=
SIfloat
(
v
[
6
])
else
:
raise
pkex
.
BasePyKatException
(
"'{0}' isnot a valid fsig command"
.
format
(
line
))
amp
=
SIfloat
(
v
[
6
])
else
:
raise
pkex
.
BasePyKatException
(
"'{0}' isnot a valid fsig command"
.
format
(
line
))
self
.
signals
.
f
=
freq
param
=
None
self
.
signals
.
f
=
freq
if
param_name
is
None
:
param
=
comp
.
_default_fsig
()
else
:
for
p
in
comp
.
_params
:
if
p
.
canFsig
and
p
.
fsigName
==
param_name
:
param
=
p
break
param
=
None
if
param_name
is
None
:
param
=
comp
.
_default_fsig
()
else
:
for
p
in
comp
.
_params
:
if
p
.
canFsig
and
p
.
fsigName
==
param_name
:
param
=
p
break
if
param
is
None
:
raise
pkex
.
BasePyKatException
(
"Line: '{0}': {1} is not a valid fsig target for {2}"
.
format
(
line
,
param_name
,
comp
.
name
))
if
param
is
None
:
raise
pkex
.
BasePyKatException
(
"Line: '{0}': {1} is not a valid fsig target for {2}"
.
format
(
line
,
param_name
,
comp
.
name
))
self
.
signals
.
apply
(
param
,
amp
,
phase
,
name
)
self
.
signals
.
apply
(
param
,
amp
,
phase
,
name
)
else
:
raise
pkex
.
BasePyKatException
(
"Haven't handled parsing of '{0}'"
.
format
(
line
))
...
...
pykat/optics/maps.py
View file @
489129df
...
...
@@ -16,6 +16,7 @@ from __future__ import print_function
from
pykat.optics.romhom
import
makeWeightsNew
from
scipy.interpolate
import
interp2d
,
interp1d
from
pykat.maths.zernike
import
*
from
pykat.exceptions
import
BasePyKatException
import
numpy
as
np
import
math
...
...
@@ -108,11 +109,11 @@ class surfacemap(object):
@
property
def
x
(
self
):
return
self
.
step_size
[
0
]
*
(
np
.
array
(
range
(
1
,
self
.
data
.
shape
[
0
]
+
1
))
-
self
.
center
[
0
])
return
self
.
step_size
[
0
]
*
(
np
.
array
(
range
(
0
,
self
.
data
.
shape
[
0
]))
-
self
.
center
[
0
])
@
property
def
y
(
self
):
return
self
.
step_size
[
1
]
*
(
np
.
array
(
range
(
1
,
self
.
data
.
shape
[
1
]
+
1
))
-
self
.
center
[
1
])
return
self
.
step_size
[
1
]
*
(
np
.
array
(
range
(
0
,
self
.
data
.
shape
[
1
]))
-
self
.
center
[
1
])
@
property
def
size
(
self
):
...
...
@@ -120,7 +121,7 @@ class surfacemap(object):
@
property
def
offset
(
self
):
return
np
.
array
(
self
.
step_size
)
*
(
np
.
array
(
self
.
center
)
-
1
/
2.
-
np
.
array
(
self
.
size
)
/
2.0
)
return
np
.
array
(
self
.
step_size
)
*
(
np
.
array
(
self
.
center
)
-
(
np
.
array
(
self
.
size
)
-
1
)
/
2.0
)
@
property
def
ROMWeights
(
self
):
...
...
@@ -176,6 +177,11 @@ class surfacemap(object):
return
np
.
sqrt
(
1.0
-
data
)
else
:
return
np
.
sqrt
(
1.0
-
data
[:,
::
-
1
])
elif
"surface_motion"
in
self
.
type
:
if
direction
==
"reflection_front"
:
return
data
else
:
return
data
[:,
::
-
1
]
else
:
raise
BasePyKatException
(
"Map type needs handling"
)
...
...
@@ -193,6 +199,9 @@ class surfacemap(object):
return
np
.
sqrt
(
1.0
-
data
)
else
:
return
np
.
sqrt
(
1.0
-
data
[:,
::
-
1
])
elif
"surface_motion"
in
self
.
type
:
return
np
.
ones
(
data
.
shape
)
else
:
raise
BasePyKatException
(
"Map type needs handling"
)
...
...
@@ -274,10 +283,10 @@ class surfacemap(object):
D
=
interp2d
(
self
.
x
,
self
.
y
,
self
.
data
,
**
kwargs
)
data
=
D
(
nx
-
self
.
offset
[
0
],
ny
-
self
.
offset
[
0
])
data
=
D
(
nx
-
self
.
offset
[
0
],
ny
-
self
.
offset
[
1
])
Dx
=
interp1d
(
nx
,
np
.
arange
(
1
,
len
(
nx
)
+
1
))
Dy
=
interp1d
(
ny
,
np
.
arange
(
1
,
len
(
ny
)
+
1
))
Dx
=
interp1d
(
nx
,
np
.
arange
(
0
,
len
(
nx
)))
Dy
=
interp1d
(
ny
,
np
.
arange
(
0
,
len
(
ny
)))
self
.
center
=
(
Dx
(
0
),
Dy
(
0
))
self
.
step_size
=
(
nx
[
1
]
-
nx
[
0
],
ny
[
1
]
-
ny
[
0
])
...
...
@@ -313,7 +322,7 @@ class surfacemap(object):
yrange
=
100
*
self
.
y
fig
=
pylab
.
figure
()
axes
=
pylab
.
pcolormesh
(
xrange
,
yrange
,
self
.
data
,
vmin
=
zmin
,
vmax
=
zmax
)
axes
=
pylab
.
pcolormesh
(
xrange
,
yrange
,
self
.
data
*
self
.
scaling
,
vmin
=
zmin
,
vmax
=
zmax
)
pylab
.
xlabel
(
'x [cm]'
)
pylab
.
ylabel
(
'y [cm]'
)
...
...
@@ -406,11 +415,11 @@ class mergedmap:
@
property
def
x
(
self
):
return
self
.
step_size
[
0
]
*
(
np
.
array
(
range
(
1
,
self
.
size
[
0
]
+
1
))
-
self
.
center
[
0
])
return
self
.
step_size
[
0
]
*
(
np
.
array
(
range
(
0
,
self
.
size
[
0
]))
-
self
.
center
[
0
])
@
property
def
y
(
self
):
return
self
.
step_size
[
1
]
*
(
np
.
array
(
range
(
1
,
self
.
size
[
1
]
+
1
))
-
self
.
center
[
1
])
return
self
.
step_size
[
1
]
*
(
np
.
array
(
range
(
0
,
self
.
size
[
1
]))
-
self
.
center
[
1
])
@
property
def
size
(
self
):
...
...
@@ -418,7 +427,7 @@ class mergedmap:
@
property
def
offset
(
self
):
return
np
.
array
(
self
.
step_size
)
*
(
np
.
array
(
self
.
center
)
-
1
/
2.
-
np
.
array
(
self
.
size
)
/
2.0
)
return
np
.
array
(
self
.
step_size
)
*
(
np
.
array
(
self
.
center
)
-
(
np
.
array
(
self
.
size
)
-
1
)
/
2.0
)
@
property
def
ROMWeights
(
self
):
...
...
pykat/optics/romhom.py
View file @
489129df
...
...
@@ -481,6 +481,7 @@ def MakeROMFromHDF5(hdf5Filename, greedyFilename=None, EIFilename=None, tol=1e-1
V
[
m
][
l
]
=
RB_matrix
[
l
][
EI_indices
[
m
]]
# Part of (5) of Algorithm 2: making V_{ij}
invV
=
inv
(
V
[
0
:
len
(
EI_indices
),
0
:
len
(
EI_indices
)])
B
=
B_matrix
(
invV
,
np
.
array
(
RB_matrix
))
_TS
=
TS
[
str
(
next_RB_index
)]
...
...
@@ -546,7 +547,7 @@ def makeWeightsNew(smap, EIxFilename, EIyFilename=None, verbose=True, newtonCote
A_xy_Q2
=
A_xy
[
Q2xy
]
A_xy_Q3
=
A_xy
[
Q3xy
]
A_xy_Q4
=
A_xy
[
Q4xy
]
full_x
=
smap
.
x
full_y
=
smap
.
y
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment