def angular_slice_to_physical(input_slice, z, slice_size_deg, output_cell_size, output_size_mpc, order=0, prefilter=True): ''' Interpolate a slice in angular coordinates to physical Returns: (physical_slice, size_mpc) ''' #Resample slice_size_mpc = cm.deg_to_cdist(slice_size_deg, z) n_cells_resampled = int(slice_size_mpc/output_cell_size) #Avoid edge effects with even number of cells if n_cells_resampled % 2 == 0: n_cells_resampled += 1 resampled_slice = resample_slice(input_slice, n_cells_resampled, order, prefilter) #Remove cells to get correct size n_cutout_cells = int(output_size_mpc/output_cell_size)# np.round(resampled_slice.shape[0]*output_size_mpc/slice_size_mpc) if n_cutout_cells > input_slice.shape[0]: if input_slice.shape[0] - n_cutout_cells > 2: print 'Warning! Cutout slice is larger than original.' print 'This should not happen' n_cutout_cells = input_slice.shape[0] slice_cutout = resampled_slice[:n_cutout_cells, :n_cutout_cells] return slice_cutout
def physical_slice_to_angular(input_slice, z, slice_size_mpc, fov_deg, dtheta, order=0): ''' Interpolate a slice in physical coordinates to angular coordinates. Parameters: * input_slice (numpy array): the 2D slice in physical coordinates * z (float): the redshift of the input slice * slice_size_Mpc (float): the size of the input slice in cMpc * fov_deg (float): the field-of-view in degrees. The output will be padded to match this size * dtheta (float): the target resolution in arcmin Returns: (angular_slice, size_deg) ''' #Resample fov_mpc = cm.deg_to_cdist(fov_deg, z) cell_size_mpc = fov_mpc / (fov_deg * 60. / dtheta) n_cells_resampled = int(slice_size_mpc / cell_size_mpc) #Avoid edge effects with even number of cells if n_cells_resampled % 2 == 0: n_cells_resampled -= 1 resampled_slice = resample_slice(input_slice, n_cells_resampled, order) #Pad the array slice_n = resampled_slice.shape[0] padded_n = fov_deg * 60. / dtheta # np.round(slice_n*(fov_mpc/slice_size_mpc)) if padded_n < slice_n: if slice_n - padded_n > 2: print 'Warning! Padded slice is significantly smaller than original!' print 'This should not happen...' padded_n = slice_n padded_slice = _get_padded_slice(resampled_slice, padded_n) return padded_slice
def physical_slice_to_angular(input_slice, z, slice_size_mpc, fov_deg, dtheta, order=0): ''' Interpolate a slice in physical coordinates to angular coordinates. Parameters: * input_slice (numpy array): the 2D slice in physical coordinates * z (float): the redshift of the input slice * slice_size_Mpc (float): the size of the input slice in cMpc * fov_deg (float): the field-of-view in degrees. The output will be padded to match this size * dtheta (float): the target resolution in arcmin Returns: (angular_slice, size_deg) ''' #Resample fov_mpc = cm.deg_to_cdist(fov_deg, z) cell_size_mpc = fov_mpc/(fov_deg*60./dtheta) n_cells_resampled = int(slice_size_mpc/cell_size_mpc) #Avoid edge effects with even number of cells if n_cells_resampled % 2 == 0: n_cells_resampled -= 1 resampled_slice = resample_slice(input_slice, n_cells_resampled, order) #Pad the array slice_n = resampled_slice.shape[0] padded_n = fov_deg*60./dtheta# np.round(slice_n*(fov_mpc/slice_size_mpc)) if padded_n < slice_n: if slice_n - padded_n > 2: print 'Warning! Padded slice is significantly smaller than original!' print 'This should not happen...' padded_n = slice_n padded_slice = _get_padded_slice(resampled_slice, padded_n) return padded_slice