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
import pykat.detectors as detectors
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
......
......@@ -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 beam_param
from pykat.optics.gaussian_beams import BeamParam
......@@ -297,22 +297,22 @@ class gauss(object):
if not values[0].endswith("*"):
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:
gpx = beam_param(kat.lambda0, w0=values[-4], z=values[-3])
gpy = beam_param(kat.lambda0, w0=values[-2], z=values[-1])
gpx = BeamParam(kat.lambda0, w0=values[-4], z=values[-3])
gpy = BeamParam(kat.lambda0, w0=values[-2], z=values[-1])
elif values[0].endswith("*"):
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:
gpx = beam_param(kat.lambda0, z=values[-4], zr=values[-3])
gpy = beam_param(kat.lambda0, z=values[-2], zr=values[-1])
gpx = BeamParam(kat.lambda0, z=values[-4], zr=values[-3])
gpy = BeamParam(kat.lambda0, z=values[-2], zr=values[-1])
elif values[0].endswith("**"):
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:
gpx = beam_param(kat.lambda0, w=values[-4], rc=values[-3])
gpy = beam_param(kat.lambda0, w=values[-2], rc=values[-1])
gpx = BeamParam(kat.lambda0, w=values[-4], rc=values[-3])
gpy = BeamParam(kat.lambda0, w=values[-2], rc=values[-1])
else:
raise pkex.BasePyKatException("Unexpected ending to gauss command '{0}'".format(text))
......
......@@ -325,7 +325,7 @@ def GUILength(L):
"""
return L # * ( 40 * erfc(L/400.0) + 0.01)
class katRun(object):
class KatRun(object):
def __init__(self):
self.runtime = None
self.StartDateTime = datetime.datetime.now()
......@@ -579,7 +579,7 @@ class katRun(object):
return fig
def savekatRun(self, filename):
def saveKatRun(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 katRun2D(object):
class KatRun2D(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 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.
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 = katRun2D()
r = KatRun2D()
else:
r = katRun()
r = KatRun()
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.beam_param(q=complex(qx), wavelength=self.lambda0),
pykat.beam_param(q=complex(qy), wavelength=self.lambda0),
traceData[-1][node_name] = (pykat.BeamParam(q=complex(qx), wavelength=self.lambda0),
pykat.BeamParam(q=complex(qy), wavelength=self.lambda0),
component_name)
finally:
......
......@@ -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 beam_param
from pykat.optics.gaussian_beams import BeamParam
from copy import deepcopy
id___ = 0
......@@ -554,11 +554,11 @@ class Node(object):
self.__q_comp = component
if len(args) == 1:
self.__q_x = beam_param(self._network.kat.lambda0, q=args[0])
self.__q_y = beam_param(self._network.kat.lambda0, q=args[0])
self.__q_x = BeamParam(self._network.kat.lambda0, q=args[0])
self.__q_y = BeamParam(self._network.kat.lambda0, q=args[0])
elif len(args) == 2:
self.__q_x = beam_param(self._network.kat.lambda0, q=args[0])
self.__q_y = beam_param(self._network.kat.lambda0, q=args[1])
self.__q_x = BeamParam(self._network.kat.lambda0, q=args[0])
self.__q_y = BeamParam(self._network.kat.lambda0, q=args[1])
else:
raise pkex.BasePyKatException("Must specify either 1 Gaussian beam parameter or 2 for astigmatic beams")
......
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):
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):
return np.matrix([[1.0,0.0],[(n2-n1)/float(Rc),1.0]])
......
......@@ -14,30 +14,34 @@ from scipy.special import hermite
from pykat.math.jacobi import jacobi
from pykat.SIfloat import SIfloat
class gauss_param(object):
"""
Use beam_param instead, will be the future name of this object.
class gauss_param(BeamParam):
pass
Gaussian beam complex parameter
class beam_param(BeamParam):
pass
beam_param is effectively a complex number with extra
class BeamParam(object):
"""
Gaussian beam complex parameter.
BeamParam 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_param(w0=w0, z=z)
q = gauss_param(z=z, zr=zr)
q = gauss_param(w=w, rc=rc)
q = gauss_param(q=a) # where a is a complex number
q = BeamParam(w0=w0, z=z)
q = BeamParam(z=z, zr=zr)
q = BeamParam(w=w, rc=rc)
q = BeamParam(q=a) # where a is a complex number
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):
if self.__class__ != beam_param:
warnings.warn("Name changed. Use beam_param instead of gauss_param.")
if self.__class__ != BeamParam:
warnings.warn("Name changed. Use BeamParam 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 beam_param(self.__lambda, self.__nr, self.__q.conjugate())
return BeamParam(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 beam_param(self.__lambda, self.__nr, self.__q * complex(a))
return BeamParam(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 beam_param(self.__lambda, self.__nr, self.__q + complex(a))
return BeamParam(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 beam_param(self.__lambda, self.__nr, self.__q - complex(a))
return BeamParam(self.__lambda, self.__nr, self.__q - complex(a))
def __isub__(self, a):
self.__q -= complex(a)
return self
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):
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):
self.__q /= complex(a)
return self
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):
return beam_param(self.__lambda, self.__nr, -self.__q)
return BeamParam(self.__lambda, self.__nr, -self.__q)
def __eq__(self, q):
if q is None:
......@@ -268,13 +272,10 @@ class gauss_param(object):
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.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.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__ == beam_param:
if value.__class__ == BeamParam:
self._qx = copy.deepcopy(value)
self._qy = copy.deepcopy(value)
else:
self._qx = beam_param(q=complex(value))
self._qy = beam_param(q=complex(value))
self._qx = BeamParam(q=complex(value))
self._qy = BeamParam(q=complex(value))
@property
def qx(self):
......@@ -330,10 +331,10 @@ class HG_mode(object):
@qx.setter
def qx(self, value):
if value.__class__ == beam_param:
if value.__class__ == BeamParam:
self._qx = copy.deepcopy(value)
else:
self._qx = beam_param(q=complex(value))
self._qx = BeamParam(q=complex(value))
@property
def qy(self):
......@@ -341,10 +342,10 @@ class HG_mode(object):
@qy.setter
def qy(self, value):
if value.__class__ == beam_param:
if value.__class__ == BeamParam:
self._qy = copy.deepcopy(value)
else:
self._qy = beam_param(q=complex(value))
self._qy = BeamParam(q=complex(value))
@property
def constant_x(self):
......
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.optics.romhom import u_star_u
from pykat.external.progressbar import ProgressBar, ETA, Percentage, Bar
......
......@@ -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 beam_param
from pykat.optics.gaussian_beams import BeamParam
from scipy.linalg import inv
from math import factorial
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