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

renamings

parent 7f0d49de
Pipeline #24889 failed with stage
in 60 minutes and 4 seconds
...@@ -59,9 +59,8 @@ if __name__ == "__main__": ...@@ -59,9 +59,8 @@ if __name__ == "__main__":
d_space = MeasurementOperator.target d_space = MeasurementOperator.target
Projection = ift.PowerProjectionOperator(domain=h_space, Distributor = ift.PowerDistributor(target=h_space, power_space=p_space)
power_space=p_space) power = Distributor(ift.exp(0.5*log_p))
power = Projection.adjoint_times(ift.exp(0.5*log_p))
# Creating the mock data # Creating the mock data
true_sky = nonlinearity(HT(power*sh)) true_sky = nonlinearity(HT(power*sh))
noiseless_data = MeasurementOperator(true_sky) noiseless_data = MeasurementOperator(true_sky)
...@@ -75,7 +74,7 @@ if __name__ == "__main__": ...@@ -75,7 +74,7 @@ if __name__ == "__main__":
m0 = ift.power_synthesize(ift.Field(p_space, val=1e-7)) m0 = ift.power_synthesize(ift.Field(p_space, val=1e-7))
t0 = ift.Field(p_space, val=-4.) t0 = ift.Field(p_space, val=-4.)
power0 = Projection.adjoint_times(ift.exp(0.5 * t0)) power0 = Distributor.times(ift.exp(0.5 * t0))
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)
...@@ -87,7 +86,7 @@ if __name__ == "__main__": ...@@ -87,7 +86,7 @@ if __name__ == "__main__":
inverter = ift.ConjugateGradient(controller=ICI) inverter = ift.ConjugateGradient(controller=ICI)
for i in range(20): for i in range(20):
power0 = Projection.adjoint_times(ift.exp(0.5*t0)) power0 = Distributor(ift.exp(0.5*t0))
map0_energy = ift.library.NonlinearWienerFilterEnergy( map0_energy = ift.library.NonlinearWienerFilterEnergy(
m0, d, MeasurementOperator, nonlinearity, HT, power0, N, S, m0, d, MeasurementOperator, nonlinearity, HT, power0, N, S,
inverter=inverter) inverter=inverter)
...@@ -103,7 +102,7 @@ if __name__ == "__main__": ...@@ -103,7 +102,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,
Projection=Projection, 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]
......
...@@ -70,7 +70,8 @@ if __name__ == "__main__": ...@@ -70,7 +70,8 @@ if __name__ == "__main__":
# Generate plots # Generate plots
zmax = max(ht(sh).max(), ht(m).max()) zmax = max(ht(sh).max(), ht(m).max())
zmin = min(ht(sh).min(), ht(m).min()) zmin = min(ht(sh).min(), ht(m).min())
plotdict = {"zmax": zmax, "zmin": zmin, "colormap": "Planck-like"} plotdict = {"zmax": zmax, "zmin": zmin,"colormap": "Planck-like"}
plotdict2 = {"colormap": "Planck-like"}
ift.plot(ht(sh), name="mock_signal.png", **plotdict) ift.plot(ht(sh), name="mock_signal.png", **plotdict)
ift.plot(ht(m), name="reconstruction.png", **plotdict) ift.plot(ht(m), name="reconstruction.png", **plotdict)
...@@ -79,10 +80,10 @@ if __name__ == "__main__": ...@@ -79,10 +80,10 @@ if __name__ == "__main__":
sample_mean = ift.Field.zeros(s_space) sample_mean = ift.Field.zeros(s_space)
mean, variance = ift.probe_with_posterior_samples(curv, ht, 50) mean, variance = ift.probe_with_posterior_samples(curv, ht, 50)
ift.plot(variance, name="posterior_variance.png", **plotdict) ift.plot(variance, name="posterior_variance.png", **plotdict2)
ift.plot(mean+ht(m), name="posterior_mean.png", **plotdict) ift.plot(mean+ht(m), name="posterior_mean.png", **plotdict)
# try to do the same with diagonal probing # try to do the same with diagonal probing
variance = ift.probe_diagonal(ht*curv.inverse*ht.adjoint, 100) variance = ift.probe_diagonal(ht*curv.inverse*ht.adjoint, 100)
#sm = ift.FFTSmoothingOperator(s_space, sigma=0.015) #sm = ift.FFTSmoothingOperator(s_space, sigma=0.005)
ift.plot(variance, name="posterior_variance2.png", **plotdict) ift.plot(variance, name="posterior_variance2.png", **plotdict2)
...@@ -12,7 +12,7 @@ Description of Operators ...@@ -12,7 +12,7 @@ Description of Operators
ScalingOperator <../mod/nifty4.operators.scaling_operator> ScalingOperator <../mod/nifty4.operators.scaling_operator>
DiagonalOperator <../mod/nifty4.operators.diagonal_operator> DiagonalOperator <../mod/nifty4.operators.diagonal_operator>
HarmonicTransformOperator <../mod/nifty4.operators.harmonic_transform_operator> HarmonicTransformOperator <../mod/nifty4.operators.harmonic_transform_operator>
PowerProjectionOperator <../mod/nifty4.operators.power_projection_operator> PowerDistributor <../mod/nifty4.operators.power_distributor>
.. toctree:: .. toctree::
:maxdepth: 1 :maxdepth: 1
...@@ -26,7 +26,7 @@ Description of Operators ...@@ -26,7 +26,7 @@ Description of Operators
.. Adjoint <../mod/nifty4.operators.adjoint_operator> .. Adjoint <../mod/nifty4.operators.adjoint_operator>
.. Chain <../mod/nifty4.operators.chain_operator> .. Chain <../mod/nifty4.operators.chain_operator>
.. DOF Projection <../mod/nifty4.operators.dof_projection_operator> .. DOF Distributor <../mod/nifty4.operators.dof_distributor>
.. Inverse <../mod/nifty4.operators.inverse_operator> .. Inverse <../mod/nifty4.operators.inverse_operator>
.. Laplace <../mod/nifty4.operators.linear_operator> .. Laplace <../mod/nifty4.operators.linear_operator>
.. Sum <../mod/nifty4.operators.sum_operator> .. Sum <../mod/nifty4.operators.sum_operator>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
from ..minimization.energy import Energy from ..minimization.energy import Energy
from ..operators.smoothness_operator import SmoothnessOperator from ..operators.smoothness_operator import SmoothnessOperator
from ..operators.power_projection_operator import PowerProjectionOperator from ..operators.power_distributor import PowerDistributor
from .critical_power_curvature import CriticalPowerCurvature from .critical_power_curvature import CriticalPowerCurvature
from ..utilities import memo from ..utilities import memo
from .. import Field, exp from .. import Field, exp
...@@ -86,17 +86,17 @@ class CriticalPowerEnergy(Energy): ...@@ -86,17 +86,17 @@ class CriticalPowerEnergy(Energy):
self._inverter = inverter self._inverter = inverter
if w is None: if w is None:
P = PowerProjectionOperator(domain=self.m.domain, Dist = PowerDistributor(target=self.m.domain,
power_space=self.position.domain[0]) power_space=self.position.domain[0])
if self.D is not None: if self.D is not None:
w = Field.zeros(self.position.domain, dtype=self.m.dtype) w = Field.zeros(self.position.domain, dtype=self.m.dtype)
for i in range(self.samples): for i in range(self.samples):
sample = self.D.draw_sample() + self.m sample = self.D.draw_sample() + self.m
w += P(abs(sample)**2) w += Dist.adjoint_times(abs(sample)**2)
w *= 1./self.samples w *= 1./self.samples
else: else:
w = P(abs(self.m)**2) w = Dist.adjoint_times(abs(self.m)**2)
self._w = w self._w = w
self._theta = exp(-self.position) * (self.q + self._w*0.5) self._theta = exp(-self.position) * (self.q + self._w*0.5)
......
...@@ -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, Projection, samples=3, nonlinearity, alpha, q, Distribution, 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.Projection = Projection self.Distribution = Distribution
self.power = self.Projection.adjoint_times(exp(0.5 * self.t)) self.power = self.Distribution(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 = Projection.adjoint_times(exp(.5*self.t)) A = Distribution(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.Projection, xi_sample_list=self.xi_sample_list, self.Distribution, xi_sample_list=self.xi_sample_list,
samples=self.samples, inverter=self.inverter) samples=self.samples, inverter=self.inverter)
@property @property
......
...@@ -52,7 +52,7 @@ class NonlinearPowerEnergy(Energy): ...@@ -52,7 +52,7 @@ class NonlinearPowerEnergy(Energy):
""" """
def __init__(self, position, d, N, xi, D, ht, Instrument, nonlinearity, def __init__(self, position, d, N, xi, D, ht, Instrument, nonlinearity,
Projection, sigma=0., samples=3, xi_sample_list=None, Distribution, 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.Projection = Projection self.Distribution = Distribution
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 = Projection.adjoint_times(exp(.5 * position)) A = Distribution(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.Projection, self.Instrument, self.nonlinearity, self.ht, self.Distribution,
self.position, xi_sample) self.position, xi_sample)
residual = self.d - \ residual = self.d - \
...@@ -106,7 +106,7 @@ class NonlinearPowerEnergy(Energy): ...@@ -106,7 +106,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.Projection, sigma=self.sigma, self.Distribution, 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)
...@@ -124,5 +124,5 @@ class NonlinearPowerEnergy(Energy): ...@@ -124,5 +124,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.Projection, self.N, self.T, self.xi_sample_list, self.Distribution, self.N, self.T, self.xi_sample_list,
self.inverter) self.inverter)
...@@ -23,8 +23,9 @@ def LinearizedSignalResponse(Instrument, nonlinearity, ht, power, m): ...@@ -23,8 +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, Projection, tau, xi): def LinearizedPowerResponse(Instrument, nonlinearity, ht, Distribution, tau,
xi):
power = exp(0.5*tau) power = exp(0.5*tau)
position = ht(Projection.adjoint_times(power)*xi) position = ht(Distribution(power)*xi)
linearization = nonlinearity.derivative(position) linearization = nonlinearity.derivative(position)
return 0.5*Instrument*linearization*ht*xi*Projection.adjoint*power return 0.5*Instrument*linearization*ht*xi*Distribution*power
...@@ -7,10 +7,10 @@ from .fft_operator import FFTOperator ...@@ -7,10 +7,10 @@ from .fft_operator import FFTOperator
from .fft_smoothing_operator import FFTSmoothingOperator from .fft_smoothing_operator import FFTSmoothingOperator
from .geometry_remover import GeometryRemover from .geometry_remover import GeometryRemover
from .laplace_operator import LaplaceOperator from .laplace_operator import LaplaceOperator
from .power_projection_operator import PowerProjectionOperator from .power_distributor import PowerDistributor
from .inversion_enabler import InversionEnabler from .inversion_enabler import InversionEnabler
__all__ = ["LinearOperator", "EndomorphicOperator", "ScalingOperator", __all__ = ["LinearOperator", "EndomorphicOperator", "ScalingOperator",
"DiagonalOperator", "HarmonicTransformOperator", "FFTOperator", "DiagonalOperator", "HarmonicTransformOperator", "FFTOperator",
"FFTSmoothingOperator", "GeometryRemover", "FFTSmoothingOperator", "GeometryRemover",
"LaplaceOperator", "PowerProjectionOperator", "InversionEnabler"] "LaplaceOperator", "PowerDistributor", "InversionEnabler"]
...@@ -25,15 +25,15 @@ from .. import dobj ...@@ -25,15 +25,15 @@ from .. import dobj
from ..domains.dof_space import DOFSpace from ..domains.dof_space import DOFSpace
class DOFProjectionOperator(LinearOperator): class DOFDistributor(LinearOperator):
def __init__(self, dofdex, domain=None, space=None): def __init__(self, dofdex, target=None, space=None):
super(DOFProjectionOperator, self).__init__() super(DOFDistributor, self).__init__()
if domain is None: if target is None:
domain = dofdex.domain target = dofdex.domain
self._domain = DomainTuple.make(domain) self._target = DomainTuple.make(target)
space = infer_space(self._domain, space) space = infer_space(self._target, space)
partner = self._domain[space] partner = self._target[space]
if not isinstance(dofdex, Field): if not isinstance(dofdex, Field):
raise TypeError("dofdex must be a Field") raise TypeError("dofdex must be a Field")
if not len(dofdex.domain) == 1: if not len(dofdex.domain) == 1:
...@@ -64,41 +64,41 @@ class DOFProjectionOperator(LinearOperator): ...@@ -64,41 +64,41 @@ class DOFProjectionOperator(LinearOperator):
def _init2(self, dofdex, space, other_space): def _init2(self, dofdex, space, other_space):
self._space = space self._space = space
tgt = list(self._domain) dom = list(self._target)
tgt[self._space] = other_space dom[self._space] = other_space
self._target = DomainTuple.make(tgt) self._domain = DomainTuple.make(dom)
if dobj.default_distaxis() in self._domain.axes[self._space]: if dobj.default_distaxis() in self._domain.axes[self._space]:
dofdex = dobj.local_data(dofdex) dofdex = dobj.local_data(dofdex)
else: # dofdex must be available fully on every task else: # dofdex must be available fully on every task
dofdex = dobj.to_global_data(dofdex) dofdex = dobj.to_global_data(dofdex)
self._dofdex = dofdex.ravel() self._dofdex = dofdex.ravel()
firstaxis = self._domain.axes[self._space][0] firstaxis = self._target.axes[self._space][0]
lastaxis = self._domain.axes[self._space][-1] lastaxis = self._target.axes[self._space][-1]
arrshape = dobj.local_shape(self._domain.shape, 0) arrshape = dobj.local_shape(self._target.shape, 0)
presize = np.prod(arrshape[0:firstaxis], dtype=np.int) presize = np.prod(arrshape[0:firstaxis], dtype=np.int)
postsize = np.prod(arrshape[lastaxis+1:], dtype=np.int) postsize = np.prod(arrshape[lastaxis+1:], dtype=np.int)
self._hshape = (presize, self._target[self._space].shape[0], postsize) self._hshape = (presize, self._domain[self._space].shape[0], postsize)
self._pshape = (presize, self._dofdex.size, postsize) self._pshape = (presize, self._dofdex.size, postsize)
def _times(self, x): def _adjoint_times(self, x):
arr = dobj.local_data(x.val) arr = dobj.local_data(x.val)
arr = arr.reshape(self._pshape) arr = arr.reshape(self._pshape)
oarr = np.zeros(self._hshape, dtype=x.dtype) oarr = np.zeros(self._hshape, dtype=x.dtype)
np.add.at(oarr, (slice(None), self._dofdex, slice(None)), arr) np.add.at(oarr, (slice(None), self._dofdex, slice(None)), arr)
if dobj.distaxis(x.val) in x.domain.axes[self._space]: if dobj.distaxis(x.val) in x.domain.axes[self._space]:
oarr = dobj.np_allreduce_sum(oarr).reshape(self._target.shape) oarr = dobj.np_allreduce_sum(oarr).reshape(self._domain.shape)
res = Field(self._target, dobj.from_global_data(oarr)) res = Field(self._domain, dobj.from_global_data(oarr))
else: else:
oarr = oarr.reshape(dobj.local_shape(self._target.shape, oarr = oarr.reshape(dobj.local_shape(self._domain.shape,
dobj.distaxis(x.val))) dobj.distaxis(x.val)))
res = Field(self._target, res = Field(self._domain,
dobj.from_local_data(self._target.shape, oarr, dobj.from_local_data(self._domain.shape, oarr,
dobj.default_distaxis())) dobj.default_distaxis()))
return res return res
def _adjoint_times(self, x): def _times(self, x):
res = Field.empty(self._domain, dtype=x.dtype) res = Field.empty(self._target, dtype=x.dtype)
if dobj.distaxis(x.val) in x.domain.axes[self._space]: if dobj.distaxis(x.val) in x.domain.axes[self._space]:
arr = dobj.to_global_data(x.val) arr = dobj.to_global_data(x.val)
else: else:
......
...@@ -16,20 +16,20 @@ ...@@ -16,20 +16,20 @@
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes. # and financially supported by the Studienstiftung des deutschen Volkes.
from .dof_projection_operator import DOFProjectionOperator from .dof_distributor import DOFDistributor
from ..domain_tuple import DomainTuple from ..domain_tuple import DomainTuple
from ..utilities import infer_space from ..utilities import infer_space
from ..domains.power_space import PowerSpace from ..domains.power_space import PowerSpace
class PowerProjectionOperator(DOFProjectionOperator): class PowerDistributor(DOFDistributor):
def __init__(self, domain, power_space=None, space=None): def __init__(self, target, power_space=None, space=None):
# Initialize domain and target # Initialize domain and target
self._domain = DomainTuple.make(domain) self._target = DomainTuple.make(target)
self._space = infer_space(self._domain, space) self._space = infer_space(self._target, space)
hspace = self._domain[self._space] hspace = self._target[self._space]
if not hspace.harmonic: if not hspace.harmonic:
raise ValueError("Operator acts on harmonic spaces only") raise ValueError("Operator requires harmonic target space")
if power_space is None: if power_space is None:
power_space = PowerSpace(hspace) power_space = PowerSpace(hspace)
else: else:
......
...@@ -21,7 +21,7 @@ from .domains.structured_domain import StructuredDomain ...@@ -21,7 +21,7 @@ from .domains.structured_domain import StructuredDomain
from .domains.power_space import PowerSpace from .domains.power_space import PowerSpace
from .field import Field, sqrt from .field import Field, sqrt
from .operators.diagonal_operator import DiagonalOperator from .operators.diagonal_operator import DiagonalOperator
from .operators.power_projection_operator import PowerProjectionOperator from .operators.power_distributor import PowerDistributor
from .operators.harmonic_transform_operator import HarmonicTransformOperator from .operators.harmonic_transform_operator import HarmonicTransformOperator
from .domain_tuple import DomainTuple from .domain_tuple import DomainTuple
from . import dobj, utilities from . import dobj, utilities
...@@ -45,8 +45,8 @@ def PS_field(pspace, func, dtype=None): ...@@ -45,8 +45,8 @@ def PS_field(pspace, func, dtype=None):
def _single_power_analyze(field, idx, binbounds): def _single_power_analyze(field, idx, binbounds):
power_domain = PowerSpace(field.domain[idx], binbounds) power_domain = PowerSpace(field.domain[idx], binbounds)
ppo = PowerProjectionOperator(field.domain, power_domain, idx) pd = PowerDistributor(field.domain, power_domain, idx)
return ppo(field.weight(1)).weight(-1) # divides by bin size return pd.adjoint_times(field.weight(1)).weight(-1) # divides by bin size
def power_analyze(field, spaces=None, binbounds=None, def power_analyze(field, spaces=None, binbounds=None,
...@@ -125,8 +125,8 @@ def power_synthesize_nonrandom(field, spaces=None): ...@@ -125,8 +125,8 @@ def power_synthesize_nonrandom(field, spaces=None):
spec = sqrt(field) spec = sqrt(field)
for i in spaces: for i in spaces:
result_domain[i] = field.domain[i].harmonic_partner result_domain[i] = field.domain[i].harmonic_partner
ppo = PowerProjectionOperator(result_domain, field.domain[i], i) pd = PowerDistributor(result_domain, field.domain[i], i)
spec = ppo.adjoint_times(spec) spec = pd(spec)
return spec return spec
...@@ -203,7 +203,7 @@ def create_power_field(domain, power_spectrum, dtype=None): ...@@ -203,7 +203,7 @@ def create_power_field(domain, power_spectrum, dtype=None):
power_domain = PowerSpace(domain) power_domain = PowerSpace(domain)
fp = PS_field(power_domain, power_spectrum, dtype) fp = PS_field(power_domain, power_spectrum, dtype)
return PowerProjectionOperator(domain, power_domain).adjoint_times(fp) return PowerDistributor(domain, power_domain)(fp)
def create_power_operator(domain, power_spectrum, space=None, dtype=None): def create_power_operator(domain, power_spectrum, space=None, dtype=None):
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# Copyright(C) 2013-2017 Max-Planck-Society # Copyright(C) 2013-2018 Max-Planck-Society
# #
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes. # and financially supported by the Studienstiftung des deutschen Volkes.
...@@ -39,12 +39,12 @@ class Energy_Tests(unittest.TestCase): ...@@ -39,12 +39,12 @@ class Energy_Tests(unittest.TestCase):
ht = ift.HarmonicTransformOperator(hspace, target=space) ht = ift.HarmonicTransformOperator(hspace, target=space)
binbounds = ift.PowerSpace.useful_binbounds(hspace, logarithmic=False) binbounds = ift.PowerSpace.useful_binbounds(hspace, logarithmic=False)
pspace = ift.PowerSpace(hspace, binbounds=binbounds) pspace = ift.PowerSpace(hspace, binbounds=binbounds)
P = ift.PowerProjectionOperator(domain=hspace, power_space=pspace) Dist = ift.PowerDistributor(target=hspace, power_space=pspace)
xi0 = ift.Field.from_random(domain=hspace, random_type='normal') xi0 = ift.Field.from_random(domain=hspace, random_type='normal')
def pspec(k): return 1 / (1 + k**2)**dim def pspec(k): return 1 / (1 + k**2)**dim
pspec = ift.PS_field(pspace, pspec) pspec = ift.PS_field(pspace, pspec)
A = P.adjoint_times(ift.sqrt(pspec)) A = Dist(ift.sqrt(pspec))
n = ift.Field.from_random(domain=space, random_type='normal') n = ift.Field.from_random(domain=space, random_type='normal')
s0 = xi0 * A s0 = xi0 * A
Instrument = ift.ScalingOperator(10., space) Instrument = ift.ScalingOperator(10., space)
...@@ -85,12 +85,12 @@ class Energy_Tests(unittest.TestCase): ...@@ -85,12 +85,12 @@ class Energy_Tests(unittest.TestCase):
ht = ift.HarmonicTransformOperator(hspace, target=space) ht = ift.HarmonicTransformOperator(hspace, target=space)
binbounds = ift.PowerSpace.useful_binbounds(hspace, logarithmic=False) binbounds = ift.PowerSpace.useful_binbounds(hspace, logarithmic=False)
pspace = ift.PowerSpace(hspace, binbounds=binbounds)