示例#1
0
    def contamination_check(self,
                            lowres=[2, 3, 5],
                            search_factor=2.5,
                            printer=True):
        from caesar.zoom_funcs import construct_lowres_tree

        construct_lowres_tree(self, lowres)

        if self.obj_type == 'halo':
            halo = self
            ID = 'Halo {}'.format(self.GroupID)
        elif self.obj_type == 'galaxy':
            if self.halo is None:
                raise Exception('Galaxy {} has no halo!'.format(self.GroupID))
            halo = self.halo
            ID = 'Galaxy {}\'s halo (ID {})'.format(self.GroupID, halo.GroupID)

        r = halo.radii['virial'].d * search_factor

        result = self.obj._lowres['TREE'].query_ball_point(halo.pos.d, r)
        ncontam = len(result)
        lrmass = np.sum(self.obj._lowres['MASS'][result])

        self.contamination = lrmass / halo.masses['total'].d

        if not printer:
            return

        if ncontam > 0:
            mylog.warning('{} has {0.2f}% mass contamination '
                          '({} LR particles with {0.2e} {}s)'.format(
                              ID, self.contamination * 100.0, ncontam, lrmass,
                              halo.masses['total'].units))
        else:
            mylog.info('{} has NO contamination!'.format(ID))
示例#2
0
    def contamination_check(self,
                            lowres=[2, 3, 5],
                            search_factor=1.0,
                            printer=True):
        """Check for low resolution particle contamination.

        This method checks for low-resolution particles within 
        ``search_factor`` of the maximum halo radius.  When this
        method is called on a galaxy, it refers to the parent halo.

        Parameters
        ----------
        lowres : list, optional
            Particle types to be considered low-res.  Defaults to
            [2,3,5]; if your simulation contains blackholes you will
            want to pass in [2,3]; if your simulation contains active
			dust particles you will not include 3.
        search_factor : float, optional
            Factor to expand the maximum halo radius search distance
            by.  Default is 2.5
        printer : boolean, optional
            Print results?

        Notes
        -----
        This method currently ONLY works on GADGET/GIZMO HDF5 files.

        """
        from yt.funcs import mylog
        from caesar.zoom_funcs import construct_lowres_tree

        construct_lowres_tree(self, lowres)

        if self.obj_type == 'halo':
            halo = self
            ID = 'Halo %d' % self.GroupID
        elif self.obj_type == 'galaxy':
            if self.halo == None:
                raise Exception('Galaxy %d has no halo!' % self.GroupID)
            halo = self.halo
            ID = "Galaxy %d's halo (ID %d)" % (self.GroupID, halo.GroupID)

        r = halo.virial_quantities['r200c'].d * search_factor

        result = self.obj._lowres['TREE'].query_ball_point(halo.pos.d, r)
        ncontam = len(result)
        lrmass = np.sum(self.obj._lowres['MASS'][result])

        self.contamination = lrmass / halo.virial_quantities['m200c'].d

        if not printer:
            return

        if ncontam > 0:
            mylog.warning('%s has %0.2f%% mass contamination ' \
                          '(%d LR particles with %0.2e % s)' %
                          (ID, self.contamination * 100.0, ncontam,
                           lrmass, halo.masses['total'].units))
        else:
            mylog.info('%s has NO contamination!' % ID)