Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
02632255
Commit
02632255
authored
Aug 24, 2017
by
Martin Reinecke
Browse files
Merge branch 'master' into fix_smoothing
parents
2c2489b9
846cc966
Pipeline
#17244
passed with stage
in 50 minutes and 31 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
demos/wiener_filter_via_hamiltonian.py
View file @
02632255
...
@@ -117,13 +117,13 @@ if __name__ == "__main__":
...
@@ -117,13 +117,13 @@ if __name__ == "__main__":
# Solving the problem analytically
# Solving the problem analytically
m0
=
D0
.
inverse_times
(
j
)
m0
=
D0
.
inverse_times
(
j
)
sample_variance
=
Field
(
sh
.
domain
,
val
=
0.
+
0j
)
sample_variance
=
Field
(
sh
.
domain
,
val
=
0.
)
sample_mean
=
Field
(
sh
.
domain
,
val
=
0.
+
0j
)
sample_mean
=
Field
(
sh
.
domain
,
val
=
0.
)
# sampling the uncertainty map
# sampling the uncertainty map
n_samples
=
1
n_samples
=
1
0
for
i
in
range
(
n_samples
):
for
i
in
range
(
n_samples
):
sample
=
sugar
.
generate_posterior_sample
(
m
0
,
D0
)
sample
=
fft
(
sugar
.
generate_posterior_sample
(
0
.
,
D0
)
)
sample_variance
+=
sample
**
2
sample_variance
+=
sample
**
2
sample_mean
+=
sample
sample_mean
+=
sample
variance
=
sample_variance
/
n_samples
-
(
sample_mean
/
n_samples
)
variance
=
(
sample_variance
-
sample_mean
**
2
)
/
n_samples
nifty/basic_arithmetics.py
View file @
02632255
...
@@ -24,7 +24,7 @@ from .field import Field
...
@@ -24,7 +24,7 @@ from .field import Field
__all__
=
[
'cos'
,
'sin'
,
'cosh'
,
'sinh'
,
'tan'
,
'tanh'
,
'arccos'
,
'arcsin'
,
__all__
=
[
'cos'
,
'sin'
,
'cosh'
,
'sinh'
,
'tan'
,
'tanh'
,
'arccos'
,
'arcsin'
,
'arccosh'
,
'arcsinh'
,
'arctan'
,
'arctanh'
,
'sqrt'
,
'exp'
,
'log'
,
'arccosh'
,
'arcsinh'
,
'arctan'
,
'arctanh'
,
'sqrt'
,
'exp'
,
'log'
,
'conjugate'
,
'clipped_exp'
,
'limited_exp'
]
'conjugate'
,
'clipped_exp'
,
'limited_exp'
,
'limited_exp_deriv'
]
def
_math_helper
(
x
,
function
):
def
_math_helper
(
x
,
function
):
...
@@ -101,15 +101,28 @@ def clipped_exp(x):
...
@@ -101,15 +101,28 @@ def clipped_exp(x):
def
limited_exp
(
x
):
def
limited_exp
(
x
):
thr
=
200
return
_math_helper
(
x
,
_limited_exp_helper
)
expthr
=
np
.
exp
(
thr
)
return
_math_helper
(
x
,
lambda
z
:
_limited_exp_helper
(
z
,
thr
,
expthr
))
def
_limited_exp_helper
(
x
):
thr
=
200.
mask
=
x
>
thr
if
np
.
count_nonzero
(
mask
)
==
0
:
return
np
.
exp
(
x
)
result
=
((
1.
-
thr
)
+
x
)
*
np
.
exp
(
thr
)
result
[
~
mask
]
=
np
.
exp
(
x
[
~
mask
])
return
result
def
_limited_exp_helper
(
x
,
thr
,
expthr
):
def
limited_exp_deriv
(
x
):
mask
=
(
x
>
thr
)
return
_math_helper
(
x
,
_limited_exp_deriv_helper
)
result
=
np
.
exp
(
x
)
result
[
mask
]
=
((
1
-
thr
)
+
x
[
mask
])
*
expthr
def
_limited_exp_deriv_helper
(
x
):
thr
=
200.
mask
=
x
>
thr
if
np
.
count_nonzero
(
mask
)
==
0
:
return
np
.
exp
(
x
)
result
=
np
.
empty_like
(
x
)
result
[
mask
]
=
np
.
exp
(
thr
)
result
[
~
mask
]
=
np
.
exp
(
x
[
~
mask
])
return
result
return
result
...
...
nifty/field.py
View file @
02632255
...
@@ -330,7 +330,7 @@ class Field(Loggable, Versionable, object):
...
@@ -330,7 +330,7 @@ class Field(Loggable, Versionable, object):
Returns
Returns
-------
-------
out : Field
out : Field
The output object. It
'
s domain is a PowerSpace and it contains
The output object. Its domain is a PowerSpace and it contains
the power spectrum of 'self's field.
the power spectrum of 'self's field.
See Also
See Also
...
...
nifty/minimization/line_searching/line_search.py
View file @
02632255
...
@@ -28,7 +28,7 @@ class LineSearch(with_metaclass(abc.ABCMeta, type('NewBase', (Loggable, object),
...
@@ -28,7 +28,7 @@ class LineSearch(with_metaclass(abc.ABCMeta, type('NewBase', (Loggable, object),
"""Class for determining the optimal step size along some descent direction.
"""Class for determining the optimal step size along some descent direction.
Initialize the line search procedure which can be used by a specific line
Initialize the line search procedure which can be used by a specific line
search method. It
s
finds the step size in a specific direction in the
search method. It finds the step size in a specific direction in the
minimization process.
minimization process.
Attributes
Attributes
...
...
nifty/sugar.py
View file @
02632255
...
@@ -108,7 +108,7 @@ def generate_posterior_sample(mean, covariance):
...
@@ -108,7 +108,7 @@ def generate_posterior_sample(mean, covariance):
R
=
covariance
.
R
R
=
covariance
.
R
N
=
covariance
.
N
N
=
covariance
.
N
power
=
S
.
diagonal
().
power_analyze
()
**
.
5
power
=
sqrt
(
S
.
diagonal
().
power_analyze
()
)
mock_signal
=
power
.
power_synthesize
(
real_signal
=
True
)
mock_signal
=
power
.
power_synthesize
(
real_signal
=
True
)
noise
=
N
.
diagonal
(
bare
=
True
)
noise
=
N
.
diagonal
(
bare
=
True
)
...
...
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