Exemplo n.º 1
0
for i in range(start_sky, end_sky):
    str_sky = str(i+1)
    file_halo = '../Data/Training_halos.csv'
    nh, xr, yr, h1x, h1y, h2x, h2y, h3x, h3y = np.loadtxt(file_halo,delimiter=',',unpack=True,usecols=(1,2,3,4,5,6,7,8,9),skiprows=1)    
    
    file = '../Data/Train_Skies/Training_Sky'+str_sky+'.csv'
    x,y,e1,e2=np.loadtxt(file,delimiter=',',unpack=True,usecols=(1,2,3,4),skiprows=1)
    
    radial_distance_galaxy_from_halo = np.sqrt( (x-h1x[i])**2 + (y-h1y[i])**2 )

    for bin_index in range(0,nbins):
        b1 = (radial_distance_galaxy_from_halo >= bin_edges[bin_index])
        b2 = (radial_distance_galaxy_from_halo < bin_edges[bin_index+1])
        these = b1*b2
        #        print np.average(x[these]), np.min(x[these]), np.max(x[these]), bin_edges[bin_index], bin_edges[bin_index+1]
        shear_array[bin_index] += scalc.dark_matter_finder_sm(x[these],y[these],e1[these],e2[these],h1x[i],h1y[i])
        count_array[bin_index] += len(x[these])
        #        single_shear_array[bin_index]  = scalc.dark_matter_finder_sm(x[these],y[these],e1[these],e2[these],h1x[i],h1y[i])
        #        single_count_array[bin_index] = len(x[these])
        #        single_shear_profile = single_shear_array/(single_count_array+0.0001)
        #        plt.plot(bin_centers,single_shear_profile,".")

        
shear_profile = shear_array/(count_array+0.0001)
err = 0.3/np.sqrt(count_array+.0001)

def stacked_log_likelihood(pars):
    A = pars[0]
    r0 = pars[1]
    profile = A/(1+bin_centers/r0)
    log_likelihood = sum((shear_profile-profile)**2/err**2)/2.
Exemplo n.º 2
0
    dx = binwidth 
    xs = np.arange(0, Sky_size, dx)
    ys = np.arange(0, Sky_size, dx)
    X_h,Y_h = np.meshgrid(xs, ys)
    Z_ml = scalc.func3(X_h, Y_h)
    Z_sm = scalc.func3(X_h, Y_h)
    Z_matched = scalc.func3(X_h, Y_h)
    
    for i in xrange(Number_of_bins):
        for j in xrange(Number_of_bins):
            x_halo = i*binwidth # Proposed x position of the halo
            y_halo = j*binwidth # Proposed y position of the halo
            gridded_map[i,j] = scalc.dark_matter_finder_ml(x, y, e1, e2, x_halo, y_halo)
            Z_ml[i,j] = scalc.dark_matter_finder_ml(x, y, e1, e2, x_halo, y_halo)
            Z_sm[i,j] = scalc.dark_matter_finder_sm(x, y, e1, e2, x_halo, y_halo)
            Z_matched[i,j] = scalc.dark_matter_finder_matched(x, y, e1, e2, x_halo, y_halo)
            
    name = '../Plots'
    save = 1
  
    ################ PLOT SKY FOR MAXIMUM LIKELIHOOD
    fig1 = plt.figure(1)       
    ax = fig1.add_subplot(111)
    splot.plot_field_galaxies(h1x,h1y,h2x,h2y,h3x,h3y, x, y, e1, e2, save, sky_num, name, ax)
    plt.pcolormesh(X_h, Y_h, Z_ml.T , cmap='BuPu')

    ################ PLOT SKY FOR SIGNAL MAP
    fig2 = plt.figure(2)       
    ax2 = fig2.add_subplot(111)
    splot.plot_field_galaxies(h1x,h1y,h2x,h2y,h3x,h3y, x, y, e1, e2, save, sky_num, name, ax2)