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


Python FlatLambdaCDM.distmod方法代码示例

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


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

示例1: LogLikelihood

# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import distmod [as 别名]
def LogLikelihood(pos, obs, sigmas, par):
    """
        Input:
            Array with the position in the parameters space
            Array with observed values
            Array with sigmas
            Dictionary of indexes of parameters in the arrays
        Return:
            Log likelihood
    """
    mb_obs, x1_obs, c_obs, z_obs = obs
    sigma_mb, sigma_x1, sigma_c = sigmas

    cosmo = FlatLambdaCDM(H0=70, Om0=pos[par["Omega_m"]])
    mu = cosmo.distmod(z_obs).value

    x1 = pos[-2 * len(obs[0]) : -len(obs[0])]
    c = pos[-len(obs[0]) :]

    mb_true = pos[par["MB"]] - pos[par["alpha"]] * x1 + pos[par["beta"]] * c + mu  # +  pos[ par['sigma_int'] ]

    #   I'm not sure this is correct. We need to check how to deal with the two
    #   scatters (sigma_int and sigma_mb)
    likelihood_m_obs = LogGaussian(mb_obs, mb_true, sigma_mb + pos[par["sigma_int"]])
    likelihood_x1 = LogGaussian(x1_obs, x1, sigma_x1)
    likelihood_c = LogGaussian(c_obs, c, sigma_c)

    return np.sum([likelihood_m_obs, likelihood_x1, likelihood_c])
开发者ID:RGTippens,项目名称:My_AHW_2015,代码行数:30,代码来源:unitpy.py

示例2: calculate_rf_lens_magnitudes

# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import distmod [as 别名]
def calculate_rf_lens_magnitudes(lens_redshift, velocity_dispersion, filters_dict):
    """Calculates the reference-frame lens magnitudes in multiple filters

    Parameters
    ----------
    lens_redshift : float
        Redshift of the lens
    velocity_dispersion : float
        Velocity dispersion of the lens
    filters_dict : dict
        (See output of `get_sdss_filters` for details)
        Throughputs of various filters

    Returns
    -------
    dict
        Each key is one of string characters 'u', 'g', 'r', 'i', 'z'
        representing the filter
        Each value is the reference-frame apparent magnitude of the quasar
        in the 'key' filter, of type float
    """
    from stellarpop import tools
    from lenspop import population_functions, distances
    from astropy.cosmology import FlatLambdaCDM

    # Instantiate Distance
    distance = distances.Distance() #TODO: necessary?
    # Instantiate LensPopulation
    lenspop = population_functions.LensPopulation_()
    # Instantiate FlatLambdaCDM cosmology with reasonable parameters
    cosmology = FlatLambdaCDM(H0=70.0, Om0=0.3)

    lens_sed = tools.getSED('BC_Z=1.0_age=9.000gyr')
    velocity_dispersion = np.atleast_1d(velocity_dispersion)

    # Absolute --> apparent magnitude conversion in the R-band
    lens_abmag_r = tools.ABFilterMagnitude(filters_dict['r'], lens_sed, lens_redshift)
    distance_modulus = cosmology.distmod(lens_redshift).value
    lens_appmag_r = lens_abmag_r + distance_modulus

    # [Reference frame] Absolute --> apparent magnitude conversion in the R-band
    rf_lens_abmag_r, _ = lenspop.EarlyTypeRelations(velocity_dispersion)
    rf_lens_appmag = {}
    rf_lens_appmag['r'] = rf_lens_abmag_r + distance_modulus

    # Quantity which is added to ~magnitude to convert it into reference-frame ~magnitude
    offset_rf = rf_lens_abmag_r - lens_abmag_r

    # Converting absolute magnitude to reference-frame apparent magnitude
    for band in 'ugiz':
        rf_lens_appmag[band] = tools.ABFilterMagnitude(filters_dict[band], lens_sed, lens_redshift) + offset_rf + distance_modulus
    return rf_lens_appmag
开发者ID:drphilmarshall,项目名称:LensPop,代码行数:54,代码来源:paint_lensed_system.py

示例3: test_fit_cosmology

# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import distmod [as 别名]
def test_fit_cosmology():
    """Test fitting cosmology on simulated data."""

    # Generate some fake data.
    cosmo = FlatLambdaCDM(H0=70., Om0=0.25)
    z = np.random.rand(200)
    mb = -19.3 + cosmo.distmod(z).value
    mberr = 0.2 * np.ones_like(z)

    # fit to fake data
    fitted_cosmo = fitting.fit_cosmology(z, mb, mberr)

    # check that fitted H0 value is same as input
    assert_allclose(cosmo.H0.value, fitted_cosmo.H0.value, rtol=1e-4)
开发者ID:nhejazi,项目名称:python-bootcamp,代码行数:16,代码来源:test.py

示例4: LC

# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import distmod [as 别名]
def LC(z, obsfilter, time_resolution = 0.1, absmag_V = -19.3, magsystem = 'ab', modelphase = 0, template = 'salt2'):
    
    cosmo = FlatLambdaCDM(H0=69.6, Om0=0.286)
       #z = 0.05
       #obsfiler = = 'besselb'
    model = sncosmo.Model(source=template)
    model.set(z=0)
    magdiff = model.bandmag('bessellv','vega',[0])-absmag_V
    templatescale = 10**(0.4*magdiff)

    epochs = np.linspace(model.mintime(),model.maxtime(),(model.maxtime()-model.mintime())/time_resolution)
    
    model.set(x0=templatescale,z=z)
    absmag = model.bandmag(obsfilter,magsystem,epochs)
    DM = cosmo.distmod(z)
    obsmag = absmag+DM.value
    return Table([epochs,obsmag],names=('phase', 'mag'))
