Commit b71c542f authored by Martin Reinecke's avatar Martin Reinecke
Browse files

tweaks

parent 88bbc09c
......@@ -2,6 +2,7 @@ import numpy as np
import nifty4 as ift
import numericalunits as nu
if __name__ == "__main__":
# In MPI mode, the random seed for numericalunits must be set by hand
#nu.reset_units(43)
......@@ -38,7 +39,7 @@ if __name__ == "__main__":
signal_space = ift.RGSpace(shape, distances=L/N_pixels)
harmonic_space = signal_space.get_default_codomain()
fft = ift.FFTOperator(harmonic_space, target=signal_space)
fft = ift.HarmonicTransformOperator(harmonic_space, target=signal_space)
power_space = ift.PowerSpace(harmonic_space)
# Creating the mock data
......@@ -48,34 +49,27 @@ if __name__ == "__main__":
mock_power = ift.PS_field(power_space, power_spectrum)
mock_harmonic = ift.power_synthesize(mock_power, real_signal=True)
print mock_harmonic.val[0]/nu.K/(nu.m**dimensionality)
mock_signal = fft(mock_harmonic)
print "msig",mock_signal.val[0:10]/nu.K
sensitivity = (1./nu.m)**dimensionality/nu.K
R = ift.ResponseOperator(signal_space, sigma=(0.*response_sigma,),
R = ift.ResponseOperator(signal_space, sigma=(response_sigma,),
sensitivity=(sensitivity,))
data_domain = R.target[0]
R_harmonic = R*fft
noise_amplitude = 1./signal_to_noise*field_sigma*sensitivity*((L/N_pixels)**dimensionality)
print noise_amplitude
print "noise amplitude:", noise_amplitude
N = ift.DiagonalOperator(
ift.Field.full(data_domain, noise_amplitude**2))
noise = ift.Field.from_random(
domain=data_domain, random_type='normal',
std=noise_amplitude, mean=0)
data = R(mock_signal)
print data.val[5:10]
data += noise
print data.val[5:10]
data = R(mock_signal) + noise
# Wiener filter
j = R_harmonic.adjoint_times(N.inverse_times(data))
print "xx",j.val[0]*nu.K*(nu.m**dimensionality)
exit()
ctrl = ift.GradientNormController(
verbose=True, tol_abs_gradnorm=1e-40/(nu.K*(nu.m**dimensionality)))
verbose=True, tol_abs_gradnorm=1e-5/(nu.K*(nu.m**dimensionality)))
inverter = ift.ConjugateGradient(controller=ctrl)
wiener_curvature = ift.library.WienerFilterCurvature(
S=S, N=N, R=R_harmonic, inverter=inverter)
......@@ -85,8 +79,10 @@ if __name__ == "__main__":
sspace2 = ift.RGSpace(shape, distances=L/N_pixels/nu.m)
ift.plot(ift.Field(sspace2, mock_signal.val)/nu.K, name="mock_signal.png")
data = ift.dobj.to_global_data(data.val).reshape(sspace2.shape)
data = ift.Field(sspace2, val=ift.dobj.from_global_data(data))
ift.plot(ift.Field(sspace2, val=data), name="data.png")
ift.plot(ift.Field(sspace2, m_s.val)/nu.K, name="map.png")
ift.plot(ift.Field(sspace2, mock_signal.val)/nu.K, title="mock_signal.png")
#data = ift.dobj.to_global_data(data.val).reshape(sspace2.shape)
#data = ift.Field(sspace2, val=ift.dobj.from_global_data(data))
ift.plot(ift.Field(sspace2, val=R.adjoint_times(data).val), title="data.png")
print "msig",np.min(mock_signal.val)/nu.K, np.max(mock_signal.val)/nu.K
print "map",np.min(m_s.val)/nu.K, np.max(m_s.val)/nu.K
ift.plot(ift.Field(sspace2, m_s.val)/nu.K, title="map.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