Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • empyre/empyre
  • weber/empyre
  • wessels/empyre
  • bryan/empyre
4 results
Show changes
demos/files/mask.png

2.37 KiB

File added
[.ShellClassInfo]
IconResource=C:\Users\Jan\PhD Thesis\Pyramid\icon.ico,0
[ViewState]
Mode=
Vid=
FolderType=Generic
docs/EMPyRe Logo.png

30.5 KiB

# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# Use command in docs to generate stubs and make html afterwards:
# > sphinx-apidoc -o api ../src/empyre
# > make html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join('..', 'src')))
# -- Project information -----------------------------------------------------
project = 'EMPyRe'
copyright = '2020, Jan Caron'
author = 'Jan Caron'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'numpydoc',
'nbsphinx',
'nbsphinx_link']
numpydoc_show_class_members = False
add_module_names = False
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'sphinx_rtd_theme'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_static_path = ['_static']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
# The name of an image file (relative to this directory) to place at the top
# of the sidebar.
html_logo = 'EMPyRe Logo.png'
# The name of an image file (relative to this directory) to use as a favicon of
# the doc. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
html_favicon = 'icon.ico'
# cannot cache unpickable configuration value: 'nbsphinx_custom_formats
# See https://github.com/sphinx-doc/sphinx/issues/12300
suppress_warnings = ["config.cache"]
Demos
-----
.. toctree::
demos/demo1
demos/demo2
demos/demo3
{
"path": "../../demos/demo1_first_steps.ipynb"
}
\ No newline at end of file
{
"path": "../../demos/demo2_handling_3d_fields.ipynb"
}
\ No newline at end of file
{
"path": "../../demos/demo3_io_and_field_manipulation.ipynb"
}
\ No newline at end of file
The Field container class
=========================
General empyre.fields docu here!
All functions implemented in the subpackages can be accessed directly in the ``empyre.fields`` namespace.
The field module
----------------
.. automodule:: empyre.fields.field
:members:
:show-inheritance:
The shapes module
-----------------
.. automodule:: empyre.fields.shapes
:members:
:show-inheritance:
The vectors module
------------------
.. automodule:: empyre.fields.vectors
:members:
:show-inheritance:
docs/icon.ico

66.1 KiB

.. EMPyRe documentation master file, created by
sphinx-quickstart on Mon Feb 17 14:19:01 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
EMPyRe - Electron Microscopy Reconstruction
===========================================
.. include:: ../README.rst
.. toctree::
:maxdepth: 2
:caption: Contents:
fields
vis
io
demos
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
The io visualization submodule
===============================
General empyre.io docu here!
The io_field module
-------------------
.. automodule:: empyre.io.io_field
:members:
:show-inheritance:
The field_plugins module
------------------------
.. automodule:: empyre.io.field_plugins
:members:
:show-inheritance:
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd
The vis visualization submodule
===============================
General empyre.vis docu here!
All functions implemented in the subpackages can be accessed directly in the ``empyre.io`` namespace, with the exception
of the ``color`` module, whose methods are accessible via ``empyre.vis.colors``.
Note that the y-axis of all image plots is flipped in comparison to ``matplotlib.pyplot.imshow``, i.e. that the
origin is `'lower'` in this case instead of `'upper'`.
Please note that 3D plots only work in your Jupyter notebook after first installing and then enabling the corresponding
mayavi extension:
.. code-block:: bash
$ jupyter nbextension install --py mayavi --user
$ jupyter nbextension enable mayavi --user --py
If you'd like to utilize 3D plots in your Jupyter Notebook or in the Python Interactive Window
.. code-block:: Python
>>> from mayavi import mlab
>>> mlab.init_notebook('x3d')
The backend, chosen by the `init_notebook` function can be `ipy` (the default, produces static images in Juypter
Notebook and does not work in VSCode), `x3d` (produces interactive plots in Jupyter Noteboo, but seems to not work with
VSCode), or `png` (produces png-images, which work in both Jupyter Notebooks and VSCode).
For more information and a quick introduction visit the `mayavi tips & tricks section <https://docs.enthought.com/mayavi/mayavi/tips.html>`_.
The plot2d module
-----------------
.. automodule:: empyre.vis.plot2d
:members:
:show-inheritance:
The decorators module
---------------------
.. automodule:: empyre.vis.decorators
:members:
:show-inheritance:
The colors module
-----------------
.. automodule:: empyre.vis.colors
:members:
:show-inheritance:
The tools module
----------------
.. automodule:: empyre.vis.tools
:members:
:show-inheritance:
icon.ico

