def __init__(self, crange=(-10.0, 10.0)): """Initialize double Gaussian beam shape. crange: 2-tuple of limits of the coordinates. """ DoubleGaussCore.__init__(self, crange) for name in [ 'xWidthN1', 'xWidthN2', 'yWidthN1', 'yWidthN2', 'xWidthM1', 'xWidthM2', 'yWidthM1', 'yWidthM2' ]: # Width par = RealVar(name, 1.3, 3.0) self._physics_parameters[name] = par for name in ['rhoN1', 'rhoN2', 'rhoM1', 'rhoM2']: # Correlation parameter par = RealVar(name, -0.48, 0.48) self._physics_parameters[name] = par for nameA, nameB in [('w1N', 'w1M'), ('w2N', 'w2M')]: # Weight of narrow component parA = RealVar(nameA, 0.0, 1.0) self._physics_parameters[nameA] = parA # Weight of wide component formulaB = '1.0-{0}'.format(nameA) arglistB = ArgList([nameA], self.parameter) errorB = (lambda a: lambda p: p(a).err(p))(nameA) parB = FormulaVar(nameB, formulaB, arglistB, errorB) self._physics_parameters[nameB] = parB
def __init__(self, crange=(-10.0, 10.0)): """Initialize triple Gaussian beam shape. crange: 2-tuple of limits of the coordinates. """ TripleGaussCore.__init__(self, crange) for name in [ 'xWidthN1', 'xWidthN2', 'yWidthN1', 'yWidthN2', 'xWidthM1', 'xWidthM2', 'yWidthM1', 'yWidthM2', 'xWidthW1', 'xWidthW2', 'yWidthW1', 'yWidthW2' ]: # Width par = RealVar(name, 1.3, 3.0) self._physics_parameters[name] = par for name in ['rhoN1', 'rhoN2', 'rhoM1', 'rhoM2', 'rhoW1', 'rhoW2']: # Correlation parameter par = RealVar(name, -0.48, 0.48) self._physics_parameters[name] = par for nameA, nameB, nameC in [('w1N', 'w1M', 'w1W'), ('w2N', 'w2M', 'w2W')]: # Weight of narrow component parA = RealVar(nameA, 0.0, 1.0) self._physics_parameters[nameA] = parA # Fraction of weight of medium component w.r.t. wide component nameD = '{0}Fraction'.format(nameB) parD = RealVar(nameD, 0.0, 1.0) self._fit_parameters[nameD] = parD # Weight of medium component formulaB = '(1.0-{0})*{1}'.format(nameA, nameD) arglistB = ArgList([nameA, nameD], self.parameter) errorB = (lambda a, d: lambda p: ((p(a).err(p) * p(d).val())**2 + ( (1.0 - p(a).val()) * p(d).err(p))**2)**0.5)(nameA, nameD) parB = FormulaVar(nameB, formulaB, arglistB, errorB) self._physics_parameters[nameB] = parB # Weight of wide component formulaC = '(1.0-{0})*(1.0-{1})'.format(nameA, nameD) arglistC = ArgList([nameA, nameD], self.parameter) errorC = (lambda a, d: lambda p: ( (p(a).err(p) * (1.0 - p(d).val()))**2 + ( (1.0 - p(a).val()) * p(d).err(p))**2)**0.5)(nameA, nameD) parC = FormulaVar(nameC, formulaC, arglistC, errorC) self._physics_parameters[nameC] = parC
def __init__(self, crange=(-10.0, 10.0)): """Initialize super double Gaussian beam shape. crange: 2-tuple of limits of the coordinates. """ TripleGaussCore.__init__(self, crange) for nameA, nameB, nameC in [('xWidthN1', 'xWidthM1', 'xWidthW1'), ('xWidthN2', 'xWidthM2', 'xWidthW2'), ('yWidthN1', 'yWidthM1', 'yWidthW1'), ('yWidthN2', 'yWidthM2', 'yWidthW2')]: # Narrow width parA = RealVar(nameA, 1.3, 3.0) self._physics_parameters[nameA] = parA # Medium width parB = RealVar(nameB, 1.3, 3.0) self._physics_parameters[nameB] = parB # Wide width parC = RealVar(nameC, 1.3, 3.0) self._physics_parameters[nameC] = parC # Ratio of narrow width to medium width nameD = '{0}Ratio'.format(nameA) formulaD = '{0}/{1}'.format(nameA, nameB) arglistD = ArgList([nameA, nameB], self.parameter) errorD = (lambda: lambda p: 0.0)() parD = FormulaVar(nameD, formulaD, arglistD, errorD) self._auxiliary_parameters[nameD] = parD # Ratio of wide width to medium width nameE = '{0}Ratio'.format(nameC) formulaE = '{0}/{1}'.format(nameC, nameB) arglistE = ArgList([nameC, nameB], self.parameter) errorE = (lambda: lambda p: 0.0)() parE = FormulaVar(nameE, formulaE, arglistE, errorE) self._auxiliary_parameters[nameE] = parE for nameA, nameB, nameC in [('rhoN1', 'rhoM1', 'rhoW1'), ('rhoN2', 'rhoM2', 'rhoW2')]: nameD = 'xWidthN{0}Ratio'.format(nameA[-1]) nameE = 'yWidthN{0}Ratio'.format(nameA[-1]) nameF = 'xWidthW{0}Ratio'.format(nameA[-1]) nameG = 'yWidthW{0}Ratio'.format(nameA[-1]) # Correlation parameter of medium component parB = RealVar(nameB, -0.48, 0.48) self._physics_parameters[nameB] = parB # Minimum value of correlation parameter (wide component) nameH = '{0}Min'.format(nameC) formulaH = ('max(-0.99,({0}-sqrt(1.0-{1})*sqrt(1.0-{2}))/{3}/{4}' '-sqrt(1.0-({1}/{3})^2)*sqrt(1.0-({2}/{4})^2))') \ .format(nameB, nameD, nameE, nameF, nameG) arglistH = ArgList([nameB, nameD, nameE, nameF, nameG], self.parameter) errorH = (lambda: lambda p: 0.0)() parH = FormulaVar(nameH, formulaH, arglistH, errorH) self._auxiliary_parameters[nameH] = parH # Maximum value of correlation parameter (wide component) nameI = '{0}Max'.format(nameC) formulaI = ('min(0.99,({0}+sqrt(1.0-{1})*sqrt(1.0-{2}))/{3}/{4}' '+sqrt(1.0-({1}/{3})^2)*sqrt(1.0-({2}/{4})^2))') \ .format(nameB, nameD, nameE, nameF, nameG) arglistI = ArgList([nameB, nameD, nameE, nameF, nameG], self.parameter) errorI = (lambda: lambda p: 0.0)() parI = FormulaVar(nameI, formulaI, arglistI, errorI) self._auxiliary_parameters[nameI] = parI # Position between minimum and maximum value of correlation # parameter (wide component) nameJ = '{0}Factor'.format(nameC) parJ = RealVar(nameJ, 0.0, 1.0) self._fit_parameters[nameJ] = parJ # Correlation parameter of wide component formulaC = '{0}+({1}-{0})*{2}'.format(nameH, nameI, nameJ) arglistC = ArgList([nameH, nameI, nameJ], self.parameter) errorC = (lambda h, i, j: lambda p: (p(i).val() - p(h).val()) * p(j).err(p)) parC = FormulaVar(nameC, formulaC, arglistC, errorC) self._physics_parameters[nameC] = parC # Minimum value of correlation parameter (narrow component) nameK = '{0}Min'.format(nameA) formulaK = ('max(-0.99,max({0}/{1}/{2}-sqrt(1.0/{1}^2-1.0)' '*sqrt(1.0/{2}^2-1.0),{5}*{3}*{4}/{1}/{2}' '-sqrt(({3}/{1})^2-1.0)*sqrt(({4}/{2})^2-1.0)))') \ .format(nameB, nameD, nameE, nameF, nameG, nameC) arglistK = ArgList([nameB, nameD, nameE, nameF, nameG, nameC], self.parameter) errorK = (lambda: lambda p: 0.0)() parK = FormulaVar(nameK, formulaK, arglistK, errorK) self._auxiliary_parameters[nameK] = parK # Maximum value of correlation parameter (narrow component) nameL = '{0}Max'.format(nameA) formulaL = ('min(0.99,min({0}/{1}/{2}+sqrt(1.0/{1}^2-1.0)' '*sqrt(1.0/{2}^2-1.0),{5}*{3}*{4}/{1}/{2}' '+sqrt(({3}/{1})^2-1.0)*sqrt(({4}/{2})^2-1.0)))') \ .format(nameB, nameD, nameE, nameF, nameG, nameC) arglistL = ArgList([nameB, nameD, nameE, nameF, nameG, nameC], self.parameter) errorL = (lambda: lambda p: 0.0)() parL = FormulaVar(nameL, formulaL, arglistL, errorL) self._auxiliary_parameters[nameL] = parL # Position between minimum and maximum value of correlation # parameter (narrow component) nameM = '{0}Factor'.format(nameA) parM = RealVar(nameM, 0.0, 1.0) self._fit_parameters[nameM] = parM # Correlation parameter of narrow component formulaA = '{0}+({1}-{0})*{2}'.format(nameK, nameL, nameM) arglistA = ArgList([nameK, nameL, nameM], self.parameter) errorA = (lambda k, l, m: lambda p: (p(l).val() - p(k).val()) * p(m).err(p)) parA = FormulaVar(nameA, formulaA, arglistA, errorA) self._physics_parameters[nameA] = parA for nameA, nameB, nameC, nameD in [('w1N', 'w1M', 'w1W', 'omega1'), ('w2N', 'w2M', 'w2W', 'omega2')]: nameE = 'xWidthN{0}Ratio'.format(nameD[-1]) nameF = 'yWidthN{0}Ratio'.format(nameD[-1]) nameG = 'xWidthW{0}Ratio'.format(nameD[-1]) nameH = 'yWidthW{0}Ratio'.format(nameD[-1]) nameI = 'rhoN{0}'.format(nameD[-1]) nameJ = 'rhoM{0}'.format(nameD[-1]) nameK = 'rhoW{0}'.format(nameD[-1]) # Fraction of weight of medium component w.r.t. wide component nameL = '{0}Fraction'.format(nameB) parL = RealVar(nameL, 0.0, 1.0) self._fit_parameters[nameL] = parL # Maximum value of weight parameter (narrow component) nameM = '{0}Max'.format(nameD) formulaM = ( '{0}*{1}*sqrt(1.0-{2}^2)*({3}/sqrt(1.0-{4}^2)+(1.0-{3})' '/sqrt(1.0-{5}^2)/{6}/{7})').format(nameE, nameF, nameI, nameL, nameJ, nameK, nameG, nameH) arglistM = ArgList( [nameE, nameF, nameI, nameL, nameJ, nameK, nameG, nameH], self.parameter) errorM = (lambda: lambda p: 0.0)() parM = FormulaVar(nameM, formulaM, arglistM, errorM) self._auxiliary_parameters[nameM] = parM # Position between minimum and maximum value of weight parameter # (narrow component) nameN = '{0}Prime'.format(nameD) parN = RealVar(nameN, 0.0, 1.0) self._fit_parameters[nameN] = parN # Weight parameter of narrow component formulaD = '{0}*{1}'.format(nameM, nameN) arglistD = ArgList([nameM, nameN], self.parameter) errorD = (lambda m, n: lambda p: p(m).val() * p(n).err(p))(nameM, nameN) parD = FormulaVar(nameD, formulaD, arglistD, errorD) self._auxiliary_parameters[nameD] = parD # Weight of narrow component formulaA = '-{0}/(1.0-{0})'.format(nameD) arglistA = ArgList([nameD], self.parameter) errorA = (lambda d: lambda p: p(d).err(p) / (1.0 - p(d).val())**2)(nameD) parA = FormulaVar(nameA, formulaA, arglistA, errorA) self._physics_parameters[nameA] = parA # Weight of medium component formulaB = '{0}/(1.0-{1})'.format(nameL, nameD) arglistB = ArgList([nameL, nameD], self.parameter) errorB = (lambda l, d: lambda p: 1.0 / (1.0 - p(d).val()) * (p(l).err(p)**2 + (p(d).err(p) * p(l).val() / (1.0 - p(d).val()))**2)**0.5)(nameL, nameD) parB = FormulaVar(nameB, formulaB, arglistB, errorB) self._physics_parameters[nameB] = parB # Weight of wide component formulaC = '(1.0-{0})/(1.0-{1})'.format(nameL, nameD) arglistC = ArgList([nameL, nameD], self.parameter) errorC = (lambda l, d: lambda p: 1.0 / (1.0 - p(d).val()) * (p(l).err(p)**2 + (p(d).err(p) * (1.0 - p(l).val()) / (1.0 - p(d).val()))**2)**0.5)(nameL, nameD) parC = FormulaVar(nameC, formulaC, arglistC, errorC) self._physics_parameters[nameC] = parC
def __init__(self, crange=(-10.0, 10.0)): """Initialize super double Gaussian beam shape. crange: 2-tuple of limits of the coordinates. """ TripleGaussCore.__init__(self, crange) for nameA, nameB, nameC in [('xWidthN1', 'xWidthM1', 'xWidthW1'), ('xWidthN2', 'xWidthM2', 'xWidthW2'), ('yWidthN1', 'yWidthM1', 'yWidthW1'), ('yWidthN2', 'yWidthM2', 'yWidthW2')]: # Medium width parB = RealVar(nameB, 1.3, 3.0) self._physics_parameters[nameB] = parB # Ratio of narrow width to medium width nameD = '{0}Ratio'.format(nameA) parD = RealVar(nameD, 0.1, 0.99) self._fit_parameters[nameD] = parD # Narrow width formulaA = '{0}*{1}'.format(nameB, nameD) arglistA = ArgList([nameB, nameD], self.parameter) errorA = (lambda b, d: lambda p: ((p(b).val() * p(d).err(p))**2 + (p(d).val() * p(b).err(p))**2)**0.5)(nameB, nameD) parA = FormulaVar(nameA, formulaA, arglistA, errorA) self._physics_parameters[nameA] = parA # Difference of wide width to medium width nameE = '{0}Diff'.format(nameC) parE = RealVar(nameE, 0.01, 1.7) self._fit_parameters[nameE] = parE # Wide width formulaC = '{0}+{1}'.format(nameB, nameE) arglistC = ArgList([nameB, nameE], self.parameter) errorC = (lambda b, e: lambda p: (p(b).err(p)**2 + p(e).err(p)**2)**0.5)(nameB, nameE) parC = FormulaVar(nameC, formulaC, arglistC, errorC) self._physics_parameters[nameC] = parC # Ratio of wide width to medium width nameF = '{0}Ratio'.format(nameC) formulaF = '{0}/{1}'.format(nameC, nameB) arglistF = ArgList([nameC, nameB], self.parameter) errorF = (lambda: lambda p: 0.0)() parF = FormulaVar(nameF, formulaF, arglistF, errorF) self._auxiliary_parameters[nameF] = parF for nameA, nameB, nameC in [('rhoN1', 'rhoM1', 'rhoW1'), ('rhoN2', 'rhoM2', 'rhoW2')]: nameD = 'xWidthN{0}Ratio'.format(nameA[-1]) nameE = 'yWidthN{0}Ratio'.format(nameA[-1]) nameF = 'xWidthW{0}Ratio'.format(nameA[-1]) nameG = 'yWidthW{0}Ratio'.format(nameA[-1]) # Correlation parameter of medium component parB = RealVar(nameB, -0.48, 0.48) self._physics_parameters[nameB] = parB # Minimum value of correlation parameter (wide component) nameH = '{0}Min'.format(nameC) formulaH = ('max(-0.99,({0}-sqrt(1.0-{1})*sqrt(1.0-{2}))/{3}/{4}' '-sqrt(1.0-({1}/{3})^2)*sqrt(1.0-({2}/{4})^2))') \ .format(nameB, nameD, nameE, nameF, nameG) arglistH = ArgList([nameB, nameD, nameE, nameF, nameG], self.parameter) errorH = (lambda: lambda p: 0.0)() parH = FormulaVar(nameH, formulaH, arglistH, errorH) self._auxiliary_parameters[nameH] = parH # Maximum value of correlation parameter (wide component) nameI = '{0}Max'.format(nameC) formulaI = ('min(0.99,({0}+sqrt(1.0-{1})*sqrt(1.0-{2}))/{3}/{4}' '+sqrt(1.0-({1}/{3})^2)*sqrt(1.0-({2}/{4})^2))') \ .format(nameB, nameD, nameE, nameF, nameG) arglistI = ArgList([nameB, nameD, nameE, nameF, nameG], self.parameter) errorI = (lambda: lambda p: 0.0)() parI = FormulaVar(nameI, formulaI, arglistI, errorI) self._auxiliary_parameters[nameI] = parI # Correlation parameter of wide component parC = RealVar(nameC, -0.48, 0.48) parC.set_fixed_minimum(parH) parC.set_fixed_maximum(parI) self._physics_parameters[nameC] = parC # Minimum value of correlation parameter (narrow component) nameJ = '{0}Min'.format(nameA) formulaJ = ('max(-0.99,max({0}/{1}/{2}-sqrt(1.0/{1}^2-1.0)' '*sqrt(1.0/{2}^2-1.0),{5}*{3}*{4}/{1}/{2}' '-sqrt(({3}/{1})^2-1.0)*sqrt(({4}/{2})^2-1.0)))') \ .format(nameB, nameD, nameE, nameF, nameG, nameC) arglistJ = ArgList([nameB, nameD, nameE, nameF, nameG, nameC], self.parameter) errorJ = (lambda: lambda p: 0.0)() parJ = FormulaVar(nameJ, formulaJ, arglistJ, errorJ) self._auxiliary_parameters[nameJ] = parJ # Maximum value of correlation parameter (narrow component) nameK = '{0}Max'.format(nameA) formulaK = ('min(0.99,min({0}/{1}/{2}+sqrt(1.0/{1}^2-1.0)' '*sqrt(1.0/{2}^2-1.0),{5}*{3}*{4}/{1}/{2}' '+sqrt(({3}/{1})^2-1.0)*sqrt(({4}/{2})^2-1.0)))') \ .format(nameB, nameD, nameE, nameF, nameG, nameC) arglistK = ArgList([nameB, nameD, nameE, nameF, nameG, nameC], self.parameter) errorK = (lambda: lambda p: 0.0)() parK = FormulaVar(nameK, formulaK, arglistK, errorK) self._auxiliary_parameters[nameK] = parK # Correlation parameter of narrow component parA = RealVar(nameA, -0.48, 0.48) parA.set_fixed_minimum(parJ) parA.set_fixed_maximum(parK) self._physics_parameters[nameA] = parA for nameA, nameB, nameC, nameD in [('w1N', 'w1M', 'w1W', 'omega1'), ('w2N', 'w2M', 'w2W', 'omega2')]: nameE = 'xWidthN{0}Ratio'.format(nameD[-1]) nameF = 'yWidthN{0}Ratio'.format(nameD[-1]) nameG = 'xWidthW{0}Ratio'.format(nameD[-1]) nameH = 'yWidthW{0}Ratio'.format(nameD[-1]) nameI = 'rhoN{0}'.format(nameD[-1]) nameJ = 'rhoM{0}'.format(nameD[-1]) nameK = 'rhoW{0}'.format(nameD[-1]) # Fraction of weight of medium component w.r.t. wide component nameL = '{0}Fraction'.format(nameB) parL = RealVar(nameL, 0.0, 1.0) self._fit_parameters[nameL] = parL # Maximum value of weight parameter (narrow component) nameM = '{0}Max'.format(nameD) formulaM = ( '{0}*{1}*sqrt(1.0-{2}^2)*({3}/sqrt(1.0-{4}^2)+(1.0-{3})' '/sqrt(1.0-{5}^2)/{6}/{7})').format(nameE, nameF, nameI, nameL, nameJ, nameK, nameG, nameH) arglistM = ArgList( [nameE, nameF, nameI, nameL, nameJ, nameK, nameG, nameH], self.parameter) errorM = (lambda: lambda p: 0.0)() parM = FormulaVar(nameM, formulaM, arglistM, errorM) self._auxiliary_parameters[nameM] = parM # Weight parameter of narrow component parD = RealVar(nameD, 0.0, 0.99) parD.set_fixed_maximum(parM) self._fit_parameters[nameD] = parD # Weight of narrow component formulaA = '-{0}/(1.0-{0})'.format(nameD) arglistA = ArgList([nameD], self.parameter) errorA = (lambda d: lambda p: p(d).err(p) / (1.0 - p(d).val())**2)(nameD) parA = FormulaVar(nameA, formulaA, arglistA, errorA) self._physics_parameters[nameA] = parA # Weight of medium component formulaB = '{0}/(1.0-{1})'.format(nameL, nameD) arglistB = ArgList([nameL, nameD], self.parameter) errorB = (lambda l, d: lambda p: 1.0 / (1.0 - p(d).val()) * (p(l).err(p)**2 + (p(d).err(p) * p(l).val() / (1.0 - p(d).val()))**2)**0.5)(nameL, nameD) parB = FormulaVar(nameB, formulaB, arglistB, errorB) self._physics_parameters[nameB] = parB # Weight of wide component formulaC = '(1.0-{0})/(1.0-{1})'.format(nameL, nameD) arglistC = ArgList([nameL, nameD], self.parameter) errorC = (lambda l, d: lambda p: 1.0 / (1.0 - p(d).val()) * (p(l).err(p)**2 + (p(d).err(p) * (1.0 - p(l).val()) / (1.0 - p(d).val()))**2)**0.5)(nameL, nameD) parC = FormulaVar(nameC, formulaC, arglistC, errorC) self._physics_parameters[nameC] = parC
def __init__(self, crange=(-10.0, 10.0)): """Initialize triple Gaussian beam shape. crange: 2-tuple of limits of the coordinates. """ TripleGaussCore.__init__(self, crange) for nameA, nameB, nameC in [('xWidthN1', 'xWidthM1', 'xWidthW1'), ('xWidthN2', 'xWidthM2', 'xWidthW2'), ('yWidthN1', 'yWidthM1', 'yWidthW1'), ('yWidthN2', 'yWidthM2', 'yWidthW2')]: # Narrow width parA = RealVar(nameA, 1.3, 3.0) self._physics_parameters[nameA] = parA # Difference of narrow width to medium width nameD = '{0}Diff'.format(nameB) parD = RealVar(nameD, 0.01, 1.7) self._fit_parameters[nameD] = parD # Medium width formulaB = '{0}+{1}'.format(nameA, nameD) arglistB = ArgList([nameA, nameD], self.parameter) errorB = (lambda a, d: lambda p: (p(a).err(p)**2 + p(d).err(p)**2)**0.5)(nameA, nameD) parB = FormulaVar(nameB, formulaB, arglistB, errorB) self._physics_parameters[nameB] = parB # Difference of medium width to wide width nameE = '{0}Diff'.format(nameC) parE = RealVar(nameE, 0.01, 1.7) self._fit_parameters[nameE] = parE # Wide width formulaC = '{0}+{1}'.format(nameB, nameE) arglistC = ArgList([nameB, nameE], self.parameter) errorC = (lambda b, e: lambda p: (p(b).err(p)**2 + p(e).err(p)**2)**0.5)(nameB, nameE) parC = FormulaVar(nameC, formulaC, arglistC, errorC) self._physics_parameters[nameC] = parC for name in ['rhoN1', 'rhoN2', 'rhoM1', 'rhoM2', 'rhoW1', 'rhoW2']: # Correlation parameter par = RealVar(name, -0.48, 0.48) self._physics_parameters[name] = par for nameA, nameB, nameC, nameD, nameE in [ ('w1N', 'w1M', 'w1W', 'theta1', 'phi1'), ('w2N', 'w2M', 'w2W', 'theta2', 'phi2') ]: # First weight parameter parD = RealVar(nameD, 0.0, 0.5 * pi) self._fit_parameters[nameD] = parD # Second weight parameter parE = RealVar(nameE, 0.0, 0.5 * pi) self._fit_parameters[nameE] = parE # Weight of narrow component formulaA = 'cos({0})^2'.format(nameD) arglistA = ArgList([nameD], self.parameter) errorA = (lambda d: lambda p: 2.0 * sin(p(d).val()) * cos( p(d).val()) * p(d).err(p))(nameD) parA = FormulaVar(nameA, formulaA, arglistA, errorA) self._physics_parameters[nameA] = parA # Weight of medium component formulaB = 'sin({0})^2*cos({1})^2'.format(nameD, nameE) arglistB = ArgList([nameD, nameE], self.parameter) errorB = (lambda d, e: lambda p: 2.0 * sin(p(d).val( )) * cos(p(e).val()) * ( (p(d).err(p) * cos(p(d).val()) * cos(p(e).val()))**2 + (p(e).err(p) * sin(p(d).val()) * sin(p(e).val()))**2)**0.5)( nameD, nameE) parB = FormulaVar(nameB, formulaB, arglistB, errorB) self._physics_parameters[nameB] = parB # Weight of wide component formulaC = 'sin({0})^2*sin({1})^2'.format(nameD, nameE) arglistC = ArgList([nameD, nameE], self.parameter) errorC = (lambda d, e: lambda p: 2.0 * sin(p(d).val( )) * sin(p(e).val()) * ( (p(d).err(p) * cos(p(d).val()) * sin(p(e).val()))**2 + (p(e).err(p) * sin(p(d).val()) * cos(p(e).val()))**2)**0.5)( nameD, nameE) parC = FormulaVar(nameC, formulaC, arglistC, errorC) self._physics_parameters[nameC] = parC
def __init__(self, crange=(-10.0, 10.0)): """Initialize super Gaussian beam shape. crange: 2-tuple of limits of the coordinates. """ DoubleGaussCore.__init__(self, crange) for nameA, nameB in [ ('xWidthN1', 'xWidthM1'), ('xWidthN2', 'xWidthM2'), ('yWidthN1', 'yWidthM1'), ('yWidthN2', 'yWidthM2') ]: # Narrow width parA = RealVar(nameA, 1.3, 3.0) self._physics_parameters[nameA] = parA # Wide width parB = RealVar(nameB, 1.3, 3.0) self._physics_parameters[nameB] = parB # Ratio of narrow width to wide width nameC = '{0}Ratio'.format(nameA) formulaC = '{0}/{1}'.format(nameA, nameB) arglistC = ArgList([nameA, nameB], self.parameter) errorC = (lambda: lambda p: 0.0)() parC = FormulaVar(nameC, formulaC, arglistC, errorC) self._auxiliary_parameters[nameC] = parC for nameA, nameB in [('rhoN1', 'rhoM1'), ('rhoN2', 'rhoM2')]: nameC = 'xWidthN{0}Ratio'.format(nameA[-1]) nameD = 'yWidthN{0}Ratio'.format(nameA[-1]) # Correlation parameter of wide component parB = RealVar(nameB, -0.48, 0.48) self._physics_parameters[nameB] = parB # Minimum value of correlation parameter (narrow component) nameE = '{0}Min'.format(nameA) formulaE = ('max(-0.99,{0}/{1}/{2}-sqrt(1.0/{1}^2-1.0)' '*sqrt(1.0/{2}^2-1.0))').format(nameB, nameC, nameD) arglistE = ArgList([nameB, nameC, nameD], self.parameter) errorE = (lambda: lambda p: 0.0)() parE = FormulaVar(nameE, formulaE, arglistE, errorE) self._auxiliary_parameters[nameE] = parE # Maximum value of correlation parameter (narrow component) nameF = '{0}Max'.format(nameA) formulaF = ('min(0.99,{0}/{1}/{2}+sqrt(1.0/{1}^2-1.0)' '*sqrt(1.0/{2}^2-1.0))').format(nameB, nameC, nameD) arglistF = ArgList([nameB, nameC, nameD], self.parameter) errorF = (lambda: lambda p: 0.0)() parF = FormulaVar(nameF, formulaF, arglistF, errorF) self._auxiliary_parameters[nameF] = parF # Position between minimum and maximum value of correlation # parameter (narrow component) nameG = '{0}Factor'.format(nameA) parG = RealVar(nameG, 0.0, 1.0) self._fit_parameters[nameG] = parG # Correlation parameter of narrow component formulaA = '{0}+({1}-{0})*{2}'.format(nameE, nameF, nameG) arglistA = ArgList([nameE, nameF, nameG], self.parameter) errorA = (lambda e, f, g: lambda p: (p(f).val() - p(e).val()) * p(g).err(p))(nameE, nameF, nameG) parA = FormulaVar(nameA, formulaA, arglistA, errorA) self._physics_parameters[nameA] = parA for nameA, nameB, nameC in [('w1N', 'w1M', 'omega1'), ('w2N', 'w2M', 'omega2')]: nameD = 'xWidthN{0}Ratio'.format(nameC[-1]) nameE = 'yWidthN{0}Ratio'.format(nameC[-1]) nameF = 'rhoN{0}'.format(nameC[-1]) nameG = 'rhoM{0}'.format(nameC[-1]) # Maximum value of weight parameter nameH = '{0}Max'.format(nameC) formulaH = '{0}*{1}*sqrt((1.0-{2}^2)/(1.0-{3}^2))' \ .format(nameD, nameE, nameF, nameG) arglistH = ArgList([nameD, nameE, nameF, nameG], self.parameter) errorH = (lambda: lambda p: 0.0)() parH = FormulaVar(nameH, formulaH, arglistH, errorH) self._auxiliary_parameters[nameH] = parH # Position between minimum and maximum value of weight parameter nameI = '{0}Prime'.format(nameC) parI = RealVar(nameI, 0.0, 1.0) self._fit_parameters[nameI] = parI # Weight parameter formulaC = '{0}*{1}'.format(nameH, nameI) arglistC = ArgList([nameH, nameI], self.parameter) errorC = (lambda h, i: lambda p: p(h).val() * p(i).err(p))(nameH, nameI) parC = FormulaVar(nameC, formulaC, arglistC, errorC) self._auxiliary_parameters[nameC] = parC # Weight of narrow component formulaA = '-{0}/(1.0-{0})'.format(nameC) arglistA = ArgList([nameC], self.parameter) errorA = (lambda c: lambda p: p(c).err(p) / (1.0 - p(c).val()**2))(nameC) parA = FormulaVar(nameA, formulaA, arglistA, errorA) self._physics_parameters[nameA] = parA # Weight of wide component formulaB = '1.0/(1.0-{0})'.format(nameC) arglistB = ArgList([nameC], self.parameter) errorB = (lambda c: lambda p: p(c).err(p) / (1.0 - p(c).val()**2))(nameC) parB = FormulaVar(nameB, formulaB, arglistB, errorB) self._physics_parameters[nameB] = parB
def __init__(self, crange=(-10.0, 10.0)): """Initialize super Gaussian beam shape. crange: 2-tuple of limits of the coordinates. """ DoubleGaussCore.__init__(self, crange) for nameA, nameB in [ ('xWidthN1', 'xWidthM1'), ('xWidthN2', 'xWidthM2'), ('yWidthN1', 'yWidthM1'), ('yWidthN2', 'yWidthM2') ]: # Wide width parB = RealVar(nameB, 1.3, 3.0) self._physics_parameters[nameB] = parB # Ratio of narrow width to wide width nameC = '{0}Ratio'.format(nameA) parC = RealVar(nameC, 0.1, 0.99) self._fit_parameters[nameC] = parC # Narrow width formulaA = '{0}*{1}'.format(nameB, nameC) arglistA = ArgList([nameB, nameC], self.parameter) errorA = (lambda b, c: lambda p: ((p(b).val() * p(c).err(p))**2 + (p(c).val() * p(b).err(p))**2)**0.5)(nameB, nameC) parA = FormulaVar(nameA, formulaA, arglistA, errorA) self._physics_parameters[nameA] = parA for nameA, nameB in [('rhoN1', 'rhoM1'), ('rhoN2', 'rhoM2')]: nameC = 'xWidthN{0}Ratio'.format(nameA[-1]) nameD = 'yWidthN{0}Ratio'.format(nameA[-1]) # Correlation parameter of wide component parB = RealVar(nameB, -0.48, 0.48) self._physics_parameters[nameB] = parB # Minimum value of correlation parameter (narrow component) nameE = '{0}Min'.format(nameA) formulaE = ('max(-0.99,{0}/{1}/{2}-sqrt(1.0/{1}^2-1.0)' '*sqrt(1.0/{2}^2-1.0))').format(nameB, nameC, nameD) arglistE = ArgList([nameB, nameC, nameD], self.parameter) errorE = (lambda: lambda p: 0.0)() parE = FormulaVar(nameE, formulaE, arglistE, errorE) self._auxiliary_parameters[nameE] = parE # Maximum value of correlation parameter (narrow component) nameF = '{0}Max'.format(nameA) formulaF = ('min(0.99,{0}/{1}/{2}+sqrt(1.0/{1}^2-1.0)' '*sqrt(1.0/{2}^2-1.0))').format(nameB, nameC, nameD) arglistF = ArgList([nameB, nameC, nameD], self.parameter) errorF = (lambda: lambda p: 0.0)() parF = FormulaVar(nameF, formulaF, arglistF, errorF) self._auxiliary_parameters[nameF] = parF # Correlation parameter of narrow component parA = RealVar(nameA, -0.48, 0.48) parA.set_fixed_minimum(parE) parA.set_fixed_maximum(parF) self._physics_parameters[nameA] = parA for nameA, nameB, nameC in [('w1N', 'w1M', 'omega1'), ('w2N', 'w2M', 'omega2')]: nameD = 'xWidthN{0}Ratio'.format(nameC[-1]) nameE = 'yWidthN{0}Ratio'.format(nameC[-1]) nameF = 'rhoN{0}'.format(nameC[-1]) nameG = 'rhoM{0}'.format(nameC[-1]) # Maximum value of weight parameter nameH = '{}Max'.format(nameC) formulaH = '{0}*{1}*sqrt((1.0-{2}^2)/(1.0-{3}^2))' \ .format(nameD, nameE, nameF, nameG) arglistH = ArgList([nameD, nameE, nameF, nameG], self.parameter) errorH = (lambda: lambda p: 0.0)() parH = FormulaVar(nameH, formulaH, arglistH, errorH) self._auxiliary_parameters[nameH] = parH # Weight parameter parC = RealVar(nameC, 0.0, 0.99) parC.set_fixed_maximum(parH) self._fit_parameters[nameC] = parC # Weight of narrow component formulaA = '-{0}/(1.0-{0})'.format(nameC) arglistA = ArgList([nameC], self.parameter) errorA = (lambda c: lambda p: p(c).err(p) / (1.0 - p(c).val()**2))(nameC) parA = FormulaVar(nameA, formulaA, arglistA, errorA) self._physics_parameters[nameA] = parA # Weight of wide component formulaB = '1.0/(1.0-{0})'.format(nameC) arglistB = ArgList([nameC], self.parameter) errorB = (lambda c: lambda p: p(c).err(p) / (1.0 - p(c).val())**2)(nameC) parB = FormulaVar(nameB, formulaB, arglistB, errorB) self._physics_parameters[nameB] = parB