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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Steinlechner
pykat
Commits
b20e1b58
Commit
b20e1b58
authored
10 years ago
by
Daniel Brown
Browse files
Options
Downloads
Patches
Plain Diff
fixing gauss param naming
parent
bc77f025
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
pykat/commands.py
+15
-1
15 additions, 1 deletion
pykat/commands.py
pykat/components.py
+9
-0
9 additions, 0 deletions
pykat/components.py
pykat/node_network.py
+19
-5
19 additions, 5 deletions
pykat/node_network.py
pykat/utilities/maps.py
+11
-3
11 additions, 3 deletions
pykat/utilities/maps.py
with
54 additions
and
9 deletions
pykat/commands.py
+
15
−
1
View file @
b20e1b58
...
...
@@ -61,7 +61,6 @@ class cavity(Command):
class
gauss
(
object
):
@staticmethod
def
parseFinesseText
(
text
,
kat
):
print
"
parsing gauss
"
,
kat
.
lambda0
values
=
text
.
split
()
if
not
values
[
0
].
startswith
(
"
gauss
"
)
or
(
len
(
values
)
!=
6
and
len
(
values
)
!=
8
):
...
...
@@ -71,6 +70,21 @@ class gauss(object):
component
=
values
[
2
]
node
=
values
[
3
]
# setting the name of the gauss parameter is slightly convoluted
# as we don't explicitly store gauss paramters as an object, they
# are simply just complex numbers stored at each node. To fix this
# the name is stored in the NodeGaussSetter object for each component
if
component
in
kat
.
components
:
c
=
kat
.
components
[
component
]
if
hasattr
(
c
,
node
):
ns
=
getattr
(
c
,
node
)
ns
.
name
=
name
else
:
raise
pkex
.
BasePyKatException
(
"
Component
'
{0}
'
is not attached to node {1}
"
.
format
(
component
,
node
))
else
:
raise
pkex
.
BasePyKatException
(
"
Component
'
{0}
'
was not found
"
.
format
(
component
))
if
not
values
[
0
].
endswith
(
"
*
"
):
if
len
(
values
)
==
6
:
gp
=
beam_param
(
kat
.
lambda0
,
w0
=
values
[
-
2
],
z
=
values
[
-
1
])
...
...
This diff is collapsed.
Click to expand it.
pykat/components.py
+
9
−
0
View file @
b20e1b58
...
...
@@ -25,6 +25,15 @@ class NodeGaussSetter(object):
def
__init__
(
self
,
component
,
node
):
self
.
__comp
=
weakref
.
ref
(
component
)
self
.
__node
=
weakref
.
ref
(
node
)
self
.
__name
=
None
@property
def
name
(
self
):
return
self
.
__name
@name.setter
def
name
(
self
,
value
):
self
.
__name
=
str
(
value
)
@property
def
node
(
self
):
...
...
This diff is collapsed.
Click to expand it.
pykat/node_network.py
+
19
−
5
View file @
b20e1b58
...
...
@@ -434,12 +434,26 @@ class Node(object):
rtn
=
[]
# to get the name of the gauss parameter is a bit convoluted...
# firstly the name is set in the NodeGaussSetter object which is
# connected to each component, so this has to be retrieved and
# then applied.
if
hasattr
(
self
.
__q_comp
,
self
.
name
):
ns
=
getattr
(
self
.
__q_comp
,
self
.
name
)
# if no name is present give it a default one
if
ns
.
name
!=
None
:
name
=
ns
.
name
else
:
name
=
"
g_%s
"
%
self
.
name
else
:
raise
pkex
.
BasePyKatException
(
"
Node {0} is not connected to {1}
"
.
format
(
self
.
name
,
self
.
__q_comp
.
name
))
if
self
.
__q_x
==
self
.
__q_y
:
rtn
.
append
(
"
gauss g_{node} {comp} {node} {w0:.15g} {z:.15g}
"
.
format
(
node
=
self
.
name
,
comp
=
self
.
__q_comp
.
name
,
w0
=
self
.
__q_x
.
w0
,
z
=
self
.
__q_x
.
z
))
#rtn.append("gauss* g_{node} {comp} {node} {z} {zr}".format(node=self.name, comp=self.__q_comp.name, z=self.__q_x.real, zr=self.__q_x.imag))
rtn
.
append
(
"
gauss {name} {comp} {node} {w0:.15g} {z:.15g}
"
.
format
(
name
=
name
,
node
=
self
.
name
,
comp
=
self
.
__q_comp
.
name
,
w0
=
self
.
__q_x
.
w0
,
z
=
self
.
__q_x
.
z
))
else
:
rtn
.
append
(
"
gauss g_{node} {comp} {node} {w0x:.15g} {zx:.15g} {w0y:.15g} {zy:.15g}
"
.
format
(
node
=
self
.
name
,
comp
=
self
.
__q_comp
.
name
,
w0x
=
self
.
__q_x
.
w0
,
zx
=
self
.
__q_x
.
z
,
w0y
=
self
.
__q_y
.
w0
,
zy
=
self
.
__q_y
.
z
))
#rtn.append("gauss* g_{node} {comp} {node} {zx} {zrx} {zy} {zry}".format(node=self.name, comp=self.__q_comp.name, zx=self.__q_x.real, zrx=self.__q_x.imag, zy=self.__q_y.real, zry=self.__q_y.imag))
rtn
.
append
(
"
gauss {name} {comp} {node} {w0x:.15g} {zx:.15g} {w0y:.15g} {zy:.15g}
"
.
format
(
name
=
name
,
node
=
self
.
name
,
comp
=
self
.
__q_comp
.
name
,
w0x
=
self
.
__q_x
.
w0
,
zx
=
self
.
__q_x
.
z
,
w0y
=
self
.
__q_y
.
w0
,
zy
=
self
.
__q_y
.
z
))
return
rtn
...
...
This diff is collapsed.
Click to expand it.
pykat/utilities/maps.py
+
11
−
3
View file @
b20e1b58
...
...
@@ -29,12 +29,20 @@ class surfacemap:
mapfile
.
write
(
"
%.15g
"
%
self
.
data
[
i
,
j
])
mapfile
.
write
(
"
\n
"
)
@property
def
x
(
self
):
return
self
.
step_size
[
0
]
*
(
numpy
.
array
(
range
(
0
,
self
.
data
.
shape
[
0
]))
-
self
.
center
[
0
])
@property
def
y
(
self
):
return
self
.
step_size
[
1
]
*
(
numpy
.
array
(
range
(
0
,
self
.
data
.
shape
[
1
]))
-
self
.
center
[
1
])
def
plot
(
self
,
show
=
True
,
clabel
=
None
):
import
pylab
xrange
=
100
*
self
.
step_size
[
0
]
*
(
numpy
.
array
(
range
(
0
,
self
.
data
.
shape
[
0
]))
-
self
.
center
[
0
])
yrange
=
100
*
self
.
step_size
[
1
]
*
(
numpy
.
array
(
range
(
0
,
self
.
data
.
shape
[
1
]))
-
self
.
center
[
1
])
xrange
=
100
*
self
.
x
yrange
=
100
*
self
.
y
fig
=
pylab
.
figure
()
axes
=
pylab
.
imshow
(
self
.
data
,
extent
=
[
min
(
xrange
),
max
(
xrange
),
min
(
yrange
),
max
(
yrange
)])
...
...
@@ -66,7 +74,7 @@ def read_map(filename):
data
=
numpy
.
loadtxt
(
filename
,
dtype
=
numpy
.
float64
,
skiprows
=
9
,
ndmin
=
2
)
data
=
numpy
.
loadtxt
(
filename
,
dtype
=
numpy
.
float64
,
ndmin
=
2
,
comments
=
'
%
'
)
return
surfacemap
(
name
,
maptype
,
size
,
center
,
step
,
scaling
,
data
)
...
...
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