def to_window(self, **params):

        window = WindowFunction1D(**params)

        sedges = self.result.sedges
        window.poles = self.result.ells
        window.los = self.result.los
        if hasattr(self.result, 's'):
            window.s = self.result.s
            empty = scipy.isnan(window.s)
            window.s[empty] = edges_to_mid(sedges)[empty]
        else:
            window.s = edges_to_mid(sedges)
        window.window = self.result.counts
        if window.zero in window:
            window.error = window.window[window.index(window.zero)]**(1. / 2.)

        volume = (4. * constants.pi) * radial_volume(sedges)
        for ill, ell in enumerate(window):
            window.window[ill] *= (
                2 * ell +
                1) / volume  #legendre normalization and radial volume

        window.window /= self.weight_tot
        if hasattr(window, 'error'): window.error /= volume * self.weight_tot

        window.norm = 1.
        window.pad_zero()

        return window
    def to_window(self, s, key='A', **params):

        poles = self.result.poles
        attrs = self.result.attrs
        self.logger.info('k-range: {:.1f} - {:.1f}.'.format(
            attrs['kfun'].max(), attrs['knyq'].min()))

        window = WindowFunction1D(**params)
        window.poles = attrs['poles']
        window.los = ('endpoint', self.params['losn'])
        window.s = scipy.asarray(s)

        self.logger.info(
            'Normalization is {:.7g} and shotnoise is {:.7g}.'.format(
                self.normalization, self.shotnoise))
        #mask = poles['k']<attrs['knyq'].min()/3.
        mask = poles['k'] >= 0.
        k = poles['k'][mask]
        volume = attrs['kfun'].prod() * poles['modes'][mask]

        if key == 'A':

            def Wk(ell):
                return poles['{}_{:d}'.format(key, ell)][mask] / scipy.sqrt(
                    self.normalization)

        if key == 'power':

            def Wk(ell):
                if ell == 0:
                    return poles['{}_{:d}'.format(
                        key,
                        ell)].real[mask] / self.normalization - self.shotnoise
                return poles['{}_{:d}'.format(
                    key, ell)].real[mask] / self.normalization

        window.window = scipy.empty((len(window.poles), len(window.s)),
                                    dtype=Wk(0).dtype)

        kk, ks = scipy.meshgrid(k, window.s, sparse=False, indexing='ij')
        ks = kk * ks
        for ill, ell in enumerate(window):
            self.logger.info('Hankel transforming {}_{:d}.'.format(key, ell))
            integrand = Wk(ell)[:, None] * 1. / (2. * constants.pi)**3 * (
                -1)**(ell // 2) * special.spherical_jn(ell, ks)
            window.window[ill] = scipy.sum(volume[:, None] * integrand, axis=0)

        window.norm = self.normref
        window.pad_zero()

        return window
Beispiel #3
0
    def to_window(self, **params):

        window = WindowFunction1D(**params)

        window.poles = self.result.ells
        window.los = self.result.los

        window.s = self.result.x
        window.window = self.result.y

        for ill, ell in enumerate(window):
            window.window[ill] *= (2 * ell + 1)  #legendre normalization

        window.window *= 1. / self.result.integral()

        window.norm = 1.
        window.pad_zero()

        return window
Beispiel #4
0
    def to_window(self, **params):

        window = WindowFunction1D(**params)

        sedges = self.result.sedges
        window.poles = self.result.ells
        window.los = self.result.los
        if hasattr(self.result, 's'):
            window.s = self.result.s
            empty = scipy.isnan(window.s)
            window.s[empty] = edges_to_mid(sedges)[empty]
        else:
            window.s = edges_to_mid(sedges)

        window.window = self.result.counts
        volume = -scipy.diff(s_to_cos(sedges))
        window.window /= volume[None, ...]

        window.pad_zero()

        window.s = s_to_cos(window.s)[::-1]
        window.window[0] = window.window[0][::-1]

        return window