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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Teresa Weßels
empyre
Commits
3da51c75
Commit
3da51c75
authored
7 years ago
by
Fengshan Zheng
Browse files
Options
Downloads
Patches
Plain Diff
PM updated for fielddata
parent
ce4f253d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyramid/utils/pm.py
+114
-5
114 additions, 5 deletions
pyramid/utils/pm.py
with
114 additions
and
5 deletions
pyramid/utils/pm.py
+
114
−
5
View file @
3da51c75
...
...
@@ -2,19 +2,79 @@
# Copyright 2016 by Forschungszentrum Juelich GmbH
# Author: J. Caron
#
"""
Convenience function for phase mapping magnetic distributions.
"""
"""
Convenience function for phase mapping magnetic
or charge
distributions.
"""
import
logging
from
..kernel
import
Kernel
from
..phasemapper
import
PhaseMapperRDFC
,
PhaseMapperFDFC
from
..kernel
import
Kernel
,
KernelCharge
from
..phasemapper
import
PhaseMapperRDFC
,
PhaseMapperFDFC
,
PhaseMapperCharge
from
..projector
import
RotTiltProjector
,
XTiltProjector
,
YTiltProjector
,
SimpleProjector
__all__
=
[
'
pm
'
]
_log
=
logging
.
getLogger
(
__name__
)
def
pm
(
magdata
,
mode
=
'
z
'
,
b_0
=
1
,
mapper
=
'
RDFC
'
,
**
kwargs
):
def
pm
(
fielddata
,
mode
=
'
z
'
,
b_0
=
1
,
electrode_vec
=
(
1E6
,
1E6
),
mapper
=
'
RDFC
'
,
**
kwargs
):
"""
Convenience function for fast magnetic phase mapping.
Parameters
----------
fielddata : :class:`~.VectorData`, or `~.ScalarData`
A :class:`~.VectorData` or `~.ScalarData` object, from which the projected phase map should be calculated.
mode: {
'
z
'
,
'
y
'
,
'
x
'
,
'
x-tilt
'
,
'
y-tilt
'
,
'
rot-tilt
'
}, optional
Projection mode which determines the :class:`~.pyramid.projector.Projector` subclass, which
is used for the projection. Default is a simple projection along the `z`-direction.
b_0 : float, optional
Saturation magnetization in Tesla, which is used for the phase calculation. Default is 1.
electrode_vec : tuple of float (N=2)
The norm vector of the counter electrode, (elec_a,elec_b), and the distance to the origin is
the norm of (elec_a,elec_b). The default value is (1E6, 1E6).
mapper : :class:
'
~. PhaseMap
'
A :class:
'
~. PhaseMap
'
object, which maps a fielddata into a phase map. The default is
'
RDFC
'
.
**kwargs : additional arguments
Additional arguments like `dim_uv`,
'
tilt
'
or
'
rotation
'
, which are passed to the
projector-constructor, defined by the `mode`.
Returns
-------
phasemap : :class:`~pyramid.phasemap.PhaseMap`
The calculated phase map as a :class:`~.PhaseMap` object.
"""
_log
.
debug
(
'
Calling pm
'
)
# In case of FDFC:
padding
=
kwargs
.
pop
(
'
padding
'
,
0
)
# Determine projection mode:
if
mode
==
'
rot-tilt
'
:
projector
=
RotTiltProjector
(
fielddata
.
dim
,
**
kwargs
)
elif
mode
==
'
x-tilt
'
:
projector
=
XTiltProjector
(
fielddata
.
dim
,
**
kwargs
)
elif
mode
==
'
y-tilt
'
:
projector
=
YTiltProjector
(
fielddata
.
dim
,
**
kwargs
)
elif
mode
in
[
'
x
'
,
'
y
'
,
'
z
'
]:
projector
=
SimpleProjector
(
fielddata
.
dim
,
axis
=
mode
,
**
kwargs
)
else
:
raise
ValueError
(
"
Invalid mode (use
'
x
'
,
'
y
'
,
'
z
'
,
'
x-tilt
'
,
'
y-tilt
'
or
'
rot-tilt
'
)
"
)
# Project:
field_proj
=
projector
(
fielddata
)
# Set up phasemapper and map phase:
if
mapper
==
'
RDFC
'
:
phasemapper
=
PhaseMapperRDFC
(
Kernel
(
fielddata
.
a
,
projector
.
dim_uv
,
b_0
=
b_0
))
elif
mapper
==
'
FDFC
'
:
phasemapper
=
PhaseMapperFDFC
(
fielddata
.
a
,
projector
.
dim_uv
,
b_0
=
b_0
,
padding
=
padding
)
# Set up phasemapper and map phase:
if
mapper
==
'
Charge
'
:
phasemapper
=
PhaseMapperCharge
(
KernelCharge
(
fielddata
.
a
,
projector
.
dim_uv
,
electrode_vec
=
electrode_vec
))
else
:
raise
ValueError
(
"
Invalid mapper (use
'
RDFC
'
,
'
FDFC
'
or
'
Charge
'"
)
phasemap
=
phasemapper
(
field_proj
)
# Get mask from fielddata:
phasemap
.
mask
=
field_proj
.
get_mask
()[
0
,
...]
# Return phase:
return
phasemap
def
pm2
(
magdata
,
mode
=
'
z
'
,
b_0
=
1
,
mapper
=
'
RDFC
'
,
**
kwargs
):
"""
Convenience function for fast magnetic phase mapping.
Parameters
...
...
@@ -36,7 +96,7 @@ def pm(magdata, mode='z', b_0=1, mapper='RDFC', **kwargs):
The calculated phase map as a :class:`~.PhaseMap` object.
"""
_log
.
debug
(
'
Calling pm
'
)
_log
.
debug
(
'
Calling pm
2
'
)
# In case of FDFC:
padding
=
kwargs
.
pop
(
'
padding
'
,
0
)
# Determine projection mode:
...
...
@@ -64,3 +124,52 @@ def pm(magdata, mode='z', b_0=1, mapper='RDFC', **kwargs):
phasemap
.
mask
=
mag_proj
.
get_mask
()[
0
,
...]
# Return phase:
return
phasemap
def
pm3
(
elecdata
,
mode
=
'
z
'
,
electrode_vec
=
(
1E6
,
1E6
),
mapper
=
'
Charge
'
,
**
kwargs
):
"""
Convenience function for fast electric phase mapping.
Parameters
----------
elecdata : :class:`~.ScalarData`
A :class:`~.ScalarData` object, from which the projected phase map should be calculated.
mode: {
'
z
'
,
'
y
'
,
'
x
'
,
'
x-tilt
'
,
'
y-tilt
'
,
'
rot-tilt
'
}, optional
Projection mode which determines the :class:`~.pyramid.projector.Projector` subclass, which
is used for the projection. Default is a simple projection along the `z`-direction.
electrode_vec : tuple of float (N=2)
The norm vector of the counter electrode, (elec_a,elec_b), and the distance to the origin is
the norm of (elec_a,elec_b).
**kwargs : additional arguments
Additional arguments like `dim_uv`,
'
tilt
'
or
'
rotation
'
, which are passed to the
projector-constructor, defined by the `mode`.
Returns
-------
phasemap : :class:`~pyramid.phasemap.PhaseMap`
The calculated phase map as a :class:`~.PhaseMap` object.
"""
_log
.
debug
(
'
Calling pm3
'
)
# Determine projection mode:
if
mode
==
'
rot-tilt
'
:
projector
=
RotTiltProjector
(
elecdata
.
dim
,
**
kwargs
)
elif
mode
==
'
x-tilt
'
:
projector
=
XTiltProjector
(
elecdata
.
dim
,
**
kwargs
)
elif
mode
==
'
y-tilt
'
:
projector
=
YTiltProjector
(
elecdata
.
dim
,
**
kwargs
)
elif
mode
in
[
'
x
'
,
'
y
'
,
'
z
'
]:
projector
=
SimpleProjector
(
elecdata
.
dim
,
axis
=
mode
,
**
kwargs
)
else
:
raise
ValueError
(
"
Invalid mode (use
'
x
'
,
'
y
'
,
'
z
'
,
'
x-tilt
'
,
'
y-tilt
'
or
'
rot-tilt
'
)
"
)
# Project:
charge_proj
=
projector
(
elecdata
)
# Set up phasemapper and map phase:
if
mapper
==
'
Charge
'
:
phasemapper
=
PhaseMapperCharge
(
KernelCharge
(
elecdata
.
a
,
projector
.
dim_uv
,
electrode_vec
=
electrode_vec
))
else
:
raise
ValueError
(
"
Invalid mapper (use
'
Charge
'"
)
phasemap
=
phasemapper
(
charge_proj
)
# Get mask from elecdata:
phasemap
.
mask
=
charge_proj
.
get_mask
()[
0
,
...]
# Return phase:
return
phasemap
\ No newline at end of file
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