Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
0
    h[::2] = hist
    h[1::2] = hist

    b = numpy.zeros(2*len(histE))
    b[::2] = binsE[:-1]
    b[1::2] = binsE[1:]

    if fmt is None:
        return pylab.plot(b,h,label=label)
    else:
        return pylab.plot(b,h,fmt,label=label)
    

if __name__ == '__main__':
    gamma,kappa,Ngal = get_from_parsed( 'gamma','kappa','Ngal',
                                        RAlim=(10,15),
                                        DEClim=(35,40) )

    r = 5.6 #arcmin

    dtheta = params.dtheta
    N1,N2 = gamma.shape

    slow = False
    if slow:
        pos_x = dtheta * numpy.arange(N1)
        pos_y = dtheta * numpy.arange(N2)
        pos = pos_x[:,None] + 1j*pos_y[None,:]
        Map_E, Map_B = Map_map(gamma,pos,pos,r)
    else:
        Map_E, Map_B = tiled_Map(gamma,dtheta,r)