当前位置: 首页>>代码示例>>Python>>正文


Python WMAP9.age方法代码示例

本文整理汇总了Python中astropy.cosmology.WMAP9.age方法的典型用法代码示例。如果您正苦于以下问题:Python WMAP9.age方法的具体用法?Python WMAP9.age怎么用?Python WMAP9.age使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在astropy.cosmology.WMAP9的用法示例。


在下文中一共展示了WMAP9.age方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(agelims=[], nbins_sfh=7, sigma=0.3, df=2, **extras):

    # we'll need this to access specific model parameters
    n = [p['name'] for p in model_params]

    # first calculate t_universe at z=1
    tuniv = WMAP9.age(1.0).value*1e9

    # now construct the nonparametric SFH
    # current scheme:  last bin is 15% age of the Universe, first two are 0-30, 30-100
    # remaining N-3 bins spaced equally in logarithmic space
    tbinmax = (tuniv*0.85)
    agelims = agelims[:2] + np.linspace(agelims[2],np.log10(tbinmax),nbins_sfh-2).tolist() + [np.log10(tuniv)]
    agebins = np.array([agelims[:-1], agelims[1:]])

    # load nvariables and agebins
    model_params[n.index('agebins')]['N'] = nbins_sfh
    model_params[n.index('agebins')]['init'] = agebins.T
    model_params[n.index('mass')]['N'] = nbins_sfh
    model_params[n.index('logsfr_ratios')]['N'] = nbins_sfh-1
    model_params[n.index('logsfr_ratios')]['init'] = np.full(nbins_sfh-1,0.0) # constant SFH
    model_params[n.index('logsfr_ratios')]['prior'] = priors.StudentT(mean=np.full(nbins_sfh-1,0.0),
                                                                      scale=np.full(nbins_sfh-1,sigma),
                                                                      df=np.full(nbins_sfh-1,df))

    # insert redshift into model dictionary
    model_params[n.index('zred')]['init'] = 0.0

    return sedmodel.SedModel(model_params)
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:31,代码来源:uvj_params.py

示例2: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(alpha_sfh=0.2,agelims=None, **extras):

    # we'll need this to access specific model parameters
    n = [p['name'] for p in model_params]

    # create SFH bins
    zred = model_params[n.index('zred')]['init']
    tuniv = WMAP9.age(zred).value

    # now construct the nonparametric SFH
    # current scheme: six bins, four spaced equally in logarithmic 
    # last bin is 15% age of the Universe, first two are 0-30, 30-100
    tbinmax = (tuniv*0.85)*1e9
    agelims = agelims[:2] + np.linspace(agelims[2],np.log10(tbinmax),len(agelims)-3).tolist() + [np.log10(tuniv*1e9)]
    agebins = np.array([agelims[:-1], agelims[1:]])
    ncomp = len(agelims) - 1

    # load nvariables and agebins
    model_params[n.index('agebins')]['N'] = ncomp
    model_params[n.index('agebins')]['init'] = agebins.T
    model_params[n.index('mass')]['N'] = ncomp
    model_params[n.index('mass')]['init'] = np.full(ncomp,1e6)
    model_params[n.index('mass')]['prior'] = priors.TopHat(mini=np.full(ncomp,1e5), maxi=np.full(ncomp,1e12))

    return sedmodel.SedModel(model_params)
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:27,代码来源:mock_nonpar_linmass_params.py

