Example #1
0
def friends_of_friends(zbin, gals, tree_dist, mode, cluster_count):
    """
    Function that looks for galaxy friends in a given
    redshift bin and returns a list of the resulting
    Cluster instances.
    """
    #make kd-tree
    tree = kdtree.make_kdtree(gals)
    #loop over galaxies
    cluster_list = []
    for i in range(len(gals)):
        if  mode == 'spec':
            link_zbin = z_bins[gals[i].bin]
        else:
            link_zbin = z_bins[zbin]
        if bin_check(mode, gal[i], link_zbin):
            #friends loop
            if gals[i].clt[zbin] == None:
                list = tree.query_ball_point([gals[i].x, gals[i].y], tree_dist)            
                for j in list:
                    if ((bin_check(mode, gal[j], link_zbin)) & (gals[i].id != gals[j].id) & (gals[j].clt[zbin] == None)):
                        if friendship(link_zbin, gals[i], gals[j], opts.mode):                              
                            if gals[i].clt[zbin] == None:
                                gals[i].clt[zbin] = len(cluster_list)
                                gals[j].clt[zbin] = gals[i].clt[zbin]
                                cluster_list.append(Cluster(cluster_count))
                                cluster_count += len(cluster_list)
                                cluster_list[gals[i].clt[zbin]].extend([gals[i].num], [gals[i].id], [gals[i].ra],
                                                                        [gals[i].dec], [gals[i].z], [gals[i].x], [gals[i].y])
                                cluster_list[gals[i].clt[zbin]].extend([gals[j].num], [gals[j].id], [gals[j].ra],
                                                                        [gals[j].dec], [gals[j].z], [gals[j].x], [gals[j].y])
                            else:
                                gals[j].clt[zbin] = gals[i].clt[zbin]
                                cluster_list[gals[i].clt[zbin]].extend([gals[j].num], [gals[j].id], [gals[j].ra],
                                                                        [gals[j].dec], [gals[j].z], [gals[j].x], [gals[j].y])
            #friends-of-friends loop
            if gals[i].clt[zbin] != None:
                clt_now = cluster_list[gals[i].clt[zbin]]
                for k in range(len(clt_now.g_id)):
                    if(gals[i].id != clt_now.g_id[k]):
                        list = tree.query_ball_point([clt_now.g_x[k], clt_now.g_y[k]], tree_dist)
                        for l in list:
                            if ((bin_check(mode, gal[l], link_zbin)) & (clt_now.g_id[k] != gals[l].id)
                                & (gals[l].clt[zbin] == None)):
                                if friendship(link_zbin, gals[clt_now.g_num[k]], gals[l], opts.mode):
                                    gals[l].clt[zbin] = gals[i].clt[zbin]
                                    cluster_list[gals[i].clt[zbin]].extend([gals[l].num], [gals[l].id], [gals[l].ra],
                                                                        [gals[l].dec], [gals[l].z], [gals[l].x], [gals[l].y])
    return cluster_list
Example #2
0
def find_matches(clusters, progress, tree_dist):
    """
    Function that returns the indicies of matching Cluster instances.
    """
    matches = []
    tree = kdtree.make_kdtree(clusters)
    for i in range(len(clusters)):
        if progress: interface.progress_bar(i, len(clusters))
        if not clusters[i].match_flag:
            list = tree.query_ball_point([clusters[i].x, clusters[i].y], tree_dist)
            for j in list:
                if not clusters[j].match_flag:
                    if ((j > i) & (np.any(np.in1d(clusters[i].g_id, clusters[j].g_id)))):
                        matches.append([i, j])
                        clusters[i].match_flag = True
                        clusters[j].match_flag = True
    matches = np.array(matches)
    if progress: print ""
    return matches
Example #3
0
def find_matches(clusters, progress, tree_dist):
    """
    Function that returns the indicies of matching Cluster instances.
    """
    matches = []
    tree = kdtree.make_kdtree(clusters)
    for i in range(len(clusters)):
        if progress: interface.progress_bar(i, len(clusters))
        if not clusters[i].match_flag:
            list = tree.query_ball_point([clusters[i].x, clusters[i].y],
                                         tree_dist)
            for j in list:
                if not clusters[j].match_flag:
                    if ((j > i) &
                        (np.any(np.in1d(clusters[i].g_id, clusters[j].g_id)))):
                        matches.append([i, j])
                        clusters[i].match_flag = True
                        clusters[j].match_flag = True
    matches = np.array(matches)
    if progress: print ""
    return matches
Example #4
0
def friends_of_friends(zbin, gals, tree_dist, mode, cluster_count):
    """
    Function that looks for galaxy friends in a given
    redshift bin and returns a list of the resulting
    Cluster instances.
    """
    #make kd-tree
    tree = kdtree.make_kdtree(gals)
    #loop over galaxies
    cluster_list = []
    for i in range(len(gals)):
        if mode == 'spec':
            link_zbin = z_bins[gals[i].bin]
        else:
            link_zbin = z_bins[zbin]
        if bin_check(mode, gal[i], link_zbin):
            #friends loop
            if gals[i].clt[zbin] == None:
                list = tree.query_ball_point([gals[i].x, gals[i].y], tree_dist)
                for j in list:
                    if ((bin_check(mode, gal[j], link_zbin)) &
                        (gals[i].id != gals[j].id) &
                        (gals[j].clt[zbin] == None)):
                        if friendship(link_zbin, gals[i], gals[j], opts.mode):
                            if gals[i].clt[zbin] == None:
                                gals[i].clt[zbin] = len(cluster_list)
                                gals[j].clt[zbin] = gals[i].clt[zbin]
                                cluster_list.append(Cluster(cluster_count))
                                cluster_count += len(cluster_list)
                                cluster_list[gals[i].clt[zbin]].extend(
                                    [gals[i].num], [gals[i].id], [gals[i].ra],
                                    [gals[i].dec], [gals[i].z], [gals[i].x],
                                    [gals[i].y])
                                cluster_list[gals[i].clt[zbin]].extend(
                                    [gals[j].num], [gals[j].id], [gals[j].ra],
                                    [gals[j].dec], [gals[j].z], [gals[j].x],
                                    [gals[j].y])
                            else:
                                gals[j].clt[zbin] = gals[i].clt[zbin]
                                cluster_list[gals[i].clt[zbin]].extend(
                                    [gals[j].num], [gals[j].id], [gals[j].ra],
                                    [gals[j].dec], [gals[j].z], [gals[j].x],
                                    [gals[j].y])
            #friends-of-friends loop
            if gals[i].clt[zbin] != None:
                clt_now = cluster_list[gals[i].clt[zbin]]
                for k in range(len(clt_now.g_id)):
                    if (gals[i].id != clt_now.g_id[k]):
                        list = tree.query_ball_point(
                            [clt_now.g_x[k], clt_now.g_y[k]], tree_dist)
                        for l in list:
                            if ((bin_check(mode, gal[l], link_zbin)) &
                                (clt_now.g_id[k] != gals[l].id)
                                    & (gals[l].clt[zbin] == None)):
                                if friendship(link_zbin,
                                              gals[clt_now.g_num[k]], gals[l],
                                              opts.mode):
                                    gals[l].clt[zbin] = gals[i].clt[zbin]
                                    cluster_list[gals[i].clt[zbin]].extend(
                                        [gals[l].num], [gals[l].id],
                                        [gals[l].ra], [gals[l].dec],
                                        [gals[l].z], [gals[l].x], [gals[l].y])
    return cluster_list