Skip to main content

Python Modules for Transmission Electron Diffraction Simulations

Project description

Introducing pyemaps

  1. Overview

  2. Requirements

  3. Installation

  4. Basic Usage

  5. Getting Started

  6. Visualisation

  7. Licence

Overview

pyemaps package is a collection of python modules and libraries designed for transmission electron diffraction simulations and related crystallographic calculations. Main features include:

Crystal : crystal data module, classes and methods for loading crystal data from various sources; for generating diffraction patterns with microscope and sample control parameters; for creating electron powder diffraction; for calculating the following crystal structure factors:

  • X-Ray Structure Factors
  • Electron Structure Factor in V (volts)
  • Electron Structure Factor in 1/Å^2
  • Electron Absorption Structure Factor in 1/Å^2

EMC : electron microscope control module. Its class EMC makes it easy to handle simulation control parameters.

DP : kinematic diffraction python class. It encapsulates diffraction pattern data generated by Crystal class instance and diffraction pattern visualisation methods such as plotting Kikuchi and HOLZ lines, and diffraction spots or disks and their indices.

See sample code and latest release notes for details.

pyemaps is based on the proprietary Fortran applications released as backend of cloudEMAPS2.0.

Future releases planned include:

Bloch : dynamic Bloch wave simulation.

Check EMlab Solution, Inc. for updates and releases. We welcome comments and suggestions from our user community. For reporting any issues and requesting pyemaps improvements, or sharing scripts using pyemaps, please go to our support page.

If you benefit from pyemaps in your microscopy and crystallography research and education, go to PayPal to donate. Your generous donations keep us in the business of providing free software to the communities.

Requirements

  • Python: Version >= 3.6

  • numpy: Version >= 1.21.2

  • matplotlib: Version >= 3.2.1

  • PyCifRW Version == 4.4.3

  • Operating Systems: Windows

Linux support planned in future releases, stay tuned.

Installation


(.venv) $ pip install pyemaps

where .venv is the python virtual environment

PYEMAPS_CRYSTALS environment variable is optional. But setting it to a directory where all custom

crystal data files are located provides central location for organizing your own crystal data. pyemaps also searches this directory for your crystal data.


    PYEMAPS_CRYSTALS=<local directory>

Basic Usage


from pyemaps import Crystal

from pyemaps import DP

Getting Started

Run the following on command line, after above successful installation:


python sample.py

where sample.py is as follows:

 #import Crystal class from pyemaps as cryst

from pyemaps import Crystal as cryst

# create a crystal class instance and load it with builtin silicon data

si = cryst.from_builtin('Silicon')



# generate diffraction on the crystal instance with all default controls

# parameters, default controls returned as the first output ignored



_, si_dp = si.generateDP()

#plot and show the diffraction pattern using pyemaps built-in plot function

si_dp.plot()

The alternative to run the above without creating sample.py:


python -m pyemaps --sample (-s)

The diffraction plot is generated with silicon crystal data built in the package:


crystal Silicon: dw = iso

cell 5.4307 5.4307 5.4307 90 90 90

atom si 0.125 0.125 0.125 0.4668 1.00

spg 227 2

and default electron microscope and sample control parameters:


zone axis: (0,0,1)

microscope mode: normal

microscope camera length : 1000 mm

microscope voltage: 200 V

sample tilt: (0.0,0.0)

sample offset: (0.0,0.0)

spot size: 0.05 Å

To see all crystal names with builtin data, call:

cryst.list_all_builtin_crystals()

where cryst is imported pyemaps Crystal class

To use a crystal data not in built-in database in above format (as xtl format), replace the code in sample.py:

si = cryst.from_builtin('Silicon')

with:

si = cryst.from_xtl(fn)

CIF format has recently been added to sources where pyemaps can import:

si = cryst.from_cif(fn)

where fn is a crystal data file name. See release notes for details how pyemaps imports .cif data

Note: pyemaps searches for fn if the full path is provided. Otherwise, it will look up the file in current working directory or in the directory set by PYEMAPS_CRYSTALS environment variable. In latter cases, fn is the file name without path.

Checking pyemaps version and displaying copyright information:


python -m pyemaps -c (--copyright)

python -m pyemaps -v (--version)

Visualisation

Accessing diffraction patterns data is easy for pyemaps users to visualize the diffraction patterns in any programs other than pyemaps' builtin plot with python's matplotlib library:

  • Raw kinematic diffraction data (DP) in python dictionary:
    dp.__dict__ #dp is a pyemaps DP class object generated from calling generateDP by a crystal object 
  • Individual components (such as Kikuchi lines, Diffracted beams or HOLZ lines) as python lists:
    dp.klines #Kikuchi lines list

    dp.nklines #number of Kikuchi lines, same as len(dp.klines)

    dp.disks #diffracted beams list

    dp.ndisks #number of diffracted beams, same as len(dp.disks)

    dp.hlines #HOLZ lines list

    dp.nklines #number of HOLZ lines, same as len(dp.hlines)

    dp.shift #deflection shifts of all of the above

    ...

Other sample scripts designed for you to explore pyemaps are available in samples directory:

  • si_tilt.py: spot diffraction patterns generated with silicon crystal data, plotted with matplotlib pyplot module. The code also shows how a list of diffraction patterns are generated and displayed as one of electron microscope and sample controls - tilt in x direction changes.

  • si_zone.py: same as above except the control that changes is zone axis.

  • si_csf.py: structure factors generation and output by CSF pyemaps module.

  • powder.py: electron powder diffraction generation and intensity plot by POWDER pyemaps module.

More samples code will be added as more features and releases are available.

To copy all of the samples from pyemaps package to the current working directory, run the following:


python -m pyemaps -cp (--copysamples)

all of the samples will be copied from pyemaps install directory to a folder named pyemaps_samples in your current working directory.

Licence

pyemaps is distributed for electron diffraction and microscopy research, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licence for more details.

  • pyemaps is for non-commercial use.

  • pyemaps is free software under the terms of the GNU General Public Licence as published by the Free Software Foundation, either version 3 of the Licence, or (at your option) any later version. You should have received a copy of the GNU General Public Licence along with pyemaps. If not, see https://www.gnu.org/licenses/.

Additional copyright notices and license terms applicable to portions of pyemaps are set forth in the COPYING file.

Contact supprort@emlabsoftware.com for any questions regarding the licence terms.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyemaps-0.3.9.tar.gz (63.8 kB view hashes)

Uploaded Source

Built Distribution

pyemaps-0.3.9-cp37-cp37m-win_amd64.whl (1.0 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page