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
13
Merge Requests
13
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
15617c75
Commit
15617c75
authored
Oct 05, 2018
by
Philipp Arras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GaussShiftModel and simplifications
parent
659c833c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
50 deletions
+40
-50
nifty5/__init__.py
nifty5/__init__.py
+1
-1
nifty5/library/amplitude_model.py
nifty5/library/amplitude_model.py
+39
-49
No files found.
nifty5/__init__.py
View file @
15617c75
...
...
@@ -74,7 +74,7 @@ from .minimization.kl_energy import KL_Energy
from
.sugar
import
*
from
.plot
import
Plot
from
.library.amplitude_model
import
AmplitudeModel
from
.library.amplitude_model
import
AmplitudeModel
,
GaussShiftModel
from
.library.inverse_gamma_model
import
InverseGammaModel
from
.library.los_response
import
LOSResponse
...
...
nifty5/library/amplitude_model.py
View file @
15617c75
...
...
@@ -86,7 +86,23 @@ def CepstrumModel(logk_space, ceps_a, ceps_k):
return
sym
(
qht
(
makeOp
(
sqrt
(
cepstrum
))))
class
SlopeModel
(
Operator
):
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
----------
...
...
@@ -94,34 +110,20 @@ class SlopeModel(Operator):
sm, sv : slope_mean = expected exponent of power law (e.g. -4),
slope_variance (default=1)
im, iv : y-intercept_mean, y-intercept_
variance
of power_slope
im, iv : y-intercept_mean, y-intercept_
std
of power_slope
'''
def
__init__
(
self
,
logk_space
,
sm
,
sv
,
im
,
iv
):
from
..operators.slope_operator
import
SlopeOperator
phi_mean
=
np
.
array
([
sm
,
im
+
sm
*
logk_space
.
t_0
[
0
]])
phi_sig
=
np
.
array
([
sv
,
iv
])
from
..operators.slope_operator
import
SlopeOperator
phi_mean
=
np
.
array
([
sm
,
im
+
sm
*
logk_space
.
t_0
[
0
]])
phi_sig
=
np
.
array
([
sv
,
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
)
self
.
_slope
=
SlopeOperator
(
logk_space
)
self
.
_slope
=
self
.
_slope
(
makeOp
(
Field
.
from_global_data
(
self
.
_slope
.
domain
,
phi_sig
)))
self
.
_norm_phi_mean
=
Field
.
from_global_data
(
self
.
_slope
.
domain
,
phi_mean
/
phi_sig
)
self
.
_domain
=
self
.
_slope
.
domain
self
.
_target
=
self
.
_slope
.
target
def
apply
(
self
,
x
):
self
.
_check_input
(
x
)
return
self
.
_slope
(
x
+
self
.
_norm_phi_mean
)
@
property
def
norm_phi_mean
(
self
):
return
self
.
_norm_phi_mean
class
AmplitudeModel
(
Operator
):
def
AmplitudeModel
(
s_space
,
Npixdof
,
ceps_a
,
ceps_k
,
sm
,
sv
,
im
,
iv
,
keys
=
[
'tau'
,
'phi'
]):
'''
Computes a smooth power spectrum.
Output lives in PowerSpace.
...
...
@@ -140,32 +142,20 @@ class AmplitudeModel(Operator):
im, iv : y-intercept_mean, y-intercept_variance of power_slope
'''
def
__init__
(
self
,
s_space
,
Npixdof
,
ceps_a
,
ceps_k
,
sm
,
sv
,
im
,
iv
,
keys
=
[
'tau'
,
'phi'
]):
from
..operators.exp_transform
import
ExpTransform
from
..operators.simple_linear_operators
import
FieldAdapter
from
..operators.scaling_operator
import
ScalingOperator
h_space
=
s_space
.
get_default_codomain
()
et
=
ExpTransform
(
PowerSpace
(
h_space
),
Npixdof
)
logk_space
=
et
.
domain
[
0
]
from
..operators.exp_transform
import
ExpTransform
from
..operators.simple_linear_operators
import
FieldAdapter
from
..operators.scaling_operator
import
ScalingOperator
smooth
=
CepstrumModel
(
logk_space
,
ceps_a
,
ceps_k
)
linear
=
SlopeModel
(
logk_space
,
sm
,
sv
,
im
,
iv
)
h_space
=
s_space
.
get_default_codomain
()
et
=
ExpTransform
(
PowerSpace
(
h_space
),
Npixdof
)
logk_space
=
et
.
domain
[
0
]
self
.
_qht
,
self
.
_ceps
=
smooth
.
qht
,
smooth
.
ceps
self
.
_norm_phi_mean
=
linear
.
norm_phi_mean
smooth
=
CepstrumModel
(
logk_space
,
ceps_a
,
ceps_k
)
linear
=
SlopeModel
(
logk_space
,
sm
,
sv
,
im
,
iv
)
fa_smooth
=
FieldAdapter
(
smooth
.
domain
,
keys
[
0
])
fa_linear
=
FieldAdapter
(
linear
.
domain
,
keys
[
1
])
fac
=
ScalingOperator
(
0.5
,
smooth
.
target
)
self
.
_op
=
et
((
fac
(
smooth
(
fa_smooth
)
+
linear
(
fa_linear
))).
exp
())
self
.
_domain
,
self
.
_target
=
self
.
_op
.
domain
,
self
.
_op
.
target
def
apply
(
self
,
x
):
self
.
_check_input
(
x
)
return
self
.
_op
(
x
)
fa_smooth
=
FieldAdapter
(
smooth
.
domain
,
keys
[
0
])
fa_linear
=
FieldAdapter
(
linear
.
domain
,
keys
[
1
])
@
property
def
norm_phi_mean
(
self
):
return
self
.
_norm_phi_mean
fac
=
ScalingOperator
(
0.5
,
smooth
.
target
)
return
et
((
fac
(
smooth
(
fa_smooth
)
+
linear
(
fa_linear
))).
exp
())
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