pyemaps 2.1.0__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. {pyemaps-2.1.0 → pyemaps-2.2.0}/MANIFEST.in +2 -2
  2. pyemaps-2.2.0/PKG-INFO +173 -0
  3. pyemaps-2.2.0/README.md +138 -0
  4. {pyemaps-2.1.0 → pyemaps-2.2.0}/__main__.py +74 -37
  5. pyemaps-2.2.0/__version__.py +1 -0
  6. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Germanium.xtl +1 -1
  7. {pyemaps-2.1.0 → pyemaps-2.2.0}/diffract/csf_dec.py +7 -4
  8. {pyemaps-2.1.0 → pyemaps-2.2.0}/diffract/dif_dec.py +35 -7
  9. {pyemaps-2.1.0 → pyemaps-2.2.0}/diffract/powder_dec.py +4 -3
  10. {pyemaps-2.1.0 → pyemaps-2.2.0}/display.py +183 -48
  11. {pyemaps-2.1.0 → pyemaps-2.2.0}/emcontrols.py +85 -63
  12. pyemaps-2.2.0/license.txt +51 -0
  13. pyemaps-2.2.0/notebooks/adf.ipynb +762 -0
  14. pyemaps-2.2.0/notebooks/al_ediom.ipynb +683 -0
  15. pyemaps-2.2.0/notebooks/powder.ipynb +526 -0
  16. pyemaps-2.2.0/notebooks/si_bloch.ipynb +844 -0
  17. pyemaps-2.2.0/notebooks/si_constructor.ipynb +493 -0
  18. pyemaps-2.2.0/notebooks/si_csf.ipynb +835 -0
  19. pyemaps-2.2.0/notebooks/si_dif.ipynb +931 -0
  20. pyemaps-2.2.0/notebooks/si_lacbed.ipynb +789 -0
  21. pyemaps-2.2.0/notebooks/si_scm.ipynb +895 -0
  22. pyemaps-2.2.0/notebooks/si_stereo.ipynb +501 -0
  23. pyemaps-2.2.0/pyemaps.egg-info/PKG-INFO +173 -0
  24. {pyemaps-2.1.0 → pyemaps-2.2.0}/pyemaps.egg-info/SOURCES.txt +10 -0
  25. {pyemaps-2.1.0 → pyemaps-2.2.0}/pyemaps.egg-info/requires.txt +1 -1
  26. pyemaps-2.2.0/samples/adf.py +89 -0
  27. pyemaps-2.2.0/samples/al_dpgen.py +58 -0
  28. pyemaps-2.2.0/samples/al_ediom.py +76 -0
  29. pyemaps-2.2.0/samples/convert_image.py +51 -0
  30. pyemaps-2.2.0/samples/dm_diff.py +175 -0
  31. pyemaps-2.2.0/samples/powder.py +55 -0
  32. pyemaps-2.2.0/samples/si_bloch.py +111 -0
  33. pyemaps-2.2.0/samples/si_constructor.py +59 -0
  34. pyemaps-2.2.0/samples/si_csf.py +69 -0
  35. pyemaps-2.2.0/samples/si_dif.py +116 -0
  36. pyemaps-2.2.0/samples/si_lacbed.py +59 -0
  37. pyemaps-2.2.0/samples/si_pyemaps.py +61 -0
  38. pyemaps-2.2.0/samples/si_scm.py +118 -0
  39. pyemaps-2.2.0/samples/si_stereo.py +85 -0
  40. {pyemaps-2.1.0 → pyemaps-2.2.0}/setup.cfg +1 -1
  41. {pyemaps-2.1.0 → pyemaps-2.2.0}/setup.py +37 -1
  42. pyemaps-2.1.0/PKG-INFO +0 -231
  43. pyemaps-2.1.0/README.md +0 -201
  44. pyemaps-2.1.0/__version__.py +0 -1
  45. pyemaps-2.1.0/license.txt +0 -42
  46. pyemaps-2.1.0/pyemaps.egg-info/PKG-INFO +0 -231
  47. pyemaps-2.1.0/samples/adf.py +0 -137
  48. pyemaps-2.1.0/samples/al_dpgen.py +0 -57
  49. pyemaps-2.1.0/samples/al_ediom.py +0 -94
  50. pyemaps-2.1.0/samples/convert_image.py +0 -88
  51. pyemaps-2.1.0/samples/dm_diff.py +0 -225
  52. pyemaps-2.1.0/samples/powder.py +0 -52
  53. pyemaps-2.1.0/samples/si_bloch.py +0 -120
  54. pyemaps-2.1.0/samples/si_constructor.py +0 -51
  55. pyemaps-2.1.0/samples/si_csf.py +0 -59
  56. pyemaps-2.1.0/samples/si_dif.py +0 -134
  57. pyemaps-2.1.0/samples/si_lacbed.py +0 -59
  58. pyemaps-2.1.0/samples/si_pyemaps.py +0 -80
  59. pyemaps-2.1.0/samples/si_scm.py +0 -156
  60. pyemaps-2.1.0/samples/si_stereo.py +0 -116
  61. {pyemaps-2.1.0 → pyemaps-2.2.0}/COPYING +0 -0
  62. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/CifFile_module.py +0 -0
  63. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/StarFile.py +0 -0
  64. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/TypeContentsParser.py +0 -0
  65. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/YappsStarParser_1_0.py +0 -0
  66. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/YappsStarParser_1_1.py +0 -0
  67. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/YappsStarParser_2_0.py +0 -0
  68. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/YappsStarParser_STAR2.py +0 -0
  69. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/__init__.py +0 -0
  70. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/drel/__init__.py +0 -0
  71. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/drel/drel_ast_yacc.py +0 -0
  72. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/drel/drel_lex.py +0 -0
  73. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/drel/drel_runtime.py +0 -0
  74. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/drel/parsetab.py +0 -0
  75. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/drel/py_from_ast.py +0 -0
  76. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/parsetab.py +0 -0
  77. {pyemaps-2.1.0 → pyemaps-2.2.0}/CifFile/src/yapps3_compiled_rt.py +0 -0
  78. {pyemaps-2.1.0 → pyemaps-2.2.0}/__config__.py +0 -0
  79. {pyemaps-2.1.0 → pyemaps-2.2.0}/__init__.py +0 -0
  80. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Aluminium.xtl +0 -0
  81. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/AluminiumOxide.xtl +0 -0
  82. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Aluminium_FCC.xtl +0 -0
  83. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/BariumTitanate_180k.xtl +0 -0
  84. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/BariumTitanate_270k.xtl +0 -0
  85. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/BariumTitanate_Tetra.xtl +0 -0
  86. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/BiMnO3.xtl +0 -0
  87. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Boron_Tetra.xtl +0 -0
  88. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/CadmiumSelenide_Hex.xtl +0 -0
  89. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/CadmiumSulfide_Cubic.xtl +0 -0
  90. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/CadmiumSulfide_Hex.xtl +0 -0
  91. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Chromium_BCC.xtl +0 -0
  92. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/CoSb3_Skutterudite.xtl +0 -0
  93. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/CopperOxide.xtl +0 -0
  94. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Copper_FCC.xtl +0 -0
  95. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Cu2O_Cuprite.xtl +0 -0
  96. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Diamond.xtl +0 -0
  97. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/ErbiumPyrogermanate.xtl +0 -0
  98. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/FePd_Tetra.xtl +0 -0
  99. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/FeS2_Pyrite.xtl +0 -0
  100. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/GalliumAntimonide.xtl +0 -0
  101. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/GalliumArsenide.xtl +0 -0
  102. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/GalliumNitride.xtl +0 -0
  103. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Gold_FCC.xtl +0 -0
  104. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/IndiumArsenide.xtl +0 -0
  105. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/LaMnO3.xtl +0 -0
  106. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/LeadZirconateTitanate.xtl +0 -0
  107. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Li2MnO3.xtl +0 -0
  108. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/NaFeO2.xtl +0 -0
  109. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Nb3Sn.xtl +0 -0
  110. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Pentacene.xtl +0 -0
  111. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/SiAlONa.xtl +0 -0
  112. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Silicon.xtl +0 -0
  113. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/StrontiumTitanate.xtl +0 -0
  114. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/TelluriumDioxide.xtl +0 -0
  115. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/TinDioxide_RT.xtl +0 -0
  116. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/TitaniumDioxide_Anatase.xtl +0 -0
  117. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/TitaniumDioxide_Rutile.xtl +0 -0
  118. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/TungstenDiselenide.xtl +0 -0
  119. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/VanadiumDioxide_RT.xtl +0 -0
  120. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/ZincOxide.xtl +0 -0
  121. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/Zinc_HCP.xtl +0 -0
  122. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/ZirconiumNitride.xtl +0 -0
  123. {pyemaps-2.1.0 → pyemaps-2.2.0}/cdata/limno2.xtl +0 -0
  124. {pyemaps-2.1.0 → pyemaps-2.2.0}/crystals.py +0 -0
  125. {pyemaps-2.1.0 → pyemaps-2.2.0}/ddiffs.py +0 -0
  126. {pyemaps-2.1.0 → pyemaps-2.2.0}/diffract/__init__.py +0 -0
  127. {pyemaps-2.1.0 → pyemaps-2.2.0}/diffract/bloch_dec.py +0 -0
  128. {pyemaps-2.1.0 → pyemaps-2.2.0}/diffract/dpgen_dec.py +0 -0
  129. {pyemaps-2.1.0 → pyemaps-2.2.0}/diffract/mxtal_dec.py +0 -0
  130. {pyemaps-2.1.0 → pyemaps-2.2.0}/diffract/stereo_dec.py +0 -0
  131. {pyemaps-2.1.0 → pyemaps-2.2.0}/errors.py +0 -0
  132. {pyemaps-2.1.0 → pyemaps-2.2.0}/fileutils.py +0 -0
  133. {pyemaps-2.1.0 → pyemaps-2.2.0}/kdiffs.py +0 -0
  134. {pyemaps-2.1.0 → pyemaps-2.2.0}/pyemaps.egg-info/dependency_links.txt +0 -0
  135. {pyemaps-2.1.0 → pyemaps-2.2.0}/pyemaps.egg-info/entry_points.txt +0 -0
  136. {pyemaps-2.1.0 → pyemaps-2.2.0}/pyemaps.egg-info/top_level.txt +0 -0
  137. {pyemaps-2.1.0 → pyemaps-2.2.0}/pyproject.toml +0 -0
  138. {pyemaps-2.1.0 → pyemaps-2.2.0}/samples/al.img +0 -0
  139. {pyemaps-2.1.0 → pyemaps-2.2.0}/samples/mask.im3 +0 -0
  140. {pyemaps-2.1.0 → pyemaps-2.2.0}/samples/raw.img +0 -0
  141. {pyemaps-2.1.0 → pyemaps-2.2.0}/scattering/__init__.py +0 -0
  142. {pyemaps-2.1.0 → pyemaps-2.2.0}/scattering/sct_dec.py +0 -0
  143. {pyemaps-2.1.0 → pyemaps-2.2.0}/spg/__init__.py +0 -0
  144. {pyemaps-2.1.0 → pyemaps-2.2.0}/spg/spg_dec.py +0 -0
  145. {pyemaps-2.1.0 → pyemaps-2.2.0}/stackimg.py +0 -0
  146. {pyemaps-2.1.0 → pyemaps-2.2.0}/xtal.py +0 -0
