Skip to content
GitLab
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
360cac16
Commit
360cac16
authored
Feb 19, 2019
by
Martin Reinecke
Browse files
tweaks
parent
0fadc5fd
Pipeline
#43905
passed with stages
in 8 minutes and 7 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
demos/misc/convolution_on_sphere.py
View file @
360cac16
...
...
@@ -15,11 +15,13 @@ for i in range(0, npix, npix//12 + 27):
signal_vals
[
i
]
=
1.
signal
=
ift
.
from_global_data
(
dom_tuple
,
signal_vals
)
# Define kernel function
def
func
(
theta
):
ct
=
np
.
cos
(
theta
)
return
1.
*
np
.
logical_and
(
ct
>
0.7
,
ct
<=
0.8
)
# Create Convolution Operator
conv_op
=
ift
.
SphericalFuncConvolutionOperator
(
dom_tuple
,
func
)
...
...
nifty5/operators/convolution_operators.py
View file @
360cac16
...
...
@@ -26,32 +26,25 @@ from ..domain_tuple import DomainTuple
from
..field
import
Field
class
SphericalFuncConvolutionOperator
(
En
dom
orphicOperator
):
def
SphericalFuncConvolutionOperator
(
dom
ain
,
func
):
"""Convolves input with a radially symmetric kernel defined by `func`
Parameters
----------
domain: domain of the operator
func: function defining the sperical convolution kernel
dependant only on theta in radians
domain: DomainTuple
Domain of the operator. Must have exactly one entry, which is
of type `HPSpace` or `GLSpace`.
func: function
This function needs to take exactly one argument, which is
colatitude in radians, and return the kernel amplitude at that
colatitude.
"""
def
__init__
(
self
,
domain
,
func
):
if
len
(
domain
)
!=
1
:
raise
ValueError
(
"need exactly one domain"
)
if
not
isinstance
(
domain
[
0
],
(
HPSpace
,
GLSpace
)):
raise
TypeError
(
"need a spherical domain"
)
self
.
_domain
=
domain
self
.
lm
=
domain
[
0
].
get_default_codomain
()
self
.
kernel
=
self
.
lm
.
get_conv_kernel_from_func
(
func
)
self
.
HT
=
HarmonicTransformOperator
(
self
.
lm
,
domain
[
0
])
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
def
apply
(
self
,
x
,
mode
):
self
.
_check_input
(
x
,
mode
)
x_lm
=
self
.
HT
.
adjoint_times
(
x
.
weight
(
1
))
x_lm
=
x_lm
*
self
.
kernel
*
(
4.
*
np
.
pi
)
return
self
.
HT
(
x_lm
)
if
len
(
domain
)
!=
1
:
raise
ValueError
(
"need exactly one domain"
)
if
not
isinstance
(
domain
[
0
],
(
HPSpace
,
GLSpace
)):
raise
TypeError
(
"need a spherical domain"
)
kernel
=
domain
[
0
].
get_default_codomain
().
get_conv_kernel_from_func
(
func
)
return
SphericalConvolutionOperator
(
domain
,
kernel
)
class
SphericalConvolutionOperator
(
EndomorphicOperator
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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