开发者ID:ufeindt,项目名称:snsurvey,代码行数:19,代码来源:ctime.py

示例5: chisq

# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import distmod [as 别名]
def chisq(params, z, mb, mb_err):
    cosmo = FlatLambdaCDM(H0=params[0], Om0=params[1])
    mb_predicted = cosmo.distmod(z).value - 19.3
    return np.sum(((mb - mb_predicted) / mb_err)**2)
开发者ID:BioXiao,项目名称:python-bootcamp,代码行数:6,代码来源:fitting.py

示例6:

# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import distmod [as 别名]
modelflux_r= 22.5-2.5*np.log10( modelflux[:,2]) - extinction_r
modelflux_i= 22.5-2.5*np.log10( modelflux[:,3]) - extinction_i


d_perp=(modelflux_r-modelflux_i) - (modelflux_g-modelflux_r)/8.



i_cmod_cut= 19.86 + 1.6*(d_perp - 0.8)
d_perp_cut=0.55


weight_cp=table.field('WEIGHT_CP')
icollided=table.field('ICOLLIDED')

distance_modulus=cosmo.distmod(redshift)
Mag_i=i_cmod - distance_modulus - (-0.5)


array=np.column_stack((ra,dec,redshift,weight_cp,polygon,i_cmod,modelflux_g,modelflux_r,modelflux_i,fiberflux_i,distance_modulus,Mag_i))
dimensions=str("ra dec redshift weight_cp polygon i_cmod modelflux_g modelflux_r modelflux_i fiberflux_i distance_modulus Mag_i")


np.savetxt('/hd0/Research/Clustering/Boss/dr11/dr11v2/dr11v2_all.out',array,delimiter='\t',newline='\n',header=str(dimensions),comments=' ')


#this really isn't necessary but it's here anyway

ids=np.where(( i_cmod > 17.5  ) & 
	( i_cmod < 19.9) & 
	( modelflux_r -  modelflux_i < 2 ) & 
开发者ID:jpiscionere,项目名称:BOSS-Clustering,代码行数:33,代码来源:filter_fits_columns_cmass.py

示例7: pecz_to_muerr

# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import distmod [as 别名]
    dzerrsq *= zfacsq/(z*z)
    
    return dzerrsq


#def pecz_to_muerr(z, zerr, pecz=300):
def pecz_to_muerr(*args, **kwargs):
    return np.sqrt(pecz_to_muerrsq(*args, **kwargs))


i_mag_err=np.empty(231)
i_mag_err=i_mag_err.fill(0.01)
cos=FlatLambdaCDM(72,0.28)
z_values=t1["zcmb"] #importing redshifts from file
z_model=np.linspace(0,0.1,1000)+0.001
mu=cos.distmod(z_values).value # distance modulus for data
mu_model=cos.distmod(z_model).value # distance modulus for model
mu_model_err=pecz_to_muerr(z_model,0,pecz=300)

print "pec velocity:" , pecz_to_muerrsq(z_values,0,pecz=300)

intrinsic_dispersion = 0.08
#errsq=i_mag_err*i_mag_err+pecz_to_muerrsq(z_values,0,pecz=300)+intrinsic_dispersion*intrinsic_dispersion
absmagH=np.average(t1["imag"]-mu),#1/errsq)
print "Absolute M: " , absmagH

residuals=t1["imag"]-(mu+absmagH)


plt.errorbar(t1["logM_"],residuals,t1["e_logM_1"]*0,t1["e_logM_1"],'o')
plt.xlabel('Stellar Mass')
开发者ID:yaseminkalender,项目名称:Research_Zyk,代码行数:33,代码来源:sullivian_SNLS.py

示例8: setup_text_plots

# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import distmod [as 别名]
# Note that with usetex=True, fonts are rendered with LaTeX.  This may
# result in an error if LaTeX is not installed on your system.  In that case,
# you can set usetex to False.
from astroML.plotting import setup_text_plots
setup_text_plots(fontsize=8, usetex=True)

#------------------------------------------------------------
# Generate data
# z_sample, mu_sample, dmu = generate_mu_z(100, random_state=0)
z_sample, mu_sample, dmu = generate_mu_z(100, random_state=0, Om0=0.27, H0=71)

# cosmo = Cosmology()
cosmo = Cosmology(Om0=0.27, H0=71)
z = np.linspace(0.01, 2, 1000)
# mu_true = np.asarray([cosmo.mu(zi) for zi in z])
mu_true = np.asarray(cosmo.distmod(z).value)

#------------------------------------------------------------
# fit the data
# Mesh the input space for evaluations of the real function,
# the prediction and its MSE
z_fit = np.linspace(0, 2, 1000)

#------------------------------------------------------------
# using scikit-learn
gp_sk = GaussianProcess(corr='squared_exponential', theta0=1e-1,
                     thetaL=1e-2, thetaU=1,
                     normalize=False,
                     nugget=(dmu / mu_sample) ** 2,
                     random_start=1)
gp_sk.fit(z_sample[:, None], mu_sample)
开发者ID:nhuntwalker,项目名称:mystuff,代码行数:33,代码来源:fig_gp_mu_z_new.py


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