diff --git a/3_more_examples.py b/3_more_examples.py index 56322d3398838653b3a2aecda20a6aee41a4d783..b71980ffcb8b0540d398d7a5686126f5e8a70d1c 100644 --- a/3_more_examples.py +++ b/3_more_examples.py @@ -28,21 +28,24 @@ for mode in [0, 1]: power_space = ift.PowerSpace(harmonic_space) HT = ift.HarmonicTransformOperator(harmonic_space, target=position_space) - # Set up an amplitude operator for the field - dct = { - 'target': power_space, - 'n_pix': 64, # 64 spectral bins - # Spectral smoothness (affects Gaussian process part) - 'a': 10, # relatively high variance of spectral curvature - 'k0': .2, # quefrency mode below which cepstrum flattens - # Power-law part of spectrum: - 'sm': -4, # preferred power-law slope - 'sv': .6, # low variance of power-law slope - 'im': -3, # y-intercept mean, in-/decrease for more/less contrast - 'iv': 2. # y-intercept variance + args = { + 'offset_mean': 0, + 'offset_std': (1e-3, 1e-6), + + # Amplitude of field fluctuations + 'fluctuations': (1., 0.8), # 1.0, 1e-2 + + # Exponent of power law power spectrum component + 'loglogavgslope': (-3., 1), # -6.0, 1 + + # Amplitude of integrated Wiener process power spectrum component + 'flexibility': (2, 1.), # 1.0, 0.5 + + # How ragged the integrated Wiener process component is + 'asperity': (0.5, 0.4) # 0.1, 0.5 } - A = ift.SLAmplitude(**dct) - correlated_field = ift.CorrelatedField(position_space, A) + correlated_field = ift.SimpleCorrelatedField(position_space, **args) + A = correlated_field.amplitude dct = {} if mode == 0: @@ -64,8 +67,8 @@ for mode in [0, 1]: # Solve inference problem ic_sampling = ift.GradientNormController(iteration_limit=100) - ic_newton = ift.GradInfNormController( - name='Newton', tol=1e-6, iteration_limit=50) + ic_newton = ift.GradInfNormController(name='Newton', tol=1e-6, + iteration_limit=10) minimizer = ift.NewtonCG(ic_newton) H = ift.StandardHamiltonian(likelihood, ic_sampling) initial_mean = ift.MultiField.full(H.domain, 0.) @@ -73,9 +76,9 @@ for mode in [0, 1]: N_samples = 5 for _ in range(5): # Draw new samples and minimize KL - KL = ift.MetricGaussianKL(mean, H, N_samples) + KL = ift.MetricGaussianKL(mean, H, N_samples, True) KL, convergence = minimizer(KL) mean = KL.position N_posterior_samples = 30 - KL = ift.MetricGaussianKL(mean, H, N_posterior_samples) + KL = ift.MetricGaussianKL(mean, H, N_posterior_samples, True) h.plot_reconstruction_2d(data, ground_truth, KL, signal, R, A, name[mode]) diff --git a/helpers/responses.py b/helpers/responses.py index cd7a87a4e2c573d62efa76daa2858c05716dbe99..ac2d902369023e85f60317384fd56c1133e9ba6e 100644 --- a/helpers/responses.py +++ b/helpers/responses.py @@ -44,7 +44,7 @@ def exposure_response(position_space): exposure[:, x_shape*4//5:x_shape] *= .1 exposure[:, x_shape//2:x_shape*3//2] *= 3. - exposure = ift.Field.makeField(position_space, exposure) + exposure = ift.makeField(position_space, exposure) E = ift.makeOp(exposure) G = ift.GeometryRemover(E.target) return G @ E