Skip to content
Snippets Groups Projects
Commit 03577165 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

demo tweaks

parent c3627c40
No related branches found
No related tags found
No related merge requests found
import nifty4 as ift import nifty4 as ift
from nifty4.library.nonlinearities import Linear from nifty4.library.nonlinearities import Linear, Tanh, Exponential
import numpy as np import numpy as np
np.random.seed(42) np.random.seed(42)
...@@ -31,7 +31,7 @@ if __name__ == "__main__": ...@@ -31,7 +31,7 @@ if __name__ == "__main__":
p_space = ift.PowerSpace(h_space, p_space = ift.PowerSpace(h_space,
binbounds=ift.PowerSpace.useful_binbounds( binbounds=ift.PowerSpace.useful_binbounds(
h_space, logarithmic=True)) h_space, logarithmic=True))
s_spec = ift.Field.full(p_space, 1.) s_spec = ift.Field.full(p_space, 1e-5)
# Choosing the prior correlation structure and defining # Choosing the prior correlation structure and defining
# correlation operator # correlation operator
p = ift.PS_field(p_space, p_spec) p = ift.PS_field(p_space, p_spec)
...@@ -44,6 +44,7 @@ if __name__ == "__main__": ...@@ -44,6 +44,7 @@ if __name__ == "__main__":
# Choosing the measurement instrument # Choosing the measurement instrument
# Instrument = SmoothingOperator(s_space, sigma=0.01) # Instrument = SmoothingOperator(s_space, sigma=0.01)
mask = np.ones(s_space.shape) mask = np.ones(s_space.shape)
#mask[6000:8000] = 0.
mask[30:70,30:70] = 0. mask[30:70,30:70] = 0.
mask = ift.Field.from_global_data(s_space, mask) mask = ift.Field.from_global_data(s_space, mask)
...@@ -74,6 +75,13 @@ if __name__ == "__main__": ...@@ -74,6 +75,13 @@ if __name__ == "__main__":
t0 = ift.Field.full(p_space, -4.) t0 = ift.Field.full(p_space, -4.)
power0 = Distributor.times(ift.exp(0.5 * t0)) power0 = Distributor.times(ift.exp(0.5 * t0))
plotdict = {"colormap": "Planck-like"}
zmin = true_sky.min()
zmax = true_sky.max()
ift.plot(true_sky, title="True sky", name="true_sky.png", **plotdict)
ift.plot(MeasurementOperator.adjoint_times(d), title="Data",
name="data.png", **plotdict)
IC1 = ift.GradientNormController(name="IC1", iteration_limit=100, IC1 = ift.GradientNormController(name="IC1", iteration_limit=100,
tol_abs_gradnorm=1e-3) tol_abs_gradnorm=1e-3)
LS = ift.LineSearchStrongWolfe(c2=0.02) LS = ift.LineSearchStrongWolfe(c2=0.02)
...@@ -111,9 +119,8 @@ if __name__ == "__main__": ...@@ -111,9 +119,8 @@ if __name__ == "__main__":
# excitation monopole to 1 # excitation monopole to 1
m0, t0 = adjust_zero_mode(m0, t0) m0, t0 = adjust_zero_mode(m0, t0)
plotdict = {"colormap": "Planck-like"}
ift.plot(true_sky, title="True sky", name="true_sky.png", **plotdict)
ift.plot(nonlinearity(HT(power0*m0)), title="Reconstructed sky", ift.plot(nonlinearity(HT(power0*m0)), title="Reconstructed sky",
name="reconstructed_sky.png", **plotdict) name="reconstructed_sky.png", zmin=zmin, zmax=zmax, **plotdict)
ift.plot(MeasurementOperator.adjoint_times(d), title="Data", ymin = np.min(p.to_global_data())
name="data.png", **plotdict) ift.plot([ift.exp(t0),p], title="Power spectra",
name="ps.png", ymin=ymin, **plotdict)
...@@ -113,7 +113,9 @@ if __name__ == "__main__": ...@@ -113,7 +113,9 @@ if __name__ == "__main__":
# excitation monopole to 1 # excitation monopole to 1
m0, t0 = adjust_zero_mode(m0, t0) m0, t0 = adjust_zero_mode(m0, t0)
ift.plot(true_sky) plotdict = {"colormap": "Planck-like"}
ift.plot(true_sky, name="true_sky.png", **plotdict)
ift.plot(nonlinearity(HT(power0*m0)), ift.plot(nonlinearity(HT(power0*m0)),
title='reconstructed_sky') name="reconstructed_sky.png", **plotdict)
ift.plot(MeasurementOperator.adjoint_times(d)) ift.plot(MeasurementOperator.adjoint_times(d), name="data.png", **plotdict)
ift.plot([ift.exp(t0),p], name="ps.png")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment