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