Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
empyre
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dieter Weber
empyre
Commits
f3c0b5a1
Commit
f3c0b5a1
authored
7 years ago
by
Fengshan Zheng
Browse files
Options
Downloads
Patches
Plain Diff
Small changes after Jan commented
parent
34aab94d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyramid/phasemapper.py
+11
-11
11 additions, 11 deletions
pyramid/phasemapper.py
tests/test_phasemapper.py
+2
-2
2 additions, 2 deletions
tests/test_phasemapper.py
with
13 additions
and
13 deletions
pyramid/phasemapper.py
+
11
−
11
View file @
f3c0b5a1
...
...
@@ -422,15 +422,15 @@ class PhaseMapperCharge(PhaseMapper):
kernelcharge : :class:`~pyramid.KernelCharge`
Convolution kernel, representing the phase contribution of one single charge pixel.
m: int
Size of the image space and input space.
Size of the image space.
n: int
Size of the input space.
c: :class:`~numpy.ndarray` (N=3)
The charge distribution
c_fft : :class:`~numpy.ndarray` (N=3)
The real FFT of the charge distribution.
phase_fft: :class:`~numpy.ndarray` (N=3)
The real FFT of the phase from the given charge distribution c.
phase_adj: :class:`~numpy.ndarray` (N=3)
The adjoint of the phase from the given charge distribution c.
"""
_log
=
logging
.
getLogger
(
__name__
+
'
.PhaseMapperCharge
'
)
...
...
@@ -439,7 +439,7 @@ class PhaseMapperCharge(PhaseMapper):
self
.
_log
.
debug
(
'
Calling __init__
'
)
self
.
kernelcharge
=
kernelcharge
self
.
m
=
np
.
prod
(
kernelcharge
.
dim_uv
)
#
self.n =
2 *
self.m
self
.
n
=
self
.
m
self
.
c
=
np
.
zeros
(
kernelcharge
.
dim_pad
,
dtype
=
kernelcharge
.
kc
.
dtype
)
self
.
phase_adj
=
np
.
zeros
(
kernelcharge
.
dim_pad
,
dtype
=
kernelcharge
.
kc
.
dtype
)
self
.
_log
.
debug
(
'
Created
'
+
str
(
self
))
...
...
@@ -462,9 +462,9 @@ class PhaseMapperCharge(PhaseMapper):
return
PhaseMap
(
elecdata
.
a
,
self
.
_convolve
())
def
_convolve
(
self
):
# Fourier transform the projected
magnetisa
tion:
# Fourier transform the projected
charge distribu
tion:
self
.
c_fft
=
fft
.
rfftn
(
self
.
c
)
# Convolve the
magnetiza
tion with the kernel in Fourier space:
# Convolve the
charge distribu
tion with the kernel in Fourier space:
self
.
phase_fft
=
self
.
c_fft
*
self
.
kernelcharge
.
kc_fft
# Return the result:
return
fft
.
irfftn
(
self
.
phase_fft
)[
self
.
kernelcharge
.
slice_phase
]
...
...
@@ -483,9 +483,9 @@ class PhaseMapperCharge(PhaseMapper):
Product of the Jacobi matrix (which is not explicitly calculated) with the vector.
"""
assert
len
(
vector
)
==
self
.
m
,
\
'
vector size not compatible!
scala
r: {}, size: {}
'
.
format
(
len
(
vector
),
self
.
m
)
self
.
c
[
self
.
kernelcharge
.
slice_c
]
=
np
.
reshape
(
vector
,
(
1
,)
+
self
.
kernelcharge
.
dim_uv
)
assert
len
(
vector
)
==
self
.
n
,
\
'
vector size not compatible!
vecto
r: {}, size: {}
'
.
format
(
len
(
vector
),
self
.
n
)
self
.
c
[
self
.
kernelcharge
.
slice_c
]
=
np
.
reshape
(
vector
,
self
.
kernelcharge
.
dim_uv
)
return
np
.
ravel
(
self
.
_convolve
())
def
jac_T_dot
(
self
,
vector
):
...
...
@@ -501,11 +501,11 @@ class PhaseMapperCharge(PhaseMapper):
-------
result : :class:`~numpy.ndarray` (N=1)
Product of the transposed Jacobi matrix (which is not explicitly calculated) with
the
scala
r, which has ``N**2`` entries like a 2D charge projection.
the
vecto
r, which has ``N**2`` entries like a 2D charge projection.
"""
assert
len
(
vector
)
==
self
.
m
,
\
'
vector size not compatible!
scala
r: {}, size: {}
'
.
format
(
len
(
vector
),
self
.
m
)
'
vector size not compatible!
vecto
r: {}, size: {}
'
.
format
(
len
(
vector
),
self
.
m
)
self
.
phase_adj
[
self
.
kernelcharge
.
slice_phase
]
=
vector
.
reshape
(
self
.
kernelcharge
.
dim_uv
)
phase_adj_fft
=
fft
.
irfft2_adj
(
self
.
phase_adj
)
kc_adj_fft
=
phase_adj_fft
*
np
.
conj
(
self
.
kernelcharge
.
kc_fft
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_phasemapper.py
+
2
−
2
View file @
f3c0b5a1
...
...
@@ -202,8 +202,8 @@ class TestCasePhaseMapperCharge(unittest.TestCase):
phase_jac
=
self
.
mapper
.
jac_dot
(
charge_proj_scalar
).
reshape
(
self
.
mapper
.
kernelcharge
.
dim_uv
)
assert_allclose
(
phase
,
phase_jac
,
atol
=
1E-7
,
err_msg
=
'
Inconsistency between __call__() and jac_dot()!
'
)
m
=
self
.
mapper
.
m
jac
=
np
.
array
([
self
.
mapper
.
jac_dot
(
np
.
eye
(
m
)[:,
i
])
for
i
in
range
(
m
)]).
T
n
=
self
.
mapper
.
n
jac
=
np
.
array
([
self
.
mapper
.
jac_dot
(
np
.
eye
(
n
)[:,
i
])
for
i
in
range
(
n
)]).
T
jac_charge_ref
=
np
.
load
(
os
.
path
.
join
(
self
.
path
,
'
jac_charge.npy
'
))
assert_allclose
(
jac
,
jac_charge_ref
,
atol
=
1E-7
,
err_msg
=
'
Unexpected behaviour in the the jacobi matrix!
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment