Scheduled maintenance on Monday 2019-06-24 between 10:00-11:00 CEST

Commit c9605c72 authored by Ruestig, Julian (jruestig)'s avatar Ruestig, Julian (jruestig)

Merge branch 'mfcorrelatedfield_withzeromodeprior' of...

Merge branch 'mfcorrelatedfield_withzeromodeprior' of https://gitlab.mpcdf.mpg.de/ift/nifty into mfcorrelatedfield_withzeromodeprior
parents 83a39b38 b247969a
......@@ -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
......@@ -169,10 +165,11 @@ def SLAmplitude(*, target, n_pix, a, k0, sm, sv, im, iv, za=None, zq=None,
iv : float
Prior standard deviation of y-intercept of power law.
za : float, optional
The alpha-parameter of the inverse-gamma distribution.
Setting the a seperate prior on the zeroGmode of the amplitude model.
Parameter of the optional zero mode prior (inverse-gamma): alpha
See :class:`InverseGammaOperator` for interpretation.
zq : float, optional
The q-parameter of the inverse-gamma distribution.
Parameter of the optional zero mode prior (inverse-gamma): q
See :class:`InverseGammaOperator` for interpretation.
Returns
-------
......@@ -189,11 +186,10 @@ 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 is not None and zq is not 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)
else:
separate_zero_mode_prior = False
if za is not None or zq is not None:
raise ValueError("za and zq have to be given together")
......@@ -219,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 = (
ValueInserter(et.target, (0,)*len(et.target.shape)) @
InverseGammaOperator(et.target, 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)
zero_mode = zero_mode @ InverseGammaOperator(
zero_mode.domain, za, zq) @ FieldAdapter(
zero_mode.domain, keys[2])
mask = makeOp(Field.from_global_data(et.target, 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