Ejemplo n.º 1
0
    def parse_halo_catalog_internal(self):
        """
        This parser works on the files output directly out of yt's internal
        halo_finder.  The parse_halo_catalog_external works with an 
        external version of FOF.

        Examples
        --------
        >>> ds = load("DD0000/DD0000")
        >>> halo_list = FOFHaloFinder(ds)
        >>> halo_list.write_out("FOF/groups_00000.txt")
        >>> halos_COM = parse_halo_catalog_internal()
        """
        hp = []
        for line in open("%s/groups_%05i.txt" % \
                        (self.FOF_directory, self.output_id)):
            if line.startswith("# RED"):
                self.redshift = float(line.split("=")[1])
                continue
            if line.strip() == "": continue  # empty
            if line[0] == "#": continue  # comment
            x, y, z = [float(f) for f in line.split()[7:10]]  # COM x,y,z
            hp.append([x, y, z])
        if hp != []:
            self.halo_positions = np.array(hp)
            self.halo_kdtree = KDTree(self.halo_positions)
        else:
            self.halo_positions = None
            self.halo_kdtree = None
        return hp
Ejemplo n.º 2
0
 def parse_halo_catalog_external(self):
     hp = []
     for line in open("%s/groups_%05i.dat" % \
                     (self.FOF_directory, self.output_id)):
         if line.strip() == "": continue  # empty
         if line.startswith("# Red"):
             self.redshift = float(line.split("=")[1])
         if line[0] == "#": continue  # comment
         if line[0] == "d": continue  # datavar
         x, y, z = [float(f) for f in line.split(None, 3)[:-1]]
         hp.append([x, y, z])
     if hp != []:
         self.halo_positions = np.array(hp)
         self.halo_kdtree = KDTree(self.halo_positions)
     else:
         self.halo_positions = None
         self.halo_kdtree = None
     return hp