Skip to content
Snippets Groups Projects
Commit 668ac34b authored by Philipp Arras's avatar Philipp Arras
Browse files

Add ConstantOperator

parent d04c627b
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,7 @@ from .field import Field
from .multi_field import MultiField
from .operators.operator import Operator
from .operators.constant_operator import ConstantOperator
from .operators.central_zero_padder import CentralZeroPadder
from .operators.diagonal_operator import DiagonalOperator
from .operators.distributors import DOFDistributor, PowerDistributor
......@@ -73,7 +74,7 @@ from .minimization.kl_energy import KL_Energy
from .sugar import *
from .plot import Plot
from .library.amplitude_model import AmplitudeModel, GaussShiftModel
from .library.amplitude_model import AmplitudeModel
from .library.inverse_gamma_model import InverseGammaModel
from .library.los_response import LOSResponse
......
......@@ -23,6 +23,7 @@ import numpy as np
from ..compat import *
from ..domains.power_space import PowerSpace
from ..field import Field
from ..operators.constant_operator import ConstantOperator
from ..operators.operator import Operator
from ..sugar import makeOp, sqrt
......@@ -93,22 +94,6 @@ def CepstrumOperator(logk_space, ceps_a, ceps_k, zero_mode=True):
return res
class GaussShiftModel(Operator):
# FIXME Remove this operator as soon as operators support addition with
# constant fields
def __init__(self, mean, std):
dom = mean.domain
dom1 = std.domain
if not dom == dom1:
raise TypeError('mean and std need to have the same domain.')
self._domain = self._target = dom
self._mean, self._std = mean, std
def apply(self, x):
self._check_input(x)
return self._std*x + self._mean
def SlopeModel(logk_space, sm, sv, im, iv):
'''
Parameters
......@@ -126,8 +111,7 @@ def SlopeModel(logk_space, sm, sv, im, iv):
slope = SlopeOperator(logk_space)
phi_mean = Field.from_global_data(slope.domain, phi_mean)
phi_sig = Field.from_global_data(slope.domain, phi_sig)
gaussshift = GaussShiftModel(phi_mean, phi_sig)
return slope(gaussshift)
return slope*ConstantOperator(phi_sig) + ConstantOperator(phi_mean)
def AmplitudeModel(s_space,
......
# 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/>.
#
# Copyright(C) 2013-2018 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from __future__ import absolute_import, division, print_function
from ..compat import *
from ..multi_domain import MultiDomain
from .operator import Operator
class ConstantOperator(Operator):
def __init__(self, field):
self._field = field
self._domain = MultiDomain.make({})
self._target = field.domain
def apply(self, x):
self._check_input(x)
return self._field
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment