Exemplo n.º 1
0
def v_to_x(v_true, zobs, Dr):
    ngal = len(v_true)
    OM = 0.31
    Dz = cc.dxx_mpch_arr(ngal, zobs, OM)
    x = np.log10(Dz/Dr)
    return x
Exemplo n.º 2
0
def observableEtaTest(mocksFolder):
    ''' Test Normalising Observed eta to Zero '''

    zfile = '/Users/Morag/Cosmology_codes/redshift_OM0.3175.dat'

    xArr = []
    magArr = []
    BFdiffArr = []
    # Read in each mock. 
    #  r  s  i  x[Mpc/h]  y[Mpc/h]  z[Mpc/h]  D_c[Mpc/h]  RA  Dec  ztrue  zobs  vpec[km/s]  appJ  V_max_sub
    for i in range(20):
        mockFile = '%svmock_Gz_highbias_c0p6_%s.dat' % (mocksFolder,str(i).zfill(2))
        data = np.loadtxt(mockFile, comments='#')
        # x[Mpc/h]  y[Mpc/h]  z[Mpc/h]  D_c[Mpc/h]  RA  Dec vpec[km/s] zobs
        g = data[:,[3,4,5,6,7,8,11,10]]
        # Calculate true SSBF
        trueBF = MLE_BF(g)

        # Calulate observable x 
        x = v_to_x(g[:,6], g[:,7], g[:,3])
        # Append x values to g
        g = np.column_stack((g, x[:,None]))

        # Find galaxies within -20 < Dec < 0
        gInC = g[g[:,5]>-20]
        # Calculate mean radial velocity within -20 < Dec < 0 circle
        meanx = np.mean(gInC[:,8])
        
        # Renormalise all x values in mock to normalise Great Circle to zero
        g[:,8] -= meanx

        # Convert these back to velocities
        OM = 0.31
        Dz = cc.dxx_mpch_arr(len(g), g[:,7], OM)
        g[:,6] = x_to_v(g[:,8], g[:,7], Dz, zfile)

        # Calculate true SSBF
        newBF = MLE_BF(g)

        BFdiff = newBF-trueBF
        print 'Old BF: ', trueBF, ', New BF: ', newBF
        print 'Change in BF: ', mag(BFdiff)
        magArr.append(mag(BFdiff))
        BFdiffArr.append((BFdiff[0],BFdiff[1],BFdiff[2]))
        xArr.append(meanx)

    xArr = np.array(xArr)
    magArr = np.array(magArr)

    meanBFdiff = meanVector(BFdiffArr)

    print 'Mean radial x in circle: ', np.mean(xArr)
    print 'Variance: ',np.var(xArr)
    print 'Std: ', np.std(xArr)
    print ''

    print 'Mean BF diff mag: ', np.mean(magArr)
    print 'Std: ', np.std(magArr)
    print ''

    print 'Mean BF diff: ', meanBFdiff
    print 'Mag: ', mag(meanBFdiff)
        
    return