def _parse_fphi(f, phs): dict = {} for i in range(len(f)): dict['f{0}'.format(i + 1)] = SIfloat(f[i]) for i in range(len(phs)): if phs[i] == "max": dict['phase{0}'.format(i + 1)] = "max" else: dict['phase{0}'.format(i + 1)] = SIfloat(phs[i]) return dict
def __init__(self, wavelength=1064e-9, nr=1, *args, **kwargs): if self.__class__ == gauss_param or self.__class__ == beam_param: warnings.warn("Name changed. Use BeamParam instead of gauss_param or beam_param.") self.__q = None self.__lambda = SIfloat(wavelength) self.__nr = SIfloat(nr) if len(args) == 1: self.__q = complex(args[0]) elif len(kwargs) == 1: if "q" in kwargs: self.__q = complex(kwargs["q"]) else: raise pkex.BasePyKatException("Must specify: z and w0 or z and zr or rc and w or q, to define the beam parameter") elif len(kwargs) == 2: if "w0" in kwargs and "z" in kwargs: q = SIfloat(kwargs["z"]) + 1j * math.pi*SIfloat(kwargs["w0"])**2/(self.__lambda/self.__nr) elif "z" in kwargs and "zr" in kwargs: q = SIfloat(kwargs["z"]) + 1j * SIfloat(kwargs["zr"]) elif "rc" in kwargs and "w" in kwargs: one_q = 1 / SIfloat(kwargs["rc"]) - 1j * SIfloat(wavelength) / (math.pi * SIfloat(nr) * SIfloat(kwargs["w"])**2) q = 1/one_q else: raise pkex.BasePyKatException("Must specify: z and w0 or z and zr or rc and w or q, to define the beam parameter") self.__q = q else: raise pkex.BasePyKatException("Incorrect usage for gauss_param constructor")
def __set_phi(self, num, value): value = SIfloat(value) if value is None and num != self.num_demods: # check if we are setting no phase that this is only on the last # demodulation phase. raise pkex.BasePyKatException( "Only last demodulation phase can be set to None") elif isinstance(value, six.string_types) and not isinstance( value, float) and value.lower() != "max": raise pkex.BasePyKatException( "Demodulation phase can only be set to a 'max' or a number (or None if the last demodulation phase)" ) p = getattr(self, '_pd__phase' + num) p.value = value
def parseFinesseText(text): values = text.split() node = values[-1] alt_beam = node[-1] == '*' if len(values) == 3: return beam(values[1], node, alternate_beam=alt_beam) elif len(values) == 4: return beam(values[1], node, alternate_beam=alt_beam, frequency=SIfloat(values[2])) else: raise pkex.BasePyKatException( 'Beam detector code "{0}" is not a valid FINESSE command'. format(text))
def wavelength(self,value): self.__lambda = SIfloat(value) def __repr__(self):
def imag(self, value): self.__q.imag = SIfloat(value) # reverse beam direction def reverse(self):
def real(self, value): self.__q.real = SIfloat(value) @property
def __set_f(self, num, value): value = SIfloat(value) p = getattr(self, '_pd__f' + num) p.value = value