Ejemplo n.º 1
0
def plot_with_mask_4(nmodes=900,
                     alpha=0.15,
                     RAmin = 10,
                     DECmin = 35,
                     xlim=(0,60),
                     ylim=(0,60),
                     plot_SN=False):
    RAlim = (RAmin,RAmin+1)
    DEClim = (DECmin,DECmin+1)
    
    gamma_out_masked, noise = get_reconstruction(nmodes,
                                                 alpha,
                                                 True,
                                                 RAmin,
                                                 DECmin)
    
    gamma_out_unmasked, noise = get_reconstruction(nmodes,
                                                   alpha,
                                                   False,
                                                   RAmin,
                                                   DECmin)
    

    if plot_SN:
        gamma_out_masked /= numpy.sqrt(noise_masked)
        gamma_out_unmasked /= numpy.sqrt(noise_unmasked)
    
    diff1 = gamma_out_masked-gamma_out_unmasked
    rms1 = numpy.sqrt(numpy.mean(abs(diff1[10:50,10:50])**2))
    
    mask = get_mask(False,RAlim,DEClim)

    gamma_true = get_from_parsed('gamma',RAlim=RAlim,DEClim=DEClim)
    
    diff2 = gamma_out_unmasked-gamma_true
    rms2 = numpy.sqrt(numpy.mean(abs(diff2[10:50,10:50])**2))
    
    diff3 = gamma_out_masked-gamma_true
    rms3 = numpy.sqrt(numpy.mean(abs(diff3[10:50,10:50])**2))

    assert gamma_out_unmasked.shape == gamma_true.shape

    dtheta = params.dtheta

    RAside = (RAlim[1]-RAlim[0])*60
    DECside = (DEClim[1]-DEClim[0])*60

    pylab.figure( figsize=(10,10) )
    #----------------------------------------
    
    pylab.subplot(221)
    pylab.imshow(mask.T*0,
                 origin='lower',
                 extent=(0,RAside,0,DECside),
                 interpolation='nearest',
                 cmap=pylab.cm.binary)
    pylab.clim(0,1)
    whiskerplot(gamma_true,params.dtheta,params.dtheta)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    pylab.title('shear field (noiseless)')

    #----------------------------------------

    pylab.subplot(222)
    pylab.imshow(mask.T*0,
                 origin='lower',
                 extent=(0,RAside,0,DECside),
                 interpolation='nearest',
                 cmap=pylab.cm.binary)
    pylab.clim(0,1)
    whiskerplot(gamma_true+noise,params.dtheta,params.dtheta)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    pylab.title('shear field (with noise)')

    #----------------------------------------
    
    pylab.subplot(223)
    pylab.imshow(mask.T*0,
                 origin='lower',
                 extent=(0,RAside,0,DECside),
                 interpolation='nearest',
                 cmap=pylab.cm.binary)
    pylab.clim(0,1)
    whiskerplot(gamma_out_unmasked,params.dtheta,params.dtheta)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    pylab.title('unmasked reconstruction')

    #----------------------------------------
    
    pylab.subplot(224)
    pylab.imshow(mask.T,
                 origin='lower',
                 extent=(0,RAside,0,DECside),
                 interpolation='nearest',
                 cmap=GreyWhite)
    pylab.clim(0,1)
    whiskerplot(gamma_out_masked,params.dtheta,params.dtheta)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    pylab.title('masked reconstruction')

    #----------------------------------------
    
    print "%i %.2f %.4f %.4f %.4f" % (nmodes,alpha,rms1,rms2,rms3)
