Esempio n. 1
0
def frequency_direction_(lightcone, z_low, box_size_mpc, dnu):

	#Figure out the comoving distances of the slices in input lightcone
	cell_size = box_size_mpc/lightcone.shape[0]
	distances = cm.z_to_cdist(z_low) + np.arange(lightcone.shape[2])*cell_size
	input_redshifts = cm.cdist_to_z(distances)
	input_frequencies = cm.z_to_nu(input_redshifts)
	nu1 = input_frequencies[0]
	nu2 = input_frequencies[-1]
	output_frequencies = np.arange(nu1, nu2, -dnu) - dnu/2.
	
	output_lightcone = np.zeros((lightcone.shape[0], lightcone.shape[1], \
                                 len(output_frequencies)))
    
	#Bin in frequencies by smoothing and indexing    
	for i in xrange(output_lightcone.shape[2]-1):
		max_cell_size = cm.nu_to_cdist(output_frequencies[i])-cm.nu_to_cdist(output_frequencies[i+1])
		smooth_scale = np.round(max_cell_size/cell_size)
		if smooth_scale < 1:
			smooth_scale = 1
		hf.print_msg('Smooth along LoS with scale %f' % smooth_scale)
		tophat3d = np.ones((1,1,smooth_scale))
		tophat3d /= np.sum(tophat3d)
		lightcone_smoothed = hf.fftconvolve(lightcone, tophat3d)
		nu = output_frequencies[i]
		idx = hf.find_idx(input_frequencies, nu)
		output_lightcone[:,:,i] = lightcone_smoothed[:,:,idx]

	return output_lightcone, output_frequencies
Esempio n. 2
0
def frequency_direction(lightcone, z_low, box_size_mpc, dnu):
	cell_size = box_size_mpc/lightcone.shape[0]
	distances = cm.z_to_cdist(z_low) + np.arange(lightcone.shape[2])*cell_size
	input_redshifts = cm.cdist_to_z(distances)
	input_frequencies = cm.z_to_nu(input_redshifts)
	nu1 = input_frequencies[0]
	nu2 = input_frequencies[-1]
	output_frequencies = np.arange(nu1, nu2, -dnu) - dnu/2.
	
	output_lightcone = np.zeros((lightcone.shape[0], lightcone.shape[1], \
                                 len(output_frequencies)))

	for i in xrange(output_lightcone.shape[2]):
		nu = output_frequencies[i]
		z_out_low  = cm.nu_to_z(nu+dnu/2.)
		z_out_high = cm.nu_to_z(nu-dnu/2.)
		if i==0:idx_low = np.ceil(hf.find_idx(input_redshifts, z_out_low))
		else:	idx_low = idx_high
		idx_high = np.ceil(hf.find_idx(input_redshifts, z_out_high))
		output_lightcone[:,:,i] = np.mean(lightcone[:,:,idx_low:idx_high], axis=2)

	return output_lightcone, output_frequencies