Commit 0611f291 authored by Médéric Boquien's avatar Médéric Boquien
Browse files

Attempt to fix the upper limit by revert a clearly wrong commit from 2014...

Attempt to fix the upper limit by revert a clearly wrong commit from 2014 which did the opposite of what was said in the comment …
parent 3f8a1282
......@@ -182,7 +182,7 @@ def save_table_best(filename, obsid, chi2, chi2_red, variables, fluxes,
delimiter=None)
def dchi2_over_ds2(s):
def dchi2_over_ds2(s, obs_fluxes, obs_errors, mod_fluxes):
"""Function used to estimate the normalization factor in the SED fitting
process when upper limits are included in the dataset to fit (from Eq. A11
in Sawicki M. 2012, PASA, 124, 1008).
......@@ -214,17 +214,17 @@ def dchi2_over_ds2(s):
# The mask "lim" selects the filter(s) for which upper limits are given
# i.e., when obs_fluxes is >=0. and obs_errors = 9990 <= obs_errors < 0.
wlim = np.where((gbl_obs_errors >= -9990.) & (gbl_obs_errors < 0.))
wdata = np.where(gbl_obs_errors >= 0.)
wlim = np.where((obs_errors >= -9990.) & (obs_errors < 0.))
wdata = np.where(obs_errors >= 0.)
mod_fluxes_data = gbl_mod_fluxes[wdata]
mod_fluxes_lim = gbl_mod_fluxes[wlim]
mod_fluxes_data = mod_fluxes[wdata]
mod_fluxes_lim = mod_fluxes[wlim]
obs_fluxes_data = gbl_obs_fluxes[wdata]
obs_fluxes_lim = gbl_obs_fluxes[wlim]
obs_fluxes_data = obs_fluxes[wdata]
obs_fluxes_lim = obs_fluxes[wlim]
obs_errors_data = gbl_obs_errors[wdata]
obs_errors_lim = -gbl_obs_errors[wlim]
obs_errors_data = obs_errors[wdata]
obs_errors_lim = -obs_errors[wlim]
dchi2_over_ds_data = np.sum(
(obs_fluxes_data-s*mod_fluxes_data) *
......
......@@ -259,7 +259,7 @@ def analysis(idx, obs):
np.sum(model_fluxes * model_fluxes / (obs_errors * obs_errors), axis=1)
)
if lim_flag is True:
if lim_flag == True:
for imod in range(len(model_fluxes)):
norm_facts[imod] = optimize.newton(dchi2_over_ds2,
norm_facts[imod], tol=1e-16,
......
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