Commit 4081eabd authored by Daniel Brown's avatar Daniel Brown
Browse files

Changing to CamelCase for katRun and beam_param

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