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
1bb2c55c
Commit
1bb2c55c
authored
Feb 18, 2019
by
Martin Reinecke
Committed by
Lukas Platz
Feb 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Martin's 'apply_spherical_convolution' function as template
parent
9e644972
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
nifty5/domains/lm_space.py
nifty5/domains/lm_space.py
+37
-0
No files found.
nifty5/domains/lm_space.py
View file @
1bb2c55c
...
...
@@ -147,3 +147,40 @@ class LMSpace(StructuredDomain):
from
..domains.hp_space
import
HPSpace
if
not
isinstance
(
codomain
,
(
GLSpace
,
HPSpace
)):
raise
TypeError
(
"codomain must be a GLSpace or HPSpace."
)
def
apply_spherical_convolution
(
inp
,
func
):
"""Convolves `inp` with a kernel defined by `func`
which is assumed to be radially symmetric around theta==0."""
import
pyHealpix
from
.gl_space
import
GLSpace
from
..operators.harmonic_operators
import
HarmonicTransformOperator
if
len
(
inp
.
domain
)
!=
1
:
raise
ValueError
(
"need exactly one domain"
)
sph
=
inp
.
domain
[
0
]
# define an appropriate harmonic partner space
lm
=
sph
.
get_default_codomain
()
if
not
isinstance
(
lm
,
LMSpace
):
raise
TypeError
(
"need a spherical domain"
)
# define azimuthally symmetric spaces for kernel transform
gl
=
GLSpace
(
lm
.
lmax
+
1
,
1
)
lm0
=
gl
.
get_default_codomain
()
theta
=
pyHealpix
.
GL_thetas
(
gl
.
nlat
)
# evaluate the kernel function at the required thetas
kernel_sphere
=
Field
.
from_global_data
(
gl
,
func
(
theta
))
# normalize the kernel such that the integral over the sphere is 4pi
kernel_sphere
=
kernel_sphere
*
(
4
*
np
.
pi
/
kernel_sphere
.
integrate
())
# compute the spherical harmonic coefficients of the kernel
op
=
HarmonicTransformOperator
(
lm0
,
gl
)
kernel_lm
=
op
.
adjoint_times
(
kernel_sphere
.
weight
(
1
)).
to_global_data
()
# evaluate the k lengths of the harmonic space
k_lengths
=
lm
.
get_k_length_array
().
to_global_data
().
astype
(
np
.
int
)
op
=
HarmonicTransformOperator
(
lm
,
sph
)
# "inverse" transform to harmonic space
inp_lm
=
op
.
adjoint_times
(
inp
.
weight
(
1
)).
to_global_data
()
# multiply the kernel to the coefficients and adjust normalization
inp_lm
=
inp_lm
*
kernel_lm
[
k_lengths
]
*
4
*
np
.
pi
out
=
Field
.
from_global_data
(
lm
,
inp_lm
)
# back to the original space
return
op
(
out
)
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