@@ -1,5 +1,4 @@
1
1
  exclude */emaps/*.f90
2
- exclude */samples/deprecated/*.py
3
2
  prune __pycache__
4
3
  prune emaps/__pycache__
5
4
 
@@ -11,4 +10,5 @@ include COPYING
11
10
  include license.txt
12
11
 
13
12
  include cdata/*.xtl
14
- include samples/*.py
13
+ include samples/*.py
14
+ include notebooks/*.ipynb
pyemaps-2.2.0/PKG-INFO ADDED
@@ -0,0 +1,173 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyemaps
3
+ Version: 2.2.0
4
+ Summary: A Python Package for Transmission Electron Diffraction Simulations and Crystallographic Computing
5
+ Home-page: https://github.com/emlab-solutions/pyemaps
6
+ Author: EMLab Solutions, Inc.
7
+ Author-email: support@emlabsoftware.com
8
+ License: Free for base features. License activation required for extended 4dstem features
9
+ Project-URL: Documentation, https://emlab-solutions.github.io/pyemaps/
10
+ Project-URL: Source, https://github.com/emlab-solutions/pyemaps
11
+ Project-URL: Issues, https://github.com/emlab-solutions/pyemaps/issues
12
+ Project-URL: Changelog, https://emlab-solutions.github.io/pyemaps/rn.html
13
+ Keywords: Transmission,Electron,Diffraction,Simulation,Crystallography,Python
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
19
+ Classifier: Operating System :: Microsoft :: Windows
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Intended Audience :: Science/Research
22
+ Requires-Python: >=3.12
23
+ Description-Content-Type: text/markdown
24
+ License-File: license.txt
25
+ License-File: COPYING
26
+ Requires-Dist: emaps>=2.0.1
27
+ Requires-Dist: numpy>=2.0
28
+ Requires-Dist: matplotlib>=3.8.4
29
+ Dynamic: description
30
+ Dynamic: description-content-type
31
+ Dynamic: license-file
32
+ Dynamic: project-url
33
+ Dynamic: requires-dist
34
+ Dynamic: summary
35
+
36
+ # pyEMAPS
37
+
38
+ **pyEMAPS** is a Python package for transmission electron diffraction simulations and
39
+ crystallographic computing, for all crystal systems. Its simulations are based on the theories of
40
+ kinematical and dynamical electron diffraction described by J. C. H. Spence and J. M. Zuo in
41
+ *Electron Microdiffraction* (Plenum Press, New York, 1992).
42
+
43
+ [Documentation](https://emlab-solutions.github.io/pyemaps/) ·
44
+ [Get started](https://emlab-solutions.github.io/pyemaps/getting_started.html) ·
45
+ [Examples](https://emlab-solutions.github.io/pyemaps/examples.html) ·
46
+ [Release notes](https://emlab-solutions.github.io/pyemaps/rn.html) ·
47
+ [Issues](https://github.com/emlab-solutions/pyemaps/issues)
48
+
49
+ ## Features
50
+
51
+ The base features are free, under the GNU General Public License v3.0:
52
+
53
+ - **Crystallography**
54
+ - Crystal construction, from your own data or the built-in crystal library
55
+ - CIF import
56
+ - Crystallographic transformations
57
+ - Real and reciprocal space vector calculations
58
+ - Stereodiagrams
59
+ - Crystal structure factors
60
+ - **Kinematical electron diffraction**
61
+ - Selected area diffraction
62
+ - Kikuchi and higher order Laue zone (HOLZ) line geometry
63
+ - Convergent beam electron diffraction (CBED)
64
+ - Electron powder diffraction
65
+ - **Dynamical electron diffraction** (Bloch wave)
66
+ - Convergent beam electron diffraction, including large-angle CBED
67
+ - The electron scattering matrix
68
+ - Electron dispersion (the eigenvalues of the Bloch wave solution)
69
+
70
+ The extended 4D-STEM features need a license:
71
+
72
+ - Building and searching diffraction pattern databases
73
+ - Indexing experimental diffraction patterns
74
+ - Annular bright and dark field images
75
+ - Masked images
76
+
77
+ ## Requirements
78
+
79
+ - 64-bit Windows
80
+ - Python 3.12, 3.13, 3.14 or 3.15
81
+ - 8 GB of RAM or more is recommended
82
+
83
+ pip also installs NumPy (2.0 or later), matplotlib (3.8.4 or later) and **emaps**, the compiled
84
+ simulation backend for your Python version. On Python 3.7, pip installs pyEMAPS 1.1.x.
85
+
86
+ ## Installation
87
+
88
+ Install pyEMAPS in its own virtual environment, so its dependencies don't clash with your other
89
+ packages:
90
+
91
+ ```
92
+ python -m venv .venv
93
+ .venv\Scripts\activate
94
+ pip install pyemaps
95
+ ```
96
+
97
+ Check the installation:
98
+
99
+ ```
100
+ pyemaps --version
101
+ pyemaps --sample
102
+ ```
103
+
104
+ `--version` prints the pyEMAPS version, and `--sample` runs a short kinematical simulation and
105
+ shows the pattern. If the installation fails, see the
106
+ [FAQ](https://emlab-solutions.github.io/pyemaps/faq.html).
107
+
108
+ ## Quick start
109
+
110
+ Load Silicon from the built-in crystal library, generate its kinematical diffraction pattern with
111
+ the default settings, and show it:
112
+
113
+ ```python
114
+ from pyemaps import Crystal, DPList, showDif
115
+
116
+ if __name__ == '__main__':
117
+ si = Crystal.from_builtin('Silicon')
118
+ emc, si_dp = si.generateDP()
119
+
120
+ dpl = DPList('Silicon')
121
+ dpl.add(emc, si_dp)
122
+ showDif(dpl)
123
+ ```
124
+
125
+ Keep the `if __name__ == '__main__':` line in scripts. The `show` functions draw in a separate
126
+ process, which on Windows runs your script again. Jupyter notebooks don't need it.
127
+
128
+ `pyemaps -cp` copies the sample scripts into a `pyemaps_samples` folder and the Jupyter
129
+ notebooks into `pyemaps_notebooks`; `pyemaps -cp samples` or `pyemaps -cp notebooks` copies just
130
+ one set.
131
+
132
+ The [documentation](https://emlab-solutions.github.io/pyemaps/) has a user guide, an examples
133
+ gallery and the full API reference.
134
+
135
+ ## Licensing
136
+
137
+ The base features are free software under the
138
+ [GNU General Public License v3.0](https://emlab-solutions.github.io/pyemaps/license.html), for
139
+ personal and commercial use. The extended 4D-STEM features need a license:
140
+
141
+ - `pyemaps --license trial` activates a 7-day trial license. It needs an internet connection.
142
+ - `pyemaps --license <token>` activates a trial or production license with a license activation
143
+ token, online or offline. Write to support@emlabsoftware.com for a token.
144
+ - `pyemaps --license info` shows the current license.
145
+
146
+ After activation, all license checks are offline. See
147
+ [License Activation](https://emlab-solutions.github.io/pyemaps/user_guide/configuration.html#license-activation)
148
+ for details.
149
+
150
+ ## Support
151
+
152
+ Report bugs and request features on [GitHub](https://github.com/emlab-solutions/pyemaps/issues),
153
+ and send other questions to support@emlabsoftware.com.
154
+
155
+ If pyEMAPS helps your microscopy and crystallography research or teaching, please consider a
156
+ [donation](https://www.paypal.com/paypalme/pyemaps22). Donations keep us providing software
157
+ tools to the education and research communities.
158
+
159
+ ## Contributing
160
+
161
+ We're looking for experts in electron microscopy and crystallography, and Python enthusiasts, to
162
+ join the project. Contact us at support@emlabsoftware.com if you're interested.
163
+
164
+ - [DEVELOPMENT.md](https://github.com/emlab-solutions/pyemaps/blob/main/DEVELOPMENT.md)
165
+ explains how to build pyEMAPS, run its tests and build the documentation, and how we work.
166
+ - Please read and agree to our
167
+ [Contributor License Agreement](https://github.com/emlab-solutions/pyemaps/blob/main/CONTRIBUTING.md)
168
+ before contributing.
169
+ - We follow the
170
+ [Contributor Covenant](https://www.contributor-covenant.org/version/2/0/code_of_conduct/) as our
171
+ code of conduct. Report unacceptable behavior to support@emlabsoftware.com.
172
+
173
+ pyEMAPS is developed by EMLab Solutions, Inc.
@@ -0,0 +1,138 @@
1
+ # pyEMAPS
2
+
3
+ **pyEMAPS** is a Python package for transmission electron diffraction simulations and
4
+ crystallographic computing, for all crystal systems. Its simulations are based on the theories of
5
+ kinematical and dynamical electron diffraction described by J. C. H. Spence and J. M. Zuo in
6
+ *Electron Microdiffraction* (Plenum Press, New York, 1992).
7
+
8
+ [Documentation](https://emlab-solutions.github.io/pyemaps/) ·
9
+ [Get started](https://emlab-solutions.github.io/pyemaps/getting_started.html) ·
10
+ [Examples](https://emlab-solutions.github.io/pyemaps/examples.html) ·
11
+ [Release notes](https://emlab-solutions.github.io/pyemaps/rn.html) ·
12
+ [Issues](https://github.com/emlab-solutions/pyemaps/issues)
13
+
14
+ ## Features
15
+
16
+ The base features are free, under the GNU General Public License v3.0:
17
+
18
+ - **Crystallography**
19
+ - Crystal construction, from your own data or the built-in crystal library
20
+ - CIF import
21
+ - Crystallographic transformations
22
+ - Real and reciprocal space vector calculations
23
+ - Stereodiagrams
24
+ - Crystal structure factors
25
+ - **Kinematical electron diffraction**
26
+ - Selected area diffraction
27
+ - Kikuchi and higher order Laue zone (HOLZ) line geometry
28
+ - Convergent beam electron diffraction (CBED)
29
+ - Electron powder diffraction
30
+ - **Dynamical electron diffraction** (Bloch wave)
31
+ - Convergent beam electron diffraction, including large-angle CBED
32
+ - The electron scattering matrix
33
+ - Electron dispersion (the eigenvalues of the Bloch wave solution)
34
+
35
+ The extended 4D-STEM features need a license:
36
+
37
+ - Building and searching diffraction pattern databases
38
+ - Indexing experimental diffraction patterns
39
+ - Annular bright and dark field images
40
+ - Masked images
41
+
42
+ ## Requirements
43
+
44
+ - 64-bit Windows
45
+ - Python 3.12, 3.13, 3.14 or 3.15
46
+ - 8 GB of RAM or more is recommended
47
+
48
+ pip also installs NumPy (2.0 or later), matplotlib (3.8.4 or later) and **emaps**, the compiled
49
+ simulation backend for your Python version. On Python 3.7, pip installs pyEMAPS 1.1.x.
50
+
51
+ ## Installation
52
+
53
+ Install pyEMAPS in its own virtual environment, so its dependencies don't clash with your other
54
+ packages:
55
+
56
+ ```
57
+ python -m venv .venv
58
+ .venv\Scripts\activate
59
+ pip install pyemaps
60
+ ```
61
+
62
+ Check the installation:
63
+
64
+ ```
65
+ pyemaps --version
66
+ pyemaps --sample
67
+ ```
68
+
69
+ `--version` prints the pyEMAPS version, and `--sample` runs a short kinematical simulation and
70
+ shows the pattern. If the installation fails, see the
71
+ [FAQ](https://emlab-solutions.github.io/pyemaps/faq.html).
72
+
73
+ ## Quick start
74
+
75
+ Load Silicon from the built-in crystal library, generate its kinematical diffraction pattern with
76
+ the default settings, and show it:
77
+
78
+ ```python
79
+ from pyemaps import Crystal, DPList, showDif
80
+
81
+ if __name__ == '__main__':
82
+ si = Crystal.from_builtin('Silicon')
83
+ emc, si_dp = si.generateDP()
84
+
85
+ dpl = DPList('Silicon')
86
+ dpl.add(emc, si_dp)
87
+ showDif(dpl)
88
+ ```
89
+
90
+ Keep the `if __name__ == '__main__':` line in scripts. The `show` functions draw in a separate
91
+ process, which on Windows runs your script again. Jupyter notebooks don't need it.
92
+
93
+ `pyemaps -cp` copies the sample scripts into a `pyemaps_samples` folder and the Jupyter
94
+ notebooks into `pyemaps_notebooks`; `pyemaps -cp samples` or `pyemaps -cp notebooks` copies just
95
+ one set.
96
+
97
+ The [documentation](https://emlab-solutions.github.io/pyemaps/) has a user guide, an examples
98
+ gallery and the full API reference.
99
+
100
+ ## Licensing
101
+
102
+ The base features are free software under the
103
+ [GNU General Public License v3.0](https://emlab-solutions.github.io/pyemaps/license.html), for
104
+ personal and commercial use. The extended 4D-STEM features need a license:
105
+
106
+ - `pyemaps --license trial` activates a 7-day trial license. It needs an internet connection.
107
+ - `pyemaps --license <token>` activates a trial or production license with a license activation
108
+ token, online or offline. Write to support@emlabsoftware.com for a token.
109
+ - `pyemaps --license info` shows the current license.
110
+
111
+ After activation, all license checks are offline. See
112
+ [License Activation](https://emlab-solutions.github.io/pyemaps/user_guide/configuration.html#license-activation)
113
+ for details.
114
+
115
+ ## Support
116
+
117
+ Report bugs and request features on [GitHub](https://github.com/emlab-solutions/pyemaps/issues),
118
+ and send other questions to support@emlabsoftware.com.
119
+
120
+ If pyEMAPS helps your microscopy and crystallography research or teaching, please consider a
121
+ [donation](https://www.paypal.com/paypalme/pyemaps22). Donations keep us providing software
122
+ tools to the education and research communities.
123
+
124
+ ## Contributing
125
+
126
+ We're looking for experts in electron microscopy and crystallography, and Python enthusiasts, to
127
+ join the project. Contact us at support@emlabsoftware.com if you're interested.
128
+
129
+ - [DEVELOPMENT.md](https://github.com/emlab-solutions/pyemaps/blob/main/DEVELOPMENT.md)
130
+ explains how to build pyEMAPS, run its tests and build the documentation, and how we work.
131
+ - Please read and agree to our
132
+ [Contributor License Agreement](https://github.com/emlab-solutions/pyemaps/blob/main/CONTRIBUTING.md)
133
+ before contributing.
134
+ - We follow the
135
+ [Contributor Covenant](https://www.contributor-covenant.org/version/2/0/code_of_conduct/) as our
136
+ code of conduct. Report unacceptable behavior to support@emlabsoftware.com.
137
+
138
+ pyEMAPS is developed by EMLab Solutions, Inc.
@@ -26,46 +26,75 @@
26
26
  '''
27
27
 
28
28
  rel_stage = 'Stable'
29
- pyemaps_samples_dir = 'pyemaps_samples'
30
29
 
31
- def copy_samples():
30
+ # What pyemaps -cp copies: (description, folder in the package, folder it copies into).
31
+ COPY_SETS = {
32
+ 'samples': ('sample scripts', 'samples', 'pyemaps_samples'),
33
+ 'notebooks': ('notebooks', 'notebooks', 'pyemaps_notebooks'),
34
+ }
35
+
36
+ # The sample that pyemaps -s runs; it isn't copied.
37
+ COPY_SKIP = {'si_pyemaps.py'}
38
+
39
+
40
+ def copy_examples(what):
32
41
  '''
33
- Copies sample code from package directory to current diretory
34
- for easy access.
42
+ Copy the sample scripts, the notebooks, or both into folders in the current directory,
43
+ after asking to confirm. *what* is 'samples', 'notebooks' or 'all'. Files that already exist
44
+ there are left alone, so copying again doesn't overwrite your changes.
35
45
  '''
36
- import os, sys
46
+ import os
37
47
  import shutil
48
+ import sys
38
49
 
50
+ names = list(COPY_SETS) if what == 'all' else [what]
51
+ pkg_dir = os.path.dirname(os.path.abspath(__file__))
39
52
  curr_dir = os.getcwd()
40
-
41
- q = str(f"Copy pyemaps samples into {pyemaps_samples_dir} in current directory?\n ")
42
-
43
- inp = input(q +"[Y/n] ")
44
53
 
45
- if inp and not inp.lower().strip()[:1] == "y":
46
- print("No sample code is copied!")
54
+ plan = ' and '.join(f'the {COPY_SETS[n][0]} into {COPY_SETS[n][2]}' for n in names)
55
+ inp = input(f'Copy {plan}, in the current directory? [Y/n] ')
56
+ if inp and not inp.lower().strip()[:1] == 'y':
57
+ print('Nothing copied.')
47
58
  sys.exit(1)
48
59
 
49
- curr_samples_dir = os.path.join(curr_dir, pyemaps_samples_dir)
60
+ for n in names:
61
+ desc, pkg_sub, dest_sub = COPY_SETS[n]
62
+ source_dir = os.path.join(pkg_dir, pkg_sub)
63
+ if not os.path.isdir(source_dir):
64
+ print(f'This pyEMAPS installation has no {desc}.')
65
+ continue
50
66
 
51
- if not os.path.exists(curr_samples_dir):
52
- os.makedirs(curr_samples_dir)
53
-
54
- pyemaps_pkgdir = os.path.dirname(os.path.abspath(__file__))
55
- pkg_samples_dir = os.path.join(pyemaps_pkgdir, "samples")
67
+ dest_dir = os.path.join(curr_dir, dest_sub)
68
+ os.makedirs(dest_dir, exist_ok=True)
56
69
 
57
- for file_name in os.listdir(pkg_samples_dir):
58
-
59
- if file_name == 'si_pyemaps.py':
60
- continue
61
- source = os.path.join(pkg_samples_dir, file_name)
62
- destination = os.path.join(curr_samples_dir, file_name)
63
-
64
- if os.path.isfile(source):
70
+ copied, skipped = 0, []
71
+ for file_name in sorted(os.listdir(source_dir)):
72
+ source = os.path.join(source_dir, file_name)
73
+ if not os.path.isfile(source) or file_name in COPY_SKIP:
74
+ continue
75
+ destination = os.path.join(dest_dir, file_name)
76
+ if os.path.exists(destination):
77
+ skipped.append(file_name)
78
+ continue
65
79
  shutil.copy(source, destination)
66
- print(f'Copied sample code: {file_name} in pyemaps package to {destination}')
80
+ copied += 1
81
+ print(f'Copied {file_name} to {destination}')
82
+
83
+ print(f'Copied {copied} file{"" if copied == 1 else "s"} into {dest_dir}.')
84
+ if len(skipped) == 1:
85
+ print(f'Skipped {skipped[0]}, which already exists there. To get a fresh copy, '
86
+ 'rename or delete it and copy again.')
87
+ elif skipped:
88
+ print(f'Skipped {len(skipped)} files that already exist there: '
89
+ f'{", ".join(skipped)}. To get fresh copies, rename or delete them and copy '
90
+ 'again.')
91
+
92
+ if n == 'samples':
93
+ print(f'Run a sample with: python {os.path.join(dest_sub, "<sample>.py")}')
94
+ else:
95
+ print(f'Open the notebooks with Jupyter (pip install jupyter): '
96
+ f'jupyter notebook {dest_sub}')
67
97
 
68
- print(f'Run sample code by typing: \"python pyemaps_samples\\<sample>\"')
69
98
 
70
99
  def is_alphanumeric_with_dash(s, slen):
71
100
  """
@@ -85,7 +114,7 @@ def main():
85
114
  Usage:
86
115
  pyemaps -s (--sample)
87
116
  pyemaps -c (--copyright)
88
- pyemaps -cp (--copysamples)
117
+ pyemaps -cp (--copy) [samples|notebooks]
89
118
  pyemaps -v (--version)
90
119
  pyemaps -l (--license) <trial|info|license token>
91
120
 
@@ -94,7 +123,7 @@ def main():
94
123
  """
95
124
 
96
125
  try:
97
- from .samples.si_pyemaps import run_si_sample
126
+ from .samples.si_pyemaps import run_sample
98
127
 
99
128
  from emaps import PKG_TYPE, TYPE_FREE, TYPE_FULL, TYPE_UIUC
100
129
 
@@ -114,11 +143,16 @@ def main():
114
143
  action='store_true',
115
144
  help="display pyEMAPS copyrights.",
116
145
  required=False)
117
- parser.add_argument("-cp",
118
- "--copysamples",
119
- default=False,
120
- action='store_true',
121
- help="copy sample code into current working directory.",
146
+ parser.add_argument("-cp",
147
+ "--copy",
148
+ "--copysamples",
149
+ nargs='?',
150
+ const='all',
151
+ default=None,
152
+ metavar='samples|notebooks',
153
+ help="copy the sample scripts into pyemaps_samples, the Jupyter\n"
154
+ "notebooks into pyemaps_notebooks, or, with neither, both.\n"
155
+ "Files that already exist there aren't overwritten.",
122
156
  required=False)
123
157
 
124
158
  if PKG_TYPE != TYPE_FREE:
@@ -155,6 +189,9 @@ The token is obtained from EMLab Solutions, Inc. by writing to support@emlabsoft
155
189
  parser.print_help()
156
190
  exit(1)
157
191
 
192
+ if args.copy not in (None, 'all', *COPY_SETS):
193
+ parser.error(f"argument -cp/--copy: expected 'samples' or 'notebooks', not '{args.copy}'")
194
+
158
195
  ver = dist_version("pyemaps") + str(f" {rel_stage}").lower()
159
196
 
160
197
  copyrit = ['PyEMAPS - Transmission Electron Diffraction Simulations In Python']
@@ -181,12 +218,12 @@ The token is obtained from EMLab Solutions, Inc. by writing to support@emlabsoft
181
218
  copyrit.append('--------------------------------')
182
219
  print('\n'.join(copyrit))
183
220
 
184
- if args.copysamples:
185
- copy_samples()
221
+ if args.copy:
222
+ copy_examples(args.copy)
186
223
  exit(0)
187
224
 
188
225
  if args.sample:
189
- run_si_sample()
226
+ run_sample()
190
227
  exit(0)
191
228
 
192
229
  if args.license is not None and PKG_TYPE != TYPE_FREE:
@@ -0,0 +1 @@
1
+ __version__ = "2.2.0"
@@ -1,4 +1,4 @@
1
1
  crystal Germanium: dw = iso
2
2
  cell 5.6576 5.6576 5.6576 90.0000 90.0000 90.0000
3
3
  atom ge 0.125 0.125 0.125 0.60 1.000000
4
- spg 227 1
4
+ spg 227 2
@@ -53,10 +53,13 @@ def add_csf(target):
53
53
  5: 'backend reflection-count estimate was too low (internal error)',
54
54
  }
55
55
 
56
+ # printCSF titles, by structure factor type (sftype 1-4). The units match the backend's
57
+ # scaling: type 2 is the crystal potential coefficient V_g, in volts; types 3 and 4 are
58
+ # U_g = 2meV_g/h^2 (relativistic) and its absorption counterpart, both in 1/Angstrom^2.
56
59
  sf_type_lookup = ['X-ray Structure Factors',
57
- 'Electron Strcture Factors in kV',
58
- 'Electron Structure Factor in 1/lambda',
59
- 'Electron Absorption Structure Factor in 1/lambda^2']
60
+ 'Electron Structure Factors in Volts',
61
+ 'Electron Structure Factors in 1/Angstrom^2',
62
+ 'Electron Absorption Structure Factors in 1/Angstrom^2']
60
63
 
61
64
  sf_ap_flag = [('real', 'imaginary'), ('amplitude', 'phase')]
62
65
 
@@ -106,7 +109,7 @@ def add_csf(target):
106
109
  print(dss)
107
110
 
108
111
  if sftype > 1:
109
- print(f" high voltage\t: {sfs[0]['kv']} V\n")
112
+ print(f" high voltage\t: {sfs[0]['kv']} kV\n")
110
113
  else:
111
114
  print(f" ")
112
115
 
@@ -24,6 +24,21 @@
24
24
  .. Date Created: May 07, 2022
25
25
 
26
26
  '''
27
+ import weakref
28
+
29
+ # The simulation backend holds one crystal at a time for the whole process. This records which
30
+ # Crystal is in it, as a weak reference, so that loading another crystal can mark the previous
31
+ # one as unloaded: otherwise the previous one would skip its next load and simulate with the
32
+ # other crystal's data. A crystal's _loaded flag is therefore True only while its data is in
33
+ # the backend.
34
+ _in_backend = {'crystal': None}
35
+
36
+
37
+ def _crystal_in_backend():
38
+ ref = _in_backend['crystal']
39
+ return ref() if ref is not None else None
40
+
41
+
27
42
  def add_dif(target):
28
43
  import numpy as np
29
44
  from numpy import asfortranarray as farray
@@ -38,9 +53,10 @@ def add_dif(target):
38
53
  Load the crystal's data into the simulation backend.
39
54
 
40
55
  The data stays in the backend's memory until :py:meth:`~pyemaps.crystals.Crystal.unload` is called or another crystal
41
- is loaded. The backend holds one crystal at a time for the whole process, so running
42
- simulations for different crystals concurrently in one process gives wrong results; use
43
- separate processes instead.
56
+ is loaded. The backend holds one crystal at a time for the whole process: using one
57
+ crystal after another is fine, since each loads itself again when it's used next, but
58
+ running simulations for different crystals concurrently in one process gives wrong
59
+ results; use separate processes instead.
44
60
 
45
61
  :param cty: 0 for simulations, 1 for the crystal constructor (:py:meth:`~pyemaps.crystals.Crystal.generateMxtal`).
46
62
  :type cty: int, optional
@@ -70,20 +86,32 @@ def add_dif(target):
70
86
 
71
87
  diff_spg = self._spg.prepare()
72
88
 
89
+ # This crystal's data replaces whichever crystal is in the backend now.
90
+ previous = _crystal_in_backend()
91
+ if previous is not None and previous is not self:
92
+ previous._loaded = False
93
+ _in_backend['crystal'] = None
94
+
73
95
  ret = dif.loadcrystal(diff_cell, diff_atoms, atn, diff_spg, ndw=self._dw, cty=cty)
74
-
96
+
75
97
  if ret != 0:
76
- self.unload() #remove any memory from backend module
98
+ dif.crystaldelete() #remove any memory from backend module
99
+ self._loaded = False
77
100
  raise CrystalClassError('Failed to load crystal')
78
101
 
79
102
  self._loaded = True
80
103
  self._ltype = cty
104
+ _in_backend['crystal'] = weakref.ref(self)
81
105
 
82
106
  def unload(self):
83
107
  """
84
- Remove the crystal's data from the simulation backend's memory.
108
+ Remove the crystal's data from the simulation backend's memory. It does nothing if
109
+ another crystal has been loaded since, so the other crystal's data stays.
85
110
  """
86
- dif.crystaldelete()
111
+ if self.loaded():
112
+ dif.crystaldelete()
113
+ if _crystal_in_backend() is self:
114
+ _in_backend['crystal'] = None
87
115
  self._loaded = False
88
116
 
89
117
  def generateDP(self, mode = None, dsize = None, em_controls = None):
@@ -82,10 +82,11 @@ def add_powder(target):
82
82
  :type t2max: float, optional
83
83
  :param smax: largest sin(θ)/λ, in 1/Å.
84
84
  :type smax: float, optional
85
- :param eta: mixing coefficient between the Gaussian and Lorentzian parts of the pseudo-Voigt
86
- peak shape.
85
+ :param eta: mixing coefficient of the pseudo-Voigt peak shape, from 0 to 1:
86
+ ``eta * Lorentzian + (1 - eta) * Gaussian``. 1 is purely Lorentzian, 0 purely
87
+ Gaussian.
87
88
  :type eta: float, optional
88
- :param gamma: peak half width at half maximum.
89
+ :param gamma: peak full width at half maximum, in radians.
89
90
  :type gamma: float, optional
90
91
  :param absp: 1 to include absorption structure factors, 0 (the default) not to.
91
92
  :type absp: int, optional