Esempio n. 1
0
    def binned(self, x, y):

        # pretty sure this treats nans in y correctly, but should double-check!
        bin_means = binnedstat(x, y, bins=self.bin_edges,
                               statistic=np.nanmean)[0]

        return (self.bin_edges[:-1] + self.bin_edges[1:]) / 2., bin_means
Esempio n. 2
0
    def binned(self,x,y):


        # pretty sure this treats nans in y correctly, but should double-check!
        bin_means = binnedstat(x,y,bins=self.bin_edges,statistic=np.nanmean)[0]


        
        return bin_means
Esempio n. 3
0
def binner(ls, cls, bin_edges):
    x = ls.copy()
    y = cls.copy()
    cents = (bin_edges[:-1] + bin_edges[1:]) / 2.0
    bin_edges_min = bin_edges.min()
    bin_edges_max = bin_edges.max()
    y[x < bin_edges_min] = 0
    y[x > bin_edges_max] = 0
    bin_means = binnedstat(x, y, bins=bin_edges, statistic=np.nanmean)[0]
    return cents, bin_means
Esempio n. 4
0
    def bin(self, ix, iy, stat=np.nanmean):
        x = ix.copy()
        y = iy.copy()
        # this just prevents an annoying warning (which is otherwise informative) everytime
        # all the values outside the bin_edges are nans
        y[x < self.bin_edges_min] = 0
        y[x > self.bin_edges_max] = 0

        # pretty sure this treats nans in y correctly, but should double-check!
        bin_means = binnedstat(x, y, bins=self.bin_edges, statistic=stat)[0]

        return self.cents, bin_means
Esempio n. 5
0
def bin1d(bin_edges,ix,iy,stat=np.nanmean):
    numbins = len(bin_edges)-1
    cents = (bin_edges[:-1]+bin_edges[1:])/2.
    bin_edges_min = bin_edges.min()
    bin_edges_max = bin_edges.max()
    x = ix.copy()
    y = iy.copy()
    # this just prevents an annoying warning (which is otherwise informative) everytime
    # all the values outside the bin_edges are nans
    y[x<bin_edges_min] = 0
    y[x>bin_edges_max] = 0
    # pretty sure this treats nans in y correctly, but should double-check!
    bin_means = binnedstat(x,y,bins=bin_edges,statistic=stat)[0]
    return cents,bin_means
Esempio n. 6
0
def bin_annuli(ells, cls, bin_edges):
    numer = binnedstat(ells, ells * cls, bins=bin_edges,
                       statistic=np.nanmean)[0]
    denom = binnedstat(ells, ells, bins=bin_edges, statistic=np.nanmean)[0]
    return numer / denom