pyemaps 2.8.0__tar.gz → 2.10.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 (143) hide show
  1. {pyemaps-2.8.0 → pyemaps-2.10.0}/MANIFEST.in +1 -0
  2. {pyemaps-2.8.0/pyemaps.egg-info → pyemaps-2.10.0}/PKG-INFO +28 -4
  3. {pyemaps-2.8.0 → pyemaps-2.10.0}/README.md +13 -1
  4. {pyemaps-2.8.0 → pyemaps-2.10.0}/__init__.py +2 -1
  5. pyemaps-2.10.0/__version__.py +1 -0
  6. {pyemaps-2.8.0 → pyemaps-2.10.0}/crystals.py +22 -0
  7. pyemaps-2.10.0/diffract/_resources.py +110 -0
  8. {pyemaps-2.8.0 → pyemaps-2.10.0}/diffract/bloch_dec.py +81 -9
  9. {pyemaps-2.8.0 → pyemaps-2.10.0}/diffract/dpgen_dec.py +9 -1
  10. {pyemaps-2.8.0 → pyemaps-2.10.0}/diffract/mxtal_dec.py +1 -1
  11. {pyemaps-2.8.0 → pyemaps-2.10.0}/emcontrols.py +0 -2
  12. {pyemaps-2.8.0 → pyemaps-2.10.0}/errors.py +14 -0
  13. {pyemaps-2.8.0 → pyemaps-2.10.0}/fileutils.py +90 -59
  14. pyemaps-2.10.0/notebooks/adf.ipynb +1500 -0
  15. pyemaps-2.10.0/notebooks/al_cu_phasemap.ipynb +725 -0
  16. {pyemaps-2.8.0 → pyemaps-2.10.0}/notebooks/al_ediom.ipynb +40 -40
  17. pyemaps-2.10.0/notebooks/al_orientmap.ipynb +1007 -0
  18. {pyemaps-2.8.0 → pyemaps-2.10.0}/notebooks/powder.ipynb +33 -33
  19. {pyemaps-2.8.0 → pyemaps-2.10.0}/notebooks/probe.ipynb +115 -99
  20. {pyemaps-2.8.0 → pyemaps-2.10.0}/notebooks/si_bloch.ipynb +54 -54
  21. {pyemaps-2.8.0 → pyemaps-2.10.0}/notebooks/si_constructor.ipynb +34 -34
  22. {pyemaps-2.8.0 → pyemaps-2.10.0}/notebooks/si_csf.ipynb +49 -49
  23. {pyemaps-2.8.0 → pyemaps-2.10.0}/notebooks/si_dif.ipynb +66 -66
  24. {pyemaps-2.8.0 → pyemaps-2.10.0}/notebooks/si_lacbed.ipynb +53 -47
  25. pyemaps-2.10.0/notebooks/si_multislice.ipynb +648 -0
  26. {pyemaps-2.8.0 → pyemaps-2.10.0}/notebooks/si_scm.ipynb +53 -53
  27. {pyemaps-2.8.0 → pyemaps-2.10.0}/notebooks/si_stereo.ipynb +34 -34
  28. pyemaps-2.10.0/phasemap.py +223 -0
  29. {pyemaps-2.8.0 → pyemaps-2.10.0}/probe.py +424 -55
  30. {pyemaps-2.8.0 → pyemaps-2.10.0/pyemaps.egg-info}/PKG-INFO +28 -4
  31. {pyemaps-2.8.0 → pyemaps-2.10.0}/pyemaps.egg-info/SOURCES.txt +11 -0
  32. {pyemaps-2.8.0 → pyemaps-2.10.0}/pyemaps.egg-info/requires.txt +1 -1
  33. pyemaps-2.10.0/samples/Al_COD_4004108.cif +262 -0
  34. pyemaps-2.10.0/samples/Cu_COD_7101269.cif +267 -0
  35. pyemaps-2.10.0/samples/Si_COD_2102763.cif +317 -0
  36. pyemaps-2.10.0/samples/al_cu_phasemap.py +180 -0
  37. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/al_orientmap.py +12 -5
  38. pyemaps-2.10.0/samples/crystal_thickness.py +88 -0
  39. {pyemaps-2.8.0 → pyemaps-2.10.0}/setup.py +6 -2
  40. {pyemaps-2.8.0 → pyemaps-2.10.0}/stackimg.py +503 -9
  41. {pyemaps-2.8.0 → pyemaps-2.10.0}/xtal.py +2 -2
  42. pyemaps-2.8.0/__version__.py +0 -1
  43. pyemaps-2.8.0/notebooks/adf.ipynb +0 -753
  44. pyemaps-2.8.0/notebooks/al_orientmap.ipynb +0 -916
  45. {pyemaps-2.8.0 → pyemaps-2.10.0}/COPYING +0 -0
  46. {pyemaps-2.8.0 → pyemaps-2.10.0}/__config__.py +0 -0
  47. {pyemaps-2.8.0 → pyemaps-2.10.0}/__main__.py +0 -0
  48. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Aluminium.xtl +0 -0
  49. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/AluminiumOxide.xtl +0 -0
  50. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Aluminium_FCC.xtl +0 -0
  51. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/BariumTitanate_180k.xtl +0 -0
  52. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/BariumTitanate_270k.xtl +0 -0
  53. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/BariumTitanate_Tetra.xtl +0 -0
  54. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/BiMnO3.xtl +0 -0
  55. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Boron_Tetra.xtl +0 -0
  56. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/CadmiumSelenide_Hex.xtl +0 -0
  57. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/CadmiumSulfide_Cubic.xtl +0 -0
  58. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/CadmiumSulfide_Hex.xtl +0 -0
  59. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Chromium_BCC.xtl +0 -0
  60. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/CoSb3_Skutterudite.xtl +0 -0
  61. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/CopperOxide.xtl +0 -0
  62. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Copper_FCC.xtl +0 -0
  63. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Cu2O_Cuprite.xtl +0 -0
  64. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Diamond.xtl +0 -0
  65. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/ErbiumPyrogermanate.xtl +0 -0
  66. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/FePd_Tetra.xtl +0 -0
  67. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/FeS2_Pyrite.xtl +0 -0
  68. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/GalliumAntimonide.xtl +0 -0
  69. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/GalliumArsenide.xtl +0 -0
  70. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/GalliumNitride.xtl +0 -0
  71. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Germanium.xtl +0 -0
  72. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Gold_FCC.xtl +0 -0
  73. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/IndiumArsenide.xtl +0 -0
  74. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/LaMnO3.xtl +0 -0
  75. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/LeadZirconateTitanate.xtl +0 -0
  76. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Li2MnO3.xtl +0 -0
  77. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/NaFeO2.xtl +0 -0
  78. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Nb3Sn.xtl +0 -0
  79. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Pentacene.xtl +0 -0
  80. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/SiAlONa.xtl +0 -0
  81. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Silicon.xtl +0 -0
  82. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/StrontiumTitanate.xtl +0 -0
  83. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/TelluriumDioxide.xtl +0 -0
  84. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/TinDioxide_RT.xtl +0 -0
  85. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/TitaniumDioxide_Anatase.xtl +0 -0
  86. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/TitaniumDioxide_Rutile.xtl +0 -0
  87. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/TungstenDiselenide.xtl +0 -0
  88. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/VanadiumDioxide_RT.xtl +0 -0
  89. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/ZincOxide.xtl +0 -0
  90. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/Zinc_HCP.xtl +0 -0
  91. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/ZirconiumNitride.xtl +0 -0
  92. {pyemaps-2.8.0 → pyemaps-2.10.0}/cdata/limno2.xtl +0 -0
  93. {pyemaps-2.8.0 → pyemaps-2.10.0}/cifreader.py +0 -0
  94. {pyemaps-2.8.0 → pyemaps-2.10.0}/ddiffs.py +0 -0
  95. {pyemaps-2.8.0 → pyemaps-2.10.0}/diffract/__init__.py +0 -0
  96. {pyemaps-2.8.0 → pyemaps-2.10.0}/diffract/csf_dec.py +0 -0
  97. {pyemaps-2.8.0 → pyemaps-2.10.0}/diffract/dif_dec.py +0 -0
  98. {pyemaps-2.8.0 → pyemaps-2.10.0}/diffract/powder_dec.py +0 -0
  99. {pyemaps-2.8.0 → pyemaps-2.10.0}/diffract/stereo_dec.py +0 -0
  100. {pyemaps-2.8.0 → pyemaps-2.10.0}/display.py +0 -0
  101. {pyemaps-2.8.0 → pyemaps-2.10.0}/dmreader.py +0 -0
  102. {pyemaps-2.8.0 → pyemaps-2.10.0}/emdreader.py +0 -0
  103. {pyemaps-2.8.0 → pyemaps-2.10.0}/expimage.py +0 -0
  104. {pyemaps-2.8.0 → pyemaps-2.10.0}/kdiffs.py +0 -0
  105. {pyemaps-2.8.0 → pyemaps-2.10.0}/license-exception.txt +0 -0
  106. {pyemaps-2.8.0 → pyemaps-2.10.0}/license.txt +0 -0
  107. {pyemaps-2.8.0 → pyemaps-2.10.0}/mibreader.py +0 -0
  108. {pyemaps-2.8.0 → pyemaps-2.10.0}/mrcreader.py +0 -0
  109. {pyemaps-2.8.0 → pyemaps-2.10.0}/orientmap.py +0 -0
  110. {pyemaps-2.8.0 → pyemaps-2.10.0}/picreader.py +0 -0
  111. {pyemaps-2.8.0 → pyemaps-2.10.0}/pyemaps.egg-info/dependency_links.txt +0 -0
  112. {pyemaps-2.8.0 → pyemaps-2.10.0}/pyemaps.egg-info/entry_points.txt +0 -0
  113. {pyemaps-2.8.0 → pyemaps-2.10.0}/pyemaps.egg-info/top_level.txt +0 -0
  114. {pyemaps-2.8.0 → pyemaps-2.10.0}/pyproject.toml +0 -0
  115. {pyemaps-2.8.0 → pyemaps-2.10.0}/readerbase.py +0 -0
  116. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/adf.py +0 -0
  117. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/al.img +0 -0
  118. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/al_dpgen.py +0 -0
  119. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/al_ediom.py +0 -0
  120. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/convert_image.py +0 -0
  121. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/crystal_imaging.py +0 -0
  122. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/ctf.py +0 -0
  123. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/dm_diff.py +0 -0
  124. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/hrem.py +0 -0
  125. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/mask.im3 +0 -0
  126. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/powder.py +0 -0
  127. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/raw.img +0 -0
  128. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/ronchigram.py +0 -0
  129. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/si_bloch.py +0 -0
  130. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/si_constructor.py +0 -0
  131. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/si_csf.py +0 -0
  132. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/si_dif.py +0 -0
  133. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/si_lacbed.py +0 -0
  134. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/si_pyemaps.py +0 -0
  135. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/si_scm.py +0 -0
  136. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/si_stereo.py +0 -0
  137. {pyemaps-2.8.0 → pyemaps-2.10.0}/samples/stem_probe.py +0 -0
  138. {pyemaps-2.8.0 → pyemaps-2.10.0}/scattering/__init__.py +0 -0
  139. {pyemaps-2.8.0 → pyemaps-2.10.0}/scattering/sct_dec.py +0 -0
  140. {pyemaps-2.8.0 → pyemaps-2.10.0}/setup.cfg +0 -0
  141. {pyemaps-2.8.0 → pyemaps-2.10.0}/spg/__init__.py +0 -0
  142. {pyemaps-2.8.0 → pyemaps-2.10.0}/spg/spg_dec.py +0 -0
  143. {pyemaps-2.8.0 → pyemaps-2.10.0}/tiffreader.py +0 -0
