本文整理汇总了Python中population.Population.arguments方法的典型用法代码示例。如果您正苦于以下问题:Python Population.arguments方法的具体用法?Python Population.arguments怎么用?Python Population.arguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类population.Population
的用法示例。
在下文中一共展示了Population.arguments方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate
# 需要导入模块: from population import Population [as 别名]
# 或者: from population.Population import arguments [as 别名]
def generate(ngen,
surveyList=None,
pDistType='lnorm',
radialDistType='lfl06',
radialDistPars=7.5,
electronModel='ne2001',
pDistPars=[2.7, -0.34],
siDistPars=[-1.6, 0.35],
lumDistType='lnorm',
lumDistPars=[-1.1, 0.9],
zscaleType='exp',
zscale=0.33,
duty_percent=6.,
scindex=-3.86,
gpsArgs=[None, None],
doubleSpec=[None, None],
nostdout=False,
pattern='gaussian',
orbits=False):
"""
Generate a population of pulsars.
Keyword args:
ngen -- the number of pulsars to generate (or detect)
surveyList -- a list of surveys you want to use to try and detect
the pulsars
pDistType -- the pulsar period distribution model to use (def=lnorm)
radialDistType -- radial distribution model
electronModel -- mode to use for Galactic electron distribution
pDistPars -- parameters to use for period distribution
siDistPars -- parameters to use for spectral index distribution
lumDistPars -- parameters to use for luminosity distribution
radialDistPars -- parameters for radial distribution
zscale -- if using exponential z height, set it here (in kpc)
scindex -- spectral index of the scattering model
gpsArgs -- add GPS-type spectrum sources
doubleSpec -- add double-spectrum type sources
nostdout -- (bool) switch off stdout
"""
pop = Population()
# check that the distribution types are supported....
if lumDistType not in ['lnorm', 'pow']:
print "Unsupported luminosity distribution: {0}".format(lumDistType)
if pDistType not in ['lnorm', 'norm', 'cc97', 'lorimer12']:
print "Unsupported period distribution: {0}".format(pDistType)
if radialDistType not in ['lfl06', 'yk04', 'isotropic',
'slab', 'disk', 'gauss']:
print "Unsupported radial distribution: {0}".format(radialDistType)
if electronModel not in ['ne2001', 'lmt85']:
print "Unsupported electron model: {0}".format(electronModel)
if pattern not in ['gaussian', 'airy']:
print "Unsupported gain pattern: {0}".format(pattern)
if duty_percent < 0.:
print "Unsupported value of duty cycle: {0}".format(duty_percent)
# need to use properties in this class so they're get/set-type props
pop.pDistType = pDistType
pop.radialDistType = radialDistType
pop.electronModel = electronModel
pop.lumDistType = lumDistType
pop.rsigma = radialDistPars
pop.pmean, pop.psigma = pDistPars
pop.simean, pop.sisigma = siDistPars
pop.gpsFrac, pop.gpsA = gpsArgs
pop.brokenFrac, pop.brokenSI = doubleSpec
if pop.lumDistType == 'lnorm':
pop.lummean, pop.lumsigma = \
lumDistPars[0], lumDistPars[1]
else:
try:
pop.lummin, pop.lummax, pop.lumpow = \
lumDistPars[0], lumDistPars[1], lumDistPars[2]
except ValueError:
raise PopulateException('Not enough lum distn parameters')
pop.zscaleType = zscaleType
pop.zscale = zscale
# store the dict of arguments inside the model. Could be useful.
try:
argspec = inspect.getargspec(generate)
key_values = [(arg, locals()[arg]) for arg in argspec.args]
pop.arguments = {key: value for (key, value) in key_values}
except SyntaxError:
pass
if not nostdout:
print "\tGenerating pulsars with parameters:"
param_string_list = []
#.........这里部分代码省略.........
示例2: generate
# 需要导入模块: from population import Population [as 别名]
# 或者: from population.Population import arguments [as 别名]
#.........这里部分代码省略.........
if pop.electronModel == 'ne2001':
pulsar.dm = go.ne2001_dist_to_dm(pulsar.dtrue,
pulsar.gl,
pulsar.gb)
elif pop.electronModel == 'lmt85':
pulsar.dm = go.lmt85_dist_to_dm(pulsar.dtrue,
pulsar.gl,
pulsar.gb)
else:
raise EvolveException('Invalid electron dist model selected')
pulsar.scindex = scindex
pulsar.t_scatter = go.scatter_bhat(pulsar.dm,
pulsar.scindex)
# if surveys are given, check if pulsar detected or not
# in ANY of the surveys
if surveyList is not None:
detect_int = 0 # just a flag if pulsar is detected
for surv in surveys:
SNR = surv.SNRcalc(pulsar, pop)
if SNR > surv.SNRlimit:
# SNR is over threshold
# increment the flag
# and survey ndetected
detect_int += 1
surv.ndet += 1
continue
elif SNR == -1:
# pulse is smeared out
surv.nsmear += 1
continue
elif SNR == -2:
# pulsar is outside survey region
surv.nout += 1
continue
else:
# pulsar is just too faint
surv.ntf += 1
continue
# if detected, increment ndet (for whole population)
# and redraw the progress bar
if detect_int:
pop.ndet += 1
# update the counter
if not nostdout:
prog.increment_amount()
print prog, '\r',
sys.stdout.flush()
else:
# no survey list, just add the pulsar to population,
# and increment number of pulsars
pop.ndet += 1
# update the counter
if not nostdout:
prog.increment_amount()
print prog, '\r',
sys.stdout.flush()
# pulsar isn't dead, add to population!
pop.population.append(pulsar)
else:
# pulsar is dead. If no survey list,
# just increment number of pulsars
if surveyList is None:
pop.ndet += 1
# update the counter
if not nostdout:
prog.increment_amount()
print prog, '\r',
sys.stdout.flush()
if not nostdout:
print "\n\n"
print " Total pulsars = {0}".format(len(pop.population))
print " Total detected = {0}".format(pop.ndet)
for surv in surveys:
print "\n Results for survey '{0}'".format(surv.surveyName)
print " Number detected = {0}".format(surv.ndet)
print " Number too faint = {0}".format(surv.ntf)
print " Number smeared = {0}".format(surv.nsmear)
print " Number outside survey area = {0}".format(surv.nout)
# save list of arguments into the pop
try:
argspec = inspect.getargspec(generate)
key_values = [(arg, locals()[arg]) for arg in argspec.args]
pop.arguments = {key: value for (key, value) in key_values}
except SyntaxError:
pass
return pop