Ejemplo n.º 2
0
def plot_reconstruction_2():
    nmodes=900
    alpha=0.15
    RAmin=11.5
    DECmin=36
    xlim=(15,45)
    ylim=(20,50)
    
    RAlim = (RAmin,RAmin+1)
    DEClim = (DECmin,DECmin+1)

    RAside = (RAlim[1]-RAlim[0])
    DECside = (DEClim[1]-DEClim[0])
    
    params.load('../run/base_params.dat')
    params.load('../run/params_sig0.1.dat')
    gamma_out_masked_1, noise = get_reconstruction(nmodes,
                                                 alpha,
                                                 True,
                                                 RAmin,
                                                 DECmin)
    gamma_out_unmasked_1, noise = get_reconstruction(nmodes,
                                                   alpha,
                                                   False,
                                                   RAmin,
                                                   DECmin)
    mask_1 = get_mask(False,RAlim,DEClim)
    
    params.load('../run/params_sig0.1_f0.35.dat')
    gamma_out_masked_2, noise = get_reconstruction(nmodes,
                                                 alpha,
                                                 True,
                                                 RAmin,
                                                 DECmin)
    mask_2 = get_mask(False,RAlim,DEClim)
    
    params.load('../run/params_sig0.1_f0.5.dat')
    gamma_out_masked_3, noise = get_reconstruction(nmodes,
                                                 alpha,
                                                 True,
                                                 RAmin,
                                                 DECmin)
    mask_3 = get_mask(False,RAlim,DEClim)

    offset = (RAmin,DECmin)
    dtheta = params.dtheta/60.
    
    xlim = (offset[0] + xlim[0]/60.,
            offset[0] + xlim[1]/60.)
    ylim = (offset[1] + ylim[0]/60.,
            offset[1] + ylim[1]/60.)

    extent=(offset[0],offset[0]+RAside,
            offset[1],offset[1]+DECside)
    
    #--------------------------------------------------
    pylab.figure(figsize=(8,8))
    ax = pylab.subplot(221)
    pylab.imshow(mask_1.T*0,
                 origin='lower',
                 extent=extent,
                 interpolation='nearest',
                 cmap=pylab.cm.binary)
    whiskerplot(gamma_out_unmasked_1,dtheta,dtheta,offset=offset)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    #pylab.title(r'$\mathdefault{unmasked\ KL}$')
    #pylab.xlabel('')
    pylab.text(0.97,0.97,'no mask',
               transform = ax.transAxes,
               va = 'top',
               ha = 'right',
               bbox=dict(facecolor='w',edgecolor='w') )
    ax.xaxis.set_major_locator(MultipleLocator(0.2))
    ax.yaxis.set_major_locator(MultipleLocator(0.2))

    #--------------------------------------------------
    ax = pylab.subplot(222)
    pylab.imshow(mask_1.T,
                 origin='lower',
                 extent=extent,
                 interpolation='nearest',
                 cmap=GreyWhite)
    pylab.clim(0,1)
    whiskerplot(gamma_out_masked_1,dtheta,dtheta,offset=offset)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    #pylab.title(r'$\mathdefault{masked\ KL}$')
    #pylab.xlabel('')
    pylab.ylabel('')
    pylab.text(0.97,0.97,'20% mask',
               transform = ax.transAxes,
               va = 'top',
               ha = 'right',
               bbox=dict(facecolor='w',edgecolor='w') )
    ax.xaxis.set_major_locator(MultipleLocator(0.2))
    ax.yaxis.set_major_locator(MultipleLocator(0.2))

    #--------------------------------------------------
    ax = pylab.subplot(223)
    pylab.imshow(mask_2.T,
                 origin='lower',
                 extent=extent,
                 interpolation='nearest',
                 cmap=GreyWhite)
    pylab.clim(0,1)
    whiskerplot(gamma_out_masked_2,dtheta,dtheta,offset=offset)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    #pylab.title(r'$\mathdefault{masked\ KL}$')
    pylab.text(0.97,0.97,'35% mask',
               transform = ax.transAxes,
               va = 'top',
               ha = 'right',
               bbox=dict(facecolor='w',edgecolor='w') )
    ax.xaxis.set_major_locator(MultipleLocator(0.2))
    ax.yaxis.set_major_locator(MultipleLocator(0.2))

    #--------------------------------------------------
    ax = pylab.subplot(224)
    pylab.imshow(mask_3.T,
                 origin='lower',
                 extent=extent,
                 interpolation='nearest',
                 cmap=GreyWhite)
    pylab.clim(0,1)
    whiskerplot(gamma_out_masked_3,dtheta,dtheta,offset=offset)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    #pylab.title(r'$\mathdefault{masked\ KL}$')
    pylab.ylabel('')
    pylab.text(0.97,0.97,'50% mask',
               transform = ax.transAxes,
               va = 'top',
               ha = 'right',
               bbox=dict(facecolor='w',edgecolor='w') )
    ax.xaxis.set_major_locator(MultipleLocator(0.2))
    ax.yaxis.set_major_locator(MultipleLocator(0.2))
    
    #--------------------------------------------------

    pylab.figtext(0.5,0.97,r'$\mathdefault{KL\ Reconstructions}$',
                  ha='center',va='top',
                  fontsize=16)
    pylab.figtext(0.5,0.94,r'$\mathdefault{n=900\ modes,\ \ n_{gal}=100/arcmin^2}$',
                  ha='center',va='top',
                  fontsize=14)
