def radon_filter(st, inv, event, p, weights, line_model, inversion_model, hyperparameters): """ This function applies the radon_inverse, the user is now able to pick a polygon around the energy that should be extracted. It returns the dataset containing only the extracted energy. example: P_axis=np.arange(-5,5.01,0.01) Mpick, x, y = radon.radon_filter(st, inv, cat[0], P_axis, None, "Linear", "L2", [5e-2]) plt.yticks(y) plt.xticks(x) plt.imshow(abs(Mpick), extent=[min(x), max(x), min(y), max(y)], aspect='auto' ) plt.show() Look in radon_example.py for more details """ st_input = st.copy() print('Starting inverse Radon-Transformation') R, t, epi = radon_inverse(st_input, inv, event, p, weights, line_model, inversion_model, hyperparameters) indicies = get_polygon(R, no_of_vert=8, xlabel=r'$\tau$', ylabel='p') Rpick=np.zeros(R.shape) Rpick.conj().transpose().flat[ indicies ]=1 Rpick=R*Rpick Delta_resampled = np.arange( int(math.floor(min(epi))), int(math.ceil(max(epi)))+1, (int(math.ceil(max(epi))) - int(math.floor(min(epi))))/20.) yticks = np.arange(int(math.ceil(min(Delta_resampled/10)))*10, int(math.ceil(max(Delta_resampled/10)))*10 + 10,10)[::-1] xticks = np.arange(int(math.ceil(min(t/100)))*100, int(math.ceil(max(t/100)))*100 + 100,100)[::2] Mpick = radon_forward(t, p, Rpick, Delta_resampled, np.mean(epi), line_model) return Mpick, xticks, yticks
def _fk_eliminate_polygon(data, polygon, xlabel=None, xticks=None, ylabel=None, yticks=None, eval_mean=1, fs=25): """ Only use with the function fk_filter! Function to test the fk workflow with synthetic data param data: data of the array type data: numpy.ndarray """ # Shift 0|0 f-k to center, for easier handling dsfk = np.fft.fftshift(data.conj().transpose()) dsfk_tmp = dsfk[0:dsfk.shape[0]/2] # Define polygon by user-input. # If eval_mean is true, select area where to calculate the mean value if eval_mean != 1: indicies_eval = get_polygon(abs(dsfk_tmp), 4, xlabel, xticks, ylabel, yticks) dsfk_eval = dsfk dsfk_eval.conj().transpose().flat[ indicies_eval ] = dsfk_eval.conj().transpose().flat[ indicies_eval ] / float(eval_mean) dsfk_tmp = dsfk_eval.copy() #indicies = get_polygon(np.log(abs(dsfk)), polygon, xlabel, xticks, ylabel, yticks) indicies = get_polygon(abs(dsfk_tmp), polygon, xlabel, xticks, ylabel, yticks, fs) # Create new array, only contains extractet energy, pointed to with indicies dsfk_elim = np.ones(dsfk_tmp.shape) dsfk_elim.conj().transpose().flat[ indicies ] = 0. dsfk_tmp = dsfk_tmp * dsfk_elim data_fk = np.zeros(dsfk.shape).astype('complex') #top half of domain. data_fk[0:dsfk.shape[0]/2] = dsfk_tmp #Bottom half of domain, exploiting symmetry and shift properties. data_fk[dsfk.shape[0]/2:] = np.roll(np.roll(np.flipud(np.fliplr(dsfk_tmp)),1).transpose(), 1).transpose() data_fk = np.fft.ifftshift(data_fk.conj().transpose()) return data_fk