response_operator.py 1.47 KB
Newer Older
1
from nifty import Field,\
2
                  FieldArray
3
4
5
from nifty.operators.linear_operator import LinearOperator
from nifty.operators.smoothing_operator import SmoothingOperator

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import numpy as np

class ResponseOperator(LinearOperator):

    def __init__(self, domain,
                 sigma=1., exposure=1., implemented=True,
                 unitary=False):

        self._domain = self._parse_domain(domain)
        self._target = self._parse_domain(FieldArray(self._domain[0].shape,
                                      dtype=np.float64))
        self._sigma = sigma
        self._implemented = implemented
        self._unitary = unitary

        self._kernel = SmoothingOperator(self._domain,
                                        sigma=self._sigma)

        self._exposure = exposure

    @property
    def domain(self):
        return self._domain

    @property
    def target(self):
        return self._target

    @property
    def implemented(self):
        return self._implemented

    @property
    def unitary(self):
        return self._unitary

    def _times(self, x, spaces):
        res = self._kernel.times(x)
        res = self._exposure * res
45
        return Field(self._target, val=res.val, dtype=np.float64)
46
47
48
49

    def _adjoint_times(self, x, spaces):
        # setting correct spaces
        res = x*self._exposure
50
        res = Field(self.domain, val=res.val, dtype=np.float64)
51
52
53
        res = res.weight(power=-1)
        res = self._kernel.adjoint_times(res)
        return res