示例3: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(objname=None, datdir=None, nbins_sfh=7, sigma=0.3, df=2, agelims=[], zred=None, runname=None, **extras):

    # we'll need this to access specific model parameters
    n = [p['name'] for p in model_params]

    # first calculate redshift and corresponding t_universe
    # if no redshift is specified, read from file
    if zred is None:
        datname = datdir + objname.split('_')[0] + '_' + runname + '.dat'
        dat = ascii.read(datname)
        idx = dat['phot_id'] == int(objname.split('_')[-1])
        zred = float(dat['z_best'][idx])
    tuniv = WMAP9.age(zred).value*1e9
    model_params[n.index('zred')]['init'] = zred

    # now construct the nonparametric SFH
    # current scheme: last bin is 15% age of the Universe, first two are 0-30, 30-100
    # remaining N-3 bins spaced equally in logarithmic space
    tbinmax = (tuniv*0.85)
    agelims = agelims[:2] + np.linspace(agelims[2],np.log10(tbinmax),nbins_sfh-2).tolist() + [np.log10(tuniv)]
    agebins = np.array([agelims[:-1], agelims[1:]])

    # load nvariables and agebins
    model_params[n.index('agebins')]['N'] = nbins_sfh
    model_params[n.index('agebins')]['init'] = agebins.T
    model_params[n.index('mass')]['N'] = nbins_sfh
    model_params[n.index('logsfr_ratios')]['N'] = nbins_sfh-1
    model_params[n.index('logsfr_ratios')]['init'] = np.full(nbins_sfh-1,0.0) # constant SFH
    model_params[n.index('logsfr_ratios')]['prior'] = priors.StudentT(mean=np.full(nbins_sfh-1,0.0),
                                                                      scale=np.full(nbins_sfh-1,sigma),
                                                                      df=np.full(nbins_sfh-1,df))

    return sedmodel.SedModel(model_params)
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:35,代码来源:fast_nonpar_params.py

示例4: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(nbins_sfh=6,sigma=0.3,datfile=None,objname=None, **extras):

    # we'll need this to access specific model parameters
    n = [p['name'] for p in model_params]

    # create SFH bins
    with open(datfile,'r') as f:
        data = json.load(f)
    zred = float(data[objname]['redshift'])
    model_params[n.index('zred')]['init'] = zred
    tuniv = WMAP9.age(zred).value*1e9

    # now construct the nonparametric SFH
    # set number of components
    # set logsfr_ratio prior
    # propagate to agebins
    model_params[n.index('agebins')]['N'] = nbins_sfh
    model_params[n.index('mass')]['N'] = nbins_sfh
    model_params[n.index('logsfr_ratios')]['N'] = nbins_sfh-1
    model_params[n.index('logsfr_ratios')]['init'] = np.full(nbins_sfh-1,0.0) # constant SFH
    model_params[n.index('logsfr_ratios')]['prior'] = SFR_Ratio(mean=np.full(nbins_sfh-1,0.0),sigma=np.full(nbins_sfh-1,sigma))

    model_params.append({'name': 'tuniv', 'N': 1,
                            'isfree': False,
                            'init': tuniv})

    # set mass-metallicity prior
    model_params[n.index('massmet')]['prior'] = MassMet(z_mini=-1.98, z_maxi=0.19, mass_mini=7, mass_maxi=12.5)

    return sedmodel.SedModel(model_params)
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:32,代码来源:sne_params.py

示例5: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(datname='', objname='', **extras):

    ###### REDSHIFT ######
    hdulist = fits.open(datname)
    idx = hdulist[1].data['Name'] == objname
    zred =  hdulist[1].data['cz'][idx][0] / 3e5
    hdulist.close()

    #### TUNIV #####
    tuniv = WMAP9.age(zred).value

    #### TAGE #####
    tage_init = 1.1
    tage_mini  = 0.11      # FSPS standard
    tage_maxi = tuniv

    #### INSERT MAXIMUM AGE AND REDSHIFT INTO MODEL PARAMETER DICTIONARY ####
    pnames = [m['name'] for m in model_params]
    zind = pnames.index('zred')
    model_params[zind]['init'] = zred
    tind = pnames.index('tage')
    model_params[tind]['prior_args']['maxi'] = tuniv
    model = BurstyModel(model_params)

    return model
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:27,代码来源:brownseds_tightbc_params.py

示例6: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(nbins_sfh=7,sigma=0.3,df=2.,agelims=None,objname=None, **extras):

    # we'll need this to access specific model parameters
    n = [p['name'] for p in model_params]

    # replace nbins_sfh
    nbins_sfh = 4 + (int(objname)-1) / 9

    # create SFH bins
    zred = model_params[n.index('zred')]['init']
    tuniv = WMAP9.age(zred).value

    # now construct the nonparametric SFH
    # current scheme: six bins, four spaced equally in logarithmic 
    # last bin is 15% age of the Universe, first two are 0-30, 30-100
    tbinmax = (tuniv*0.85)*1e9
    agelims = agelims[:2] + np.linspace(agelims[2],np.log10(tbinmax),nbins_sfh-2).tolist() + [np.log10(tuniv*1e9)]
    agebins = np.array([agelims[:-1], agelims[1:]])

    # load nvariables and agebins
    model_params[n.index('agebins')]['N'] = nbins_sfh
    model_params[n.index('agebins')]['init'] = agebins.T
    model_params[n.index('mass')]['N'] = nbins_sfh
    model_params[n.index('logsfr_ratios')]['N'] = nbins_sfh-1
    model_params[n.index('logsfr_ratios')]['init'] = np.full(nbins_sfh-1,0.0) # constant SFH
    model_params[n.index('logsfr_ratios')]['prior'] = priors.StudentT(mean=np.full(nbins_sfh-1,0.0),
                                                                      scale=np.full(nbins_sfh-1,sigma),
                                                                      df=np.full(nbins_sfh-1,df))

    return sedmodel.SedModel(model_params)
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:32,代码来源:mock_timebin_params.py