132 KiB

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "empyre"
dynamic = ["version"]
description = "Electron Microscopy Python Reconstruction"
readme = "README.rst"
license = "GPL-3.0-or-later"
requires-python = ">=3.6"
authors = [
{ name = "Jan Caron", email = "j.caron@fz-juelich.de" },
]
keywords = [
"Electron Microscopy",
"Inverse Problem Solving",
"Model-based Reconstrution",
]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering",
]
dependencies = [
"matplotlib >= 3.2",
"numpy >= 1.17",
"Pillow",
"scikit-image",
"scipy",
"tqdm",
]
[project.optional-dependencies]
3d = [
"mayavi >= 4.7",
]
all = [
"cmocean",
"pyfftw",
]
colors = [
"cmocean",
]
docs = [
"nbsphinx",
"nbsphinx_link",
"numpydoc",
"pandoc",
"sphinx",
"sphinx_rtd_theme",
]
fftw = [
"pyfftw",
]
io = [
"hyperspy",
"tvtk",
]
tests = [
"coverage",
"pyroma",
"pytest",
"pytest-cov",
"pytest-flake8",
"pytest-runner",
]
[project.urls]
Homepage = "https://iffgit.fz-juelich.de/empyre/empyre"
[tool.hatch.version]
path = "src/empyre/__init__.py"
[tool.hatch.build.targets.sdist]
include = [
"/src",
"/tests",
]
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
"""Create simple phasemaps from analytic solutions."""
import numpy as np
import matplotlib.pyplot as plt
from numpy import pi
PHI_0 = 2067.83 # magnetic flux in T*nm²
def plot_phase(phase, res, name):
fig = plt.figure()
ax = fig.add_subplot(111, aspect='equal')
plt.pcolormesh(phase, cmap='gray')
ticks = ax.get_xticks() * res
ax.set_xticklabels(ticks.astype(int))
ticks = ax.get_yticks() * res
ax.set_yticklabels(ticks.astype(int))
ax.set_title('Analytical Solution' + name)
ax.set_xlabel('x-axis [nm]')
ax.set_ylabel('y-axis [nm]')
plt.colorbar()
plt.show()
def phasemap_slab(dim, res, beta, center, width, b_0):
'''INPUT VARIABLES'''
y_dim, x_dim = dim
# y0, x0 have to be in the center of a pixel, hence: cellindex + 0.5
y0 = res * (center[0] + 0.5)
x0 = res * (center[1] + 0.5)
# Ly, Lx have to be odd, because the slab borders should not lie in the
# center of a pixel (so L/2 can't be an integer)
Ly = res * ( width[0] + (width[0]+1)%2)
Lx = res * ( width[1] + (width[1]+1)%2)
'''COMPUTATION MAGNETIC PHASE SHIFT (REAL SPACE) SLAB'''
coeff = b_0 * res / ( 4 * PHI_0 )
def F0(x,y):
a = np.log(x**2 + y**2)
b = np.arctan(x / y)
return x*a - 2*x + 2*y*b
def phiMag(x,y):
return coeff * ( - np.cos(beta) * ( F0(x-x0-Lx/2, y-y0-Ly/2)
-F0(x-x0+Lx/2, y-y0-Ly/2)
-F0(x-x0-Lx/2, y-y0+Ly/2)
+F0(x-x0+Lx/2, y-y0+Ly/2) )
+ np.sin(beta) * ( F0(y-y0-Ly/2, x-x0-Lx/2)
-F0(y-y0+Ly/2, x-x0-Lx/2)
-F0(y-y0-Ly/2, x-x0+Lx/2)
+F0(y-y0+Ly/2, x-x0+Lx/2) ) )
'''CREATE COORDINATE GRIDS'''
x = np.linspace(res/2,x_dim*res-res/2,num=x_dim)
y = np.linspace(res/2,y_dim*res-res/2,num=y_dim)
xx, yy = np.meshgrid(x,y)
return phiMag(xx, yy)
def phasemap_disc(dim, res, beta, center, radius, b_0):
'''INPUT VARIABLES'''
y_dim, x_dim = dim
# y0, x0 have to be in the center of a pixel, hence: cellindex + 0.5
y0 = res * (center[0] + 0.5)
x0 = res * (center[1] + 0.5)
# TODO: Explanation
# Ly, Lx have to be odd, because the slab borders should not lie in the
# center of a pixel (so L/2 can't be an integer)
R = res * radius
'''COMPUTATION MAGNETIC PHASE SHIFT (REAL SPACE) DISC'''
coeff = - pi * res * b_0 / ( 2 * PHI_0 )
# import pdb; pdb.set_trace()
def phiMag(x,y):
r = np.hypot(x-x0, y-y0)
r[center[0], center[1]] = 1E-18
result = coeff * ((y-y0) * np.cos(beta) - (x-x0) * np.sin(beta))
in_or_out = 1 * (r < R) + (R / r) ** 2 * (r > R)
# import pdb; pdb.set_trace()
result *= in_or_out
return result
'''CREATE COORDINATE GRIDS'''
x = np.linspace(res/2,x_dim*res-res/2,num=x_dim)
y = np.linspace(res/2,y_dim*res-res/2,num=y_dim)
xx, yy = np.meshgrid(x,y)
return phiMag(xx, yy)
def phasemap_sphere(dim, res, beta, center, radius, b_0):
# TODO: Sphere is equivalent to disc, if only one pixel in z is used!
'''INPUT VARIABLES'''
y_dim, x_dim = dim
y0, x0 = center
R = radius
'''COMPUTATION MAGNETIC PHASE SHIFT (REAL SPACE) SPHERE'''
coeff = - 2/3 * pi * R**3 * b_0 / PHI_0 * res/R
def phiMag(x,y):
r = np.sqrt((x-x0) ** 2 + (y-y0) ** 2)
result = coeff / r**2 * ((y-y0) * np.cos(beta) - (x-x0) * np.sin(beta))
in_or_out = 1 * (r > R) + (1 - (1-(r/R)**2)**(3/2)) * (r < R)
result *= in_or_out
return result
'''CREATE COORDINATE GRIDS'''
x = np.linspace(res/2,x_dim*res-res/2,num=x_dim)
y = np.linspace(res/2,y_dim*res-res/2,num=y_dim)
xx, yy = np.meshgrid(x,y)
return phiMag(xx, yy)
\ No newline at end of file