def tominimize(p): """ Log of posterior probability function """ lnp = lnpriorfn(p) if not np.isfinite(lnp): return (-np.inf) # compute the model brightness profile f = ModelJ1615(p) ModelVal = sampleProfile(f, Rmin, dR, nxy, dxy, u, v) chi2 = chi2compute(ModelVal, Re, Im, w) return (chi2)
def lnpostfnbis(p): """ Log of posterior probability function using less galario (faster)""" lnp = lnpriorfn(p) if not np.isfinite(lnp): return (-np.inf) # compute the model brightness profile f = ModelJ1615(p) ModelVal = sampleProfile(f, Rmin, dR, nxy, dxy, u, v) chi2 = chi2compute(ModelVal, Re, Im, w) return (-0.5 * chi2)
def tominimize(p): """ Only for the classical optimization process """ print(p) lnp = lnpriorfn(p) if not np.isfinite(lnp): return (-np.inf) # compute the model brightness profile f = ModelJ1615(p) ModelVal = sampleProfile(f, Rmin, dR, nxy, dxy, u, v) chi2 = chi2compute(ModelVal, Re, Im, w) return (chi2 / 1000000)
def lnpostfn(p, p_ranges, rmin, dr, nr, nxy, dxy, u, v, re, im, w): """ Log of posterior probability function """ ### apply prior lnprior = lnpriorfn(p, p_ranges) if not np.isfinite(lnprior): return -np.inf ### unpack the parameters f0_a, sigma_a, inc_a, pa_a, dra_a, ddec_a, f0_b, sigma_b, inc_b, pa_b, dra_b, ddec_b = p ### convert to correct units f0_a = 10.**f0_a f0_b = 10.**f0_b sigma_a *= arcsec sigma_b *= arcsec inc_a *= deg inc_b *= deg pa_a *= deg pa_b *= deg dra_a *= arcsec dra_b *= arcsec ddec_a *= arcsec ddec_b *= arcsec ### get gaussian profile f_a = GaussianProfile(f0_a, sigma_a, rmin, dr, nr) f_b = GaussianProfile(f0_b, sigma_b, rmin, dr, nr) ### calculate the visibilities of the two gaussians Vmod_a = g_double.sampleProfile(f_a, rmin, dr, nxy, dxy, u, v, inc=inc_a, PA=pa_a, dRA=dra_a, dDec=ddec_a) Vmod_b = g_double.sampleProfile(f_b, rmin, dr, nxy, dxy, u, v, inc=inc_b, PA=pa_b, dRA=dra_b, dDec=ddec_b) ### calculate the chi2 using the sum of the visibilities chi2 = g_double.reduce_chi2(re, im, w, Vmod_a + Vmod_b) ### return likelihood return -0.5 * chi2 + lnprior