示例7: cosmoAge

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def cosmoAge(redshift,
             WMAP9=False,
             H0=70.0,
             Om0=0.30,
             Planck15=False,
             Myr=False):
    """
    Get the Age of the Universe at redshift=z.

    This is simply a wrapper of astropy.cosmology
    The input redsfhit can be an array
    """
    if WMAP9:
        from astropy.cosmology import WMAP9 as cosmo
    elif Planck15:
        from astropy.cosmology import Planck15 as cosmo
    else:
        from astropy.cosmology import FlatLambdaCDM
        cosmo = FlatLambdaCDM(H0=H0, Om0=Om0)

    age = cosmo.age(redshift)

    if not Myr:
        return age.value
    else:
        return age.to(u.Myr).value
开发者ID:dr-guangtou,项目名称:hs_hsc,代码行数:28,代码来源:hscUtils.py

示例8: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(nbins_sfh=5,sigma=0.3,df=2, **extras):

    # we'll need this to access specific model parameters
    n = [p['name'] for p in model_params]

    # create SFH bins
    zred = model_params[n.index('zred')]['init']
    tuniv = WMAP9.age(zred).value*1e9

    # now construct the nonparametric SFH
    # set number of components
    # set logsfr_ratio prior
    # propagate to agebins
    model_params[n.index('agebins')]['N'] = nbins_sfh
    model_params[n.index('mass')]['N'] = nbins_sfh
    model_params[n.index('logsfr_ratios')]['N'] = nbins_sfh-1
    model_params[n.index('logsfr_ratios')]['init'] = np.full(nbins_sfh-1,0.0) # constant SFH
    model_params[n.index('logsfr_ratios')]['prior'] = priors.StudentT(mean=np.full(nbins_sfh-1,0.0),
                                                                      scale=np.full(nbins_sfh-1,sigma),
                                                                      df=np.full(nbins_sfh-1,df))
    model_params[n.index('logsfr_ratio30')]['prior'] = priors.StudentT(mean=0.0,
                                                                      scale=sigma,
                                                                      df=df)
    model_params[n.index('logsfr_ratiomax')]['prior'] = priors.StudentT(mean=0.0,
                                                                      scale=sigma,
                                                                      df=df)
    model_params.append({'name': 'tuniv', 'N': 1,
                            'isfree': False,
                            'init': tuniv})

    return sedmodel.SedModel(model_params)
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:33,代码来源:mock_student_params.py

