def update(val): zL, zS = slzL.val, slzS.val xL, yL = slxL.val, slyL.val ML, eL, PAL = slML.val, sleL.val, slPAL.val sh, sha = slss.val, slsa.val xs, ys = slxs.val, slys.val Fs, ws = slFs.val, slws.val ns, ars, pas = slns.val, slars.val, slPAs.val newDd = cosmo.angular_diameter_distance(zL).value newDs = cosmo.angular_diameter_distance(zS).value newDds = cosmo.angular_diameter_distance_z1z2(zL, zS).value newLens = vl.SIELens(zLens, xL, yL, 10**ML, eL, PAL) newShear = vl.ExternalShear(sh, sha) newSource = vl.SersicSource(zS, True, xs, ys, Fs, ws, ns, ars, pas) xs, ys = vl.LensRayTrace(xim, yim, [newLens, newShear], newDd, newDs, newDds) imbg = vl.SourceProfile(xim, yim, newSource, [newLens, newShear]) imlensed = vl.SourceProfile(xs, ys, newSource, [newLens, newShear]) caustics = vl.CausticsSIE(newLens, newDd, newDs, newDds, newShear) ax.cla() ax.imshow(imbg, cmap=cmbg, extent=[xim.min(), xim.max(), yim.min(), yim.max()], origin='lower') ax.imshow(imlensed, cmap=cmlens, extent=[xim.min(), xim.max(), yim.min(), yim.max()], origin='lower') mu = imlensed.sum() * (xim[0, 1] - xim[0, 0])**2 / newSource.flux['value'] ax.text(0.9, 1.02, '$\\mu$ = {0:.2f}'.format(mu), transform=ax.transAxes) #for i in range(caustics.shape[0]): # ax.plot(caustics[i,0,:],caustics[i,1,:],'k-') for caustic in caustics: ax.plot(caustic[:, 0], caustic[:, 1], 'k-') f.canvas.draw_idle()
def update(val): zL,zS = slzL.val,slzS.val xL,yL = slxL.val, slyL.val ML,eL,PAL = slML.val,sleL.val,slPAL.val sh,sha = slss.val,slsa.val newDd = cosmo.angular_diameter_distance(zL).value newDs = cosmo.angular_diameter_distance(zS).value newDds= cosmo.angular_diameter_distance_z1z2(zL,zS).value newLens = vl.SIELens(zLens,xL,yL,10**ML,eL,PAL) newShear = vl.ExternalShear(sh,sha) xsource,ysource = vl.LensRayTrace(xim,yim,[newLens,newShear],newDd,newDs,newDds) caustics = vl.get_caustics([newLens,newShear],newDd,newDs,newDds) ax.cla() ax.plot(xsource,ysource,'b-') for caustic in caustics: ax.plot(caustic[:,0],caustic[:,1],'k-') #ax.set_xlim(-0.5,0.5) #ax.set_ylim(-0.5,0.5) #for i in range(len(xs)): # p[i].set_xdata(xs[i]) # p[i].set_ydata(ys[i]) f.canvas.draw_idle()
# Just a quick demo script to help build intuition about lensing. xim = np.arange(-2., 2., .02) yim = np.arange(-2., 2., .02) xim, yim = np.meshgrid(xim, yim) zLens, zSource = 0.8, 5.656 xLens, yLens = 0., 0. MLens, eLens, PALens = 2.87e11, 0.5, 70. xSource, ySource, FSource = 0.216, 0.24, 0.02 # arcsec, arcsec, Jy aSource, nSource, arSource, PAsource = 0.1, 0.5, 1.0, 120. - 90 # arcsec,[],[],deg CCW from x-axis shear, shearangle = 0.12, 120. Lens = vl.SIELens(zLens, xLens, yLens, MLens, eLens, PALens) Shear = vl.ExternalShear(shear, shearangle) Source = vl.SersicSource(zSource, True, xSource, ySource, FSource, aSource, nSource, arSource, PAsource) Dd = cosmo.angular_diameter_distance(zLens).value Ds = cosmo.angular_diameter_distance(zSource).value Dds = cosmo.angular_diameter_distance_z1z2(zLens, zSource).value xsource, ysource = vl.LensRayTrace(xim, yim, [Lens, Shear], Dd, Ds, Dds) imbg = vl.SourceProfile(xim, yim, Source, [Lens, Shear]) imlensed = vl.SourceProfile(xsource, ysource, Source, [Lens, Shear]) caustics = vl.CausticsSIE(Lens, Dd, Ds, Dds, Shear) f = pl.figure(figsize=(12, 6)) ax = f.add_subplot(111, aspect='equal') pl.subplots_adjust(right=0.48, top=0.97, bottom=0.03, left=0.05)
from astropy.cosmology import Planck15 as cosmo import matplotlib.pyplot as pl pl.ioff() xim = np.arange(-3, 3, .03) yim = np.arange(-3, 3, .03) xim, yim = np.meshgrid(xim, yim) zLens, zSource = 0.8, 5.656 xLens, yLens = 0., 0. MLens, eLens, PALens = 2.87e11, 0.5, 90. xSource, ySource, FSource, sSource = 0.216, -0.24, 0.023, 0.074 Lens = vl.SIELens(zLens, xLens, yLens, MLens, eLens, PALens) Shear = vl.ExternalShear(0., 0.) lens = [Lens, Shear] Source = vl.GaussSource(zSource, True, xSource, ySource, FSource, sSource) Dd = cosmo.angular_diameter_distance(zLens).value Ds = cosmo.angular_diameter_distance(zSource).value Dds = cosmo.angular_diameter_distance_z1z2(zLens, zSource).value caustics = vl.get_caustics(lens, Dd, Ds, Dds) xsource, ysource = vl.LensRayTrace(xim, yim, lens, Dd, Ds, Dds) f = pl.figure() ax = f.add_subplot(111, aspect='equal') pl.subplots_adjust(bottom=0.25, top=0.98) ax.plot(xsource, ysource, 'b-') for caustic in caustics:
'prior': [1e9, 1e13] }, e={ 'value': 0.51, 'fixed': False, 'prior': [0., 0.8] }, PA={ 'value': 70.9, 'fixed': False, 'prior': [0, 180] }), vl.ExternalShear(shear={ 'value': 0.12, 'prior': [0., 0.5] }, shearangle={ 'value': 122., 'prior': [0., 180.] }) ] # We define a Sersic profile source which will be lensed by the above. # For lensed sources, their positions are relative to the position of # the lens we defined earlier. Flux is in Jy (because our data # amplitudes are also in Jy), and the source major axis is in arcsec. # You can add additional source profiles similar to this if the data # you're modeling aren't well-fit with a single source. You can also # include "unlensed" sources in the field by setting lensed=False, in # which case the position is relative to the ALMA phase center. source = [ vl.SersicSource(
'prior': [1e10, 5e13] }, e={ 'value': 0.515, 'fixed': True, 'prior': [0.4, 0.6] }, PA={ 'value': 70.90, 'fixed': True, 'prior': [60, 95] }), vl.ExternalShear(shear={ 'value': 0.119, 'fixed': True }, shearangle={ 'value': 122.13, 'fixed': True }) ] # We're just going to model the source as a simple symmetric Gaussian src = vl.GaussSource(z=5.65, xoff={ 'value': 0.142, 'fixed': False, 'prior': [-1., 1.] }, yoff={ 'value': 0.30, 'fixed': False,