From 857b5dc95d8ec798c992d4b63bcbd7e43483dc5d Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Fri, 10 Oct 2014 12:04:43 +0200 Subject: [PATCH] Added randomization of the galaxies direction --- python_sample/build_dipole_ksz_from_galaxies.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/python_sample/build_dipole_ksz_from_galaxies.py b/python_sample/build_dipole_ksz_from_galaxies.py index 271584e..77db90d 100644 --- a/python_sample/build_dipole_ksz_from_galaxies.py +++ b/python_sample/build_dipole_ksz_from_galaxies.py @@ -38,7 +38,7 @@ def build_unit_vectors(N): return ux,uy,uz -def generate_from_catalog(dmin,dmax,Nside): +def generate_from_catalog(dmin,dmax,Nside,do_random=False): import progressbar as pbar cat = np.load("2m++.npy") @@ -55,8 +55,11 @@ def generate_from_catalog(dmin,dmax,Nside): ksz_mask = np.ones(Npix, dtype=np.uint8) for i in pbar.ProgressBar(maxval = cat.size, widgets=[pbar.Bar(), pbar.ETA()])(cat): - l,b=i['gal_long'],i['gal_lat'] - ra,dec=i['ra'],i['dec'] + if do_random: + l = np.random.rand()*360 + b = np.arcsin(2*np.random.rand()-1)*90/np.pi + else: + l,b=i['gal_long'],i['gal_lat'] l=ne.evaluate('l*deg2rad') b=ne.evaluate('b*deg2rad') @@ -100,6 +103,7 @@ def get_args(): parser.add_argument('--base_fig', type=str, default="kszfig.png") parser.add_argument('--build_dipole', type=bool, default=False) parser.add_argument('--degrade', type=int, default=-1) + parser.add_argument('--random', type=bool, default=False) return parser.parse_args() def main(): @@ -112,7 +116,7 @@ def main(): print("Generating map...") - proj,mask = generate_from_catalog(args.depth_min,args.depth_max,args.Nside) + proj,mask = generate_from_catalog(args.depth_min,args.depth_max,args.Nside,do_random=args.random) if args.degrade > 0: proj *= mask