Ejemplo n.º 3
0
def plot_with_mask_6_horiz(nmodes=900,
                           alpha=0.15,
                           RAmin = 10,
                           DECmin = 35,
                           xlim=(0,60),
                           ylim=(0,60),
                           plot_SN=False,
                           additional_n = [500,1500],
                           additional_a = [0.0,0.0] ):
    from six_squares import six_squares
    
    RAlim = (RAmin,RAmin+1)
    DEClim = (DECmin,DECmin+1)

    combine = 1
    if combine==1:
        scale = 5
    elif combine==2:
        scale = 4

    assert len(additional_n) == 2
    assert len(additional_a) == 2
    
    gamma_out_masked, noise = get_reconstruction(nmodes,
                                                 alpha,
                                                 True,
                                                 RAmin,
                                                 DECmin)
    
    gamma_out_unmasked, noise = get_reconstruction(nmodes,
                                                   alpha,
                                                   False,
                                                   RAmin,
                                                   DECmin)
    
    g1,n1 = get_reconstruction(additional_n[0],
                               additional_a[0],
                               True,
                               RAmin,
                               DECmin)
    
    g2,n2 = get_reconstruction(additional_n[1],
                               additional_a[1],
                               True,
                               RAmin,
                               DECmin)
                               

    if plot_SN:
        gamma_out_masked /= numpy.sqrt(noise_masked)
        gamma_out_unmasked /= numpy.sqrt(noise_unmasked)
        g1 /= numpy.sqrt(n1)
        g2 /= numpy.sqrt(n2)

    
    diff1 = gamma_out_masked-gamma_out_unmasked
    rms1 = numpy.sqrt(numpy.mean(abs(diff1[10:50,10:50])**2))
    
    mask = get_mask(False,RAlim,DEClim)

    gamma_true = get_from_parsed('gamma',RAlim=RAlim,DEClim=DEClim)
    
    diff2 = gamma_out_unmasked-gamma_true
    rms2 = numpy.sqrt(numpy.mean(abs(diff2[10:50,10:50])**2))
    
    diff3 = gamma_out_masked-gamma_true
    rms3 = numpy.sqrt(numpy.mean(abs(diff3[10:50,10:50])**2))

    assert gamma_out_unmasked.shape == gamma_true.shape

    dtheta = params.dtheta/60.

    RAside = (RAlim[1]-RAlim[0])
    DECside = (DEClim[1]-DEClim[0])

    #pylab.figure( figsize=(10,8) )
    ax_list = six_squares(11,8)

    offset = (RAmin,DECmin)
    dtheta = params.dtheta/60.
    
    xlim = (offset[0] + xlim[0]/60.,
            offset[0] + xlim[1]/60.)
    ylim = (offset[1] + ylim[0]/60.,
            offset[1] + ylim[1]/60.)

    extent=(offset[0],offset[0]+RAside,
            offset[1],offset[1]+DECside)

    #----------------------------------------

    ax = ax_list[0]
    pylab.sca(ax)
    #ax = pylab.subplot(231)
    pylab.imshow(mask.T*0,
                 origin='lower',
                 extent=extent,
                 interpolation='nearest',
                 cmap=pylab.cm.binary)
    pylab.clim(0,1)
    whiskerplot(gamma_true,dtheta,dtheta,
                combine=combine,scale=scale,offset=offset)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    pylab.title('shear field (noiseless)')
    pylab.xlabel('')
    ax.xaxis.set_major_locator(MultipleLocator(0.2))
    ax.yaxis.set_major_locator(MultipleLocator(0.2))

    #----------------------------------------
 
    ax = ax_list[1]
    pylab.sca(ax)
    #ax = pylab.subplot(232)
    pylab.imshow(mask.T*0,
                 origin='lower',
                 extent=extent,
                 interpolation='nearest',
                 cmap=pylab.cm.binary)
    pylab.clim(0,1)
    whiskerplot(gamma_true+noise,dtheta,dtheta,
                combine=combine,scale=scale,offset=offset)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    pylab.title('shear field (with noise)')
    pylab.xlabel('')
    pylab.ylabel('')
    ax.xaxis.set_major_locator(MultipleLocator(0.2))
    ax.yaxis.set_major_locator(MultipleLocator(0.2))

    #----------------------------------------
    
    ax = ax_list[2]
    pylab.sca(ax)
    #ax = pylab.subplot(233)
    pylab.imshow(mask.T*0,
                 origin='lower',
                 extent=extent,
                 interpolation='nearest',
                 cmap=pylab.cm.binary)
    pylab.clim(0,1)
    whiskerplot(gamma_out_unmasked,dtheta,dtheta,
                combine=combine,scale=scale,offset=offset)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    pylab.title('unmasked KL (n=%i)' % nmodes)
    pylab.xlabel('')
    pylab.ylabel('')
    #pylab.text(0.97,0.97,'n=%i' % nmodes,
    #           transform = pylab.gca().transAxes,
    #           va = 'top',
    #           ha = 'right',
    #           bbox=dict(facecolor='w',edgecolor='w') )
    ax.xaxis.set_major_locator(MultipleLocator(0.2))
    ax.yaxis.set_major_locator(MultipleLocator(0.2))

    #----------------------------------------
    
    ax = ax_list[3]
    pylab.sca(ax)
    #ax = pylab.subplot(234)
    pylab.imshow(mask.T,
                 origin='lower',
                 extent=extent,
                 interpolation='nearest',
                 cmap=GreyWhite)
    pylab.clim(0,1)
    whiskerplot(g1,dtheta,dtheta,
                combine=combine,scale=scale,offset=offset)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    pylab.title(r'$\mathdefault{masked\ KL\ (n=%i)}$' % additional_n[0])
    #pylab.text(0.97,0.97,'n=%i' % additional_n[0],
    #           transform = pylab.gca().transAxes,
    #           va = 'top',
    #           ha = 'right',
    #           bbox=dict(facecolor='w',edgecolor='w') )
    ax.xaxis.set_major_locator(MultipleLocator(0.2))
    ax.yaxis.set_major_locator(MultipleLocator(0.2))

    #----------------------------------------
    
    ax = ax_list[4]
    pylab.sca(ax)
    #ax = pylab.subplot(235)
    pylab.imshow(mask.T,
                 origin='lower',
                 extent=extent,
                 interpolation='nearest',
                 cmap=GreyWhite)
    pylab.clim(0,1)
    whiskerplot(gamma_out_masked,dtheta,dtheta,
                combine=combine,scale=scale,offset=offset)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    pylab.title(r'$\mathdefault{masked\ KL\ (n=%i)}$' % nmodes)
    pylab.ylabel('')
    #pylab.text(0.97,0.97,'n=%i' % nmodes,
    #           transform = pylab.gca().transAxes,
    #           va = 'top',
    #           ha = 'right',
    #           bbox=dict(facecolor='w',edgecolor='w') )
    ax.xaxis.set_major_locator(MultipleLocator(0.2))
    ax.yaxis.set_major_locator(MultipleLocator(0.2))

    #----------------------------------------
    
    ax = ax_list[5]
    pylab.sca(ax)
    #ax = pylab.subplot(236)
    pylab.imshow(mask.T,
                 origin='lower',
                 extent=extent,
                 interpolation='nearest',
                 cmap=GreyWhite)
    pylab.clim(0,1)
    whiskerplot(g2,dtheta,dtheta,
                combine=combine,scale=scale,offset=offset)
    pylab.xlim(xlim)
    pylab.ylim(ylim)
    pylab.title(r'$\mathdefault{masked\ KL\ (n=%i)}$' % additional_n[1])
    pylab.ylabel('')
    #pylab.text(0.97,0.97,'n=%i' % additional_n[1],
    #           transform = pylab.gca().transAxes,
    #           va = 'top',
    #           ha = 'right',
    #           bbox=dict(facecolor='w',edgecolor='w') )
    ax.xaxis.set_major_locator(MultipleLocator(0.2))
    ax.yaxis.set_major_locator(MultipleLocator(0.2))

    #----------------------------------------

    pylab.suptitle(r'$\mathdefault{Reconstructions\ with\ n_{gal}=20/arcmin^2}$',
                   fontsize=16)