Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Neel Shah
NIFTy
Commits
5eb2400b
Commit
5eb2400b
authored
Oct 31, 2019
by
Philipp Haim
Browse files
Improved readability
parent
71dc438a
Changes
3
Hide whitespace changes
Inline
Side-by-side
nifty5/library/correlated_fields.py
View file @
5eb2400b
...
...
@@ -27,7 +27,7 @@ from ..utilities import infer_space
from
..sugar
import
get_default_codomain
def
CorrelatedField
(
target
,
amplitude_operator
,
name
=
'xi'
,
codomain
=
None
,
space
=
None
):
def
CorrelatedField
(
target
,
amplitude_operator
,
name
=
'xi'
,
codomain
=
None
,
space
=
None
):
"""Constructs an operator which turns a white Gaussian excitation field
into a correlated field.
...
...
nifty5/library/smooth_linear_amplitude.py
View file @
5eb2400b
...
...
@@ -90,9 +90,11 @@ def CepstrumOperator(target, a, k0, space = None):
target
=
DomainTuple
.
make
(
target
)
space
=
infer_space
(
target
,
space
)
dim
=
len
(
target
[
space
].
shape
)
shape
=
tuple
(
s
for
i
in
range
(
len
(
target
))
if
i
!=
space
for
s
in
target
[
i
].
shape
)
a
=
_parameter_shaper
(
a
,
shape
)
k0
=
_parameter_shaper
(
k0
,
(
dim
,)
+
shape
)
#Shape of the domain without target[space] subdomain
param_shape
=
tuple
(
s
for
i
in
range
(
len
(
target
))
for
s
in
target
[
i
].
shape
if
i
!=
space
)
a
=
_parameter_shaper
(
a
,
param_shape
)
k0
=
_parameter_shaper
(
k0
,
(
dim
,)
+
param_shape
)
if
target
[
space
].
harmonic
:
raise
TypeError
...
...
@@ -109,12 +111,12 @@ def CepstrumOperator(target, a, k0, space = None):
shape
=
dom
.
shape
sl_extender
=
(
slice
(
None
),)
+
(
None
,)
*
n
+
(
slice
(
None
),)
*
dim
+
(
None
,)
*
(
N
-
n
-
dim
+
1
)
q_array
=
dom
[
space
].
get_k_array
()[
sl_extender
]
a
=
a
[(
slice
(
None
),)
*
n
+
(
None
,)
*
dim
]
k0
=
k0
[(
slice
(
None
),)
*
(
1
+
n
)
+
(
None
,)
*
dim
]
a
=
a
[(
slice
(
None
),)
*
n
+
(
None
,)
*
dim
]
k0
=
k0
[(
slice
(
None
),)
*
(
1
+
n
)
+
(
None
,)
*
dim
]
# Fill all non-zero modes
no_zero_modes
=
(
slice
(
None
),)
*
(
n
)
+
(
slice
(
1
,
None
),)
*
dim
ks
=
q_array
[(
slice
(
None
),)
+
no_zero_modes
]
ks
=
q_array
[(
slice
(
None
),)
+
no_zero_modes
]
cepstrum_field
=
np
.
zeros
(
shape
)
cepstrum_field
[
no_zero_modes
]
=
_ceps_kernel
(
ks
,
a
,
k0
)
...
...
@@ -214,8 +216,9 @@ def LinearSLAmplitude(*, target, n_pix, a, k0, sm, sv, im, iv,
if
not
(
isinstance
(
n_pix
,
int
)
and
isinstance
(
target
[
space
],
PowerSpace
)):
raise
TypeError
shape
=
tuple
(
s
for
i
in
range
(
len
(
target
))
if
i
!=
space
for
s
in
target
[
i
].
shape
)
sm
,
sv
,
im
,
iv
=
(
_parameter_shaper
(
a
,
shape
)
for
a
in
(
sm
,
sv
,
im
,
iv
))
#Shape of the domain without target[space] subdomain
param_shape
=
tuple
(
s
for
i
in
range
(
len
(
target
))
for
s
in
target
[
i
].
shape
if
i
!=
space
)
sm
,
sv
,
im
,
iv
=
(
_parameter_shaper
(
a
,
param_shape
)
for
a
in
(
sm
,
sv
,
im
,
iv
))
if
np
.
any
(
sv
<=
0
)
or
np
.
any
(
iv
<=
0
):
raise
ValueError
...
...
nifty5/sugar.py
View file @
5eb2400b
...
...
@@ -424,14 +424,17 @@ def get_default_codomain(domainoid, space=None):
codomain. `domain[space]` must be of class `RGSpace`.
"""
from
.domains.rg_space
import
RGSpace
from
.domains.hp_space
import
HPSpace
from
.domains.gl_space
import
GLSpace
from
.domains.lm_space
import
LMSpace
if
isinstance
(
domainoid
,
RGSpace
):
return
domainoid
.
get_default_codomain
()
if
not
isinstance
(
domainoid
,
DomainTuple
):
raise
TypeError
(
'Works only on RGSpaces and DomainTuples containing those'
)
space
=
utilities
.
infer_space
(
domainoid
,
space
)
if
not
isinstance
(
domainoid
[
space
],
RGSpace
):
raise
TypeError
(
"can only codomain
RGS
paces"
)
if
not
isinstance
(
domainoid
[
space
],
(
RGSpace
,
HPSpace
,
GLSpace
,
LMSpace
)
):
raise
TypeError
(
"can only codomain
structrued s
paces"
)
ret
=
[
dom
for
dom
in
domainoid
]
ret
[
space
]
=
domainoid
[
space
].
get_default_codomain
()
return
DomainTuple
.
make
(
ret
)
...
...
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