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

adjust tests

parent 12e3d597
Pipeline #18570 failed with stage
in 3 minutes and 55 seconds
......@@ -64,7 +64,7 @@ if __name__ == "__main__":
# Choose the measurement instrument
# Instrument = SmoothingOperator(s_space, sigma=0.01)
Instrument = ift.DiagonalOperator(s_space, diagonal=1.)
Instrument = ift.DiagonalOperator(ift.Field(s_space, 1.))
# Instrument._diagonal.val[200:400, 200:400] = 0
# Instrument._diagonal.val[64:512-64, 64:512-64] = 0
......@@ -72,7 +72,7 @@ if __name__ == "__main__":
R = AdjointFFTResponse(fft, Instrument)
noise = 1.
N = ift.DiagonalOperator(s_space, ift.Field(s_space,noise).weight(1))
N = ift.DiagonalOperator(ift.Field(s_space,noise).weight(1))
n = ift.Field.from_random(domain=s_space,
random_type='normal',
std=np.sqrt(noise),
......@@ -101,7 +101,7 @@ if __name__ == "__main__":
def ps0(k):
return (1./(1.+k)**2)
t0 = ift.Field(p_space, val=np.log(1./(1+p_space.k)_lengths)**2))
t0 = ift.Field(p_space, val=np.log(1./(1+p_space.k_lengths)**2))
for i in range(500):
S0 = ift.create_power_operator(h_space, power_spectrum=ps0)
......
......@@ -39,7 +39,7 @@ if __name__ == "__main__":
# Setting up the noise covariance and drawing a random noise realization
ndiag = ift.Field(data_domain, mock_signal.var()/signal_to_noise).weight(1)
N = ift.DiagonalOperator(data_domain, ndiag)
N = ift.DiagonalOperator(ndiag)
noise = ift.Field.from_random(domain=data_domain, random_type='normal',
std=mock_signal.std()/np.sqrt(signal_to_noise), mean=0)
data = R(ift.exp(mock_signal)) + noise #|\label{code:wf_mock_data}|
......
......@@ -58,8 +58,7 @@ if __name__ == "__main__":
diagonal = mock_power.power_synthesize_special(spaces=(0, 1))**2
diagonal = diagonal.real
S = ift.DiagonalOperator(domain=(harmonic_space_1, harmonic_space_2),
diagonal=diagonal)
S = ift.DiagonalOperator(diagonal)
np.random.seed(10)
......@@ -82,7 +81,7 @@ if __name__ == "__main__":
# Setting up the noise covariance and drawing a random noise realization
ndiag = ift.Field(data_domain, mock_signal.var()/signal_to_noise).weight(1)
N = ift.DiagonalOperator(data_domain, ndiag)
N = ift.DiagonalOperator(ndiag)
noise = ift.Field.from_random(domain=data_domain, random_type='normal',
std=mock_signal.std()/np.sqrt(signal_to_noise),
mean=0)
......
......@@ -38,14 +38,14 @@ if __name__ == "__main__":
# Setting up the noise covariance and drawing a random noise realization
ndiag = ift.Field(data_domain, mock_signal.var()/signal_to_noise).weight(1)
N = ift.DiagonalOperator(data_domain, ndiag)
N = ift.DiagonalOperator(ndiag)
noise = ift.Field.from_random(domain=data_domain, random_type='normal',
std=mock_signal.std()/np.sqrt(signal_to_noise), mean=0)
data = R(mock_signal) + noise #|\label{code:wf_mock_data}|
# Wiener filter
j = R_harmonic.adjoint_times(N.inverse_times(data))
ctrl = ift.DefaultIterationController(verbose=True,tol_abs_gradnorm=0.1,iteration_limit=10)
ctrl = ift.DefaultIterationController(verbose=True,tol_abs_gradnorm=0.1)
inverter = ift.ConjugateGradient(controller=ctrl)
wiener_curvature = ift.library.WienerFilterCurvature(S=S, N=N, R=R_harmonic,inverter=inverter)
m_k = wiener_curvature.inverse_times(j) #|\label{code:wf_wiener_filter}|
......
......@@ -17,7 +17,7 @@ class MultiProber(ift.DiagonalProberMixin, ift.TraceProberMixin, ift.Prober):
x = ift.RGSpace((8, 8))
f = ift.Field.from_random(domain=x, random_type='normal')
diagOp = ift.DiagonalOperator(domain=x, diagonal=f)
diagOp = ift.DiagonalOperator(f)
diagProber = DiagonalProber(domain=x)
diagProber(diagOp)
......
......@@ -47,8 +47,7 @@ if __name__ == "__main__":
data_domain = R.target[0]
R_harmonic = ift.ComposedOperator([fft, R], default_spaces=[0, 0])
N = ift.DiagonalOperator(data_domain,
diagonal=ift.Field(data_domain,mock_signal.var()/signal_to_noise).weight(1))
N = ift.DiagonalOperator(ift.Field(data_domain,mock_signal.var()/signal_to_noise).weight(1))
noise = ift.Field.from_random(domain=data_domain,
random_type='normal',
std=mock_signal.std()/np.sqrt(signal_to_noise),
......
......@@ -56,14 +56,14 @@ if __name__ == "__main__":
# Choosing the measurement instrument
# Instrument = SmoothingOperator(s_space, sigma=0.05)
Instrument = ift.DiagonalOperator(s_space, diagonal=1.)
Instrument = ift.DiagonalOperator(ift.Field(s_space, 1.))
# Instrument._diagonal.val[200:400, 200:400] = 0
# Adding a harmonic transformation to the instrument
R = AdjointFFTResponse(fft, Instrument)
signal_to_noise = 1.
ndiag = ift.Field(s_space, ss.var()/signal_to_noise).weight(1)
N = ift.DiagonalOperator(s_space, ndiag)
N = ift.DiagonalOperator(ndiag)
n = ift.Field.from_random(domain=s_space,
random_type='normal',
std=ss.std()/np.sqrt(signal_to_noise),
......
......@@ -2,7 +2,7 @@
import numpy as np
from numpy import ndarray as data_object
from numpy import full, empty, sqrt, ones, zeros, vdot, abs, bincount
from numpy import full, empty, sqrt, ones, zeros, vdot, abs, bincount, exp, log
from ..nifty_utilities import cast_iseq_to_tuple, get_slice_list
from functools import reduce
......
......@@ -22,7 +22,7 @@ class CriticalPowerCurvature(InvertibleOperatorMixin, EndomorphicOperator):
# ---Overwritten properties and methods---
def __init__(self, theta, T, inverter, preconditioner=None, **kwargs):
self.theta = DiagonalOperator(theta.domain, diagonal=theta)
self.theta = DiagonalOperator(theta)
self.T = T
if preconditioner is None:
preconditioner = self.theta.inverse_times
......
......@@ -66,7 +66,7 @@ def create_power_operator(domain, power_spectrum, dtype=None):
f = f.real
f **= 2
return DiagonalOperator(domain, diagonal=Field(domain,f).weight(1))
return DiagonalOperator(Field(domain,f).weight(1))
def generate_posterior_sample(mean, covariance):
......
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