Commit b247969a authored by Martin Reinecke's avatar Martin Reinecke

tweaks

parent e77b5d08
Pipeline #44431 passed with stages
in 8 minutes and 35 seconds
......@@ -24,13 +24,6 @@ from ..operators.distributors import PowerDistributor
from ..operators.harmonic_operators import HarmonicTransformOperator
from ..operators.simple_linear_operators import ducktape
# import numpy as np
# from ..operators.value_inserter import ValueInserter
# from ..operators.simple_linear_operators import FieldAdapter
# from ..operators.diagonal_operator import DiagonalOperator
# from ..sugar import from_global_data
# from ..library.inverse_gamma_operator import InverseGammaOperator
def CorrelatedField(target, amplitude_operator, name='xi', codomain=None):
"""Constructs an operator which turns a white Gaussian excitation field
......@@ -81,7 +74,7 @@ def CorrelatedField(target, amplitude_operator, name='xi', codomain=None):
# will scale with a square root. `vol` cancels this effect such that the
# same power spectrum can be used for the spaces with the same volume,
# different resolutions and the same object in them.
return ht(vol*(A)*ducktape(h_space, None, name))
return ht(vol*A*ducktape(h_space, None, name))
def MfCorrelatedField(target, amplitudes, name='xi'):
......@@ -148,16 +141,17 @@ def MfPartiallyCorrelatedField(target, energy_amplitude, name='xi_u'):
into a correlated field defined on a DomainTuple with two entries.
On the first domain, a white correlation structure is assumed. On
the second domain, the correlation structures given by energy_amplitude
is used.
are used.
This operator may be used as a model for multi-frequency reconstructions
with correlation structure only in the energy direction.
Parameters
----------
target : Domain, DomainTuple or tuple of Domain
target : DomainTuple or tuple of Domain
Target of the operator. Must contain exactly two spaces.
It is assumed that the second space is the energy domain.
It is assumed that the second space is the energy domain, so it must
be a one-dimensional RGSpace.
energy_amplitude: Operator
amplitude operator for the energy correlation structure
name : string
......
......@@ -26,11 +26,7 @@ from ..operators.qht_operator import QHTOperator
from ..operators.slope_operator import SlopeOperator
from ..operators.symmetrizing_operator import SymmetrizingOperator
from ..sugar import makeOp
from ..library.inverse_gamma_operator import InverseGammaOperator
from ..sugar import from_global_data
from ..operators.diagonal_operator import DiagonalOperator
from ..operators.simple_linear_operators import FieldAdapter
from ..operators.value_inserter import ValueInserter
......@@ -190,13 +186,11 @@ def SLAmplitude(*, target, n_pix, a, k0, sm, sv, im, iv, za=None, zq=None,
if sv <= 0 or iv <= 0:
raise ValueError
if za != None and zq != None:
separate_zero_mode_prior = True
separate_zero_mode_prior = za is not None and zq is not None
if separate_zero_mode_prior:
za, zq = float(za), float(zq)
print(keys[2] + " mean: ", (zq/(1+za)))
else:
separate_zero_mode_prior = False
if za != None or zq != None:
if za is not None or zq is not None:
raise ValueError("za and zq have to be given together")
et = ExpTransform(target, n_pix)
......@@ -221,14 +215,12 @@ def SLAmplitude(*, target, n_pix, a, k0, sm, sv, im, iv, za=None, zq=None,
# Go from loglog-space to linear-linear-space
return et @ loglog_ampl.exp()
else:
zero_mode = ValueInserter(et.target, (0,)*len(et.target.shape))
zero_mode = zero_mode @ InverseGammaOperator(
zero_mode.domain, za, zq) @ FieldAdapter(
zero_mode.domain, keys[2])
zero_mode = (
ValueInserter(et.target, (0,)*len(et.target.shape)) @
InverseGammaOperator(zero_mode.domain, za, zq).ducktape(keys[2]))
mask = np.ones(et.target.shape)
mask[(0,)*len(et.target.shape)] = 0.
mask = from_global_data(et.target, mask)
mask = DiagonalOperator(mask)
mask = makeOp(Field.from_global_data(et.target, mask))
return mask @ et @ loglog_ampl.exp() + zero_mode
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