コード例 #1
0
    def ConfidenceArea(self, adLevels):
        
        # create a normalized cumulative distribution
        self.log_skymap_sorted = np.sort(self.log_skymap.flatten())[::-1]
        self.log_skymap_cum = cumulative.fast_log_cumulative(self.log_skymap_sorted)
        # find the indeces  corresponding to the given CLs
        adLevels = np.ravel([adLevels])
        args = [(self.log_skymap_sorted,self.log_skymap_cum,level) for level in adLevels]
        adHeights = self.pool.map(FindHeights,args)

        dA = hp.nside2pixarea(self.nside, degrees=True)
        areas = []
        for height in adHeights:
            (index_hp,) = np.where(self.log_skymap>height)
            areas.append(len(index_hp)*dA)
        self.area_confidence = np.array(areas)
        
        if self.injection!=None:
            ra,dec = self.injection.get_ra_dec()
            theta,phi = eq2ang(ra,dec)
            ipix = hp.pixelfunc.ang2pix(self.nside,theta,phi, nest=True)
            logPval = self.log_skymap[ipix]
            confidence_level = np.exp(self.log_skymap_cum[np.abs(self.log_skymap_sorted-logPval).argmin()])
            height = FindHeights((self.log_skymap_sorted,self.log_skymap_cum,confidence_level))
            (index_hp,) = np.where(self.log_skymap >= height)
            searched_area = len(index_hp)*dA
            return self.area_confidence,(confidence_level,searched_area)

        del self.log_skymap_sorted
        del self.log_skymap_cum
        return self.area_confidence,None
コード例 #2
0
    def ConfidenceVolume(self, adLevels):
        # create a normalized cumulative distribution
        self.log_volume_map_sorted = np.sort(self.log_volume_map.flatten())[::-1]
        self.log_volume_map_cum = cumulative.fast_log_cumulative(self.log_volume_map_sorted)
        
        # find the indeces  corresponding to the given CLs
        adLevels = np.ravel([adLevels])
        args = [(self.log_volume_map_sorted,self.log_volume_map_cum,level) for level in adLevels]
        adHeights = self.pool.map(FindHeights,args)
        self.heights = {str(lev):hei for lev,hei in zip(adLevels,adHeights)}
        dd = np.diff(self.d_grid)[0]
        dA = hp.nside2pixarea(self.nside)
        volumes = []
        for height in adHeights:
            (index_d, index_hp) = np.where(self.log_volume_map>height)
            volumes.append(np.sum([self.d_grid[i_d]**2. * dd * dA for i_d in index_d]))
        self.volume_confidence = np.array(volumes)

        if self.injection!=None:
            ra,dec = self.injection.get_ra_dec()
            distance = self.injection.distance
            logPval = self.logPosterior(distance,ra,dec)
            confidence_level = np.exp(self.log_volume_map_cum[np.abs(self.log_volume_map_sorted-logPval).argmin()])
            height = FindHeights((self.log_volume_map_sorted,self.log_volume_map_cum,confidence_level))
            (index_d, index_hp) = np.where(self.log_volume_map >= height)
            searched_volume = np.sum([self.d_grid[i_d]**2. * dd * dA for i_d in index_d])
            self.injection_volume_confidence = confidence_level
            self.injection_volume_height = height
            return self.volume_confidence,(confidence_level,searched_volume)

        del self.log_volume_map_sorted
        del self.log_volume_map_cum
        return self.volume_confidence,None
コード例 #3
0
    def ConfidenceVolume(self, adLevels):
        # create a normalized cumulative distribution
        self.log_volume_map_sorted = np.sort(
            self.log_volume_map.flatten())[::-1]
        self.log_volume_map_cum = cumulative.fast_log_cumulative(
            self.log_volume_map_sorted)

        # find the indeces  corresponding to the given CLs
        adLevels = np.ravel([adLevels])
        args = [(self.log_volume_map_sorted, self.log_volume_map_cum, level)
                for level in adLevels]
        adHeights = self.pool.map(FindHeights, args)
        self.heights = {str(lev): hei for lev, hei in zip(adLevels, adHeights)}
        dd = np.diff(self.d_grid)[0]
        dA = hp.nside2pixarea(self.nside)
        volumes = []
        for height in adHeights:
            (index_d, index_hp) = np.where(self.log_volume_map > height)
            volumes.append(
                np.sum([self.d_grid[i_d]**2. * dd * dA for i_d in index_d]))
        self.volume_confidence = np.array(volumes)

        if self.injection != None:
            ra, dec = self.injection.get_ra_dec()
            distance = self.injection.distance
            logPval = self.logPosterior(distance, ra, dec)
            confidence_level = np.exp(
                self.log_volume_map_cum[np.abs(self.log_volume_map_sorted -
                                               logPval).argmin()])
            height = FindHeights((self.log_volume_map_sorted,
                                  self.log_volume_map_cum, confidence_level))
            (index_d, index_hp) = np.where(self.log_volume_map >= height)
            searched_volume = np.sum(
                [self.d_grid[i_d]**2. * dd * dA for i_d in index_d])
            self.injection_volume_confidence = confidence_level
            self.injection_volume_height = height
            return self.volume_confidence, (confidence_level, searched_volume)

        del self.log_volume_map_sorted
        del self.log_volume_map_cum
        return self.volume_confidence, None
コード例 #4
0
    def ConfidenceArea(self, adLevels):

        # create a normalized cumulative distribution
        self.log_skymap_sorted = np.sort(self.log_skymap.flatten())[::-1]
        self.log_skymap_cum = cumulative.fast_log_cumulative(
            self.log_skymap_sorted)
        # find the indeces  corresponding to the given CLs
        adLevels = np.ravel([adLevels])
        args = [(self.log_skymap_sorted, self.log_skymap_cum, level)
                for level in adLevels]
        adHeights = self.pool.map(FindHeights, args)

        dA = hp.nside2pixarea(self.nside, degrees=True)
        areas = []
        for height in adHeights:
            (index_hp, ) = np.where(self.log_skymap > height)
            areas.append(len(index_hp) * dA)
        self.area_confidence = np.array(areas)

        if self.injection != None:
            ra, dec = self.injection.get_ra_dec()
            theta, phi = eq2ang(ra, dec)
            ipix = hp.pixelfunc.ang2pix(self.nside, theta, phi, nest=True)
            logPval = self.log_skymap[ipix]
            confidence_level = np.exp(
                self.log_skymap_cum[np.abs(self.log_skymap_sorted -
                                           logPval).argmin()])
            height = FindHeights((self.log_skymap_sorted, self.log_skymap_cum,
                                  confidence_level))
            (index_hp, ) = np.where(self.log_skymap >= height)
            searched_area = len(index_hp) * dA
            return self.area_confidence, (confidence_level, searched_area)

        del self.log_skymap_sorted
        del self.log_skymap_cum
        return self.area_confidence, None