Skip to content
Snippets Groups Projects
Forked from empyre / empyre
347 commits behind the upstream repository.
  • Jan Caron's avatar
    622c59d8
    Phase offset and ramp can now be fitted! Many updates and fixes to plotting! · 622c59d8
    Jan Caron authored
    colormap: New module with colormap subclass which has special functions to
              calculate directional rgb-colors, now used in many plots!
    __init__: On star import now also has abbreviations for a few modules.
    fwd_model: Now has flags for fitting an offset and/or ramp.
               CAUTION: will be moved next update to new class!
    magdata: Removed colorwheel stuff (all moved to 'colormap'). Overhaul of quiver
             plot in 2D and 3D. Now shows mask and uses new colormap for angular
             color coding.
    phasemap: Now uses the new colormap for holo plots. Removed color wheel (moved
              to the new class). Added function to add ramps.
    phasemapper: Now handles also offsets and ramps in the phase.
                 CAUTION: will be moved next update to new class!
    projector: Fixed bugs in SimpleProjector. 1) leftmost pixels are no longer moved
               moved to left corner of padded projection (when dim_uv is not None).
               2) odd padding when using dim_uv are now handled properly (one more
               pixel on top and right if necessary).
    costfunction: n is now taken from the fwd_model instead of the data_set.
    dataset: Introduced the count variable which gives the number of images.
    magcreator: In the process of updating, more on next commit.
    reconstruction: Also handles ramps and offsets now, properly extracts them after
                    reconstruction.
    regularisator: New argument 'add_params' is used to cut off input (for offset
                   and ramp) which are not used in the regularisation.
    scripts: several small changes...
    622c59d8
    History
    Phase offset and ramp can now be fitted! Many updates and fixes to plotting!
    Jan Caron authored
    colormap: New module with colormap subclass which has special functions to
              calculate directional rgb-colors, now used in many plots!
    __init__: On star import now also has abbreviations for a few modules.
    fwd_model: Now has flags for fitting an offset and/or ramp.
               CAUTION: will be moved next update to new class!
    magdata: Removed colorwheel stuff (all moved to 'colormap'). Overhaul of quiver
             plot in 2D and 3D. Now shows mask and uses new colormap for angular
             color coding.
    phasemap: Now uses the new colormap for holo plots. Removed color wheel (moved
              to the new class). Added function to add ramps.
    phasemapper: Now handles also offsets and ramps in the phase.
                 CAUTION: will be moved next update to new class!
    projector: Fixed bugs in SimpleProjector. 1) leftmost pixels are no longer moved
               moved to left corner of padded projection (when dim_uv is not None).
               2) odd padding when using dim_uv are now handled properly (one more
               pixel on top and right if necessary).
    costfunction: n is now taken from the fwd_model instead of the data_set.
    dataset: Introduced the count variable which gives the number of images.
    magcreator: In the process of updating, more on next commit.
    reconstruction: Also handles ramps and offsets now, properly extracts them after
                    reconstruction.
    regularisator: New argument 'add_params' is used to cut off input (for offset
                   and ramp) which are not used in the regularisation.
    scripts: several small changes...
phasemap_from_dm3.py 1.25 KiB
# -*- coding: utf-8 -*-
"""Create magnetization distributions from DM3 (Digital Micrograph 3) files."""


import os
import numpy as np
from pyDM3reader import DM3lib as dm3
import pyramid as py
import logging.config


logging.config.fileConfig(py.LOGGING_CONFIG, disable_existing_loggers=False)

###################################################################################################
path_mag = 'zi_an_elongated_nanorod.dm3'
path_ele = 'zi_an_elongated_nanorod_mip.dm3'
filename = 'phasemap_dm3_zi_an_elongated_nanorod.nc'
a = 1.
dim_uv = None
threshold = 4.5
###################################################################################################

# Load images:
im_mag = dm3.DM3(os.path.join(py.DIR_FILES, 'dm3', path_mag)).image
im_ele = dm3.DM3(os.path.join(py.DIR_FILES, 'dm3', path_ele)).image
if dim_uv is not None:
    im_mag = im_mag.resize(dim_uv)
    im_ele = im_ele.resize(dim_uv)
# Calculate phase and mask:
phase = np.asarray(im_mag)
mask = np.where(np.asarray(im_ele) >= threshold, True, False)

# Create and save PhaseMap object:
phase_map = py.PhaseMap(a, phase, mask, confidence=None, unit='rad')
phase_map.save_to_netcdf4(os.path.join(py.DIR_FILES, 'phasemap', filename))
phase_map.display_combined()