From c3f95b80df2627a7a634f221c803b2504e2dbe4f Mon Sep 17 00:00:00 2001
From: Fengshan Zheng <f.zheng@fz-juelich.de>
Date: Mon, 11 Dec 2017 14:12:41 +0100
Subject: [PATCH] PM updated

---
 pyramid/kernel.py   |   2 +-
 pyramid/utils/pm.py | 106 ++------------------------------------------
 2 files changed, 4 insertions(+), 104 deletions(-)

diff --git a/pyramid/kernel.py b/pyramid/kernel.py
index 5f351fd..1e1d149 100644
--- a/pyramid/kernel.py
+++ b/pyramid/kernel.py
@@ -183,7 +183,7 @@ class KernelCharge(object):
     v_acc : float, optional
         The acceleration voltage of the electron microscope in V. The default is 300000.
     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 vector of the counter electrode in pixels, (elec_a,elec_b), and the distance to the origin is
         the norm of (elec_a,elec_b).
     dim_uv : tuple of int (N=2), optional
         Dimensions of the 2-dimensional electrostatic charge grid from which the phase should
diff --git a/pyramid/utils/pm.py b/pyramid/utils/pm.py
index e609967..0d17692 100644
--- a/pyramid/utils/pm.py
+++ b/pyramid/utils/pm.py
@@ -15,8 +15,9 @@ _log = logging.getLogger(__name__)
 
 # TODO: rename magdata to vecdata everywhere!
 
+
 def pm(fielddata, mode='z', b_0=1, electrode_vec=(1E6, 1E6), mapper='RDFC', **kwargs):
-    """Convenience function for fast magnetic phase mapping.
+    """Convenience function for fast electric charge and magnetic phase mapping.
 
     Parameters
     ----------
@@ -64,7 +65,7 @@ def pm(fielddata, mode='z', b_0=1, electrode_vec=(1E6, 1E6), mapper='RDFC', **kw
     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':
+    elif mapper == 'Charge':
         phasemapper = PhaseMapperCharge(KernelCharge(fielddata.a, projector.dim_uv, electrode_vec=electrode_vec))
     else:
         raise ValueError("Invalid mapper (use 'RDFC', 'FDFC' or 'Charge'")
@@ -73,104 +74,3 @@ def pm(fielddata, mode='z', b_0=1, electrode_vec=(1E6, 1E6), mapper='RDFC', **kw
     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
-    ----------
-    magdata : :class:`~.VectorData`
-        A :class:`~.VectorData` 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.
-    **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 pm2')
-    # In case of FDFC:
-    padding = kwargs.pop('padding', 0)
-    # Determine projection mode:
-    if mode == 'rot-tilt':
-        projector = RotTiltProjector(magdata.dim, **kwargs)
-    elif mode == 'x-tilt':
-        projector = XTiltProjector(magdata.dim, **kwargs)
-    elif mode == 'y-tilt':
-        projector = YTiltProjector(magdata.dim, **kwargs)
-    elif mode in ['x', 'y', 'z']:
-        projector = SimpleProjector(magdata.dim, axis=mode, **kwargs)
-    else:
-        raise ValueError("Invalid mode (use 'x', 'y', 'z', 'x-tilt', 'y-tilt' or 'rot-tilt')")
-    # Project:
-    mag_proj = projector(magdata)
-    # Set up phasemapper and map phase:
-    if mapper == 'RDFC':
-        phasemapper = PhaseMapperRDFC(Kernel(magdata.a, projector.dim_uv, b_0=b_0))
-    elif mapper == 'FDFC':
-        phasemapper = PhaseMapperFDFC(magdata.a, projector.dim_uv, b_0=b_0, padding=padding)
-    else:
-        raise ValueError("Invalid mapper (use 'RDFC' or 'FDFC'")
-    phasemap = phasemapper(mag_proj)
-    # Get mask from magdata:
-    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
-- 
GitLab