本文整理汇总了Python中parameter.Parameter类的典型用法代码示例。如果您正苦于以下问题:Python Parameter类的具体用法?Python Parameter怎么用?Python Parameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Gauss1D
class Gauss1D(ArithmeticModel):
def __init__(self, name='gauss1d'):
self.fwhm = Parameter(name, 'fwhm', 10, tinyval, hard_min=tinyval)
self.pos = Parameter(name, 'pos', 0)
self.ampl = Parameter(name, 'ampl', 1)
ArithmeticModel.__init__(self, name, (self.fwhm, self.pos, self.ampl))
def get_center(self):
return (self.pos.val,)
def set_center(self, pos, *args, **kwargs):
self.pos.set(pos)
def guess(self, dep, *args, **kwargs):
norm = guess_amplitude(dep, *args)
pos = get_position(dep, *args)
fwhm = guess_fwhm(dep, *args)
param_apply_limits(norm, self.ampl, **kwargs)
param_apply_limits(pos, self.pos, **kwargs)
param_apply_limits(fwhm, self.fwhm, **kwargs)
@modelCacher1d
def calc(self, *args, **kwargs):
kwargs['integrate']=bool_cast(self.integrate)
return _modelfcts.gauss1d(*args, **kwargs)
示例2: Delta2D
class Delta2D(ArithmeticModel):
def __init__(self, name='delta2d'):
self.xpos = Parameter(name, 'xpos', 0)
self.ypos = Parameter(name, 'ypos', 0)
self.ampl = Parameter(name, 'ampl', 1)
ArithmeticModel.__init__(self, name, (self.xpos, self.ypos, self.ampl))
self.cache = 0
def get_center(self):
return (self.xpos.val, self.ypos.val)
def set_center(self, xpos, ypos, *args, **kwargs):
self.xpos.set(xpos)
self.ypos.set(ypos)
def guess(self, dep, *args, **kwargs):
xpos, ypos = guess_position(dep, *args)
norm = guess_amplitude2d(dep, *args)
param_apply_limits(xpos, self.xpos, **kwargs)
param_apply_limits(ypos, self.ypos, **kwargs)
param_apply_limits(norm, self.ampl, **kwargs)
def calc(self, *args, **kwargs):
kwargs['integrate']=bool_cast(self.integrate)
return _modelfcts.delta2d(*args, **kwargs)
示例3: NormGauss1D
class NormGauss1D(ArithmeticModel):
def __init__(self, name='normgauss1d'):
self.fwhm = Parameter(name, 'fwhm', 10, tinyval, hard_min=tinyval)
self.pos = Parameter(name, 'pos', 0)
self.ampl = Parameter(name, 'ampl', 1)
ArithmeticModel.__init__(self, name, (self.fwhm, self.pos, self.ampl))
def get_center(self):
return (self.pos.val,)
def set_center(self, pos, *args, **kwargs):
self.pos.set(pos)
def guess(self, dep, *args, **kwargs):
ampl = guess_amplitude(dep, *args)
pos = get_position(dep, *args)
fwhm = guess_fwhm(dep, *args)
param_apply_limits(pos, self.pos, **kwargs)
param_apply_limits(fwhm, self.fwhm, **kwargs)
# Apply normalization factor to guessed amplitude
norm = numpy.sqrt(numpy.pi/_gfactor)*self.fwhm.val
for key in ampl.keys():
if ampl[key] is not None:
ampl[key] *= norm
param_apply_limits(ampl, self.ampl, **kwargs)
@modelCacher1d
def calc(self, *args, **kwargs):
kwargs['integrate']=bool_cast(self.integrate)
return _modelfcts.ngauss1d(*args, **kwargs)
示例4: Gauss2D
class Gauss2D(ArithmeticModel):
def __init__(self, name='gauss2d'):
self.fwhm = Parameter(name, 'fwhm', 10, tinyval, hard_min=tinyval)
self.xpos = Parameter(name, 'xpos', 0)
self.ypos = Parameter(name, 'ypos', 0)
self.ellip = Parameter(name, 'ellip', 0, 0, 0.999, 0, 0.9999,
frozen=True)
self.theta = Parameter(name, 'theta', 0, 0, 2*numpy.pi, -2*numpy.pi,
4*numpy.pi, 'radians', frozen=True)
self.ampl = Parameter(name, 'ampl', 1)
ArithmeticModel.__init__(self, name,
(self.fwhm, self.xpos, self.ypos, self.ellip,
self.theta, self.ampl))
self.cache = 0
def get_center(self):
return (self.xpos.val, self.ypos.val)
def set_center(self, xpos, ypos, *args, **kwargs):
self.xpos.set(xpos)
self.ypos.set(ypos)
def guess(self, dep, *args, **kwargs):
xpos, ypos = guess_position(dep, *args)
norm = guess_amplitude2d(dep, *args)
param_apply_limits(xpos, self.xpos, **kwargs)
param_apply_limits(ypos, self.ypos, **kwargs)
param_apply_limits(norm, self.ampl, **kwargs)
def calc(self, *args, **kwargs):
kwargs['integrate']=bool_cast(self.integrate)
return _modelfcts.gauss2d(*args, **kwargs)
示例5: __init__
def __init__(self):
# Parameters
self.charging_current_limit = 5
self.gyro_limit = 0.15
self.min_number_of_values_over_limit = 25
self.array_length = 90
self.min_trip_length = 300 #s
self.trip_started = False
self.max_time_between_movement = 280 #s
self.max_avg_speed = 30 #km/h
# Declaring variables
self.charging_currents = Parameter(self.array_length, self.charging_current_limit, self.min_number_of_values_over_limit)
self.gyroscopes = Parameter(self.array_length, self.gyro_limit, self.min_number_of_values_over_limit)
self.start_times = []
self.end_times = []
# Declaring temporary variable for trips
self.tmp_start_time = 0
# Defining positions of variables in DB
self.time_db = 0
# latGPS_db = 3
# lenGPS_db = 4
self.charging_current_db = 26
self.gyro_x_db = 13
self.gyro_y_db = 14
self.gyro_z_db = 15
示例6: initialize
def initialize(self):
parameters = []
configure_parameters = self.configure.get(self.name)
if type(configure_parameters) is list:
parameters.extend(configure_parameters)
else:
parameters.append(configure_parameters)
files=listdir(self.path)
for parameterName in parameters:
##for example cpu.shares then it will start with cpu, we only configure these files.
if parameterName in files:
##we pass the path fo the file under this subsystem to Parameter class
fileName = self.path+"/"+parameterName
parameter = Parameter(name=parameterName,
path=fileName,
configure=self.configure)
self.subParameters[parameterName]=parameter
else:
log.error("can not find file parameter %s",parameterName)
##TODO we can't find a file mathed with parameter log error message here
pass
##read initial values
for parameter in self.subParameters.values():
parameter.read()
示例7: __init__
def __init__(self, name="normgauss2d"):
self.fwhm = Parameter(name, "fwhm", 10, tinyval, hard_min=tinyval)
self.xpos = Parameter(name, "xpos", 0)
self.ypos = Parameter(name, "ypos", 0)
self.ellip = Parameter(name, "ellip", 0, 0, 0.999, 0, 0.9999, frozen=True)
self.theta = Parameter(
name, "theta", 0, -2 * numpy.pi, 2 * numpy.pi, -2 * numpy.pi, 4 * numpy.pi, "radians", frozen=True
)
self.ampl = Parameter(name, "ampl", 1)
ArithmeticModel.__init__(self, name, (self.fwhm, self.xpos, self.ypos, self.ellip, self.theta, self.ampl))
self.cache = 0
示例8: __init__
def __init__(self, name='normgauss2d'):
self.fwhm = Parameter(name, 'fwhm', 10, tinyval, hard_min=tinyval)
self.xpos = Parameter(name, 'xpos', 0)
self.ypos = Parameter(name, 'ypos', 0)
self.ellip = Parameter(name, 'ellip', 0, 0, 0.999, 0, 0.9999,
frozen=True)
self.theta = Parameter(name, 'theta', 0, 0, 2*numpy.pi, -2*numpy.pi,
4*numpy.pi, 'radians', frozen=True)
self.ampl = Parameter(name, 'ampl', 1)
ArithmeticModel.__init__(self, name,
(self.fwhm, self.xpos, self.ypos, self.ellip,
self.theta, self.ampl))
self.cache = 0
示例9: __init__
def __init__(self, name, parts):
self.parts = tuple(parts)
allpars = []
for part in self.parts:
for p in part.pars:
if p in allpars:
# If we already have a reference to this parameter, store
# a hidden, linked proxy instead
pnew = Parameter(p.modelname, p.name, 0.0, hidden=True)
pnew.link = p
p = pnew
allpars.append(p)
Model.__init__(self, name, allpars)
示例10: inject
def inject(cls, cmd):
if isinstance(cmd, type):
if issubclass(cmd, Action):
return A_CMD(cmd)
if isinstance(cmd, CLI_CMD):
return cmd
elif isinstance(cmd, str):
return LIT_CMD(cmd)
elif isinstance(cmd, Message):
return MESSAGE_CMD(cmd)
elif isinstance(cmd, dict):
return ASSIGN_CMD(**cmd)
elif isinstance(cmd, Delete):
return ENVIRONMENT_DEL_CMD(*cmd.keys)
elif isinstance(cmd, GetVariable):
return ENVIRONMENT_CMD(cmd.name)
elif isinstance(cmd, GeneratorType):
return GEN_CMD(cmd)
elif isinstance(cmd, tuple):
return PAR_CMD(*cmd)
try:
cmd = Parameter.inject(cmd)
return PAR_INP(cmd)
except:
pass
raise TypeError('invalid command value: {} '
'(type: {})'.format(cmd, type(cmd)))
示例11: NormGauss2D
class NormGauss2D(ArithmeticModel):
def __init__(self, name='normgauss2d'):
self.fwhm = Parameter(name, 'fwhm', 10, tinyval, hard_min=tinyval)
self.xpos = Parameter(name, 'xpos', 0)
self.ypos = Parameter(name, 'ypos', 0)
self.ellip = Parameter(name, 'ellip', 0, 0, 0.999, 0, 0.9999,
frozen=True)
self.theta = Parameter(name, 'theta', 0, 0, 2*numpy.pi, -2*numpy.pi,
4*numpy.pi, 'radians', frozen=True)
self.ampl = Parameter(name, 'ampl', 1)
ArithmeticModel.__init__(self, name,
(self.fwhm, self.xpos, self.ypos, self.ellip,
self.theta, self.ampl))
self.cache = 0
def get_center(self):
return (self.xpos.val, self.ypos.val)
def set_center(self, xpos, ypos, *args, **kwargs):
self.xpos.set(xpos)
self.ypos.set(ypos)
def guess(self, dep, *args, **kwargs):
xpos, ypos = guess_position(dep, *args)
ampl = guess_amplitude2d(dep, *args)
param_apply_limits(xpos, self.xpos, **kwargs)
param_apply_limits(ypos, self.ypos, **kwargs)
# Apply normalization factor to guessed amplitude
norm = (numpy.pi/_gfactor)*self.fwhm.val*self.fwhm.val*numpy.sqrt(1.0 - (self.ellip.val*self.ellip.val))
for key in ampl.keys():
if ampl[key] is not None:
ampl[key] *= norm
param_apply_limits(ampl, self.ampl, **kwargs)
def calc(self, *args, **kwargs):
kwargs['integrate']=bool_cast(self.integrate)
return _modelfcts.ngauss2d(*args, **kwargs)
示例12: Delta1D
class Delta1D(ArithmeticModel):
def __init__(self, name="delta1d"):
self.pos = Parameter(name, "pos", 0)
self.ampl = Parameter(name, "ampl", 1)
ArithmeticModel.__init__(self, name, (self.pos, self.ampl))
def get_center(self):
return (self.pos.val,)
def set_center(self, pos, *args, **kwargs):
self.pos.set(pos)
def guess(self, dep, *args, **kwargs):
norm = guess_amplitude(dep, *args)
pos = get_position(dep, *args)
param_apply_limits(norm, self.ampl, **kwargs)
param_apply_limits(pos, self.pos, **kwargs)
@modelCacher1d
def calc(self, *args, **kwargs):
kwargs["integrate"] = bool_cast(self.integrate)
return _modelfcts.delta1d(*args, **kwargs)
示例13: __init__
def __init__(self, name, parts):
self.parts = tuple(parts)
allpars = []
for part in self.parts:
for p in part.pars:
if p in allpars:
# If we already have a reference to this parameter, store
# a hidden, linked proxy instead
pnew = Parameter(p.modelname, p.name, 0.0, hidden=True)
pnew.link = p
p = pnew
allpars.append(p)
Model.__init__(self, name, allpars)
for part in self.parts:
try:
self.is_discrete = self.is_discrete or part.is_discrete
except:
warning("Could not determine whether the model is discrete.\n"+
"This probably means that you have restored a session saved with a previous version of Sherpa.\n"+
"Falling back to assuming that the model is continuous.\n")
self.is_discrete = False
示例14: parse
def parse(tkns):
""" Parse a verilog module
module :=
'module' identifier [module_param_port_list] [list_of_ports]
';' {module_item} 'endmodule'
| 'module' identifier [module_param_port_list]
[list_of_port_declarations] ';' {non_port_module_item}
'endmodule'
"""
tkns.expect(Tokens.KW_MODULE)
# get module name
name = tkns.current().text
tkns.expect(Tokens.IDENTIFIER)
# get parameter port list, if it exists
params = []
if tkns.check(Tokens.HASH):
params = Parameter.parse_module_param_port_list(tkns)
# get i/o port list, if it exists
io = []
if tkns.check(Tokens.OPEN_PAREN):
if tkns.peek(Tokens.CLOSE_PAREN):
tkns.next()
tkns.next()
elif tkns.peek(Tokens.KW_INOUT) or tkns.peek(Tokens.KW_INPUT) or tkns.peek(Tokens.KW_OUTPUT):
io = Port.parse_list_of_port_declarations(tkns)
else:
io = Port.parse_list_of_ports(tkns)
# get module contents
# TODO: look at contents for more parameters, do other parsing
contents = []
while not tkns.accept(Tokens.KW_ENDMODULE):
contents.append(tkns.next())
return Module(name, params, io, contents)
示例15: open
for x in open("contain-angle-quotes.csv")]
def title_index(lst, title):
try:
return lst.index(title)
except Exception:
return -1
def generate_csv_list(clm1, index, title_lst):
line_count = max(len(clm1), len(title_lst), 1)
column1 = clm1 + ['']*(line_count-1)
column2 = [index+1] + ['']*(line_count-1)
column3 = title_lst + ['']*(line_count-len(title_lst))
return zip(column1, column2, column3)
Parameter.setEnv('kevin')
simpleRes = LncSimpleSearchResultTestCase()
csv_output_filename = "angle-quotes-results.csv"
csv_output_file = open(csv_output_filename, "a")
for legal in legislation:
for tag in legal[2:]:
cur_titles = simpleRes.get_results_list(tag)
index = title_index(cur_titles, legal[1])
csv_line = generate_csv_list([tag, legal[1], legal[0]], index, cur_titles)
for cl in csv_line:
line = ("%s\t%s\t%s\n" % cl)
csv_output_file.write(line.encode('utf-8'))