示例9: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(objname=None, datdir=None, runname=None, agelims=[], zred=None, alpha_sfh=0.3, **extras):

    # we'll need this to access specific model parameters
    n = [p['name'] for p in model_params]

    # first calculate redshift and corresponding t_universe
    # if no redshift is specified, read from file
    hdu = fits.open(APPS+'/prospector_alpha/data/3dhst/shivaei_sample.fits')
    fields = np.array([f.replace('-','') for f in hdu[1].data['FIELD']])
    ids = hdu[1].data['V4ID'].astype(str)
    idx_obj = (fields == objname.split('_')[0]) & (ids == objname.split('_')[1])
    zred = float(hdu[1].data['Z_MOSFIRE'][idx_obj][0])

    tuniv = WMAP9.age(zred).value

    # now construct the nonparametric SFH
    # current scheme: six bins, four spaced equally in logarithmic 
    # last bin is 15% age of the Universe, first two are 0-30, 30-100
    tbinmax = (tuniv*0.85)*1e9
    agelims = agelims[:2] + np.linspace(agelims[2],np.log10(tbinmax),len(agelims)-3).tolist() + [np.log10(tuniv*1e9)]
    agebins = np.array([agelims[:-1], agelims[1:]])
    ncomp = len(agelims) - 1

    # load into `agebins` in the model_params dictionary
    model_params[n.index('agebins')]['N'] = ncomp
    model_params[n.index('agebins')]['init'] = agebins.T

    # now we do the computational z-fraction setup
    # number of zfrac variables = (number of SFH bins - 1)
    # set initial with a constant SFH
    # if alpha_SFH is a vector, use this as the alpha array
    # else assume all alphas are the same
    model_params[n.index('mass')]['N'] = ncomp
    model_params[n.index('z_fraction')]['N'] = ncomp-1
    if type(alpha_sfh) != type(np.array([])):
        alpha = np.repeat(alpha_sfh,ncomp-1)
    else:
        alpha = alpha_sfh
    tilde_alpha = np.array([alpha[i-1:].sum() for i in xrange(1,ncomp)])
    model_params[n.index('z_fraction')]['prior'] = priors.Beta(alpha=tilde_alpha, beta=alpha, mini=0.0, maxi=1.0)
    model_params[n.index('z_fraction')]['init'] = np.array([(i-1)/float(i) for i in range(ncomp,1,-1)])
    model_params[n.index('z_fraction')]['init_disp'] = 0.02

    # set mass-metallicity prior
    # insert redshift into model dictionary
    model_params[n.index('massmet')]['prior'] = MassMet(z_mini=-1.98, z_maxi=0.19, mass_mini=7, mass_maxi=12.5)
    model_params[n.index('zred')]['init'] = zred

    # set gas-phase metallicity prior
    # log(Z/Zsun) = -3.07 for model
    mean = hdu[1].data['m_12LOGOH'][idx_obj][0]
    if (mean > -100):
        gas_logz_mean = np.clip((mean - 12) + 3.06, -2, 0.5)
        sigma = (hdu[1].data['U68_12LOGOH'] - hdu[1].data['L68_12LOGOH'])[idx_obj][0] / 2.
        model_params[n.index('gas_logz')]['prior'] = priors.ClippedNormal(mean=gas_logz_mean,sigma=sigma,mini=-2,maxi=0.5)

    return sedmodel.SedModel(model_params)
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:59,代码来源:td_shivaei_params.py

示例10: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(**extras):

    # set tage_max, fix redshift
    n = [p['name'] for p in model_params]
    zred = 0.0001
    tuniv = WMAP9.age(zred).value
    model_params[n.index('tage')]['prior'].update(maxi=tuniv)

    return sedmodel.SedModel(model_params)
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:11,代码来源:vis_fmimic_params.py

示例11: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(**extras):

    # we'll need this to access specific model parameters
    n = [p['name'] for p in model_params]

    # set tmax = tuniv
    zred = model_params[n.index('zred')]['init']
    tuniv = WMAP9.age(zred).value
    model_params[n.index('tage')]['prior'].update(maxi=tuniv)

    return sedmodel.SedModel(model_params)
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:13,代码来源:mock_delexp_params.py

