Пример #1
0
def mo_matrix(mock, obs, opts):

    """
    Function to determine the mass-observable matrix.
    """

    n_mass_bins = comp.num_bins(opts.mass_bin[0], opts.mass_bin[1], opts.mass_bin[2])
    n_proxy_bins = comp.num_bins(opts.proxy_bin[0], opts.proxy_bin[1], opts.proxy_bin[2])

    mass_x = comp.x_vals(n_mass_bins, opts.mass_bin[0], opts.mass_bin[2])
    proxy_x = comp.x_vals(n_proxy_bins, opts.proxy_bin[0], opts.proxy_bin[2])
    
    matrix = np.zeros((n_proxy_bins, n_mass_bins))

    clusters = find_matches(mock, obs, opts)

    for cluster in clusters:
    
        proxy_bin = n_proxy_bins - 1 - \
          comp.find_bin(np.log10(cluster.proxy), opts.proxy_bin[0], opts.proxy_bin[2])

        for i in range(n_proxy_bins):
            if proxy_bin == i and opts.z_bin[0] <= cluster.z < opts.z_bin[1]:
                matrix[proxy_bin] += comp.scale(cluster.hist, min(cluster.hist),
                                                np.sum(cluster.hist))
                   
    for i in range(n_proxy_bins):
        matrix[i] = comp.scale(matrix[i], min(matrix[i]), np.sum(matrix[i]))

    return matrix, mass_x, proxy_x
Пример #2
0
def mo_matrix(mock, obs, opts):

    n_mass_bins = comp.num_bins(opts.mass_bin[0], opts.mass_bin[1], opts.mass_bin[2])
    n_proxy_bins = comp.num_bins(opts.proxy_bin[0], opts.proxy_bin[1], opts.proxy_bin[2])
    
    mass_index = np.floor((mock.mass - opts.mass_bin[0]) / opts.mass_bin[2]).astype('int')
    proxy_index = np.floor((obs.proxy - opts.proxy_bin[0]) / opts.proxy_bin[2]).astype('int')

    mass_hist = np.zeros(n_mass_bins)
    for i in mass_index:
        mass_hist[i] += 1
    
    mass_x = comp.x_vals(n_mass_bins, opts.mass_bin[0], opts.mass_bin[2])
    proxy_x = comp.x_vals(n_proxy_bins, opts.proxy_bin[0], opts.proxy_bin[2])

    matrix = np.zeros((n_proxy_bins, n_mass_bins))
    
    index, dists = find_matches(mock, obs, 2.0 * opts.delta_z)

    tag_index = halo_tag(mock, np.copy(index))

    mass_hist2 = np.zeros(n_mass_bins)
    for i in mass_index[tag_index]:
        mass_hist2[i] += 1

    print_matches(mock, obs, index, opts)

    for i in range(obs.size):
        for j in range(len(index[i])):
            matrix[proxy_index[i], mass_index[index[i][j]]] += dists[i][j]
            
    return np.nan_to_num(np.flipud(matrix)), mass_hist, mass_hist2, mass_x, proxy_x
Пример #3
0
def mo_matrix(mock, obs, opts):
    """
    Function to determine the mass-observable matrix.
    """

    n_mass_bins = comp.num_bins(opts.mass_bin[0], opts.mass_bin[1],
                                opts.mass_bin[2])
    n_proxy_bins = comp.num_bins(opts.proxy_bin[0], opts.proxy_bin[1],
                                 opts.proxy_bin[2])

    mass_x = comp.x_vals(n_mass_bins, opts.mass_bin[0], opts.mass_bin[2])
    proxy_x = comp.x_vals(n_proxy_bins, opts.proxy_bin[0], opts.proxy_bin[2])

    matrix = np.zeros((n_proxy_bins, n_mass_bins))

    clusters = find_matches(mock, obs, opts)

    for cluster in clusters:

        proxy_bin = n_proxy_bins - 1 - \
          comp.find_bin(np.log10(cluster.proxy), opts.proxy_bin[0], opts.proxy_bin[2])

        for i in range(n_proxy_bins):
            if proxy_bin == i and opts.z_bin[0] <= cluster.z < opts.z_bin[1]:
                matrix[proxy_bin] += comp.scale(cluster.hist,
                                                min(cluster.hist),
                                                np.sum(cluster.hist))

    for i in range(n_proxy_bins):
        matrix[i] = comp.scale(matrix[i], min(matrix[i]), np.sum(matrix[i]))

    return matrix, mass_x, proxy_x
Пример #4
0
def mo_matrix(mock, obs, matches, opts):

    index, weights, mock_index = matches

    n_z_bins = comp.num_bins(opts.z_bin[0], opts.z_bin[1], opts.z_bin[2])
    n_mass_bins = comp.num_bins(opts.mass_bin[0], opts.mass_bin[1], opts.mass_bin[2])
    n_proxy_bins = comp.num_bins(opts.proxy_bin[0], opts.proxy_bin[1], opts.proxy_bin[2])

    z_index = np.floor((mock.z - opts.z_bin[0]) / opts.z_bin[2]).astype('int')
    mass_index = np.floor((mock.mass - opts.mass_bin[0]) / opts.mass_bin[2]).astype('int')
    proxy_index = np.floor((obs.proxy - opts.proxy_bin[0]) / opts.proxy_bin[2]).astype('int')

    z_x = comp.x_vals(n_z_bins, opts.z_bin[0], opts.z_bin[2])
    mass_x = comp.x_vals(n_mass_bins, opts.mass_bin[0], opts.mass_bin[2])
    proxy_x = comp.x_vals(n_proxy_bins, opts.proxy_bin[0], opts.proxy_bin[2])

    matrix = np.zeros((n_z_bins, n_mass_bins, n_proxy_bins))
    hm_matrix = np.zeros((n_z_bins, n_mass_bins))

    for i in range(len(mass_index)):
        hm_matrix[z_index[i], mass_index[i]] += 1
        
    mock_matched = mock[mock_index]
    
    for i in range(mock_matched.size):
        if opts.unique:
            matrix[z_index[i], mass_index[i], proxy_index[index[i]]] += 1
        else:
            for j in range(len(index[i])):
                matrix[z_index[i], mass_index[i], proxy_index[index[i][j]]] += weights[i][j]

    return matrix, hm_matrix, (z_x, mass_x, proxy_x)