Commit 8054b9ce by Jakob Knollmueller

### everything not essential thrown out

parent a7371557
 from sugar import build_problem, problem_iteration import nifty4 as ift import numpy as np from matplotlib import rc rc('font',**{'family':'serif','serif':['Palatino']}) rc('text', usetex=True) from matplotlib import pyplot as plt np.random.seed(42) if __name__ == '__main__': s_space = ift.RGSpace([1024]) h_space = s_space.get_default_codomain() FFT = ift.FFTOperator(h_space) p_spec = lambda k: (1./(1+k)**2.5) S = ift.create_power_operator(h_space, power_spectrum=p_spec) sh = S.draw_sample() s = FFT(sh) u = ift.Field(s_space, val = -12) u.val[200] = 1 u.val[300] = 3 u.val[500] = 4 u.val[700] = 5 u.val[900] = 2 u.val[154] = 0.5 u.val[421] = 0.25 u.val[652] = 1 u.val[1002] = 2.5 d = ift.exp(s) + ift.exp(u) data = d.val energy1 = build_problem(data,1.25) energy2 = build_problem(data,1.5) energy3 = build_problem(data,1.75) for i in range(20): energy1 = problem_iteration(energy1) energy2 = problem_iteration(energy2) energy3 = problem_iteration(energy3) size = 15 plt.figure() # plt.plot(data, 'k-') f, (ax0, ax1,ax2) = plt.subplots(3, sharex=True, sharey=True) plt.suptitle('diffuse components', size=size) ax0.plot(ift.exp(energy1.s).val, 'k-') ax0.yaxis.set_label_position("right") ax0.set_ylabel(r'$\alpha = 1.25$', size=size) ax0.set_ylim(1e-1,1e3) ax0.set_yscale("log") ax1.plot(ift.exp(energy2.s).val, 'k-') ax1.yaxis.set_label_position("right") ax1.set_ylabel(r'$\alpha = 1.5$', size=size) ax2.plot(ift.exp(energy3.s).val, 'k-') ax2.yaxis.set_label_position("right") ax2.set_ylabel(r'$\alpha = 1.75$', size=size) plt.savefig('1d_diffuse.pdf') plt.figure() f, (ax0, ax1,ax2) = plt.subplots(3, sharex=True, sharey=True) plt.suptitle('point-like components', size=size) ax0.plot(ift.exp(energy1.u).val, 'k-') ax0.yaxis.set_label_position("right") ax0.set_ylabel(r'$\alpha = 1.25$', size=size) ax0.set_ylim(1e-1,1e3) ax0.set_yscale("log") ax1.plot(ift.exp(energy2.u).val, 'k-') ax1.yaxis.set_label_position("right") ax1.set_ylabel(r'$\alpha = 1.5$', size=size) ax2.plot(ift.exp(energy3.u).val, 'k-') ax2.yaxis.set_label_position("right") ax2.set_ylabel(r'$\alpha = 1.75$', size=size) ax0.set_yscale("log") ax0.set_ylim(1e-1,1e3) # plt.ylim(1e-0) plt.savefig('1d_points.pdf') plt.figure() f, (ax0, ax1,ax2) = plt.subplots(3, sharex=True, sharey=True) plt.suptitle('data and true components', size=size) ax0.plot(data, 'k-') ax0.set_yscale("log") ax0.set_ylim(1e-1,1e3) ax0.yaxis.set_label_position("right") ax0.set_ylabel(r'data', size=size) ax1.plot(ift.exp(s).val, 'k-') ax1.yaxis.set_label_position("right") ax1.set_ylabel(r'diffuse', size=size) ax2.plot(ift.exp(u).val, 'k-') ax2.yaxis.set_label_position("right") ax2.set_ylabel(r'point-like', size=size) # plt.ylim(1e-0) plt.savefig('1d_data.pdf')