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
4081eabd
Commit
4081eabd
authored
Jan 06, 2017
by
Daniel Brown
Browse files
Changing to CamelCase for katRun and beam_param
parent
100345ec
Pipeline
#1761
failed with stage
in 13 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pykat/__init__.py
View file @
4081eabd
...
...
@@ -26,7 +26,7 @@ import pykat.components as components
import
pykat.detectors
as
detectors
import
pykat.commands
as
commands
from
pykat.optics.gaussian_beams
import
b
eam
_p
aram
from
pykat.optics.gaussian_beams
import
B
eam
P
aram
from
pykat.plotting
import
init_pykat_plotting
...
...
pykat/commands.py
View file @
4081eabd
...
...
@@ -21,7 +21,7 @@ from pykat.structs import *
from
numpy
import
min
,
max
from
pykat.param
import
Param
,
putter
from
collections
import
namedtuple
from
pykat.optics.gaussian_beams
import
b
eam
_p
aram
from
pykat.optics.gaussian_beams
import
B
eam
P
aram
...
...
@@ -297,22 +297,22 @@ class gauss(object):
if
not
values
[
0
].
endswith
(
"*"
):
if
len
(
values
)
==
6
:
gp
=
b
eam
_p
aram
(
kat
.
lambda0
,
w0
=
values
[
-
2
],
z
=
values
[
-
1
])
gp
=
B
eam
P
aram
(
kat
.
lambda0
,
w0
=
values
[
-
2
],
z
=
values
[
-
1
])
elif
len
(
values
)
==
8
:
gpx
=
b
eam
_p
aram
(
kat
.
lambda0
,
w0
=
values
[
-
4
],
z
=
values
[
-
3
])
gpy
=
b
eam
_p
aram
(
kat
.
lambda0
,
w0
=
values
[
-
2
],
z
=
values
[
-
1
])
gpx
=
B
eam
P
aram
(
kat
.
lambda0
,
w0
=
values
[
-
4
],
z
=
values
[
-
3
])
gpy
=
B
eam
P
aram
(
kat
.
lambda0
,
w0
=
values
[
-
2
],
z
=
values
[
-
1
])
elif
values
[
0
].
endswith
(
"*"
):
if
len
(
values
)
==
6
:
gp
=
b
eam
_p
aram
(
kat
.
lambda0
,
z
=
values
[
-
2
],
zr
=
values
[
-
1
])
gp
=
B
eam
P
aram
(
kat
.
lambda0
,
z
=
values
[
-
2
],
zr
=
values
[
-
1
])
elif
len
(
values
)
==
8
:
gpx
=
b
eam
_p
aram
(
kat
.
lambda0
,
z
=
values
[
-
4
],
zr
=
values
[
-
3
])
gpy
=
b
eam
_p
aram
(
kat
.
lambda0
,
z
=
values
[
-
2
],
zr
=
values
[
-
1
])
gpx
=
B
eam
P
aram
(
kat
.
lambda0
,
z
=
values
[
-
4
],
zr
=
values
[
-
3
])
gpy
=
B
eam
P
aram
(
kat
.
lambda0
,
z
=
values
[
-
2
],
zr
=
values
[
-
1
])
elif
values
[
0
].
endswith
(
"**"
):
if
len
(
values
)
==
6
:
gp
=
b
eam
_p
aram
(
kat
.
lambda0
,
w
=
values
[
-
2
],
rc
=
values
[
-
1
])
gp
=
B
eam
P
aram
(
kat
.
lambda0
,
w
=
values
[
-
2
],
rc
=
values
[
-
1
])
elif
len
(
values
)
==
8
:
gpx
=
b
eam
_p
aram
(
kat
.
lambda0
,
w
=
values
[
-
4
],
rc
=
values
[
-
3
])
gpy
=
b
eam
_p
aram
(
kat
.
lambda0
,
w
=
values
[
-
2
],
rc
=
values
[
-
1
])
gpx
=
B
eam
P
aram
(
kat
.
lambda0
,
w
=
values
[
-
4
],
rc
=
values
[
-
3
])
gpy
=
B
eam
P
aram
(
kat
.
lambda0
,
w
=
values
[
-
2
],
rc
=
values
[
-
1
])
else
:
raise
pkex
.
BasePyKatException
(
"Unexpected ending to gauss command '{0}'"
.
format
(
text
))
...
...
pykat/finesse.py
View file @
4081eabd
...
...
@@ -325,7 +325,7 @@ def GUILength(L):
"""
return
L
# * ( 40 * erfc(L/400.0) + 0.01)
class
k
atRun
(
object
):
class
K
atRun
(
object
):
def
__init__
(
self
):
self
.
runtime
=
None
self
.
StartDateTime
=
datetime
.
datetime
.
now
()
...
...
@@ -579,7 +579,7 @@ class katRun(object):
return
fig
def
save
k
atRun
(
self
,
filename
):
def
save
K
atRun
(
self
,
filename
):
with
open
(
filename
,
'w'
)
as
outfile
:
pickle
.
dump
(
self
,
outfile
)
...
...
@@ -618,7 +618,7 @@ class katRun(object):
else
:
raise
pkex
.
BasePyKatException
(
"No output by the name '{0}' found in the output"
.
format
(
str
(
value
)))
class
k
atRun2D
(
object
):
class
K
atRun2D
(
object
):
def
__init__
(
self
):
self
.
runtime
=
None
self
.
startDateTime
=
datetime
.
datetime
.
now
()
...
...
@@ -1546,7 +1546,7 @@ class kat(object):
def
run
(
self
,
plot
=
None
,
save_output
=
False
,
save_kat
=
False
,
kat_name
=
None
,
cmd_args
=
None
,
getTraceData
=
False
,
rethrowExceptions
=
False
,
usePipe
=
True
):
"""
Runs the current simulation setup that has been built thus far.
It returns a
k
atRun or
k
atRun2D object which is populated with the various
It returns a
K
atRun or
K
atRun2D object which is populated with the various
data from the simulation run.
plot (string) - Sets gnuterm for plotting
save_output (bool) - if true does not delete out file
...
...
@@ -1597,9 +1597,9 @@ class kat(object):
if
self
.
verbose
:
print
(
"Running kat - Started at "
+
str
(
datetime
.
datetime
.
fromtimestamp
(
start
)))
if
hasattr
(
self
,
"x2axis"
)
and
self
.
noxaxis
==
False
:
r
=
k
atRun2D
()
r
=
K
atRun2D
()
else
:
r
=
k
atRun
()
r
=
K
atRun
()
r
.
yaxis
=
self
.
yaxis
...
...
@@ -1782,8 +1782,8 @@ class kat(object):
qx
=
spqx
[
0
].
split
(
"="
)[
1
].
replace
(
'i'
,
'j'
).
replace
(
' '
,
''
)
qy
=
spqy
[
0
].
split
(
"="
)[
1
].
replace
(
'i'
,
'j'
).
replace
(
' '
,
''
)
traceData
[
-
1
][
node_name
]
=
(
pykat
.
b
eam
_p
aram
(
q
=
complex
(
qx
),
wavelength
=
self
.
lambda0
),
pykat
.
b
eam
_p
aram
(
q
=
complex
(
qy
),
wavelength
=
self
.
lambda0
),
traceData
[
-
1
][
node_name
]
=
(
pykat
.
B
eam
P
aram
(
q
=
complex
(
qx
),
wavelength
=
self
.
lambda0
),
pykat
.
B
eam
P
aram
(
q
=
complex
(
qy
),
wavelength
=
self
.
lambda0
),
component_name
)
finally
:
...
...
pykat/gauss/__init__.py
deleted
100644 → 0
View file @
100345ec
pykat/node_network.py
View file @
4081eabd
...
...
@@ -20,7 +20,7 @@ import pykat.external.six as six
from
pykat.components
import
Component
,
NodeGaussSetter
from
pykat.detectors
import
BaseDetector
as
Detector
from
pykat.optics.gaussian_beams
import
b
eam
_p
aram
from
pykat.optics.gaussian_beams
import
B
eam
P
aram
from
copy
import
deepcopy
id___
=
0
...
...
@@ -554,11 +554,11 @@ class Node(object):
self
.
__q_comp
=
component
if
len
(
args
)
==
1
:
self
.
__q_x
=
b
eam
_p
aram
(
self
.
_network
.
kat
.
lambda0
,
q
=
args
[
0
])
self
.
__q_y
=
b
eam
_p
aram
(
self
.
_network
.
kat
.
lambda0
,
q
=
args
[
0
])
self
.
__q_x
=
B
eam
P
aram
(
self
.
_network
.
kat
.
lambda0
,
q
=
args
[
0
])
self
.
__q_y
=
B
eam
P
aram
(
self
.
_network
.
kat
.
lambda0
,
q
=
args
[
0
])
elif
len
(
args
)
==
2
:
self
.
__q_x
=
b
eam
_p
aram
(
self
.
_network
.
kat
.
lambda0
,
q
=
args
[
0
])
self
.
__q_y
=
b
eam
_p
aram
(
self
.
_network
.
kat
.
lambda0
,
q
=
args
[
1
])
self
.
__q_x
=
B
eam
P
aram
(
self
.
_network
.
kat
.
lambda0
,
q
=
args
[
0
])
self
.
__q_y
=
B
eam
P
aram
(
self
.
_network
.
kat
.
lambda0
,
q
=
args
[
1
])
else
:
raise
pkex
.
BasePyKatException
(
"Must specify either 1 Gaussian beam parameter or 2 for astigmatic beams"
)
...
...
pykat/optics/ABCD.py
View file @
4081eabd
import
numpy
as
np
from
pykat.optics.gaussian_beams
import
b
eam
_p
aram
from
pykat.optics.gaussian_beams
import
B
eam
P
aram
def
apply
(
ABCD
,
q1
,
n1
,
n2
):
return
b
eam
_p
aram
(
nr
=
n2
,
q
=
n2
*
(
ABCD
[
0
,
0
]
*
q1
/
float
(
n1
)
+
ABCD
[
0
,
1
])
/
(
ABCD
[
1
,
0
]
*
q1
/
float
(
n1
)
+
ABCD
[
1
,
1
]))
return
B
eam
P
aram
(
nr
=
n2
,
q
=
n2
*
(
ABCD
[
0
,
0
]
*
q1
/
float
(
n1
)
+
ABCD
[
0
,
1
])
/
(
ABCD
[
1
,
0
]
*
q1
/
float
(
n1
)
+
ABCD
[
1
,
1
]))
def
mirror_trans
(
n1
,
n2
,
Rc
):
return
np
.
matrix
([[
1.0
,
0.0
],[(
n2
-
n1
)
/
float
(
Rc
),
1.0
]])
...
...
pykat/optics/gaussian_beams.py
View file @
4081eabd
...
...
@@ -14,30 +14,34 @@ from scipy.special import hermite
from
pykat.math.jacobi
import
jacobi
from
pykat.SIfloat
import
SIfloat
class
gauss_param
(
object
):
class
gauss_param
(
BeamParam
):
pass
class
beam_param
(
BeamParam
):
pass
class
BeamParam
(
object
):
"""
Use beam_param instead, will be the future name of this object.
Gaussian beam complex parameter
Gaussian beam complex parameter.
b
eam
_p
aram is effectively a complex number with extra
B
eam
P
aram is effectively a complex number with extra
functionality to determine beam parameters.
Defaults to 1064e-9m for wavelength and refractive index 1
usage:
q =
gauss_p
aram(w0=w0, z=z)
q =
gauss_p
aram(z=z, zr=zr)
q =
gauss_p
aram(w=w, rc=rc)
q =
gauss_p
aram(q=a) # where a is a complex number
q =
BeamP
aram(w0=w0, z=z)
q =
BeamP
aram(z=z, zr=zr)
q =
BeamP
aram(w=w, rc=rc)
q =
BeamP
aram(q=a) # where a is a complex number
or change default wavelength and refractive index with:
q =
gauss_p
aram(wavelength, nr, w0=w0, zr=zr)
q =
BeamP
aram(wavelength, nr, w0=w0, zr=zr)
"""
def
__init__
(
self
,
wavelength
=
1064e-9
,
nr
=
1
,
*
args
,
**
kwargs
):
if
self
.
__class__
!=
b
eam
_p
aram
:
warnings
.
warn
(
"Name changed. Use
b
eam
_p
aram instead of gauss_param."
)
if
self
.
__class__
!=
B
eam
P
aram
:
warnings
.
warn
(
"Name changed. Use
B
eam
P
aram instead of gauss_param
or beam_param
."
)
self
.
__q
=
None
self
.
__lambda
=
SIfloat
(
wavelength
)
...
...
@@ -195,7 +199,7 @@ class gauss_param(object):
return
abs
(
4
*
q1
.
imag
*
q2
.
imag
)
/
abs
(
q1
.
conjugate
()
-
q2
)
**
2
def
conjugate
(
self
):
return
b
eam
_p
aram
(
self
.
__lambda
,
self
.
__nr
,
self
.
__q
.
conjugate
())
return
B
eam
P
aram
(
self
.
__lambda
,
self
.
__nr
,
self
.
__q
.
conjugate
())
def
__abs__
(
self
):
return
abs
(
complex
(
self
.
__q
))
...
...
@@ -207,7 +211,7 @@ class gauss_param(object):
return
str
(
self
.
__q
)
def
__mul__
(
self
,
a
):
return
b
eam
_p
aram
(
self
.
__lambda
,
self
.
__nr
,
self
.
__q
*
complex
(
a
))
return
B
eam
P
aram
(
self
.
__lambda
,
self
.
__nr
,
self
.
__q
*
complex
(
a
))
def
__imul__
(
self
,
a
):
self
.
__q
*=
complex
(
a
)
...
...
@@ -216,7 +220,7 @@ class gauss_param(object):
__rmul__
=
__mul__
def
__add__
(
self
,
a
):
return
b
eam
_p
aram
(
self
.
__lambda
,
self
.
__nr
,
self
.
__q
+
complex
(
a
))
return
B
eam
P
aram
(
self
.
__lambda
,
self
.
__nr
,
self
.
__q
+
complex
(
a
))
def
__iadd__
(
self
,
a
):
self
.
__q
+=
complex
(
a
)
...
...
@@ -225,27 +229,27 @@ class gauss_param(object):
__radd__
=
__add__
def
__sub__
(
self
,
a
):
return
b
eam
_p
aram
(
self
.
__lambda
,
self
.
__nr
,
self
.
__q
-
complex
(
a
))
return
B
eam
P
aram
(
self
.
__lambda
,
self
.
__nr
,
self
.
__q
-
complex
(
a
))
def
__isub__
(
self
,
a
):
self
.
__q
-=
complex
(
a
)
return
self
def
__rsub__
(
self
,
a
):
return
b
eam
_p
aram
(
self
.
__lambda
,
self
.
__nr
,
complex
(
a
)
-
self
.
__q
)
return
B
eam
P
aram
(
self
.
__lambda
,
self
.
__nr
,
complex
(
a
)
-
self
.
__q
)
def
__div__
(
self
,
a
):
return
b
eam
_p
aram
(
self
.
__lambda
,
self
.
__nr
,
self
.
__q
/
complex
(
a
))
return
B
eam
P
aram
(
self
.
__lambda
,
self
.
__nr
,
self
.
__q
/
complex
(
a
))
def
__idiv__
(
self
,
a
):
self
.
__q
/=
complex
(
a
)
return
self
def
__pow__
(
self
,
q
):
return
b
eam
_p
aram
(
self
.
__lambda
,
self
.
__nr
,
self
.
__q
**
q
)
return
B
eam
P
aram
(
self
.
__lambda
,
self
.
__nr
,
self
.
__q
**
q
)
def
__neg__
(
self
,
q
):
return
b
eam
_p
aram
(
self
.
__lambda
,
self
.
__nr
,
-
self
.
__q
)
return
B
eam
P
aram
(
self
.
__lambda
,
self
.
__nr
,
-
self
.
__q
)
def
__eq__
(
self
,
q
):
if
q
is
None
:
...
...
@@ -266,15 +270,12 @@ class gauss_param(object):
# reverse beam direction
def
reverse
(
self
):
self
.
__q
=
-
1.0
*
self
.
__q
.
real
+
1j
*
self
.
__q
.
imag
class
beam_param
(
gauss_param
):
pass
class
HG_mode
(
object
):
""" Hermite-Gauss mode profile. Example usage:
import pykat.optics.gaussian_beams as gb
qx=gb.
b
eam
_p
aram(w0=1e-3,z=0)
qx=gb.
B
eam
P
aram(w0=1e-3,z=0)
beam=gb.HG_mode(qx,n=2,m=0)
beam.plot()
"""
...
...
@@ -317,12 +318,12 @@ class HG_mode(object):
return
(
self
.
_qx
.
q
,
self
.
_qy
.
q
)
@
q
.
setter
def
q
(
self
,
value
):
if
value
.
__class__
==
b
eam
_p
aram
:
if
value
.
__class__
==
B
eam
P
aram
:
self
.
_qx
=
copy
.
deepcopy
(
value
)
self
.
_qy
=
copy
.
deepcopy
(
value
)
else
:
self
.
_qx
=
b
eam
_p
aram
(
q
=
complex
(
value
))
self
.
_qy
=
b
eam
_p
aram
(
q
=
complex
(
value
))
self
.
_qx
=
B
eam
P
aram
(
q
=
complex
(
value
))
self
.
_qy
=
B
eam
P
aram
(
q
=
complex
(
value
))
@
property
def
qx
(
self
):
...
...
@@ -330,10 +331,10 @@ class HG_mode(object):
@
qx
.
setter
def
qx
(
self
,
value
):
if
value
.
__class__
==
b
eam
_p
aram
:
if
value
.
__class__
==
B
eam
P
aram
:
self
.
_qx
=
copy
.
deepcopy
(
value
)
else
:
self
.
_qx
=
b
eam
_p
aram
(
q
=
complex
(
value
))
self
.
_qx
=
B
eam
P
aram
(
q
=
complex
(
value
))
@
property
def
qy
(
self
):
...
...
@@ -341,10 +342,10 @@ class HG_mode(object):
@
qy
.
setter
def
qy
(
self
,
value
):
if
value
.
__class__
==
b
eam
_p
aram
:
if
value
.
__class__
==
B
eam
P
aram
:
self
.
_qy
=
copy
.
deepcopy
(
value
)
else
:
self
.
_qy
=
b
eam
_p
aram
(
q
=
complex
(
value
))
self
.
_qy
=
B
eam
P
aram
(
q
=
complex
(
value
))
@
property
def
constant_x
(
self
):
...
...
pykat/optics/knm.py
View file @
4081eabd
from
itertools
import
combinations_with_replacement
as
combinations
from
pykat.optics.gaussian_beams
import
b
eam
_p
aram
,
HG_mode
from
pykat.optics.gaussian_beams
import
B
eam
P
aram
,
HG_mode
from
pykat.exceptions
import
BasePyKatException
from
pykat.optics.romhom
import
u_star_u
from
pykat.external.progressbar
import
ProgressBar
,
ETA
,
Percentage
,
Bar
...
...
pykat/optics/romhom.py
View file @
4081eabd
...
...
@@ -13,7 +13,7 @@ import itertools
from
copy
import
copy
from
pykat.external.progressbar
import
ProgressBar
,
ETA
,
Percentage
,
Bar
from
itertools
import
combinations_with_replacement
as
combinations
from
pykat.optics.gaussian_beams
import
b
eam
_p
aram
from
pykat.optics.gaussian_beams
import
B
eam
P
aram
from
scipy.linalg
import
inv
from
math
import
factorial
from
pykat.math.hermite
import
*
...
...
Write
Preview
Markdown
is supported
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