Commit 6a53d6c5 authored by Médéric Boquien's avatar Médéric Boquien
Browse files

Scale the extensive properties to the right distance when computing the χ².

parent f10d9f86
......@@ -165,7 +165,7 @@ def _compute_scaling(model_fluxes, model_propsmass, observation):
def compute_chi2(model_fluxes, model_props, model_propsmass, observation,
corr_dz, lim_flag):
"""Compute the χ² of observed fluxes with respect to the grid of models. We
take into account upper limits if need be. Note that we look over the bands
to avoid the creation of an array of the same size as the model_fluxes
......@@ -183,6 +183,8 @@ def compute_chi2(model_fluxes, model_props, model_propsmass, observation,
observation: Class
Class instance containing the fluxes, intensive properties, extensive
properties and their errors, for a sigle observation.
corr_dz: correction factor to scale the extensive properties to the right
lim_flag: boolean
Boolean indicating whether upper limits should be treated (True) or
discarded (False)
......@@ -222,10 +224,12 @@ def compute_chi2(model_fluxes, model_props, model_propsmass, observation,
if np.isfinite(obs_fluxes[i]) and obs_fluxes_err[i] > 0.:
chi2 += np.square((obs_fluxes[i] - model_fluxes[i, :] * scaling) *
for i in range(obs_propsmass.size):
if np.isfinite(obs_propsmass[i]):
chi2 += np.square((obs_propsmass[i] - model_propsmass[i, :] *
scaling) * (1./obs_propsmass_err[i]))
chi2 += np.square((obs_propsmass[i] - corr_dz * (scaling *
model_propsmass[i, :])) *
for i in range(obs_props.size):
if np.isfinite(obs_props[i]):
......@@ -178,10 +178,9 @@ def analysis(idx, obs):
wz = slice(0, None, 1)
corr_dz = 1.
observation = gbl_obs.observations[idx]
chi2, scaling = compute_chi2(gbl_models.fluxes[:, wz],
gbl_models.intprops[:, wz],
gbl_models.extprops[:, wz], observation,
gbl_models.extprops[:, wz], obs, corr_dz,
if np.any(np.isfinite(chi2)):
......@@ -260,10 +259,11 @@ def bestfit(oidx, obs):
intprops = np.array([[prop] for prop in gbl_obs.intprops])
extprops = np.array([[prop] for prop in gbl_obs.extprops])
corr_dz = compute_corr_dz(obs.redshift, obs.distance)
_, scaling = compute_chi2(fluxes[:, None], intprops[:, None],
extprops[:, None], obs,
extprops[:, None], obs, corr_dz,
corr_dz = compute_corr_dz(obs.redshift, obs.distance)[oidx, :] = [[k] for k in]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment