def lnlike2(par, data_table, ebv_map=0, gaussian_ebv=False, return_fit=False): g1, Teff1, g2, Teff2, EBV, sig_ext = par if (g1 <= 5) or (g1 > 25): return -np.inf if (g2 <= 5) or (g2 > 25): return -np.inf if (Teff1 <= 3450) or (Teff1 > 8600): return -np.inf if (Teff2 <= 3450) or (Teff2 > 8600): return -np.inf if (sig_ext < 0): return -np.inf if (EBV < 0): return -np.inf if gaussian_ebv: j = np.where(data_table['type'] == 'ebv') v = data_table['value'][j] s = data_table['error'][j] lnprior = -0.5 * np.sum(((v - EBV) / s)**2) elif (EBV > ebv_map): lnprior = -0.5 * ((EBV - ebv_map) / 0.034)**2 else: lnprior = 0.0 t = synth_binary(g1, Teff1, g2, Teff2, EBV) j = joinTables(data_table, t, keys=("band", "type")) wt = weights(j, sig_ext) z2 = (j["value_1"] - j["value_2"])**2 * wt j.add_column(Column(np.sqrt(z2), name="z", format="%.2f")) if return_fit: return j else: lnlike = -0.5 * (np.sum(z2 - np.log(wt))) if np.isfinite(lnlike): return lnlike + lnprior else: return -np.inf
def chisqd(param, data_table, sig_ext): g1, Teff1, dg, Teff2, EBV = param g2 = g1 + dg t = synth_binary(g1, Teff1, g2, Teff2, EBV) j = joinTables(data_table, t, keys=["band", "type"]) c = np.sum((j["value_1"] - j["value_2"])**2 * weights(j, sig_ext)) return c
def lnlike3(par, data_table, ebv_map=0, ms_interp=None, gaussian_ebv=False, return_fit=False): g1, Teff1, g2, Teff2, g3, Teff3, EBV, sig_ext = par if (g1 <= 5) or (g1 > 25): return -np.inf if (g2 <= 5) or (g2 > 25): return -np.inf if (g3 <= 5) or (g3 > 25): return -np.inf if (Teff1 <= 3450) or (Teff1 > 8600): return -np.inf if (Teff2 <= 3450) or (Teff2 > 8600): return -np.inf if (Teff3 <= 3450) or (Teff3 > 8600): return -np.inf if (sig_ext < 0): return -np.inf if (EBV < 0): return -np.inf if gaussian_ebv: j = np.where(data_table['type'] == 'ebv') v = data_table['value'][j] s = data_table['error'][j] lnprior = -0.5 * np.sum(((v - EBV) / s)**2) elif (EBV > ebv_map): lnprior = -0.5 * ((EBV - ebv_map) / 0.033)**2 else: lnprior = 0.0 if ms_interp is not None: g_ZAMS_3, g_TAMS_3 = ms_interp(Teff3) if g2 > g1: g_ZAMS_B, g_TAMS_B = ms_interp(Teff2) if ((g3 - g2) < (g_ZAMS_3 - g_ZAMS_B)): return -np.inf if ((g3 - g2) > (g_TAMS_3 - g_TAMS_B)): return -np.inf else: g_ZAMS_B, g_TAMS_B = ms_interp(Teff1) if ((g3 - g1) < (g_ZAMS_3 - g_ZAMS_B)): return -np.inf if ((g3 - g1) > (g_TAMS_3 - g_TAMS_B)): return -np.inf t = synth_triple(g1, Teff1, g2, Teff2, g3, Teff3, EBV) j = joinTables(data_table, t, keys=("band", "type")) wt = weights(j, sig_ext) z2 = (j["value_1"] - j["value_2"])**2 * wt j.add_column(Column(np.sqrt(z2), name="Z", format="%.3f")) if return_fit: return j else: lnlike = -0.5 * (np.sum(z2 - np.log(wt))) if np.isfinite(lnlike): return lnlike + lnprior else: return -np.inf
def chisq3(param, data_table, sig_ext): g1, Teff1, g2, Teff2, g3, Teff3, EBV = param t = synth_triple(g1, Teff1, g2, Teff2, g3, Teff3, EBV) j = joinTables(data_table, t, keys=["band", "type"]) c = np.sum((j["value_1"] - j["value_2"])**2 * weights(j, sig_ext)) return c
def chisq1(param, data_table, sig_ext): g1, Teff1, EBV = param t = gTeff_to_magTable(g1, Teff1, EBV) j = joinTables(data_table, t, keys=["band", "type"]) c = np.sum((j["value_1"] - j["value_2"])**2 * weights(j, sig_ext)) return c