Commit 77c928e1 authored by Philipp Arras's avatar Philipp Arras

Cosmetics

parent 0ee3afdc
......@@ -41,11 +41,12 @@ if __name__ == '__main__':
power_space = A.target[0]
power_distributor = ift.PowerDistributor(harmonic_space, power_space)
dummy = ift.Field.from_random('normal', harmonic_space)
domain = ift.MultiDomain.union(
(A.domain, ift.MultiDomain.make({'xi': harmonic_space})))
domain = ift.MultiDomain.union((A.domain,
ift.MultiDomain.make({
'xi': harmonic_space
})))
correlated_field = ht(
power_distributor(A)*ift.FieldAdapter(domain, "xi"))
correlated_field = ht(power_distributor(A)*ift.FieldAdapter(domain, "xi"))
# alternatively to the block above one can do:
# correlated_field = ift.CorrelatedField(position_space, A)
......@@ -54,8 +55,7 @@ if __name__ == '__main__':
# Building the Line of Sight response
LOS_starts, LOS_ends = get_random_LOS(100)
R = ift.LOSResponse(position_space, starts=LOS_starts,
ends=LOS_ends)
R = ift.LOSResponse(position_space, starts=LOS_starts, ends=LOS_ends)
# build signal response model and model likelihood
signal_response = R(signal)
# specify noise
......@@ -68,8 +68,7 @@ if __name__ == '__main__':
data = signal_response(MOCK_POSITION) + N.draw_sample()
# set up model likelihood
likelihood = ift.GaussianEnergy(
mean=data, covariance=N)(signal_response)
likelihood = ift.GaussianEnergy(mean=data, covariance=N)(signal_response)
# set up minimization and inversion schemes
ic_sampling = ift.GradientNormController(iteration_limit=100)
......@@ -86,14 +85,15 @@ if __name__ == '__main__':
ift.plot(signal(MOCK_POSITION), title='Ground Truth')
ift.plot(R.adjoint_times(data), title='Data')
ift.plot([A(MOCK_POSITION)], title='Power Spectrum')
ift.plot_finish(ny=1,nx=3, xsize=24, ysize=6, name="setup.png")
ift.plot_finish(ny=1, nx=3, xsize=24, ysize=6, name="setup.png")
# number of samples used to estimate the KL
N_samples = 20
for i in range(2):
metric = H(ift.Linearization.make_var(position)).metric
samples = [metric.draw_sample(from_inverse=True)
for _ in range(N_samples)]
samples = [
metric.draw_sample(from_inverse=True) for _ in range(N_samples)
]
KL = ift.SampledKullbachLeiblerDivergence(H, samples)
KL = ift.EnergyAdapter(position, KL)
......@@ -106,10 +106,12 @@ if __name__ == '__main__':
sc = ift.StatCalculator()
for sample in samples:
sc.add(signal(sample+position))
sc.add(signal(sample + position))
ift.plot(sc.mean, title="Posterior Mean")
ift.plot(ift.sqrt(sc.var), title="Posterior Standard Deviation")
powers = [A(s+position) for s in samples]
ift.plot([A(position), A(MOCK_POSITION)]+powers, title="Sampled Posterior Power Spectrum")
powers = [A(s + position) for s in samples]
ift.plot(
[A(position), A(MOCK_POSITION)] + powers,
title="Sampled Posterior Power Spectrum")
ift.plot_finish(ny=1, nx=3, xsize=24, ysize=6, name="results.png")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment