Ejemplo n.º 1
0
def z_grid(n_src, ret_val_1):
    global T, P, theta, phi, s_theta, s_phi
    [z, zL, zR, pL, pR] = MX_producer.Z_maker(T, P, theta, phi, n_src)
    i, j = np.unravel_index(z.argmax(), z.shape)
    plotter.llr_contour(z, T, P, theta, phi, T[i, j], P[i, j], s_theta, s_phi, "MD_C")
    plotter.llr_contour(zL, T, P, theta, phi, T[i, j], P[i, j], s_theta, s_phi, "MD_L")
    plotter.llr_contour(zR, T, P, theta, phi, T[i, j], P[i, j], s_theta, s_phi, "MD_R")
    z_L = zL[i, j]
    z_R = zR[i, j]
    p_L = pL[i, j]
    p_R = pR[i, j]
    Mod_F_c = F_c_F_s.Mod_F_DP_c(theta, phi, T, P)[i, j]
    Mod_F_s = F_c_F_s.Mod_F_DP_s(theta, phi, T, P)[i, j]
    Y = (np.sqrt(z_L) * Mod_F_s * complex(np.cos(p_L), np.sin(p_L))) / (
        np.sqrt(z_R) * Mod_F_c * complex(np.cos(p_R), np.sin(p_R))
    )
    quant1 = np.absolute(((1j * Y) - 1) / (1j * Y + 1))
    print "DP_theta     : ", F_c_F_s.DP_theta(theta, phi, T, P)[i, j]
    print "Mod_F_DP_+   : ", Mod_F_c
    print "Mod_F_DP_x   : ", Mod_F_s
    print "Max LLR      : ", z_L + z_R
    print "rho_L^2      : ", z_L
    print "rho_R^2      : ", z_R
    print "phase_L      : ", p_L
    print "phase_R      : ", p_R
    print "Recov. Loc   : ", T[i, j], P[i, j]
    print "Cos(4 Psi)   : ", np.cos(np.angle(((1j * Y) - 1) / (1j * Y + 1)) + F_c_F_s.DP_theta(theta, phi, T, P)[i, j])
    print "Cos(inc)     : ", ((1 - np.sqrt(quant1)) / (1 + np.sqrt(quant1)))
    ret_val1.put(z)
Ejemplo n.º 2
0
s_theta=np.array(s_theta)
s_phi=np.array(s_phi)

t=np.sort(np.append(t,s_theta))
p=np.sort(np.append(p,s_phi))

#to sum F_c and F_s over all pulsars

[T,P]=np.meshgrid(t,p)
print 'Calculating Log Likelihood pattern'

#calculate X_j via Sesana et. al 2012 eqn 22
x=MX_producer.X_maker(T,P,theta,phi,1)

#calculate inverse of M_jk via Sesana et. al 2012 eqn 22
Mat=MX_producer.M_maker(T,P,theta,phi,1)

print Mat.shape,x.shape

#maximized log likelihood and revoered a_is's
result= 0.5*np.einsum('inm,ijnm,jnm->nm', x, Mat, x)
recovery= np.einsum('ijnm,jnm->inm', Mat, x)
#
#
i,j = np.unravel_index(result.argmax(), result.shape)
print "Max LLR : ",result[i,j]
print "Source  : ",T[i,j],P[i,j]
print "a_i's   : ",recovery[:,i,j]
plotter.llr_contour(result,T,P,theta,phi,T[i,j],P[i,j],s_theta,s_phi,"llr_2")
print "Log Likelihood map saved as \'llr_2.png\'"