Commit 346cb2a2 authored by Philipp Arras's avatar Philipp Arras
Browse files

Adopt demo script

parent bb7cd0dd
Pipeline #63018 failed with stages
in 5 minutes and 38 seconds
......@@ -2,54 +2,32 @@ import nifty5 as ift
import numpy as np
np.random.seed(42)
sspace = ift.RGSpace((128, 128), (0.2, 0.2))
sspace = ift.RGSpace((128,))
hspace = sspace.get_default_codomain()
target = ift.PowerSpace(hspace)
target0 = ift.PowerSpace(hspace)
fa = ift.FinalAmplitude()
fa.add_fluctuations(target, 1, 0.1, 1, 0.1, 1, 0.1, -2, 0.1, 'fst')
fa.add_fluctuations(target, 1, 0.1, 1, 0.1, 1, 0.1, -2, 0.1, 'snd')
fa.finalize(1, 0.1, '', offset=-10)
exit()
A = ift.NormalizedAmplitude(target, 16, 1, 1, -3, 1, 0, 1, 0, 1)
A = ift.WPAmplitude(target, [0, -2, 0], [1E-5, 1, 1], 1, 0.99,
['rest', 'smooth', 'wienersigma'])
avgA = ift.full(A.target, 0.)
n = 1000
for _ in range(n):
avgA = avgA + A(ift.from_random('normal', A.domain))
avgA = avgA/n
corfldfixA = ift.CorrelatedField(sspace, avgA)
corfld = ift.CorrelatedField(sspace, A)
corfld = ift.CorrelatedFieldNormAmplitude(sspace, A, 0, 1)
corfldfixA = ift.CorrelatedFieldNormAmplitude(sspace, avgA, 0, 1)
cstpos = ift.from_random('normal', corfld.domain)
p, p1, p2 = [ift.Plot() for _ in range(3)]
lst, lst1 = [avgA**2], []
skys, skys1, skys2 = [], [], []
fa.add_fluctuations(target0, 10, 2, 1, 1e-6, 2, 1e-6, -2, 1e-6, 'spatial')
op = fa.finalize(10, 0.1, '')
A = fa.amplitudes[0]
cstpos = ift.from_random('normal', op.domain)
p1, p2 = [ift.Plot() for _ in range(2)]
lst1 = []
skys1, skys2 = [], []
for _ in range(8):
pos = ift.from_random('normal', corfld.domain)
skyfixA = corfldfixA.force(pos)
skys.append(skyfixA)
ft = ift.HartleyOperator(hspace, sspace).scale(hspace.scalar_dvol**-0.5)
lst.append(ift.power_analyze(ft.inverse(skyfixA)))
pos = ift.from_random('normal', op.domain)
foo = ift.MultiField.union([cstpos, pos.extract(A.domain)])
skys2.append(corfld(foo))
skys2.append(op(foo))
sky = corfld(pos)
sky = op(pos)
skys1.append(sky)
lst1.append(A.force(pos))
for pp, ll in [(p, skys), (p1, skys1), (p2, skys2)]:
for pp, ll in [(p1, skys1), (p2, skys2)]:
mi, ma = None, None
if True:
if False:
mi, ma = np.inf, -np.inf
for ss in ll:
mi = min([mi, np.amin(ss.val)])
......@@ -57,9 +35,7 @@ for pp, ll in [(p, skys), (p1, skys1), (p2, skys2)]:
for ss in ll:
pp.add(ss, zmin=mi, zmax=ma)
p.add(lst)
p1.add(lst1)
p2.add(lst1)
p1.output(name='full.png')
p.output(name='A_fixed.png')
p2.output(name='xi_fixed.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