Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIFTy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ift
NIFTy
Commits
668ac34b
Commit
668ac34b
authored
Oct 07, 2018
by
Philipp Arras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ConstantOperator
parent
d04c627b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
19 deletions
+38
-19
nifty5/__init__.py
nifty5/__init__.py
+2
-1
nifty5/library/amplitude_model.py
nifty5/library/amplitude_model.py
+2
-18
nifty5/operators/constant_operator.py
nifty5/operators/constant_operator.py
+34
-0
No files found.
nifty5/__init__.py
View file @
668ac34b
...
...
@@ -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
...
...
nifty5/library/amplitude_model.py
View file @
668ac34b
...
...
@@ -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
,
...
...
nifty5/operators/constant_operator.py
0 → 100644
View file @
668ac34b
# 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment