Exemplo n.º 1
0
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()
Exemplo n.º 2
0
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()
Exemplo n.º 3
0
# 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')
Exemplo n.º 4
0
# Lens position is relative to the ALMA phase center, with +x west (sorry not
# sorry) and +y north, in arcseconds.
lens = [
    vl.SIELens(z=0.8,
               x={
                   'value': -0.5,
                   'fixed': False,
                   'prior': [-1.5, 0.5]
               },
               y={
                   'value': 0.0,
                   'fixed': False,
                   'prior': [-1., 1.]
               },
               M={
                   'value': 2.8e11,
                   'fixed': False,
                   '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]
# Best-fit lens to combined data, sersic + shear
# ALMA xL = 0.806, yL = 3.036 --> xL_atca = 0.253, yL_atca = -0.364
lens = [
    vl.SIELens(z=0.8,
               x={
                   'value': 0.253,
                   'fixed': True,
                   'prior': [-0.221, 0.779]
               },
               y={
                   'value': -0.364,
                   'fixed': True,
                   'prior': [-0.828, 0.172]
               },
               M={
                   'value': 2.811e11,
                   'fixed': True,
                   '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