Commit 0f2f262e authored by Martin Reinecke's avatar Martin Reinecke
Browse files

add FieldAdapter

parent c960121b
......@@ -33,6 +33,7 @@ from .operators.domain_distributor import DomainDistributor
from .operators.endomorphic_operator import EndomorphicOperator
from .operators.exp_transform import ExpTransform
from .operators.fft_operator import FFTOperator
from .operators.field_adapter import FieldAdapter
from .operators.field_zero_padder import FieldZeroPadder
from .operators.hartley_operator import HartleyOperator
from .operators.harmonic_smoothing_operator import HarmonicSmoothingOperator
from __future__ import absolute_import, division, print_function
from ..compat import *
from .linear_operator import LinearOperator
from ..multi.multi_domain import MultiDomain
from ..multi.multi_field import MultiField
class FieldAdapter(LinearOperator):
def __init__(self, op, name_dom, name_tgt):
if name_dom is None:
self._domain = op.domain
self._domain = MultiDomain.make({name_dom: op.domain})
if name_tgt is None:
self._target =
self._target = MultiDomain.make({name_tgt:})
self._op = op
def domain(self):
return self._domain
def target(self):
return self._target
def capability(self):
return self._op.capability
def apply(self, x, mode):
self._check_input(x, mode)
dom = self._dom(mode)
if x.domain is not dom:
x = dom.values()[0]
res = self._op.apply(x. mode)
tgt = self._tgt(mode)
if res.domain is not tgt:
res = MultiField(tgt, (res,))
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