wiener_filter_curvature.py 2.44 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
14
# Copyright(C) 2013-2020 Max-Planck-Society
15
#
16
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
Philipp Arras's avatar
Philipp Arras committed
17

Martin Reinecke's avatar
Martin Reinecke committed
18
from ..operators.inversion_enabler import InversionEnabler
19
from ..operators.sampling_enabler import SamplingDtypeSetter, SamplingEnabler
Philipp Arras's avatar
Philipp Arras committed
20
from ..operators.sandwich_operator import SandwichOperator
21

Martin Reinecke's avatar
PEP8    
Martin Reinecke committed
22

23
def WienerFilterCurvature(R, N, S, iteration_controller=None,
Philipp Arras's avatar
Philipp Arras committed
24
25
26
                          iteration_controller_sampling=None,
                          data_sampling_dtype=None,
                          prior_sampling_dtype=None):
Jakob Knollmueller's avatar
Jakob Knollmueller committed
27
28
29
30
    """The curvature of the WienerFilterEnergy.

    This operator implements the second derivative of the
    WienerFilterEnergy used in some minimization algorithms or
31
32
    for error estimates of the posterior maps. It is the
    inverse of the propagator operator.
Jakob Knollmueller's avatar
Jakob Knollmueller committed
33
34
35

    Parameters
    ----------
Martin Reinecke's avatar
Martin Reinecke committed
36
    R : LinearOperator
Martin Reinecke's avatar
Martin Reinecke committed
37
        The response operator of the Wiener filter measurement.
Martin Reinecke's avatar
Martin Reinecke committed
38
    N : EndomorphicOperator
Martin Reinecke's avatar
Martin Reinecke committed
39
        The noise covariance.
Martin Reinecke's avatar
Martin Reinecke committed
40
    S : DiagonalOperator
Martin Reinecke's avatar
Martin Reinecke committed
41
        The prior signal covariance
42
43
44
45
46
    iteration_controller : IterationController
        The iteration controller to use during numerical inversion via
        ConjugateGradient.
    iteration_controller_sampling : IterationController
        The iteration controller to use for sampling.
Jakob Knollmueller's avatar
Jakob Knollmueller committed
47
    """
Philipp Arras's avatar
Philipp Arras committed
48
49
50
    Ninv = N.inverse
    Sinv = S.inverse
    if data_sampling_dtype is not None:
51
        Ninv = SamplingDtypeSetter(Ninv, data_sampling_dtype)
Philipp Arras's avatar
Philipp Arras committed
52
    if prior_sampling_dtype is not None:
53
        Sinv = SamplingDtypeSetter(Sinv, data_sampling_dtype)
Philipp Arras's avatar
Philipp Arras committed
54
    M = SandwichOperator.make(R, Ninv)
55
    if iteration_controller_sampling is not None:
Philipp Arras's avatar
Philipp Arras committed
56
57
        op = SamplingEnabler(M, Sinv, iteration_controller_sampling,
                             Sinv)
58
    else:
Philipp Arras's avatar
Philipp Arras committed
59
60
61
        op = M + Sinv
    op = InversionEnabler(op, iteration_controller, Sinv)
    return op