KSZ work
This commit is contained in:
parent
7a27dae025
commit
f12c9a0c1a
5 changed files with 128 additions and 33 deletions
|
@ -100,13 +100,35 @@ def build_unit_vectors(N):
|
|||
|
||||
return ux,uy,uz
|
||||
|
||||
def generate_from_catalog(dmin,dmax,Nside,perturb=0.0,y=0.0,do_random=False,do_hubble=False):
|
||||
def compute_vcmb(l, b):
|
||||
# Motion is obtained from Tully (2007): sun_vs_LS + LS_vs_CMB
|
||||
motion = [-25.,-246.,277.];
|
||||
|
||||
x = np.cos(l*np.pi/180) * np.cos(b*np.pi/180)
|
||||
y = np.sin(l*np.pi/180) * np.cos(b*np.pi/180)
|
||||
z = np.sin(b*np.pi/180)
|
||||
|
||||
return x*motion[0] + y*motion[1] + z*motion[2]
|
||||
|
||||
|
||||
def compute_vlg(l,b):
|
||||
|
||||
motion = [-79,296,-36]; # [-86, 305, -33];
|
||||
|
||||
x = np.cos(l*np.pi/180) * np.cos(b*np.pi/180)
|
||||
y = np.sin(l*np.pi/180) * np.cos(b*np.pi/180)
|
||||
z = np.sin(b*np.pi/180)
|
||||
|
||||
return x*motion[0] + y*motion[1] + z*motion[2]
|
||||
|
||||
|
||||
def generate_from_catalog(dmin,dmax,Nside,perturb=0.0,y=0.0,do_random=False,do_hubble=False,x=2.37,bright=-np.inf,bright_list=[],use_vlg=True,sculpt=-1):
|
||||
import progressbar as pbar
|
||||
|
||||
cat = np.load("2m++.npy")
|
||||
|
||||
cat['distance'] = cat['best_velcmb']
|
||||
cat = cat[np.where((cat['distance']>100*dmin)*(cat['distance']<dmax*100))]
|
||||
# cat = cat[np.where((cat['distance']>100*dmin)*(cat['distance']<dmax*100))]
|
||||
|
||||
deg2rad = np.pi/180
|
||||
Npix = 12*Nside**2
|
||||
|
@ -119,14 +141,19 @@ def generate_from_catalog(dmin,dmax,Nside,perturb=0.0,y=0.0,do_random=False,do_h
|
|||
ksz_hubble_template = np.zeros(ksz_template.size, dtype=np.float64)
|
||||
|
||||
for i in pbar.ProgressBar(maxval = cat.size, widgets=[pbar.Bar(), pbar.ETA()])(cat):
|
||||
# Skip too point sources
|
||||
if i['name'] in bright_list:
|
||||
print("Object %s is in bright list" % i['name'])
|
||||
continue
|
||||
|
||||
if do_random:
|
||||
l = np.random.rand()*360
|
||||
b = np.arcsin(2*np.random.rand()-1)*180/np.pi
|
||||
else:
|
||||
l,b=i['gal_long'],i['gal_lat']
|
||||
l0,b0=i['gal_long'],i['gal_lat']
|
||||
|
||||
l=ne.evaluate('l*deg2rad')
|
||||
b=ne.evaluate('b*deg2rad')
|
||||
l=ne.evaluate('l0*deg2rad')
|
||||
b=ne.evaluate('b0*deg2rad')
|
||||
|
||||
dtheta,dphi = np.random.randn(2)*perturb
|
||||
theta,l=move_direction(dtheta,dphi,0.5*np.pi - b, l)
|
||||
|
@ -137,10 +164,23 @@ def generate_from_catalog(dmin,dmax,Nside,perturb=0.0,y=0.0,do_random=False,do_h
|
|||
y0 = np.sin(l)*np.cos(b)
|
||||
z0 = np.sin(b)
|
||||
|
||||
DA =i['distance']/100
|
||||
if use_vlg:
|
||||
vlg = i['best_velcmb'] - compute_vcmb(l0, b0) + compute_vlg(l0, b0)
|
||||
DA = vlg/100
|
||||
else:
|
||||
DA = i['best_velcmb'] / 100
|
||||
|
||||
if DA < dmin or DA > dmax:
|
||||
continue
|
||||
|
||||
Lgal = DA**2*10**(0.4*(tmpp_cat['Msun']-i['K2MRS']+25))
|
||||
|
||||
profiler = ksz.KSZ_Isothermal(Lgal, 2.37, y=y)
|
||||
M_K=i['K2MRS']-5*np.log10(DA)-25
|
||||
# Skip too bright galaxies
|
||||
if M_K < bright:
|
||||
continue
|
||||
|
||||
profiler = ksz.KSZ_Isothermal(Lgal, x, y=y, sculpt=sculpt)
|
||||
|
||||
idx0 = hp.query_disc(Nside, (x0,y0,z0), 3*profiler.rGalaxy/DA)
|
||||
|
||||
|
@ -177,12 +217,17 @@ def get_args():
|
|||
parser.add_argument('--depth_max', type=float, default=60)
|
||||
parser.add_argument('--ksz_map', type=str, required=True)
|
||||
parser.add_argument('--base_fig', type=str, default="kszfig.png")
|
||||
parser.add_argument('--build_dipole', type=bool, default=False)
|
||||
parser.add_argument('--build_dipole', action='store_true')
|
||||
parser.add_argument('--degrade', type=int, default=-1)
|
||||
parser.add_argument('--y',type=float,default=0.0)
|
||||
parser.add_argument('--random', type=bool, default=False)
|
||||
parser.add_argument('--x',type=float,default=2.37)
|
||||
parser.add_argument('--random', action='store_true')
|
||||
parser.add_argument('--perturb', type=float, default=0)
|
||||
parser.add_argument('--hubble_monopole', type=bool, default=False)
|
||||
parser.add_argument('--hubble_monopole', action='store_true')
|
||||
parser.add_argument('--remove_bright', type=float, default=-np.inf)
|
||||
parser.add_argument('--bright_file', type=str)
|
||||
parser.add_argument('--lg', action='store_true')
|
||||
parser.add_argument('--sculpt_beam', type=float, default=-1)
|
||||
return parser.parse_args()
|
||||
|
||||
def main():
|
||||
|
@ -195,7 +240,16 @@ def main():
|
|||
|
||||
print("Generating map...")
|
||||
|
||||
r = generate_from_catalog(args.depth_min,args.depth_max,args.Nside,perturb=args.perturb,y=args.y,do_random=args.random,do_hubble=args.hubble_monopole)
|
||||
with open("crap.txt", mode="r") as f:
|
||||
bright_list = [l.split('#')[0].strip(" \t\n\r") for l in f]
|
||||
|
||||
if args.bright_file:
|
||||
with open(args.bright_file, mode="r") as f:
|
||||
idx_name = f.readline().split(',').index('name_2')
|
||||
bright_list = bright_list + [l.split(',')[idx_name] for l in f]
|
||||
|
||||
print("Built bright point source list: " + repr(bright_list))
|
||||
r = generate_from_catalog(args.depth_min,args.depth_max,args.Nside,perturb=args.perturb,y=args.y,do_random=args.random,do_hubble=args.hubble_monopole,x=args.x,bright=args.remove_bright,use_vlg=args.lg,bright_list=bright_list,sculpt=args.sculpt_beam)
|
||||
hubble_map = None
|
||||
if args.hubble_monopole:
|
||||
proj,mask,hubble_map = r
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue