def einstein_radii(lp1, lp2, sp1, sp2, detA, lambda_t, cosmo, ax, method): """ Calculate Critical Curves, Caustics, and Einstein Radii Input: lp1,lp2[float] : lensing plane x,y-coordinates sp1,sp2[float] : source plane x,y-coordinates """ crit_curve = ax.contour(lp1, lp2, detA, levels=(0, ), colors='r', linewidths=1.5, zorder=200) Ncrit = len(crit_curve.allsegs[0]) crit_curve = crit_curve.allsegs[0] tan_crit_curve = ax.contour(lp1, lp2, lambda_t, levels=(0, ), colors='r', linewidths=1.5, zorder=200) NumTCC = len(tan_crit_curve.allsegs[0]) if NumTCC > 0: # Find tangential critical curve on which to base Rein len_tan_crit = np.zeros(NumTCC) for i in range(NumTCC): len_tan_crit[i] = len(tan_crit_curve.allsegs[0][i]) tan_crit_curve = tan_crit_curve.allsegs[0][len_tan_crit.argmax()] # Einstein Radius if method == 'eqv': Rein = np.sqrt(np.abs(area(tan_crit_curve)) / np.pi) #[arcsec] if method == 'med': dist = np.sqrt(tan_crit_curve[:, 0]**2 + tan_crit_curve[:, 1]**2) Rein = np.median(dist) #[arcsec] # Caustics for pp in range(len(tan_crit_curve)): c1, c2 = (cf.call_mapping_triangles( [tan_crit_curve[pp, 0], tan_crit_curve[pp, 1]], sp1, sp2, lp1, lp2)) if pp == 0: caustic1 = c1 caustic2 = c2 else: caustic1 = np.hstack((caustic1, c1)) caustic2 = np.hstack((caustic2, c2)) caustic = np.array([caustic1, caustic2]).T else: tan_crit_curve = np.array([]) caustic = np.array([]) Rein = 0 return NumTCC, tan_crit_curve, caustic, Rein
def timedelay_magnification(mu_map, phi_map, dsx_arc, Ncells, lp1, lp2, alpha1, alpha2, SrcPosSky, zs, zl, cosmo): """ Calculate Photon-travel-time and Magnification of strong lensed supernovae Input: lp1, lp2: lens place grid coordinates Output: len(mu): number of multiple images of supernova delta_t: Time it takes for photon to cover distance source-observer mu: luminosity magnification of source """ # Mapping light rays from image plane to source plan [sp1, sp2] = [lp1 - alpha1, lp2 - alpha2] #yi1,yi2[arcsec] # Source position [arcsec] #x = SrcPosSky[0]*u.Mpc #y = SrcPosSky[1]*u.Mpc #z = SrcPosSky[2]*u.Mpc #if (y == 0.) and (z == 0.): # beta1 = 1e-3 # beta2 = 1e-3 #else: # beta1 = ((y/x)*u.rad).to_value('arcsec') # beta2 = ((z/x)*u.rad).to_value('arcsec') beta1 = 1e-3 beta2 = 1e-3 #print("Wait here mapping_triangles") theta1, theta2 = cf.call_mapping_triangles([beta1, beta2], lp1, lp2, sp1, sp2) # calculate magnifications of lensed Supernovae #print("Wait here inverse_cic_single") mu = cf.call_inverse_cic_single(mu_map, 0.0, 0.0, theta1, theta2, dsx_arc) # calculate time delays of lensed Supernovae in Days prts = cf.call_inverse_cic_single(phi_map, 0.0, 0.0, theta1, theta2, dsx_arc) Kc = ((1.0+zl)/const.c.to('Mpc/s') * \ (cosmo.angular_diameter_distance(zl) * \ cosmo.angular_diameter_distance(zs) / \ (cosmo.angular_diameter_distance(zs) - \ cosmo.angular_diameter_distance(zl)))).to('sday').value delta_t = Kc*(0.5*((theta1 - beta1)**2.0 + (theta2 - beta2)**2.0) - prts)/cf.apr**2 beta = [beta1, beta2] theta = [theta1, theta2] return len(mu), delta_t, mu, theta, beta
def timedelay_magnification(mu_map, phi_map, dsx_arc, Ncells, lp1, lp2, alpha1, alpha2, SrcPosSky, zs, zl, cosmo): """ Calculate Photon-travel-time and Magnification of strong lensed supernovae Input: FOV: Field-of-View [Mpc] Ncells: number of cells for grid on FOV kappa: convergence map SrcPosSky: Position of Source relative to Lens [Mpc] zs: Redshift of Source zl: Redshift of Lens cosmo: Cosmology Output: len(mu): number of multiple images of supernova delta_t: Time it takes for photon to cover distance source-observer mu: luminosity magnification of source """ # Mapping light rays from image plane to source plan [sp1, sp2] = [lp1 - alpha1, lp2 - alpha2] #yi1,yi2[arcsec] # Source position [arcsec] x = SrcPosSky[0]*u.Mpc y = SrcPosSky[1]*u.Mpc z = SrcPosSky[2]*u.Mpc beta1 = ((y/x)*u.rad).to_value('arcsec') beta2 = ((z/x)*u.rad).to_value('arcsec') theta1, theta2 = cf.call_mapping_triangles([beta1, beta2], lp1, lp2, sp1, sp2) # calculate magnifications of lensed Supernovae mu = cf.call_inverse_cic_single(mu_map, 0.0, 0.0, theta1, theta2, dsx_arc) # calculate time delays of lensed Supernovae in Days prts = cf.call_inverse_cic_single(phi_map, 0.0, 0.0, theta1, theta2, dsx_arc) Kc = ((1.0+zl)/const.c.to('Mpc/s') * \ (cosmo.angular_diameter_distance(zl) * \ cosmo.angular_diameter_distance(zs) / \ (cosmo.angular_diameter_distance(zs) - \ cosmo.angular_diameter_distance(zl)))).to('sday').value delta_t = Kc*(0.5*((theta1 - beta1)**2.0 + (theta2 - beta2)**2.0) - prts)/cf.apr**2 beta = [beta1, beta2] theta = [theta1, theta2] return len(mu), delta_t, mu, theta, beta
def timedelay_magnification(mu_map, phi_map, dsx_arc, Ncells, lp1, lp2, alpha1, alpha2, beta, zs, zl, cosmo): """ Input: mu_map: 2D magnification map phi_map: 2D potential map dsx_arc: cell size in arcsec Ncells: number of cells lp1, lp2: lens place grid coordinates alpha1, alpha2: 2D deflection map SrcPosSky: source position in Mpc zs: source redshift zl: lens redshift Output: len(mu): number of multiple images of supernova delta_t: Time it takes for photon to cover distance source-observer mu: luminosity magnification of source """ # Mapping light rays from image plane to source plan [sp1, sp2] = [lp1 - alpha1, lp2 - alpha2] #[arcsec] theta1, theta2 = cf.call_mapping_triangles([beta[0], beta[1]], lp1, lp2, sp1, sp2) # calculate magnifications of lensed Supernovae mu = cf.call_inverse_cic_single(mu_map, 0.0, 0.0, theta1, theta2, dsx_arc) # calculate time delays of lensed Supernovae in Days prts = cf.call_inverse_cic_single(phi_map, 0.0, 0.0, theta1, theta2, dsx_arc) Kc = ((1.0+zl)/const.c.to('Mpc/s') * \ (cosmo.angular_diameter_distance(zl) * \ cosmo.angular_diameter_distance(zs) / \ (cosmo.angular_diameter_distance(zs) - \ cosmo.angular_diameter_distance(zl)))).to('sday').value delta_t = Kc*(0.5*((theta1 - beta[0])**2.0 + \ (theta2 - beta[1])**2.0) - prts)/cf.apr**2 theta = np.array([theta1, theta2]).T return len(mu), delta_t, mu, theta