Example #1
0
def pylians3Bispectrum(delta, k1, k2, theta):
    ''' Get data from pylians3 Bispectrum measurements.
        returns: array_like
            k1/kF | k2/kF | k3/kF | P(k1) | P(k2) | P(k3) | B(k1,k2,k3) | Number of triangles

        delta : array_like
            input data, shape = (numfiles, gridsize, gridsize, gridsize)
        k1,k2: fixed wavenumber in units of the fundamental frequency.
            integer number.
        theta: angle between k1 and k2.
    '''
    Bk = PKL.Bk(delta, BoxSize, k1 * kf, k2 * kf, theta, MAS, threads)
    BSk_pyl = Bk.B  #bispectrm
    triangle_conf = Bk.triangles  #triangle counts
    k3_pyl = Bk.k[2:]  #k-bins for power spectrum
    Pk1_pyl = Bk.Pk[0]  #power spectrum PS(k1)
    Pk2_pyl = Bk.Pk[1]  #         ´´    PS(k2)
    Pk3_pyl = Bk.Pk[2:]  #         ´´    PS(k3)

    lenn = len(theta)
    return np.vstack([
        np.full(lenn, k1),
        np.full(lenn, k2), k3_pyl / kf,
        np.full(lenn, Pk1_pyl),
        np.full(lenn, Pk2_pyl), Pk3_pyl, BSk_pyl, triangle_conf
    ])
Example #2
0
def compute_matter_bispectrum(vols, cubedim=64, k1=0.1, k2=0.5):
    thetas = np.linspace(0.0, 2.5, 10)
    bks = []
    for i in xrange(vols.shape[0]):
        with HiddenPrints():
            bis = PKL.Bk(vols[i] - np.mean(vols[i]), float(cubedim), k1, k2,
                         thetas)
            bks.append(bis.B)
    return bks, thetas
Example #3
0
    def compute_bispectrum(self, save=True):  #{{{
        # (1) triangle configurations k = 1, 3, varying angles
        _k1 = 1.0
        _k2 = 3.0
        _theta = np.linspace(0.0, np.pi, num=20)
        Bk1 = PKL.Bk(self.data, self.BoxSize, _k1, _k2, _theta, self.MAS,
                     ARGS.threads).Q
        if ARGS.verbose:
            print 'Computed Bk1 in Field(%s)' % self.mode

        # (2) triangle configurations k = 0.1, 0.3, varying angles
        _k1 = 0.2
        _k2 = 0.3
        _theta = np.linspace(0.0, np.pi, num=20)
        Bk2 = PKL.Bk(self.data, self.BoxSize, _k1, _k2, _theta, self.MAS,
                     ARGS.threads).Q
        if ARGS.verbose:
            print 'Computed Bk2 in Field(%s)' % self.mode

        # (3) equilateral triangle configurations
        _k = 10.0**np.linspace(np.log10(0.2), np.log10(3.0), num=20)
        _theta = np.array([np.pi / 3.0])
        Bk3 = []
        for k in _k:
            Bk3.append(
                PKL.Bk(self.data, self.BoxSize, k, k, _theta, self.MAS,
                       ARGS.threads).Q)
        if ARGS.verbose:
            print 'Computed Bk3 in Field(%s)' % self.mode

        self.bispectrum = {
            'Bk1': Bk1,
            'Bk2': Bk2,
            'Bk3': Bk3,
        }
        if save:
            np.savez(self.summary_path + '%s.npz' % self.bispectrumname,
                     **self.bispectrum)

        if ARGS.verbose:
            print 'Computed bispectrum in Field(%s)' % self.mode
Example #4
0

BoxSize = 31.82373046875 #Size of the density field in Mpc/h


axis = 0
k1      = 0.5    #h/Mpc
k2      = 0.6    #h/Mpc
MAS     = 'CIC'
threads = 32
theta   = np.linspace(0, np.pi, 25) #array with the angles between k1 and k2



# compute true bispectrum
Bk_target = PKL.Bk(test_cube, BoxSize, k1, k2, theta, MAS, threads)

Bk = Bk_target.B     #bispectrum
Qk = Bk_target.Q     #reduced bispectrum
k  = Bk_target.k_all #k-bins for power spectrum
Pk = Bk_target.Pk    #power spectrum


# save bispectrum and k
np.save('../dat/processed/'+'target_theta_values.npy',theta)
np.save('../dat/processed/'+'target_Bk_values.npy',Bk)

# compute dm2gak bispectrum

# compute bispectrum
Bk_pred = PKL.Bk(pred_cube, BoxSize, k1, k2, theta, MAS, threads)