本文整理汇总了Python中population.Population.simean方法的典型用法代码示例。如果您正苦于以下问题:Python Population.simean方法的具体用法?Python Population.simean怎么用?Python Population.simean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类population.Population
的用法示例。
在下文中一共展示了Population.simean方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate
# 需要导入模块: from population import Population [as 别名]
# 或者: from population.Population import simean [as 别名]
def generate(ngen,
surveyList=None,
age_max=1.0E9,
pDistPars=[.3, .15],
bFieldPars=[12.65, 0.55],
birthVPars=[0.0, 180.],
siDistPars=[-1.6, 0.35],
alignModel='orthogonal',
lumDistType='fk06',
lumDistPars=[-1.5, 0.5],
alignTime=None,
spinModel='fk06',
beamModel='tm98',
birthVModel='gaussian',
electronModel='ne2001',
braking_index=0,
zscale=0.05,
duty=5.,
scindex=-3.86,
widthModel=None,
nodeathline=False,
efficiencycut=None,
nostdout=False,
nospiralarms=False,
keepdead=False):
pop = Population()
# set the parameters in the population object
pop.pmean, pop.psigma = pDistPars
pop.bmean, pop.bsigma = bFieldPars
if lumDistType == 'pow':
try:
pop.lummin, pop.lummax, pop.lumpow = \
lumDistPars[0], lumDistPars[1], lumDistPars[2]
except ValueError:
raise EvolveException('Not enough lum distn parameters for "pow"')
elif lumDistType == 'fk06':
pop.lumPar1, pop.lumPar2 = lumDistPars[0], lumDistPars[1]
if len(lumDistPars) == 3:
pop.lumPar3 = lumDistPars[2]
else:
pop.lumPar3 = 0.18
else:
pop.lumPar1, pop.lumPar2 = lumDistPars
pop.simean, pop.sisigma = siDistPars
pop.birthvmean, pop.birthvsigma = birthVPars
pop.alignModel = alignModel
pop.alignTime = alignTime
pop.spinModel = spinModel
pop.beamModel = beamModel
pop.birthVModel = birthVModel
pop.electronModel = electronModel
pop.braking_index = braking_index
pop.deathline = not nodeathline
pop.nospiralarms = nospiralarms
pop.zscale = zscale
if widthModel == 'kj07':
print "\tLoading KJ07 models...."
kj_p_vals, kj_pdot_vals, kj_dists = beammodels.load_kj2007_models()
print "\tDone\n"
if not nostdout:
print "\tGenerating evolved pulsars with parameters:"
print "\t\tngen = {0}".format(ngen)
print "\t\tUsing electron distn model {0}".format(
pop.electronModel)
print "\n\t\tPeriod mean, sigma = {0}, {1}".format(
pop.pmean,
pop.psigma)
print "\t\tLuminosity mean, sigma = {0}, {1}".format(
pop.lummean,
pop.lumsigma)
print "\t\tSpectral index mean, sigma = {0}, {1}".format(
pop.simean,
pop.sisigma)
print "\t\tGalactic z scale height = {0} kpc".format(
pop.zscale)
if widthModel is None:
print "\t\tWidth {0}% ".format(duty)
else:
print "\t\tUsing Karastergiou & Johnston beam width model"
# set up progress bar for fun :)
prog = ProgressBar(min_value=0,
max_value=ngen,
width=65,
mode='dynamic')
# create survey objects here and put them in a list
if surveyList is not None:
surveys = [Survey(s) for s in surveyList]
#.........这里部分代码省略.........
示例2: generate
# 需要导入模块: from population import Population [as 别名]
# 或者: from population.Population import simean [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 = []
#.........这里部分代码省略.........
示例3: generate
# 需要导入模块: from population import Population [as 别名]
# 或者: from population.Population import simean [as 别名]
def generate(ngen,
surveyList=None,
age_max=1.0E9,
pDistPars=[.3, .15],
bFieldPars=[12.65, 0.55],
birthVPars=[0.0, 180.],
siDistPars= [-1.6,0.35],
alignModel='orthogonal',
lumDistType='fk06',
lumDistPars=[-1.5, 0.5],
alignTime=None,
spinModel = 'fk06',
beamModel = 'tm98',
birthVModel = 'gaussian',
electronModel='ne2001',
braking_index=0,
zscale=0.33,
duty=5.,
nodeathline=False,
nostdout=False,
nospiralarms=False):
pop = Population()
# set the parameters in the population object
pop.pmean, pop.psigma = pDistPars
pop.bmean, pop.bsigma = bFieldPars
if lumDistType=='pow':
try:
pop.lummin, pop.lummax, pop.lumpow = \
lumDistPars[0], lumDistPars[1], lumDistPars[2]
except ValueError:
raise EvolveException('Not enough lum distn parameters')
else:
pop.lumPar1, pop.lumPar2 = lumDistPars
pop.simean, pop.sisigma = siDistPars
pop.birthvmean, pop.birthvsigma = birthVPars
pop.alignModel = alignModel
pop.alignTime= alignTime
pop.spinModel = spinModel
pop.beamModel = beamModel
pop.birthVModel = birthVModel
pop.electronModel = electronModel
pop.braking_index = braking_index
pop.nodeathline = nodeathline
pop.nospiralarms = nospiralarms
pop.zscale = zscale
if not nostdout:
print "\tGenerating evolved pulsars with parameters:"
print "\t\tngen = {0}".format(ngen)
print "\t\tUsing electron distn model {0}".format(
pop.electronModel)
print "\n\t\tPeriod mean, sigma = {0}, {1}".format(
pop.pmean,
pop.psigma)
print "\t\tLuminosity mean, sigma = {0}, {1}".format(
pop.lummean,
pop.lumsigma)
print "\t\tSpectral index mean, sigma = {0}, {1}".format(
pop.simean,
pop.sisigma)
print "\t\tGalactic z scale height = {0} kpc".format(
pop.zscale)
print "\t\tWidth {0}% ".format(duty)
# set up progress bar for fun :)
prog = ProgressBar(min_value = 0,
max_value=ngen,
width=65,
mode='dynamic')
# create survey objects here and put them in a list
if surveyList is not None:
surveys = [Survey(s) for s in surveyList]
else:
# make an empty list here - makes some code just a little
# simpler - can still loop over an empty list (ie zero times)
surveys=[]
# initialise these counters to zero
for surv in surveys:
surv.ndet =0 # number detected
surv.nout=0 # number outside survey region
surv.nsmear=0 # number smeared out
surv.ntf=0 # number too faint
# this is the nitty-gritty loop for generating the pulsars
while pop.ndet < ngen:
pulsar = Pulsar()
# initial age for pulsar
pulsar.age = random.random() * age_max
#.........这里部分代码省略.........