示例12: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(objname=None, datdir=None, runname=None, agelims=[], **extras):

    ###### REDSHIFT ######
    ### open file, load data
    # this is zgris
    datname = datdir + objname.split('_')[0] + '_' + runname + '.dat'
    dat = ascii.read(datname)
    zred = dat['z_max_grism'][np.array(dat['phot_id']) == int(objname.split('_')[-1])][0]

    #### CALCULATE TUNIV #####
    tuniv = WMAP9.age(zred).value

    #### NONPARAMETRIC SFH #####
    # six bins, four spaced equally in logarithmic space AFTER t=100 Myr + BEFORE tuniv-1 Gyr
    if tuniv > 5:
        tbinmax = (tuniv-2)*1e9
    else:
        tbinmax = (tuniv-1)*1e9
    agelims = [agelims[0]] + np.linspace(agelims[1],np.log10(tbinmax),5).tolist() + [np.log10(tuniv*1e9)]
    agebins = np.array([agelims[:-1], agelims[1:]])
    ncomp = len(agelims) - 1

    #### ADJUST MODEL PARAMETERS #####
    n = [p['name'] for p in model_params]

    #### SET UP AGEBINS
    model_params[n.index('agebins')]['N'] = ncomp
    model_params[n.index('agebins')]['init'] = agebins.T

    ### computational z-fraction setup
    # N-1 bins
    # set initial by drawing randomly from the prior
    model_params[n.index('mass')]['N'] = ncomp
    model_params[n.index('z_fraction')]['N'] = ncomp-1
    tilde_alpha = np.array([ncomp-i for i in xrange(1,ncomp)])
    model_params[n.index('z_fraction')]['prior'] = priors.Beta(alpha=tilde_alpha, beta=np.ones_like(tilde_alpha),mini=0.0,maxi=1.0)
    model_params[n.index('z_fraction')]['init'] = np.array([(i-1)/float(i) for i in range(ncomp,1,-1)])
    model_params[n.index('z_fraction')]['init_disp'] = 0.02

    ### apply SDSS mass-metallicity prior
    model_params[n.index('logzsol')]['prior'] = MassMet(mini=-1.98, maxi=0.19)

    #### INSERT REDSHIFT INTO MODEL PARAMETER DICTIONARY ####
    zind = n.index('zred')
    model_params[zind]['init'] = zred

    #### CREATE MODEL
    model = SedMet(model_params)

    return model
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:52,代码来源:td_ha_params.py

示例13: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(objname=None, datdir=None, runname=None, agelims=[], zred=None, alpha_sfh=0.2, **extras):

    # we'll need this to access specific model parameters
    n = [p['name'] for p in model_params]

    # first calculate redshift and corresponding t_universe
    # if no redshift is specified, read from file
    if zred is None:
        datname = datdir + objname.split('_')[0] + '_' + runname + '.dat'
        dat = ascii.read(datname)
        idx = dat['phot_id'] == int(objname.split('_')[-1])
        zred = float(dat['z_best'][idx])
    tuniv = WMAP9.age(zred).value

    # now construct the nonparametric SFH
    # current scheme: six bins, four spaced equally in logarithmic 
    # last bin is 15% age of the Universe, first two are 0-30, 30-100
    tbinmax = (tuniv*0.85)*1e9
    agelims = agelims[:2] + np.linspace(agelims[2],np.log10(tbinmax),len(agelims)-3).tolist() + [np.log10(tuniv*1e9)]
    agebins = np.array([agelims[:-1], agelims[1:]])
    ncomp = len(agelims) - 1

    # load into `agebins` in the model_params dictionary
    model_params[n.index('agebins')]['N'] = ncomp
    model_params[n.index('agebins')]['init'] = agebins.T

    # now we do the computational z-fraction setup
    # number of zfrac variables = (number of SFH bins - 1)
    # set initial with a constant SFH
    # if alpha_SFH is a vector, use this as the alpha array
    # else assume all alphas are the same
    model_params[n.index('mass')]['N'] = ncomp
    model_params[n.index('z_fraction')]['N'] = ncomp-1
    if type(alpha_sfh) != type(np.array([])):
        alpha = np.repeat(alpha_sfh,ncomp-1)
    else:
        alpha = alpha_sfh
    tilde_alpha = np.array([alpha[i-1:].sum() for i in xrange(1,ncomp)])
    model_params[n.index('z_fraction')]['prior'] = priors.Beta(alpha=tilde_alpha, beta=alpha, mini=0.0, maxi=1.0)
    model_params[n.index('z_fraction')]['init'] = np.array([(i-1)/float(i) for i in range(ncomp,1,-1)])
    model_params[n.index('z_fraction')]['init_disp'] = 0.02

    # set mass-metallicity prior
    # insert redshift into model dictionary
    model_params[n.index('massmet')]['prior'] = MassMet(z_mini=-1.98, z_maxi=0.19, mass_mini=7, mass_maxi=12.5)
    model_params[n.index('zred')]['init'] = zred

    return sedmodel.SedModel(model_params)
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:50,代码来源:td_new_params.py

