Commit f1a8c751 authored by Médéric Boquien's avatar Médéric Boquien

Multiplications are faster than division, so we directly use the inverse error

parent 44625d3d
...@@ -144,17 +144,19 @@ def _compute_scaling(model_fluxes, model_propsmass, obs): ...@@ -144,17 +144,19 @@ def _compute_scaling(model_fluxes, model_propsmass, obs):
num = np.zeros(model_fluxes.shape[1]) num = np.zeros(model_fluxes.shape[1])
denom = np.zeros(model_fluxes.shape[1]) denom = np.zeros(model_fluxes.shape[1])
for i in range(obs.fluxes.size): for i in range(obs.fluxes.size):
# Multiplications are faster than division, so we directly use the
# inverse error
inv_err2 = 1. / obs.fluxes_err[i] ** 2.
if np.isfinite(obs.fluxes[i]) and obs.fluxes_err[i] > 0.: if np.isfinite(obs.fluxes[i]) and obs.fluxes_err[i] > 0.:
num += model_fluxes[i, :] * (obs.fluxes[i] / (obs.fluxes_err[i] * num += model_fluxes[i, :] * (obs.fluxes[i] * inv_err2)
obs.fluxes_err[i]))
denom += np.square(model_fluxes[i, :] * (1./obs.fluxes_err[i])) denom += np.square(model_fluxes[i, :] * (1./obs.fluxes_err[i]))
for i in range(obs.extprops.size): for i in range(obs.extprops.size):
# Multiplications are faster than division, so we directly use the
# inverse error
inv_err2 = 1. / obs.extprops_err[i] ** 2.
if np.isfinite(obs.extprops[i]) and obs.extprops_err[i] > 0.: if np.isfinite(obs.extprops[i]) and obs.extprops_err[i] > 0.:
num += model_propsmass[i, :] * (obs.extprops[i] / num += model_propsmass[i, :] * (obs.extprops[i] * inv_err2)
(obs.extprops_err[i] * denom += model_propsmass[i, :] ** 2. * inv_err2
obs.extprops_err[i]))
denom += np.square(model_propsmass[i, :] *
(1./obs.extprops_err[i]))
return num/denom return num/denom
......
Markdown is supported
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