@@ -12,4 +12,5 @@ include license-exception.txt
12
12
 
13
13
  include cdata/*.xtl
14
14
  include samples/*.py
15
+ include samples/*.cif
15
16
  include notebooks/*.ipynb
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyemaps
3
- Version: 2.8.0
3
+ Version: 2.10.0
4
4
  Summary: A Python Package for Transmission Electron Diffraction Simulations and Crystallographic Computing
5
5
  Home-page: https://github.com/emlab-solutions/pyemaps
6
6
  Author: EMLab Solutions, Inc.
@@ -24,7 +24,7 @@ Description-Content-Type: text/markdown
24
24
  License-File: license-exception.txt
25
25
  License-File: license.txt
26
26
  License-File: COPYING
27
- Requires-Dist: emaps>=2.5.0
27
+ Requires-Dist: emaps>=2.7.0
28
28
  Requires-Dist: numpy>=2.0
29
29
  Requires-Dist: matplotlib>=3.8.4
30
30
  Provides-Extra: emd
@@ -37,6 +37,8 @@ Dynamic: provides-extra
37
37
  Dynamic: requires-dist
38
38
  Dynamic: summary
39
39
 
40
+ <p align="center"><img src="https://emlab-solutions.github.io/pyemaps/_static/pyemaps-logo.svg" alt="pyEMAPS icon: an electron diffraction pattern" width="96"></p>
41
+
42
+
43
+
40
44
  # pyEMAPS
41
45
 
42
46
 
43
47
 
44
48
  **pyEMAPS** is a Python package for transmission electron diffraction simulations and
45
49
 
@@ -50,6 +52,13 @@ kinematical and dynamical electron diffraction described by J. C. H. Spence and
50
52
  [Release notes](https://emlab-solutions.github.io/pyemaps/rn.html) ·
51
53
 
52
54
  [Issues](https://github.com/emlab-solutions/pyemaps/issues)
53
55
 
54
56
 
55
57
 
58
+ <p align="center">
59
+
60
+ <a href="https://emlab-solutions.github.io/pyemaps/user_guide/kinematic.html"><img src="https://emlab-solutions.github.io/pyemaps/_static/images/cards/kinematic.png" alt="Kinematic diffraction pattern of silicon" width="180"></a>
61
+
62
+ <a href="https://emlab-solutions.github.io/pyemaps/user_guide/dynamic.html"><img src="https://emlab-solutions.github.io/pyemaps/_static/images/cards/bloch.png" alt="Bloch-wave CBED pattern of silicon" width="180"></a>
63
+
64
+ <a href="https://emlab-solutions.github.io/pyemaps/user_guide/probe/ctf.html"><img src="https://emlab-solutions.github.io/pyemaps/_static/images/cards/ctf.png" alt="Contrast transfer function of an objective lens" width="180"></a>
65
+
66
+ <a href="https://emlab-solutions.github.io/pyemaps/user_guide/stem4d/phase.html"><img src="https://emlab-solutions.github.io/pyemaps/_static/images/cards/phasemap.png" alt="Phase map of aluminium and copper grains" width="180"></a>
67
+
68
+ </p>
69
+
70
+
71
+
56
72
  ## Features
57
73
 
58
74
 
59
75
 
60
76
  The base features are free, under the GNU General Public License v3.0:
61
77
 
@@ -178,10 +187,13 @@ tools to the education and research communities.
178
187
  We're looking for experts in electron microscopy and crystallography, and Python enthusiasts, to
179
188
 
180
189
  join the project. Contact us at support@emlabsoftware.com if you're interested.
181
190
 
182
191
 
183
192
 
193
+ - [CONTRIBUTING.md](https://github.com/emlab-solutions/pyemaps/blob/main/CONTRIBUTING.md)
194
+
195
+ explains how to report a bug, suggest an idea and contribute changes. For licenses and everything
196
+
197
+ else, see [Contact](https://emlab-solutions.github.io/pyemaps/contact.html).
198
+
184
199
  - [DEVELOPMENT.md](https://github.com/emlab-solutions/pyemaps/blob/main/DEVELOPMENT.md)
185
200
 
186
201
  explains how to build pyEMAPS, run its tests and build the documentation, and how we work.
187
202
 
188
203
  - Please read and agree to our
189
204
 
190
- [Contributor License Agreement](https://github.com/emlab-solutions/pyemaps/blob/main/CONTRIBUTING.md)
191
-
205
+ [Contributor License Agreement](https://github.com/emlab-solutions/pyemaps/blob/main/CLA.md)
206
+
192
207
  before contributing.
193
208
 
194
209
  - We follow the
195
210
 
196
211
  [Contributor Covenant](https://www.contributor-covenant.org/version/2/0/code_of_conduct/) as our
197
212
 
@@ -1,3 +1,5 @@
1
+ <p align="center"><img src="https://emlab-solutions.github.io/pyemaps/_static/pyemaps-logo.svg" alt="pyEMAPS icon: an electron diffraction pattern" width="96"></p>
2
+
1
3
  # pyEMAPS
2
4
 
3
5
  **pyEMAPS** is a Python package for transmission electron diffraction simulations and
@@ -11,6 +13,13 @@ kinematical and dynamical electron diffraction described by J. C. H. Spence and
11
13
  [Release notes](https://emlab-solutions.github.io/pyemaps/rn.html) ·
12
14
  [Issues](https://github.com/emlab-solutions/pyemaps/issues)
13
15
 
16
+ <p align="center">
17
+ <a href="https://emlab-solutions.github.io/pyemaps/user_guide/kinematic.html"><img src="https://emlab-solutions.github.io/pyemaps/_static/images/cards/kinematic.png" alt="Kinematic diffraction pattern of silicon" width="180"></a>
18
+ <a href="https://emlab-solutions.github.io/pyemaps/user_guide/dynamic.html"><img src="https://emlab-solutions.github.io/pyemaps/_static/images/cards/bloch.png" alt="Bloch-wave CBED pattern of silicon" width="180"></a>
19
+ <a href="https://emlab-solutions.github.io/pyemaps/user_guide/probe/ctf.html"><img src="https://emlab-solutions.github.io/pyemaps/_static/images/cards/ctf.png" alt="Contrast transfer function of an objective lens" width="180"></a>
20
+ <a href="https://emlab-solutions.github.io/pyemaps/user_guide/stem4d/phase.html"><img src="https://emlab-solutions.github.io/pyemaps/_static/images/cards/phasemap.png" alt="Phase map of aluminium and copper grains" width="180"></a>
21
+ </p>
22
+
14
23
  ## Features
15
24
 
16
25
  The base features are free, under the GNU General Public License v3.0:
@@ -139,10 +148,13 @@ tools to the education and research communities.
139
148
  We're looking for experts in electron microscopy and crystallography, and Python enthusiasts, to
140
149
  join the project. Contact us at support@emlabsoftware.com if you're interested.
141
150
 
151
+ - [CONTRIBUTING.md](https://github.com/emlab-solutions/pyemaps/blob/main/CONTRIBUTING.md)
152
+ explains how to report a bug, suggest an idea and contribute changes. For licenses and everything
153
+ else, see [Contact](https://emlab-solutions.github.io/pyemaps/contact.html).
142
154
  - [DEVELOPMENT.md](https://github.com/emlab-solutions/pyemaps/blob/main/DEVELOPMENT.md)
143
155
  explains how to build pyEMAPS, run its tests and build the documentation, and how we work.
144
156
  - Please read and agree to our
145
- [Contributor License Agreement](https://github.com/emlab-solutions/pyemaps/blob/main/CONTRIBUTING.md)
157
+ [Contributor License Agreement](https://github.com/emlab-solutions/pyemaps/blob/main/CLA.md)
146
158
  before contributing.
147
159
  - We follow the
148
160
  [Contributor Covenant](https://www.contributor-covenant.org/version/2/0/code_of_conduct/) as our
@@ -172,6 +172,7 @@ from .expimage import read_image, write_im3, image_readers, image_datasets, Expe
172
172
 
173
173
  #--------------Orientation maps (made by StackImage.mapOrientation; loading needs no license)----
174
174
  from .orientmap import OrientationMap, OM_INDEXED, OM_FEW_PEAKS, OM_FAILED, OM_NOT_RUN
175
+ from .phasemap import PhaseMap, PM_NONE
175
176
 
176
177
  #--------------Electron probes, Ronchigrams and CTF (emaps' probe module; free)----------------
177
178
  from .probe import Probe
@@ -224,6 +225,6 @@ if PKG_TYPE != TYPE_FREE:
224
225
  # python not allowing numeric starting letter for variables such as 4dstem
225
226
  from emaps.stem4d import send, ediom
226
227
  try:
227
- from .stackimg import StackImage
228
+ from .stackimg import StackImage, polar_transform
228
229
  except ImportError as e:
229
230
  print(f'Error importing image module: {e}. The 4D STEM module not available')
@@ -0,0 +1 @@
1
+ __version__ = "2.10.0"
@@ -1181,6 +1181,28 @@ class Crystal:
1181
1181
  :rtype: Crystal
1182
1182
  :raise ~pyemaps.errors.CrystalClassError: if the file isn't found, or its cell, atoms or space group don't
1183
1183
  validate.
1184
+
1185
+ pyEMAPS reads the unit cell, the space group (from the symmetry operators, the
1186
+ Hermann-Mauguin symbol or the number) and the atom sites with their occupancies and
1187
+ thermal factors. The crystal is named after the file's data block.
1188
+
1189
+ Example files: the samples include three CIF files of refined crystal structures from the
1190
+ `Crystallography Open Database <https://www.crystallography.net>`_ (COD), as COD
1191
+ distributes them:
1192
+ `Al_COD_4004108.cif <https://github.com/emlab-solutions/pyemaps/blob/main/samples/Al_COD_4004108.cif>`_
1193
+ (aluminium),
1194
+ `Cu_COD_7101269.cif <https://github.com/emlab-solutions/pyemaps/blob/main/samples/Cu_COD_7101269.cif>`_
1195
+ (copper) and
1196
+ `Si_COD_2102763.cif <https://github.com/emlab-solutions/pyemaps/blob/main/samples/Si_COD_2102763.cif>`_
1197
+ (silicon). ``pyemaps -cp samples`` copies them, with the sample scripts, into a
1198
+ *pyemaps_samples* folder in the current directory:
1199
+
1200
+ .. code-block:: python
1201
+
1202
+ from pyemaps import Crystal
1203
+
1204
+ al = Crystal.from_cif('Al_COD_4004108.cif') # run in pyemaps_samples
1205
+ print(al.name) # 4004108, the file's data block
1184
1206
  """
1185
1207
 
1186
1208
  cfn = fn
@@ -0,0 +1,110 @@
1
+ # This file is part of pyEMAPS.
2
+ # Copyright (C) 2021-2026 EMLab Solutions, Inc.
3
+ #
4
+ # SPDX-License-Identifier: GPL-3.0-or-later
5
+ #
6
+ # Additional permission under GPLv3 Section 7:
7
+ # See license-exception.txt for the exception permitting
8
+ # combination with the separately licensed backend, emaps.
9
+
10
+ '''
11
+ Memory and time estimates for dynamic diffraction (Bloch) sessions, so that a run too large
12
+ for the computer stops with a clear message before it allocates the memory, and a long run
13
+ says how long it will take before it starts.
14
+
15
+ The memory figures follow the backend's allocations:
16
+
17
+ * the beam matrix, one complex value (8 bytes) for each pair of beams: 8 x nbeams**2 bytes;
18
+ * at each sampling point, the strong-beam eigenproblem of N beams (the beams diagonalized):
19
+ about 48 x N**2 bytes for each thread working on one;
20
+ * the images, 4 bytes per pixel.
21
+ '''
22
+
23
+ import os
24
+ import sys
25
+
26
+ BEAM_MATRIX_BYTES = 8 # bytes per beam pair (COMPLEX)
27
+ EIGEN_BYTES = 48 # bytes per N**2, for each thread solving a sampling point
28
+ PIXEL_BYTES = 4 # float32 images
29
+
30
+ # Memory use above this fraction of the free memory gets a warning
31
+ MEMORY_WARN_FRACTION = 0.5
32
+
33
+ # The images' run time is estimated from one sampling point solved on its own, which the
34
+ # backend does with all threads: on a 6-core PC the sampling points then took 0.35 to 0.5
35
+ # times as long each, run side by side, for 500 to 1300 beams diagonalized.
36
+ PILOT_FACTOR = 0.5
37
+
38
+ # Runs estimated to take longer than this get a warning
39
+ LONG_RUN_SECONDS = 60
40
+
41
+ # The timing point is solved only when this many beams or more are diagonalized: below it, runs on
42
+ # a 6-core PC took under 10 seconds at the default sampling, and the point would cost up to 3%.
43
+ PILOT_MIN_NDIAG = 400
44
+
45
+
46
+ def available_memory():
47
+ '''Free physical memory in bytes, or None if it can't be found.'''
48
+ if sys.platform == 'win32':
49
+ import ctypes
50
+
51
+ class _MemoryStatusEx(ctypes.Structure):
52
+ _fields_ = [('dwLength', ctypes.c_ulong), ('dwMemoryLoad', ctypes.c_ulong),
53
+ ('ullTotalPhys', ctypes.c_ulonglong), ('ullAvailPhys', ctypes.c_ulonglong),
54
+ ('ullTotalPageFile', ctypes.c_ulonglong),
55
+ ('ullAvailPageFile', ctypes.c_ulonglong),
56
+ ('ullTotalVirtual', ctypes.c_ulonglong),
57
+ ('ullAvailVirtual', ctypes.c_ulonglong),
58
+ ('ullAvailExtendedVirtual', ctypes.c_ulonglong)]
59
+
60
+ status = _MemoryStatusEx()
61
+ status.dwLength = ctypes.sizeof(_MemoryStatusEx)
62
+ try:
63
+ if ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(status)):
64
+ return int(status.ullAvailPhys)
65
+ except (AttributeError, OSError):
66
+ return None
67
+ return None
68
+ try:
69
+ return os.sysconf('SC_AVPHYS_PAGES') * os.sysconf('SC_PAGE_SIZE')
70
+ except (AttributeError, ValueError, OSError):
71
+ return None
72
+
73
+
74
+ def openmp_threads():
75
+ '''The number of threads the backend's OpenMP loops use.'''
76
+ try:
77
+ n = int(os.environ.get('OMP_NUM_THREADS', '').split(',')[0])
78
+ if n > 0:
79
+ return n
80
+ except ValueError:
81
+ pass
82
+ return os.cpu_count() or 1
83
+
84
+
85
+ def beam_matrix_bytes(nbeams):
86
+ return BEAM_MATRIX_BYTES * nbeams * nbeams
87
+
88
+
89
+ def images_bytes(ndiag, threads, det_size, nslices):
90
+ '''Memory the images need: the eigenproblems solved at once, and the images themselves.'''
91
+ return EIGEN_BYTES * ndiag * ndiag * threads + PIXEL_BYTES * det_size * det_size * nslices
92
+
93
+
94
+ def gb(nbytes):
95
+ '''A memory size: "8.6 GB", "250 MB" below 1 GB, "4 KB" below 1 MB.'''
96
+ if nbytes < 1024**2:
97
+ return f'{max(1, round(nbytes / 1024))} KB'
98
+ if nbytes < 1024**3:
99
+ return f'{max(1, round(nbytes / 1024**2))} MB'
100
+ return f'{nbytes / 1024**3:.1f} GB'
101
+
102
+
103
+ def duration(seconds):
104
+ '''A rough duration: "about 3 minutes", "about 1.5 hours".'''
105
+ if seconds < 90:
106
+ n = max(1, round(seconds))
107
+ return f'about {n} second{"" if n == 1 else "s"}'
108
+ if seconds < 5400:
109
+ return f'about {round(seconds / 60)} minutes'
110
+ return f'about {seconds / 3600:.1f} hours'
@@ -66,6 +66,9 @@ def add_bloch(target):
66
66
  import numpy as np
67
67
  from numpy import asfortranarray as farray
68
68
  from .. import TY_NORMAL, TY_LACBED
69
+ import time
70
+ import warnings
71
+ from . import _resources as _res
69
72
 
70
73
  BIMG_EXT = '.im3'
71
74
  MAX_BIMGFN = 256
@@ -128,8 +131,10 @@ def add_bloch(target):
128
131
  :return: ``(n, points)``: the number of sampling points, and the points as a list of
129
132
  ``(i, j)`` tuples.
130
133
  :rtype: tuple
131
- :raise ~pyemaps.errors.BlochError: if an input is invalid, the backend's resource limit is reached, or the
132
- simulation fails.
134
+ :raise ~pyemaps.errors.BlochError: if an input is invalid, the backend's resource limit is reached, the
135
+ beam matrix (8 bytes for each pair of beams) needs more memory than is free, or the
136
+ simulation fails. The memory is checked before the session allocates it, and a
137
+ Python warning says if it needs more than half of what's free.
133
138
  """
134
139
  if aperture is None or not isinstance(aperture, (int, float)):
135
140
  raise BlochError('Objective aperture must be valid numberal')
@@ -176,17 +181,38 @@ def add_bloch(target):
176
181
  if ret == 0:
177
182
  dif.diff_internaldelete(1)
178
183
  raise BlochError('Error bloch runtime1')
179
-
184
+
185
+ # The session allocates the beam matrix first, 8 bytes per pair of beams: stop here,
186
+ # before it does, if it can't fit in the free memory.
187
+ nbeams = dif.get_nbeams()
188
+ need, free = _res.beam_matrix_bytes(nbeams), _res.available_memory()
189
+ if free is not None and need > free:
190
+ dif.diff_internaldelete(1)
191
+ raise BlochError(f'This crystal and zone have {nbeams:,} beams, which need '
192
+ f'{_res.gb(need)} of memory for the Bloch run, and this computer has '
193
+ f'{_res.gb(free)} free. Lower gmax or the excitation error limits '
194
+ f'in em_controls, or choose another zone, and retry')
195
+ if free is not None and need > _res.MEMORY_WARN_FRACTION * free:
196
+ warnings.warn(f'This crystal and zone have {nbeams:,} beams, which need '
197
+ f'{_res.gb(need)} of memory for the Bloch run, more than half of the '
198
+ f'{_res.gb(free)} free; the computer may slow down. Lowering gmax or '
199
+ f'the excitation error limits in em_controls uses less.', stacklevel=2)
200
+
180
201
  dif.diff_internaldelete(1)
181
-
202
+
182
203
  ret = bloch.dobloch(aperture,omega,sampling,0.0)
183
-
204
+
184
205
  if ret == 2:
185
206
  raise BlochError('Predefined Bloch computation resource limit reached')
186
207
 
208
+ if ret == -200:
209
+ raise BlochError(f'Too many beams to diagonalize ({int(bloch.ndiag_max):,}) for this '
210
+ f'crystal and zone: lower omega, or gmax or the excitation error '
211
+ f'limits in em_controls, and retry')
212
+
187
213
  if ret != 0:
188
214
  raise BlochError('Error computing dynamic diffraction')
189
-
215
+
190
216
  nsampling = bloch.get_nsampling()
191
217
  sampling_points = farray(np.zeros((2, nsampling)), dtype=int)
192
218
  sampling_points, ret = bloch.get_samplingpoints(sampling_points)
@@ -220,7 +246,39 @@ def add_bloch(target):
220
246
  self.session_controls=em_controls
221
247
  return nsampling, sp
222
248
 
223
- def getBlochImages(self,
249
+ def _checkBlochImages(self, det_size, nslices):
250
+ """
251
+ Before the session's images are made: raise BlochError if they need more memory than is
252
+ free, and warn if they will take long. The time is measured on this computer, by solving
253
+ one sampling point on its own (about 1% of the work) and scaling to all of them; only
254
+ when at least PILOT_MIN_NDIAG (400) beams are diagonalized, since smaller runs are short.
255
+ """
256
+ ndiag, ntilt = int(bloch.ndiag_max), int(bloch.ntilt)
257
+ threads = min(_res.openmp_threads(), max(ntilt, 1))
258
+ need, free = _res.images_bytes(ndiag, threads, det_size, nslices), _res.available_memory()
259
+ if free is not None and need > free:
260
+ images = f'{nslices:,} image' + ('' if nslices == 1 else 's')
261
+ raise BlochError(f'The images need {_res.gb(need)} of memory ({ndiag:,} beams '
262
+ f'diagonalized on {threads} threads, and {images} of '
263
+ f'{det_size} x {det_size}), and this computer has {_res.gb(free)} '
264
+ f'free. Lower omega, gmax or the excitation error limits, or make '
265
+ f'fewer or smaller images, and retry')
266
+ if free is not None and need > _res.MEMORY_WARN_FRACTION * free:
267
+ warnings.warn(f'The images need {_res.gb(need)} of memory, more than half of the '
268
+ f'{_res.gb(free)} free; the computer may slow down.', stacklevel=3)
269
+
270
+ if ndiag < _res.PILOT_MIN_NDIAG:
271
+ return # a short run: not worth timing
272
+ start = time.perf_counter()
273
+ _, ret = bloch.compute_scm([0, 0])
274
+ seconds = _res.PILOT_FACTOR * ntilt * (time.perf_counter() - start)
275
+ if ret == 0 and seconds > _res.LONG_RUN_SECONDS:
276
+ warnings.warn(f'These Bloch images will take {_res.duration(seconds)} on this '
277
+ f'computer: {ndiag:,} beams are diagonalized at each of {ntilt} '
278
+ f'sampling points. To shorten it, lower sampling (the time grows with '
279
+ f'its square), omega, or gmax in em_controls.', stacklevel=3)
280
+
281
+ def getBlochImages(self,
224
282
  sample_thickness = DEF_THICKNESS,
225
283
  pix_size = DEF_PIXSIZE,
226
284
  det_size = DEF_DETSIZE,
@@ -250,7 +308,8 @@ def add_bloch(target):
250
308
  :rtype: :py:class:`~pyemaps.ddiffs.BlochImgs`
251
309
  :raise ~pyemaps.errors.BlochListError: if *sample_thickness*, *pix_size* or *det_size* is invalid, or there
252
310
  are too many thicknesses.
253
- :raise ~pyemaps.errors.BlochError: if the images can't be made or the file can't be written.
311
+ :raise ~pyemaps.errors.BlochError: if the images need more memory than is free, they can't be made, or
312
+ the file can't be written.
254
313
 
255
314
  .. warning::
256
315
 
@@ -260,6 +319,11 @@ def add_bloch(target):
260
319
  - the detector size *det_size*: 256 instead of the default 512, for example, uses a
261
320
  quarter of the image memory;
262
321
  - the number of sampling points *sampling*.
322
+
323
+ Before making the images, pyEMAPS checks that they fit in the free memory. When 400
324
+ or more beams are diagonalized, it also times one sampling point on this computer, and
325
+ if the images will take more than a minute, a Python warning says roughly how long. The time grows with the square of *sampling*
326
+ and steeply with the number of beams diagonalized, which *omega* and *gmax* set.
263
327
  """
264
328
  from copy import deepcopy
265
329
 
@@ -291,6 +355,8 @@ def add_bloch(target):
291
355
  if ndep > MAX_DEPTH:
292
356
  raise BlochListError(f'Number of sample thickness cannot exceed {MAX_DEPTH}')
293
357
 
358
+ self._checkBlochImages(det_size, ndep * (bloch.getncalcbeams() if nType == TY_LACBED else 1))
359
+
294
360
  # save the input as optional control attributes
295
361
  imgfn =''
296
362
  if bSave:
@@ -591,7 +657,8 @@ def add_bloch(target):
591
657
  :type bSave: bool, optional
592
658
  :return: the images, each with the controls and thickness it was made with.
593
659
  :rtype: :py:class:`~pyemaps.ddiffs.BlochImgs`
594
- :raise ~pyemaps.errors.BlochError: if an input is invalid or the simulation fails.
660
+ :raise ~pyemaps.errors.BlochError: if an input is invalid, the run needs more memory than is free, or
661
+ the simulation fails.
595
662
  :raise ~pyemaps.errors.BlochListError: if *sample_thickness*, *pix_size* or *det_size* is invalid.
596
663
 
597
664
  .. warning::
@@ -602,6 +669,10 @@ def add_bloch(target):
602
669
  - the detector size *det_size*: 256 instead of the default 512, for example, uses a
603
670
  quarter of the image memory;
604
671
  - the number of sampling points *sampling*.
672
+
673
+ The run stops with a ``BlochError`` before allocating memory that isn't free, and a
674
+ Python warning says if the images will take more than a minute, timed on this
675
+ computer (see :py:meth:`~pyemaps.crystals.Crystal.getBlochImages`).
605
676
  """
606
677
  try:
607
678
 
@@ -654,6 +725,7 @@ def add_bloch(target):
654
725
  target.getSCMatrix = getSCMatrix
655
726
  target.getBlochImages = getBlochImages
656
727
  target.getCalculatedBeams = getCalculatedBeams
728
+ target._checkBlochImages = _checkBlochImages
657
729
  # target.getLACBEDImage = getLACBEDImage
658
730
  # ---These calls must be between beginBloch and endBloch calls
659
731
 
@@ -84,8 +84,10 @@ def add_dpgen(target):
84
84
  :return: ``(status, file_name)``: 0 and the database file's path on success, or -1 and
85
85
  ``None`` (or the intended path) on failure. A message is printed either way.
86
86
  :rtype: tuple
87
+ :raise ~pyemaps.errors.LicenseError: without an active pyEMAPS license (emaps 2.6.0
88
+ and later).
87
89
 
88
- .. image:: https://github.com/emlab-solutions/imagepypy/raw/main/stereoprojectionmap.png
90
+ .. image:: https://raw.githubusercontent.com/emlab-solutions/imagepypy/main/stereoprojectionmap.png
89
91
  :width: 75%
90
92
  :align: center
91
93
  """
@@ -136,6 +138,12 @@ def add_dpgen(target):
136
138
  #release the memory
137
139
  dpgen.cleanup()
138
140
 
141
+ if ret == -5:
142
+ from ..errors import LicenseError
143
+ raise LicenseError('Diffraction pattern database generation is a licensed feature, '
144
+ 'and no active pyEMAPS license was found. Run "pyemaps -l trial" '
145
+ 'for a 7-day trial license, or contact '
146
+ 'support@emlabsoftware.com for one.')
139
147
  if ret != 0:
140
148
  print(f'Error generating diffraction patterns for {self.name}')
141
149
  return -1, final_fp
@@ -24,7 +24,7 @@ def add_mxtal(target):
24
24
  def printXYZ( mx):
25
25
  """
26
26
  Print a crystal structure from :py:meth:`~pyemaps.crystals.Crystal.generateMxtal` in XYZ format. See
27
- `XYZ format <https://wiki.jmol.org/index.php/File_formats/Formats/XYZ>`_.
27
+ `XYZ format <https://en.wikipedia.org/wiki/XYZ_file_format>`_.
28
28
 
29
29
  :param mx: the crystal structure.
30
30
  :type mx: :py:class:`~pyemaps.xtal.Xtal`, required
@@ -8,8 +8,6 @@
8
8
  # combination with the separately licensed backend, emaps.
9
9
 
10
10
  """
11
- Microscope and simulation controls.
12
-
13
11
  This module defines two control classes: :py:class:`EMControl` for the microscope, sample
14
12
  and detector, and :py:class:`SIMControl` for the simulation. The simulation controls change
15
13
  less often, so an EMControl holds a SIMControl.
@@ -220,3 +220,17 @@ class XDPImageError(Exception):
220
220
  def __init__(self, message=''):
221
221
  self.message = str(f'{message}')
222
222
  super().__init__(self.message)
223
+
224
+
225
+ class LicenseError(Exception):
226
+ """
227
+ Raised when a licensed feature is used without an active pyEMAPS license, or isn't in this
228
+ emaps package: the multislice simulations of :py:class:`~pyemaps.probe.Probe`
229
+ (:py:meth:`~pyemaps.probe.Probe.crystal_exit_wave` and
230
+ :py:meth:`~pyemaps.probe.Probe.crystal_ronchigram`) and diffraction pattern database
231
+ generation (:py:meth:`~pyemaps.crystals.Crystal.generateDPDB`). Run ``pyemaps -l trial``
232
+ for a 7-day trial license, or contact support@emlabsoftware.com for one.
233
+ """
234
+ def __init__(self, message=''):
235
+ self.message = str(f'{message}')
236
+ super().__init__(self.message)