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


Python FlatLambdaCDM.lookback_time方法代码示例

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


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

示例1: range

# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import lookback_time [as 别名]
    
    for e in range(41):
        EBV = 0.025*e
        for j in range(115, 195, 3):#107 = 50Myr, 69 = 10Myr
     
            wavs, sfd = sp.get_spectrum(tage=ages[j])
            spectrum = np.array([wavs, sfd]).T
            spectrum[:,1] = spectrum[:,1]*(3.83*10**33)*10**(-EBV*coef/2.5) #erg/s/Hz
            spectrum[:,1] = spectrum[:,1]*(3*10**18)/spectrum[:,0]/spectrum[:,0] #erg/s/A
            synmags = np.zeros(13*700, dtype="float")
            synmags.shape = (700, 13)
            synmags[:,0] = np.arange(0.01, 7.01, 0.01)

            for i in range(1, 701):
                z = 0.01*i
                if ages[j]*(10**-9) < 14.00 - cosmo.lookback_time(z).value:
                    print "Calculating colours for age: " + str(ages[j]) + " and redshift: " + str(z) + ", total age: " + str(ages[j]*(10**-9) + cosmo.lookback_time(z).value) + ", tau = " + tauvals[t]
                    zspectrum = np.copy(spectrum)
                    for k in range(len(zspectrum)):
                        if zspectrum[k,0] < 912.:
                            zspectrum[k,1] = 0.
                        elif zspectrum[k,0] > 912. and zspectrum[k,0] < 1026.:
                            zspectrum[k,1] = zspectrum[k,1]*(1-D[i-1,1])
                        elif zspectrum[k,0] > 1026. and zspectrum[k,0] < 1216.:
                            zspectrum[k,1] = zspectrum[k,1]*(1-D[i-1,0])
                    zspectrum[:,1] = zspectrum[:,1]/(4*np.pi*(cosmo.luminosity_distance(z)*3.086*10**24)**2) #convert to observed flux at given redshift in erg/s/A/cm^2
                    zspectrum[:,1] = zspectrum[:,1]/(1+z) #reduce flux by a factor of 1/(1+z)   to account for redshifting
                    zspectrum[:,0] = zspectrum[:,0]*(1+z) #change wavelength values to account for redshifting

                    th_mags = s.AB_mags_UDS(zspectrum)
                    synmags[i-1, 1:] = th_mags
开发者ID:ACCarnall,项目名称:SED_fitting,代码行数:33,代码来源:model_mags_make_fsps.py

示例2: str

# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import lookback_time [as 别名]
        offset_errs[0, i, 0] = 0.