示例14: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(objname='',datname='', agelims=[], **extras):

    ###### REDSHIFT ######
    hdulist = fits.open(datname)
    idx = hdulist[1].data['Name'] == objname
    zred =  hdulist[1].data['cz'][idx][0] / 3e5
    lumdist = hdulist[1].data['Dist'][idx][0]
    hdulist.close()

    #### CALCULATE TUNIV #####
    tuniv = WMAP9.age(zred).value

    #### NONPARAMETRIC SFH ######
    agelims[-1] = np.log10(tuniv*1e9)
    agebins = np.array([agelims[:-1], agelims[1:]])
    ncomp = len(agelims) - 1

    #### ADJUST MODEL PARAMETERS #####
    n = [p['name'] for p in model_params]

    #### SET UP AGEBINS
    model_params[n.index('agebins')]['N'] = ncomp
    model_params[n.index('agebins')]['init'] = agebins.T

    #### FRACTIONAL MASS INITIALIZATION
    # N-1 bins, last is set by x = 1 - np.sum(sfr_fraction)
    model_params[n.index('z_fraction')]['N'] = ncomp-1
    tilde_alpha = np.array([ncomp-i for i in xrange(1,ncomp)])
    model_params[n.index('z_fraction')]['prior'] = priors.Beta(alpha=tilde_alpha, beta=np.ones_like(tilde_alpha),mini=0.0,maxi=1.0)
    model_params[n.index('z_fraction')]['init'] =  model_params[n.index('z_fraction')]['prior'].sample()
    model_params[n.index('z_fraction')]['init_disp'] = 0.02

    model_params[n.index('sfr_fraction')]['N'] = ncomp-1
    model_params[n.index('sfr_fraction')]['prior'] = priors.TopHat(maxi=np.full(ncomp-1,1.0), mini=np.full(ncomp-1,0.0))
    model_params[n.index('sfr_fraction')]['init'] =  np.zeros(ncomp-1)+1./ncomp
    model_params[n.index('sfr_fraction')]['init_disp'] = 0.02

    #### INSERT REDSHIFT INTO MODEL PARAMETER DICTIONARY ####
    model_params[n.index('zred')]['init'] = zred
    model_params[n.index('lumdist')]['init'] = lumdist

    #### CREATE MODEL
    model = BurstyModel(model_params)

    return model
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:47,代码来源:brownseds_agn_nestle_params.py

示例15: load_model

# 需要导入模块: from astropy.cosmology import WMAP9 [as 别名]
# 或者: from astropy.cosmology.WMAP9 import age [as 别名]
def load_model(objname='', datname='', agelims=[], **extras):

    ###### REDSHIFT ######
    hdulist = fits.open(datname)
    idx = hdulist[1].data['Name'] == objname
    zred =  hdulist[1].data['cz'][idx][0] / 3e5
    hdulist.close()

    #### CALCULATE TUNIV #####
    tuniv = WMAP9.age(zred).value

    #### NONPARAMETRIC SFH ######
    agelims[-1] = np.log10(tuniv*1e9)
    agebins = np.array([agelims[:-1], agelims[1:]])
    ncomp = len(agelims) - 1
    mass_init =  expsfh(agelims, **extras)*1e5

    #### ADJUST MODEL PARAMETERS #####
    n = [p['name'] for p in model_params]

    #### SET UP AGEBINS
    model_params[n.index('agebins')]['N'] = ncomp
    model_params[n.index('agebins')]['init'] = agebins.T

    #### FRACTIONAL MASS
    # N-1 bins, last is set by x = 1 - np.sum(sfr_fraction)
    model_params[n.index('sfr_fraction')]['N'] = ncomp-1
    model_params[n.index('sfr_fraction')]['init'] = mass_init[:-1] / np.sum(mass_init)
    model_params[n.index('sfr_fraction')]['prior_args'] = {
                                                           'maxi':np.full(ncomp-1,1.0), 
                                                           'mini':np.full(ncomp-1,0.0),
                                                           'alpha':1.0,
                                                           'alpha_sum':ncomp 
                                                           # NOTE: ncomp instead of ncomp-1 makes the prior take into account the implicit Nth variable too
                                                          }
    model_params[n.index('sfr_fraction')]['init_disp'] = 0.15

    #### INSERT REDSHIFT INTO MODEL PARAMETER DICTIONARY ####
    zind = n.index('zred')
    model_params[zind]['init'] = zred

    #### CREATE MODEL
    model = BurstyModel(model_params)

    return model
开发者ID:jrleja,项目名称:threedhst_bsfh,代码行数:47,代码来源:brownseds_np_params.py


注:本文中的astropy.cosmology.WMAP9.age方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。