本文整理汇总了Python中bumps.parameter.Parameter类的典型用法代码示例。如果您正苦于以下问题:Python Parameter类的具体用法?Python Parameter怎么用?Python Parameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, thickness=0, interface=0, name="VolumeProfile",
material=None, solvent=None, profile=None, **kw):
if interface != 0: raise NotImplementedError("interface not yet supported")
if profile is None or material is None or solvent is None:
raise TypeError("Need polymer, solvent and profile")
self.name = name
self.thickness = Parameter.default(thickness, name="solvent thickness")
self.interface = Parameter.default(interface, name="solvent interface")
self.profile = profile
self.solvent = solvent
self.material = material
# Query profile function for the list of arguments
vars = inspect.getargspec(profile)[0]
#print "vars",vars
if inspect.ismethod(profile): vars = vars[1:] # Chop self
vars = vars[1:] # Chop z
#print vars
unused = [k for k in kw.keys() if k not in vars]
if len(unused) > 0:
raise TypeError("Profile got unexpected keyword argument '%s'"%unused[0])
dups = [k for k in vars
if k in ('thickness','interface','polymer','solvent','profile')]
if len(dups) > 0:
raise TypeError("Profile has conflicting argument '%s'"%dups[0])
for k in vars: kw.setdefault(k,0)
for k,v in kw.items():
setattr(self,k,Parameter.default(v,name=k))
self._parameters = vars
示例2: __init__
def __init__(self, stack, rhoM=(0, 0), thetaM=(270, 270),
name="twist", **kw):
MagneticLayer.__init__(self, stack=stack, name=name, **kw)
self.rhoM = [Parameter.default(v, name=name+" rhoM[%d]"%i)
for i, v in enumerate(rhoM)]
self.thetaM = [Parameter.default(v, name=name+" angle[%d]"%i)
for i, v in enumerate(thetaM)]
示例3: __init__
def __init__(self, edges=None, cdf=None,
args=(), loc=None, scale=None, truncated=True):
self.edges = numpy.asarray(edges)
self.cdf = cdf
self.truncated = truncated
self.loc = Parameter.default(loc)
self.scale = Parameter.default(scale)
self.args = [Parameter.default(a) for a in args]
示例4: __init__
def __init__(self,
rhoM=(0, 0), thetaM=(270, 270),
name="LAYER", **kw):
BaseMagnetism.__init__(self, name=name, **kw)
self.rhoM = [Parameter.default(v, name=name+" rhoM[%d]"%i)
for i, v in enumerate(rhoM)]
self.thetaM = [Parameter.default(v, name=name+" thetaM[%d]"%i)
for i, v in enumerate(thetaM)]
示例5: __init__
def __init__(self, thickness=0, interface=0, name="Mushroom", polymer=None, solvent=None, sigma=0, vf=0, delta=0):
self.thickness = Parameter.default(thickness, name="Mushroom thickness")
self.interface = Parameter.default(interface, name="Mushroom interface")
self.delta = Parameter.default(delta, name="delta")
self.vf = Parameter.default(vf, name="vf")
self.sigma = Parameter.default(sigma, name="sigma")
self.solvent = solvent
self.polymer = polymer
self.name = name
示例6: __init__
def __init__(self, extent=1, dead_below=0, dead_above=0, interface_below=None, interface_above=None, name="LAYER"):
self.dead_below = Parameter.default(dead_below, limits=(0, inf), name=name + " deadM below")
self.dead_above = Parameter.default(dead_above, limits=(0, inf), name=name + " deadM above")
if interface_below is not None:
interface_below = Parameter.default(interface_below, limits=(0, inf), name=name + " interfaceM below")
if interface_above is not None:
interface_above = Parameter.default(interface_above, limits=(0, inf), name=name + " interfaceM above")
self.interface_below = interface_below
self.interface_above = interface_above
self.name = name
self.extent = extent
示例7: __init__
def __init__(self, thickness=0, interface=0, profile=None, tol=1e-3,
magnetism=None, name=None, **kw):
if not name: name = profile.__name__
if interface != 0: raise NotImplementedError("interface not yet supported")
if profile is None: raise TypeError("Need profile")
self.name = name
self.thickness = Parameter.default(thickness, name=name+" thickness")
self.interface = Parameter.default(interface, name=name+" interface")
self.profile = profile
self.tol = tol
self.magnetism = magnetism
self._parameters = _set_vars(self, name, profile, kw, self.RESERVED)
示例8: __init__
def __init__(self, thickness=0, interface=0, profile=None, tol=1e-3,
magnetism=None, name=None, **kw):
if not name: name = profile.__name__
if interface != 0: raise NotImplementedError("interface not yet supported")
if profile is None: raise TypeError("Need profile")
self.name = name
self.thickness = Parameter.default(thickness, name=name+" thickness")
self.interface = Parameter.default(interface, name=name+" interface")
self.profile = profile
self.tol = tol
self.magnetism = magnetism
# TODO: maybe make these lazy (and for magnetism below as well)
rho_start = _LayerLimit(self, isend=False, isrho=True)
irho_start = _LayerLimit(self, isend=False, isrho=False)
rho_end= _LayerLimit(self, isend=True, isrho=True)
irho_end= _LayerLimit(self, isend=True, isrho=False)
self.start = SLD(name+" start", rho=rho_start, irho=irho_start)
self.end = SLD(name+" end", rho=rho_end, irho=irho_end)
self._parameters = _set_vars(self, name, profile, kw, self.RESERVED)
示例9: _set_vars
def _set_vars(self, name, profile, kw, reserved):
# Query profile function for the list of arguments
vars = inspect.getargspec(profile)[0]
#print "vars",vars
if inspect.ismethod(profile): vars = vars[1:] # Chop self
vars = vars[1:] # Chop z
#print vars
unused = [k for k in kw.keys() if k not in vars]
if len(unused) > 0:
raise TypeError("Profile got unexpected keyword argument '%s'"%unused[0])
dups = [k for k in vars if k in reserved]
if len(dups) > 0:
raise TypeError("Profile has conflicting argument %r"%dups[0])
for k in vars: kw.setdefault(k,0)
for k,v in kw.items():
setattr(self,k,Parameter.default(v,name=name+" "+k))
return vars
示例10: parvec
def parvec(vector, name, limits):
return [Parameter.default(p, name=name + "[%d]" % i, limits=limits) for i, p in enumerate(vector)]
示例11: __init__
def __init__(self, center=0, width=0, sigma=1, name="gauss"):
self.center = Par.default(center, limits=(-inf,inf),
name=name + " center")
self.width = Par.default(width, limits=(0,inf),
name=name + " width")
self.stretch = Par.default(sigma, limits=(0,inf),
name=name + " sigma")
示例12: __init__
def __init__(self, thickness=0, interface=0,
below=None, above=None,
dz=None, dp=None, name="Interface"):
self.name = name
self.below, self.above = below,above
self.thickness = Par.default(thickness, limits=(0,inf),
name=name+" thickness")
self.interface = Par.default(interface, limits=(0,inf),
name=name+" interface")
# Choose reasonable defaults if not given
if dp is None and dz is None:
dp = [1]*5
if dp is None:
dp = [1]*len(dz)
if dz is None:
dz = [1]*len(dp)
if len(dz) != len(dp):
raise ValueError("Need one dz for every dp")
#if len(z) != len(vf)+2:
# raise ValueError("Only need vf for interior z, so len(z)=len(vf)+2")
self.dz = [Par.default(p,name=name+" dz[%d]"%i,limits=(0,inf))
for i,p in enumerate(dz)]
self.dp = [Par.default(p,name=name+" dp[%d]"%i,limits=(0,inf))
for i,p in enumerate(dp)]
self.inflections = ParFunction(inflections, dx=self.dz, dy=self.dp,
name=name+" inflections")
示例13: __init__
def __init__(self, thickness=0, interface=0,
material=None, solvent=None, vf=None,
name="ChebyVF", method="interp"):
if interface != 0:
raise NotImplementedError("interface not yet supported")
self.name = name
self.thickness = Par.default(thickness, name="solvent thickness")
self.interface = Par.default(interface, name="solvent interface")
self.solvent = solvent
self.material = material
self.vf = [Par.default(p, name="vf[%d]"%i) for i,p in enumerate(vf)]
self.method = method
示例14: __init__
def __init__(self, base, parts, by='volume', name=None, use_incoherent=False):
# Split [M1, M2, F2, ...] into [M1, M2, ...], [F2, ...]
material = [parts[i] for i in range(0, len(parts), 2)]
fraction = [parts[i] for i in range(1, len(parts), 2)]
# Convert M1, M2, ... to materials if necessary
if not isinstance(base, Scatterer):
base = Material(base)
material = [p if isinstance(p, Scatterer) else Material(p)
for p in material]
# Specify the volume calculator based on the type of fraction
if by == 'volume':
_volume = _VolumeFraction(base, material)
elif by == 'mass':
_volume = _MassFraction(base, material)
else:
raise ValueError('fraction must be one of volume, mass or number')
# Name defaults to names of individual components
if name is None:
name = "+".join(p.name for p in material)
# Make the fractions into fittable parameters
fraction = [Par.default(w, limits=(0, 100), name=f.name+"% "+by)
for w, f in zip(fraction, material)]
self._volume = _volume
self.base = base
self.material = material
self.fraction = fraction
self.name = name
self.use_incoherent = use_incoherent
示例15: __init__
def __init__(self, thickness=0, interface=0,
below=None, above=None,
z=None, vf=None, name="Interface"):
self.name = name
self.below, self.above = below,above
self.thickness = Par.default(thickness, limits=(0,inf),
name=name+" thickness")
self.interface = Par.default(interface, limits=(0,inf),
name=name+" interface")
if len(z) != len(vf):
raise ValueError("Need one vf for every z")
#if len(z) != len(vf)+2:
# raise ValueError("Only need vf for interior z, so len(z)=len(vf)+2")
self.z = [Par.default(p,name=name+" z[%d]"%i,limits=(0,1))
for i,p in enumerate(z)]
self.vf = [Par.default(p,name=name+" vf[%d]"%i,limits=(0,1))
for i,p in enumerate(vf)]