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

tweaks

parent 119da1a5
Pipeline #22725 passed with stage
in 4 minutes and 43 seconds
......@@ -52,7 +52,7 @@ if __name__ == "__main__":
np.outer(ift.dobj.to_global_data(mock_power_1.val),
ift.dobj.to_global_data(mock_power_2.val))))
diagonal = ift.power_synthesize_special(mock_power, spaces=(0, 1))**2
diagonal = ift.power_synthesize_nonrandom(mock_power, spaces=(0, 1))**2
S = ift.DiagonalOperator(diagonal)
......
......@@ -13,7 +13,7 @@ class PropagatorOperator(ift.InversionEnabler, ift.EndomorphicOperator):
self.R = R
self.N = N
self.Sh = Sh
self.fft = ift.FFTOperator(R.domain, target=Sh.domain)
self.fft = ift.FFTOperator(R.domain, target=Sh.domain[0])
def _inverse_times(self, x):
return self.R.adjoint_times(self.N.inverse_times(self.R(x))) \
......
......@@ -72,7 +72,6 @@ class FFTOperator(LinearOperator):
if "domain" or "target" are not of the proper type.
"""
# MR FIXME: target should only be a single DomainObject, not the full tuple
def __init__(self, domain, target=None, space=None):
super(FFTOperator, self).__init__()
......@@ -89,13 +88,13 @@ class FFTOperator(LinearOperator):
adom = self.domain[self._space]
if target is None:
target = [dom for dom in self.domain]
target[self._space] = adom.get_default_codomain()
target = adom.get_default_codomain()
self._target = DomainTuple.make(target)
atgt = self._target[space]
adom.check_codomain(atgt)
atgt.check_codomain(adom)
self._target = [dom for dom in self.domain]
self._target[self._space] = target
self._target = DomainTuple.make(self._target)
adom.check_codomain(target)
target.check_codomain(adom)
if self._target[space].harmonic:
pdom, hdom = (self._domain, self._target)
......
......@@ -24,7 +24,7 @@ from . import Space, PowerSpace, Field, ComposedOperator, DiagonalOperator,\
__all__ = ['PS_field',
'power_analyze',
'power_synthesize',
'power_synthesize_special',
'power_synthesize_nonrandom',
'create_power_field',
'create_power_operator',
'create_composed_fft_operator']
......@@ -58,7 +58,7 @@ def power_analyze(field, spaces=None, binbounds=None,
field : Field
The field to be analyzed
spaces : int *optional*
The subspace for which the powerspectrum shall be computed.
The set of subspaces for which the powerspectrum shall be computed.
(default : None).
binbounds : array-like *optional*
Inner bounds of the bins (default : None).
......@@ -116,7 +116,7 @@ def power_analyze(field, spaces=None, binbounds=None,
return parts[0] + 1j*parts[1] if keep_phase_information else parts[0]
def _compute_spec(field, spaces):
def power_synthesize_nonrandom(field, spaces=None):
spaces = range(len(field.domain)) if spaces is None \
else utilities.cast_iseq_to_tuple(spaces)
......@@ -168,7 +168,7 @@ def power_synthesize(field, spaces=None, real_power=True, real_signal=True):
ValueError : If domain specified by `spaces` is not a PowerSpace.
"""
spec = _compute_spec(field, spaces)
spec = power_synthesize_nonrandom(field, spaces)
self_real = not np.issubdtype(spec.dtype, np.complexfloating)
if (not real_power) and self_real:
raise ValueError("can't draw complex realizations from real spectrum")
......@@ -181,11 +181,6 @@ def power_synthesize(field, spaces=None, real_power=True, real_signal=True):
else np.complex)
for x in range(1 if real_power else 2)]
# MR FIXME: dummy call - will be removed soon
if real_signal:
field.from_random('normal', mean=0., std=1.,
domain=spec.domain, dtype=np.float)
result[0] *= spec if self_real else spec.real
if not real_power:
result[1] *= spec.imag
......@@ -193,16 +188,6 @@ def power_synthesize(field, spaces=None, real_power=True, real_signal=True):
return result[0] if real_power else result[0] + 1j*result[1]
def power_synthesize_special(field, spaces=None):
spec = _compute_spec(field, spaces)
# MR FIXME: dummy call - will be removed soon
field.from_random('normal', mean=0., std=1.,
domain=spec.domain, dtype=np.complex)
return spec
def create_power_field(domain, power_spectrum, dtype=None):
if not callable(power_spectrum): # we have a Field living on a PowerSpace
if not isinstance(power_spectrum, Field):
......@@ -241,7 +226,6 @@ def create_power_operator(domain, power_spectrum, space=None, dtype=None):
Returns
-------
DiagonalOperator : An operator that implements the given power spectrum.
"""
domain = DomainTuple.make(domain)
if space is None:
......@@ -261,7 +245,7 @@ def create_composed_fft_operator(domain, codomain=None, all_to='other'):
if codomain is None:
codomain = [None]*len(domain)
interdomain = list(domain)
tdom = list(domain)
for i, space in enumerate(domain):
if not isinstance(space, Space):
continue
......@@ -269,11 +253,9 @@ def create_composed_fft_operator(domain, codomain=None, all_to='other'):
(all_to == 'position' and space.harmonic) or
(all_to == 'harmonic' and not space.harmonic)):
if codomain[i] is None:
interdomain[i] = domain[i].get_default_codomain()
tgt = domain[i].get_default_codomain()
else:
interdomain[i] = codomain[i]
fft_op_list += [FFTOperator(domain=domain, target=interdomain,
space=i)]
# MR FIXME: this looks slightly fishy...
domain = interdomain
tgt = codomain[i]
fft_op_list += [FFTOperator(domain=tdom, target=tgt, space=i)]
tdom[i] = tgt
return ComposedOperator(fft_op_list)
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