From 1e733f23188b5ecc3436d34be3bde399542bf945 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Tue, 23 Sep 2014 11:06:43 +0200 Subject: [PATCH] Added code to generate the dipole ksz --- .../build_dipole_ksz_from_galaxies.py | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 python_sample/build_dipole_ksz_from_galaxies.py diff --git a/python_sample/build_dipole_ksz_from_galaxies.py b/python_sample/build_dipole_ksz_from_galaxies.py new file mode 100644 index 0000000..29358b1 --- /dev/null +++ b/python_sample/build_dipole_ksz_from_galaxies.py @@ -0,0 +1,130 @@ +import numexpr as ne +import healpy as hp +import numpy as np +import cosmotool as ct +import argparse +import h5py as h5 +import matplotlib +matplotlib.use('Agg') +from matplotlib import pyplot as plt +import ksz +from ksz.constants import * +from cosmotool import interp3d + +def wrapper_impulsion(f): + + class _Wrapper(object): + def __init__(self): + pass + + def __getitem__(self,direction): + + if 'velocity' in f: + return f['velocity'][:,:,:,direction] + + n = "p%d" % direction + return f[n] + + return _Wrapper() + + +def build_unit_vectors(N): + ii = np.arange(N,dtype=np.float64)/N - 0.5 + d = np.sqrt(ii[:,None,None]**2 + ii[None,:,None]**2 + ii[None,None,:]**2) + d[N/2,N/2,N/2] = 1 + ux = ii[:,None,None] / d + uy = ii[None,:,None] / d + uz = ii[None,None,:] / d + + return ux,uy,uz + +def generate_from_catalog(dmin,dmax,Nside): + import progressbar as pbar + + cat = np.load("2m++.npy") + + cat['distance'] = cat['best_velcmb'] + cat = cat[np.where((cat['distance']>100*dmin)*(cat['distance']