all_obj_fluxes = all_obj_fluxes/offsets
all_obj_fluxerrs = all_obj_fluxes*np.sqrt((all_obj_fluxerrs/all_obj_fluxes)**2 + (offset_errs/offsets**3)**2)
"""

### Build array for photometric redshift and parameter outputs
output = np.zeros(len(all_obj_fluxes)*11, dtype="float")
output.shape = (len(all_obj_fluxes), 11)
output[:,10] = 9999999999999999999.


### output = np.loadtxt("photoz_V_" + str(foldmin) + "_" + str(foldmax) + ".txt")   

zarr = np.arange(0.01, 7.01, 0.01)
lbtarr = cosmo.lookback_time(zarr).value

### Perform model fitting using a 2D chi squared array over object and redshift with max age of stellar pop phy sically determined

for j in range(8):
    arg = 0
    while oldages[j]*(10**-9) < 14.0 - lbtarr[arg] and arg < 699:
        arg = arg+1
    for k in range(41):
        EBV = 0.025*k
        print "Initial burst age: " + str(oldages[j]) + ", EBV: " + str(EBV)
        for l in range(8):
        
            th_flux_array_old_raw = np.loadtxt("../../models/spec/burst_" + model_type + "/synmagsUDS_age_" + str(oldages[j]) + "_EBV_" + str(EBV) + ".txt")[:, :arg+1]
            th_flux_array_new_raw = np.loadtxt("../../models/spec/const_" + model_type + "/synmagsUDS_age_" + str(newages[l]) + "_EBV_" + str(EBV) + ".txt")[:, :arg+1] ######_new 
            
开发者ID:ACCarnall,项目名称:SED_fitting,代码行数:32,代码来源:fitspec_specplusphot.py

示例3: range

# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import lookback_time [as 别名]
    elif oldwavs[j] < 0.63:
        oldcoef[j] = 2.659*(-2.156 + (1.509/oldwavs[j]) - (0.198/(oldwavs[j]**2)) + (0.011/(oldwavs[j]**3))) + 4.05
    else:
        oldcoef[j] = 2.659*(-1.857 + (1.040/oldwavs[j])) + 4.05


if sys_arg < 8:
    for e in range(41):
        EBV = 0.025*e
        for j in range(sys_arg, sys_arg+1):
            newspectrum = np.array([newspecdata[0, :], newspecdata[newagevals[j]+1, :]]).T
            newsynmags = np.copy(newsynmags_raw)
            newagenorms = np.copy(newagenorms_raw)
            for i in range(0, 700):
                z = zarr[i]
                if newages[newagevals[j]]*(10**-9) < 14.00 - cosmo.lookback_time(z).value:
                    print "Calculating colours for EBV: " + str(EBV) + ", age: " + str(newages[newagevals[j]]) + " and redshift: " + str(z)
                    newzspectrum = np.copy(newspectrum)
                    newzspectrum[:,1] = newzspectrum[:,1]*10**(-EBV*newcoef/2.5)

                    for k in range(len(newzspectrum)):
                        if newzspectrum[k,0] < 912.:
                            newzspectrum[k,1] = 0.
                        elif newzspectrum[k,0] > 912. and newzspectrum[k,0] < 1026.:
                            newzspectrum[k,1] = newzspectrum[k,1]*(1-D[int(z/0.01 - 1),1])#*(1-D[int(z/0.01 - 1),0])
                        elif newzspectrum[k,0] > 1026. and newzspectrum[k,0] < 1216.:
                            newzspectrum[k,1] = newzspectrum[k,1]*(1-D[int(z/0.01 - 1),0])
                            
                    newzspectrum[:,1] = newzspectrum[:,1]*3.826*10**33 #luminosity in erg/s/A
                    newzspectrum[:,1] = newzspectrum[:,1]/(4*np.pi*(cosmo.luminosity_distance(z).value*3.086*10**24)**2) #convert to observed flux at given redshift in erg/s/A/cm^2
                    newzspectrum[:,1] = newzspectrum[:,1]/(1+z) #reduce flux by a factor of 1/(1+z) to account for redshifting
开发者ID:mahmoud-lsw,项目名称:SED_fitting,代码行数:33,代码来源:model_mags_make_2c_UDS.py

示例4: open

# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import lookback_time [as 别名]
SED_file = open(SEDpath+"P94_Chab_zsun_t10.00Gyr_noabs/P94_Chab_zsun_t10.00Gyr_noabs.ised_ASCII")
ages = np.array(SED_file.readline().split(), dtype="float")[1:] #ages[0] = 0.
SED_file.close()


galcat = np.zeros(28000)
galcat.shape = (1000, 28)


for i in range(1000):
    zseed = int(r.random()*699)
    tauseed = int(r.random()*10)
    ageseed = 3*int(r.random()*29) + 108
    EBVseed = int(r.random()*41)
    
    while ages[ageseed]*(10**-9) > 14.00 - cosmo.lookback_time((zseed+1)*0.01).value:
        zseed = int(r.random()*699)
        ageseed = 3*int(r.random()*29) + 108
        EBVseed = int(r.random()*41)
        tauseed = int(r.random()*10)
    
    galcat[i,:4] = np.array([(zseed + 1)*0.01, float(tauvals[tauseed]), ages[ageseed], 0.025*EBVseed])
    galcat[i,4:16] = np.loadtxt("../models/tau/" + tauvals[tauseed] + "/synmags_age_" + str(ages[ageseed]) + "_EBV_" + str(0.025*EBVseed) + ".txt")[zseed, 1:]
    

galcat_flux_noerr = np.copy(galcat)

galcat_flux_noerr[:,4:16] = 10**((23.9 - galcat_flux_noerr[:,4:16])/2.5)


for j in range(12):
开发者ID:ACCarnall,项目名称:SED_fitting,代码行数:33,代码来源:fake_cat_builder.py

示例5: FlatLambdaCDM

# 需要导入模块: from astropy.cosmology import FlatLambdaCDM [as 别名]
# 或者: from astropy.cosmology.FlatLambdaCDM import lookback_time [as 别名]
from astropy.cosmology import FlatLambdaCDM
from astropy import units as u

from scipy.interpolate import interp1d
from scipy.optimize import curve_fit

import pandas as pd

import gc


# Set a function that returns the redshift for a given look-back time
model = FlatLambdaCDM(H0=70, Om0=0.3)
z = np.linspace(0.0, 20.0, 1000)
t = model.lookback_time(z)

redshift_from_time = interp1d(t.value, z)


def analytical_mass_metallicity(z, stellar_mass):
    """Analytical mass-metallicty relationship as computed by Maiolino 2008

    Args:
        z: redshift, valid values are 0.07, 0.7, 2.2 and 3.5
        stellar_mass: stellar mass in MSun

    Returns:
        Oxygen abundance in 12 + log10(O/H)
    """
开发者ID:lbignone,项目名称:pygadget,代码行数:31,代码来源:mass_metallicity.py


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