def params_to_chi2(params_modelo,Mabs):
    '''Dados los parámetros del modelo devuelve un chi2'''

    [b,c,d,r_0,n] = params_modelo

    def dX_dz(z, variables):
        x = variables[0]
        y = variables[1]
        v = variables[2]
        w = variables[3]
        r = variables[4]

        G = gamma(r,b,c,d,n)

        s0 = (-w + x**2 + (1+v)*x - 2*v + 4*y) / (z+1)
        s1 = - (v*x*G - x*y + 4*y - 2*y*v) / (z+1)
        s2 = -v * (x*G + 4 - 2*v) / (z+1)
        s3 = w * (-1 + x+ 2*v) / (z+1)
        s4 = -x*r*G/(1+z)
        return [s0,s1,s2,s3,s4]

    z,E = integrador(dX_dz,ci, params_modelo)
    os.chdir(path_git+'/Software/Estadística/')
    zcmb,zhel, Cinv, mb = leer_data_pantheon('lcparam_full_long_zhel.txt')
    muth = magn_aparente_teorica(z,E,zhel,zcmb)

    if isinstance(Mabs,list):
        chis_M = np.zeros(len(Mabs))
        for i,M_0 in enumerate(Mabs):
            chis_M[i] = chi_2(muth,mb,M_0,Cinv)
        return chis_M
    else:
        chi2 = chi_2(muth,mb,Mabs,Cinv)
        return chi2
Exemple #2
0
import os
from os.path import join as osjoin
from pc_path import definir_path

path_git, path_datos_global = definir_path()
os.chdir(path_git)
sys.path.append('./Software/Funcionales/')
from funciones_sampleo import MCMC_sampler
from funciones_data import leer_data_pantheon, leer_data_cronometros, leer_data_BAO, leer_data_AGN
from funciones_alternativos import params_to_chi2
#ORDEN DE PRESENTACION DE LOS PARAMETROS: Mabs,omega_m,b,H_0,n

#%%
## Supernovas
os.chdir(path_git + '/Software/Estadística/Datos/Datos_pantheon/')
ds_SN = leer_data_pantheon('lcparam_full_long_zhel.txt')

# Cronómetros
os.chdir(path_git + '/Software/Estadística/Datos/')
ds_CC = leer_data_cronometros('datos_cronometros.txt')

# BAO
os.chdir(path_git + '/Software/Estadística/Datos/BAO/')
ds_BAO = []
archivos_BAO = [
    'datos_BAO_da.txt', 'datos_BAO_dh.txt', 'datos_BAO_dm.txt',
    'datos_BAO_dv.txt', 'datos_BAO_H.txt'
]
for i in range(5):
    aux = leer_data_BAO(archivos_BAO[i])
    ds_BAO.append(aux)
Exemple #3
0
#ORDEN DE PRESENTACION DE LOS PARAMETROS: Mabs,omega_m,b,H_0,n

#%% Predeterminados:
n = 1
#Coindiciones iniciales e intervalo
x_0 = -0.339
y_0 = 1.246
v_0 = 1.64
w_0 = 1 + x_0 + y_0 - v_0
r_0 = 41
ci = [x_0, y_0, v_0, w_0, r_0]  #Condiciones iniciales
#%%

os.chdir(path_git + '/Software/Estadística/Datos/Datos_pantheon/')
zcmb, zhel, Cinv, mb = leer_data_pantheon('lcparam_full_long_zhel.txt')
#%%
#Parametros a ajustar
M_true = -19.6
omega_m_true = 0.26
b_true = -1.2
H0_true = 73  #73.48 #Unidades de (km/seg)/Mpc

#%%
np.random.seed(42)
nll = lambda theta: params_to_chi2(ci, theta, n, zcmb, zhel, Cinv, mb)
initial = np.array([M_true, omega_m_true, b_true, H0_true])
soln = minimize(nll,
                initial,
                bounds=((-20, -18), (0.2, 0.3), (None, None),
                        (60, 80)))  #,options = {'eps': 0.001})
Exemple #4
0
import os
from os.path import join as osjoin
from pc_path import definir_path
path_git, path_datos_global = definir_path()
os.chdir(path_git)
sys.path.append('./Software/Funcionales/')
from funciones_data import leer_data_pantheon
from funciones_LambdaCDM_1 import params_to_chi2
#%%

min_z = 0
max_z = 3

os.chdir(path_git + '/Software/Estadística/Datos/Datos_pantheon/')
zcmb, zhel, Cinv, mb = leer_data_pantheon('lcparam_full_long_zhel.txt',
                                          min_z=min_z,
                                          max_z=max_z)
sn = len(zcmb)
Cinv.shape

#%%
#Parametros a ajustar
H0_true = 73.5  #Unidades de (km/seg)/Mpc
M_true = -19.22

# Calculo el chi 2
omegas = np.linspace(0, 1, 100)
chies = np.zeros((len(omegas)))
for i, omega_m in enumerate(omegas):
    theta = omega_m
    chies[i] = params_to_chi2(theta, [M_true, H0_true], zcmb, zhel, Cinv,
    H0_true = 73.48  #Unidades de (km/seg)/Mpc
    alpha_true = 0.154
    beta_true = 3.02
    gamma_true = 0.053
    n = 1

    params_fijos = [H0_true, n]
    theta = [M_true, omega_m_true, b_true]

    #%%
    #Datos de SN
    os.chdir(path_git + '/Software/Estadística/Datos/Datos_pantheon/')

    _, zcmb, zhel, Cinv, mb0, x1, cor, hmass = leer_data_pantheon_2(
        'lcparam_full_long_zhel.txt', 'ancillary_g10.txt')
    zcmb_1, zhel_1, Cinv_1, mb_1 = leer_data_pantheon(
        'lcparam_full_long_zhel.txt')

    params_to_chi2(theta, params_fijos, zcmb, zhel, Cinv, mb_1)
    #%%
    np.all(zhel_1 == zhel)
    np.where(zcmb_1 == zcmb)
    zcmb
    zcmb_1
    alpha_0 = 0.154
    beta_0 = 3.02
    gamma_0 = 0.053
    mstep0 = 10.13
    tau0 = 0.001
    from matplotlib import pyplot as plt
    plt.figure()
    plt.plot(hmass,