Commit e2526ae8 authored by Pumpe, Daniel (dpumpe)'s avatar Pumpe, Daniel (dpumpe)
Browse files

more generic ResponseOperator

parent f6ed99f4
Pipeline #12118 passed with stage
in 4 minutes and 55 seconds
......@@ -4,12 +4,12 @@ from nifty import Field,\
from nifty.operators.linear_operator import LinearOperator
from nifty.operators.smoothing_operator import SmoothingOperator
from nifty.operators.composed_operator import ComposedOperator
from nifty.operators.diagonal_operator import DiagonalOperator
class ResponseOperator(LinearOperator):
def __init__(self, domain,
sigma=[1.], exposure=1., implemented=True,
sigma=[1.], exposure=[1.], implemented=True,
unitary=False):
self._domain = self._parse_domain(domain)
......@@ -20,9 +20,9 @@ class ResponseOperator(LinearOperator):
shapes[ii] = self._domain[ii].shape
shape_target = np.append(shape_target, self._domain[ii].shape)
self._target = self._parse_domain(FieldArray(shape_target,
dtype=np.float64))
self._target = self._parse_domain(FieldArray(shape_target))
self._sigma = sigma
self._exposure = exposure
self._implemented = implemented
self._unitary = unitary
......@@ -35,7 +35,16 @@ class ResponseOperator(LinearOperator):
self._composed_kernel = ComposedOperator(self._kernel)
self._exposure = exposure
self._exposure_op = len(self._domain)*[None]
if len(self._exposure_op)!= len(self._kernel):
raise ValueError("Definition of kernel and exposure do not suit each other")
else:
for ii in xrange(len(self._exposure_op)):
self._exposure_op[ii] = DiagonalOperator(self._domain[ii],
diagonal=self._exposure[ii])
self._composed_exposure = ComposedOperator(self._exposure_op)
@property
def domain(self):
......@@ -54,16 +63,16 @@ class ResponseOperator(LinearOperator):
return self._unitary
def _times(self, x, spaces):
res = self._composed_kernel.times(x)
res = self._exposure * res
res = self._composed_kernel.times(x, spaces)
res = self._composed_exposure.times(res, spaces)
# res = res.weight(power=1)
# removing geometric information
return Field(self._target, val=res.val)
def _adjoint_times(self, x, spaces):
# setting correct spaces
res = x*self._exposure
res = Field(self.domain, val=res.val)
res = Field(self.domain, val=x.val)
res = self._composed_exposure.adjoint_times(res, spaces)
res = res.weight(power=-1)
res = self._composed_kernel.adjoint_times(res, spaces)
return res
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