Commit 9021e88f authored by Martin Reinecke's avatar Martin Reinecke
Browse files

Distribution -> Distributor

parent 1314c2ac
Pipeline #25217 passed with stages
in 5 minutes and 54 seconds
...@@ -106,7 +106,7 @@ if __name__ == "__main__": ...@@ -106,7 +106,7 @@ if __name__ == "__main__":
power0_energy = ift.library.NonlinearPowerEnergy( power0_energy = ift.library.NonlinearPowerEnergy(
position=t0, d=d, N=N, xi=m0, D=D0, ht=HT, position=t0, d=d, N=N, xi=m0, D=D0, ht=HT,
Instrument=MeasurementOperator, nonlinearity=nonlinearity, Instrument=MeasurementOperator, nonlinearity=nonlinearity,
Distribution=Distributor, sigma=1., samples=2, inverter=inverter) Distributor=Distributor, sigma=1., samples=2, inverter=inverter)
power0_energy = minimizer(power0_energy)[0] power0_energy = minimizer(power0_energy)[0]
......
...@@ -100,7 +100,7 @@ if __name__ == "__main__": ...@@ -100,7 +100,7 @@ if __name__ == "__main__":
power0_energy = ift.library.NonlinearPowerEnergy( power0_energy = ift.library.NonlinearPowerEnergy(
position=t0, d=d, N=N, xi=m0, D=D0, ht=HT, position=t0, d=d, N=N, xi=m0, D=D0, ht=HT,
Instrument=MeasurementOperator, nonlinearity=nonlinearity, Instrument=MeasurementOperator, nonlinearity=nonlinearity,
Distribution=Distributor, sigma=1., samples=2, inverter=inverter) Distributor=Distributor, sigma=1., samples=2, inverter=inverter)
power0_energy = minimizer(power0_energy)[0] power0_energy = minimizer(power0_energy)[0]
......
...@@ -25,7 +25,7 @@ from ..minimization.energy import Energy ...@@ -25,7 +25,7 @@ from ..minimization.energy import Energy
class NoiseEnergy(Energy): class NoiseEnergy(Energy):
def __init__(self, position, d, xi, D, t, ht, Instrument, def __init__(self, position, d, xi, D, t, ht, Instrument,
nonlinearity, alpha, q, Distribution, samples=3, nonlinearity, alpha, q, Distributor, samples=3,
xi_sample_list=None, inverter=None): xi_sample_list=None, inverter=None):
super(NoiseEnergy, self).__init__(position=position) super(NoiseEnergy, self).__init__(position=position)
self.xi = xi self.xi = xi
...@@ -40,8 +40,8 @@ class NoiseEnergy(Energy): ...@@ -40,8 +40,8 @@ class NoiseEnergy(Energy):
self.alpha = alpha self.alpha = alpha
self.q = q self.q = q
self.Distribution = Distribution self.Distributor = Distributor
self.power = self.Distribution(exp(0.5 * self.t)) self.power = self.Distributor(exp(0.5 * self.t))
if xi_sample_list is None: if xi_sample_list is None:
if samples is None or samples == 0: if samples is None or samples == 0:
xi_sample_list = [xi] xi_sample_list = [xi]
...@@ -51,7 +51,7 @@ class NoiseEnergy(Energy): ...@@ -51,7 +51,7 @@ class NoiseEnergy(Energy):
self.xi_sample_list = xi_sample_list self.xi_sample_list = xi_sample_list
self.inverter = inverter self.inverter = inverter
A = Distribution(exp(.5*self.t)) A = Distributor(exp(.5*self.t))
self._gradient = None self._gradient = None
for sample in self.xi_sample_list: for sample in self.xi_sample_list:
...@@ -81,7 +81,7 @@ class NoiseEnergy(Energy): ...@@ -81,7 +81,7 @@ class NoiseEnergy(Energy):
return self.__class__( return self.__class__(
position, self.d, self.xi, self.D, self.t, self.ht, position, self.d, self.xi, self.D, self.t, self.ht,
self.Instrument, self.nonlinearity, self.alpha, self.q, self.Instrument, self.nonlinearity, self.alpha, self.q,
self.Distribution, xi_sample_list=self.xi_sample_list, self.Distributor, xi_sample_list=self.xi_sample_list,
samples=self.samples, inverter=self.inverter) samples=self.samples, inverter=self.inverter)
@property @property
......
...@@ -20,12 +20,12 @@ from ..operators.inversion_enabler import InversionEnabler ...@@ -20,12 +20,12 @@ from ..operators.inversion_enabler import InversionEnabler
from .response_operators import LinearizedPowerResponse from .response_operators import LinearizedPowerResponse
def NonlinearPowerCurvature(tau, ht, Instrument, nonlinearity, Distribution, N, def NonlinearPowerCurvature(tau, ht, Instrument, nonlinearity, Distributor, N,
T, xi_sample_list, inverter): T, xi_sample_list, inverter):
result = None result = None
for xi_sample in xi_sample_list: for xi_sample in xi_sample_list:
LinearizedResponse = LinearizedPowerResponse( LinearizedResponse = LinearizedPowerResponse(
Instrument, nonlinearity, ht, Distribution, tau, xi_sample) Instrument, nonlinearity, ht, Distributor, tau, xi_sample)
op = LinearizedResponse.adjoint*N.inverse*LinearizedResponse op = LinearizedResponse.adjoint*N.inverse*LinearizedResponse
result = op if result is None else result + op result = op if result is None else result + op
result = result*(1./len(xi_sample_list)) + T result = result*(1./len(xi_sample_list)) + T
......
...@@ -52,7 +52,7 @@ class NonlinearPowerEnergy(Energy): ...@@ -52,7 +52,7 @@ class NonlinearPowerEnergy(Energy):
""" """
# MR FIXME: docstring incomplete and outdated # MR FIXME: docstring incomplete and outdated
def __init__(self, position, d, N, xi, D, ht, Instrument, nonlinearity, def __init__(self, position, d, N, xi, D, ht, Instrument, nonlinearity,
Distribution, sigma=0., samples=3, xi_sample_list=None, Distributor, sigma=0., samples=3, xi_sample_list=None,
inverter=None): inverter=None):
super(NonlinearPowerEnergy, self).__init__(position) super(NonlinearPowerEnergy, self).__init__(position)
self.xi = xi self.xi = xi
...@@ -64,7 +64,7 @@ class NonlinearPowerEnergy(Energy): ...@@ -64,7 +64,7 @@ class NonlinearPowerEnergy(Energy):
self.ht = ht self.ht = ht
self.Instrument = Instrument self.Instrument = Instrument
self.nonlinearity = nonlinearity self.nonlinearity = nonlinearity
self.Distribution = Distribution self.Distributor = Distributor
self.sigma = sigma self.sigma = sigma
if xi_sample_list is None: if xi_sample_list is None:
if samples is None or samples == 0: if samples is None or samples == 0:
...@@ -75,7 +75,7 @@ class NonlinearPowerEnergy(Energy): ...@@ -75,7 +75,7 @@ class NonlinearPowerEnergy(Energy):
self.xi_sample_list = xi_sample_list self.xi_sample_list = xi_sample_list
self.inverter = inverter self.inverter = inverter
A = Distribution(exp(.5 * position)) A = Distributor(exp(.5 * position))
map_s = self.ht(A * xi) map_s = self.ht(A * xi)
Tpos = self.T(position) Tpos = self.T(position)
...@@ -83,7 +83,7 @@ class NonlinearPowerEnergy(Energy): ...@@ -83,7 +83,7 @@ class NonlinearPowerEnergy(Energy):
for xi_sample in self.xi_sample_list: for xi_sample in self.xi_sample_list:
map_s = self.ht(A * xi_sample) map_s = self.ht(A * xi_sample)
LinR = LinearizedPowerResponse( LinR = LinearizedPowerResponse(
self.Instrument, self.nonlinearity, self.ht, self.Distribution, self.Instrument, self.nonlinearity, self.ht, self.Distributor,
self.position, xi_sample) self.position, xi_sample)
residual = self.d - \ residual = self.d - \
...@@ -107,7 +107,7 @@ class NonlinearPowerEnergy(Energy): ...@@ -107,7 +107,7 @@ class NonlinearPowerEnergy(Energy):
def at(self, position): def at(self, position):
return self.__class__(position, self.d, self.N, self.xi, self.D, return self.__class__(position, self.d, self.N, self.xi, self.D,
self.ht, self.Instrument, self.nonlinearity, self.ht, self.Instrument, self.nonlinearity,
self.Distribution, sigma=self.sigma, self.Distributor, sigma=self.sigma,
samples=len(self.xi_sample_list), samples=len(self.xi_sample_list),
xi_sample_list=self.xi_sample_list, xi_sample_list=self.xi_sample_list,
inverter=self.inverter) inverter=self.inverter)
...@@ -125,5 +125,5 @@ class NonlinearPowerEnergy(Energy): ...@@ -125,5 +125,5 @@ class NonlinearPowerEnergy(Energy):
def curvature(self): def curvature(self):
return NonlinearPowerCurvature( return NonlinearPowerCurvature(
self.position, self.ht, self.Instrument, self.nonlinearity, self.position, self.ht, self.Instrument, self.nonlinearity,
self.Distribution, self.N, self.T, self.xi_sample_list, self.Distributor, self.N, self.T, self.xi_sample_list,
self.inverter) self.inverter)
...@@ -23,9 +23,9 @@ def LinearizedSignalResponse(Instrument, nonlinearity, ht, power, m): ...@@ -23,9 +23,9 @@ def LinearizedSignalResponse(Instrument, nonlinearity, ht, power, m):
return Instrument * nonlinearity.derivative(m) * ht * power return Instrument * nonlinearity.derivative(m) * ht * power
def LinearizedPowerResponse(Instrument, nonlinearity, ht, Distribution, tau, def LinearizedPowerResponse(Instrument, nonlinearity, ht, Distributor, tau,
xi): xi):
power = exp(0.5*tau) power = exp(0.5*tau)
position = ht(Distribution(power)*xi) position = ht(Distributor(power)*xi)
linearization = nonlinearity.derivative(position) linearization = nonlinearity.derivative(position)
return 0.5*Instrument*linearization*ht*xi*Distribution*power return 0.5*Instrument*linearization*ht*xi*Distributor*power
...@@ -86,7 +86,7 @@ class Noise_Energy_Tests(unittest.TestCase): ...@@ -86,7 +86,7 @@ class Noise_Energy_Tests(unittest.TestCase):
energy0 = ift.library.NoiseEnergy( energy0 = ift.library.NoiseEnergy(
position=eta0, d=d, xi=xi, D=D, t=tau, Instrument=R, position=eta0, d=d, xi=xi, D=D, t=tau, Instrument=R,
alpha=alpha, q=q, Distribution=Dist, nonlinearity=f, alpha=alpha, q=q, Distributor=Dist, nonlinearity=f,
ht=ht, samples=10) ht=ht, samples=10)
energy1 = energy0.at(eta1) energy1 = energy0.at(eta1)
......
...@@ -82,7 +82,7 @@ class Energy_Tests(unittest.TestCase): ...@@ -82,7 +82,7 @@ class Energy_Tests(unittest.TestCase):
xi=xi, xi=xi,
D=D, D=D,
Instrument=R, Instrument=R,
Distribution=Dist, Distributor=Dist,
nonlinearity=f, nonlinearity=f,
ht=ht, ht=ht,
N=N, N=N,
......
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