pyemaps 2.10.0__tar.gz → 2.11.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 (141) hide show
  1. {pyemaps-2.10.0/pyemaps.egg-info → pyemaps-2.11.0}/PKG-INFO +32 -18
  2. {pyemaps-2.10.0 → pyemaps-2.11.0}/README.md +15 -8
  3. pyemaps-2.11.0/__version__.py +1 -0
  4. {pyemaps-2.10.0 → pyemaps-2.11.0}/diffract/_resources.py +43 -9
  5. {pyemaps-2.10.0 → pyemaps-2.11.0}/diffract/bloch_dec.py +35 -14
  6. {pyemaps-2.10.0 → pyemaps-2.11.0}/diffract/dpgen_dec.py +5 -6
  7. {pyemaps-2.10.0 → pyemaps-2.11.0}/diffract/mxtal_dec.py +4 -1
  8. {pyemaps-2.10.0 → pyemaps-2.11.0}/errors.py +32 -5
  9. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/adf.ipynb +97 -91
  10. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/al_cu_phasemap.ipynb +61 -54
  11. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/al_ediom.ipynb +38 -38
  12. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/al_orientmap.ipynb +63 -84
  13. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/powder.ipynb +33 -33
  14. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/probe.ipynb +61 -61
  15. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/si_bloch.ipynb +54 -54
  16. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/si_constructor.ipynb +34 -34
  17. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/si_csf.ipynb +49 -49
  18. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/si_dif.ipynb +66 -66
  19. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/si_lacbed.ipynb +47 -53
  20. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/si_multislice.ipynb +38 -44
  21. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/si_scm.ipynb +53 -53
  22. {pyemaps-2.10.0 → pyemaps-2.11.0}/notebooks/si_stereo.ipynb +34 -34
  23. {pyemaps-2.10.0 → pyemaps-2.11.0}/probe.py +6 -6
  24. {pyemaps-2.10.0 → pyemaps-2.11.0/pyemaps.egg-info}/PKG-INFO +32 -18
  25. {pyemaps-2.10.0 → pyemaps-2.11.0}/pyemaps.egg-info/requires.txt +1 -1
  26. {pyemaps-2.10.0 → pyemaps-2.11.0}/setup.py +1 -1
  27. {pyemaps-2.10.0 → pyemaps-2.11.0}/stackimg.py +19 -33
  28. pyemaps-2.10.0/__version__.py +0 -1
  29. {pyemaps-2.10.0 → pyemaps-2.11.0}/COPYING +0 -0
  30. {pyemaps-2.10.0 → pyemaps-2.11.0}/MANIFEST.in +0 -0
  31. {pyemaps-2.10.0 → pyemaps-2.11.0}/__config__.py +0 -0
  32. {pyemaps-2.10.0 → pyemaps-2.11.0}/__init__.py +0 -0
  33. {pyemaps-2.10.0 → pyemaps-2.11.0}/__main__.py +0 -0
  34. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Aluminium.xtl +0 -0
  35. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/AluminiumOxide.xtl +0 -0
  36. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Aluminium_FCC.xtl +0 -0
  37. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/BariumTitanate_180k.xtl +0 -0
  38. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/BariumTitanate_270k.xtl +0 -0
  39. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/BariumTitanate_Tetra.xtl +0 -0
  40. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/BiMnO3.xtl +0 -0
  41. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Boron_Tetra.xtl +0 -0
  42. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/CadmiumSelenide_Hex.xtl +0 -0
  43. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/CadmiumSulfide_Cubic.xtl +0 -0
  44. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/CadmiumSulfide_Hex.xtl +0 -0
  45. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Chromium_BCC.xtl +0 -0
  46. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/CoSb3_Skutterudite.xtl +0 -0
  47. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/CopperOxide.xtl +0 -0
  48. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Copper_FCC.xtl +0 -0
  49. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Cu2O_Cuprite.xtl +0 -0
  50. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Diamond.xtl +0 -0
  51. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/ErbiumPyrogermanate.xtl +0 -0
  52. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/FePd_Tetra.xtl +0 -0
  53. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/FeS2_Pyrite.xtl +0 -0
  54. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/GalliumAntimonide.xtl +0 -0
  55. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/GalliumArsenide.xtl +0 -0
  56. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/GalliumNitride.xtl +0 -0
  57. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Germanium.xtl +0 -0
  58. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Gold_FCC.xtl +0 -0
  59. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/IndiumArsenide.xtl +0 -0
  60. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/LaMnO3.xtl +0 -0
  61. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/LeadZirconateTitanate.xtl +0 -0
  62. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Li2MnO3.xtl +0 -0
  63. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/NaFeO2.xtl +0 -0
  64. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Nb3Sn.xtl +0 -0
  65. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Pentacene.xtl +0 -0
  66. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/SiAlONa.xtl +0 -0
  67. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Silicon.xtl +0 -0
  68. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/StrontiumTitanate.xtl +0 -0
  69. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/TelluriumDioxide.xtl +0 -0
  70. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/TinDioxide_RT.xtl +0 -0
  71. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/TitaniumDioxide_Anatase.xtl +0 -0
  72. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/TitaniumDioxide_Rutile.xtl +0 -0
  73. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/TungstenDiselenide.xtl +0 -0
  74. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/VanadiumDioxide_RT.xtl +0 -0
  75. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/ZincOxide.xtl +0 -0
  76. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/Zinc_HCP.xtl +0 -0
  77. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/ZirconiumNitride.xtl +0 -0
  78. {pyemaps-2.10.0 → pyemaps-2.11.0}/cdata/limno2.xtl +0 -0
  79. {pyemaps-2.10.0 → pyemaps-2.11.0}/cifreader.py +0 -0
  80. {pyemaps-2.10.0 → pyemaps-2.11.0}/crystals.py +0 -0
  81. {pyemaps-2.10.0 → pyemaps-2.11.0}/ddiffs.py +0 -0
  82. {pyemaps-2.10.0 → pyemaps-2.11.0}/diffract/__init__.py +0 -0
  83. {pyemaps-2.10.0 → pyemaps-2.11.0}/diffract/csf_dec.py +0 -0
  84. {pyemaps-2.10.0 → pyemaps-2.11.0}/diffract/dif_dec.py +0 -0
  85. {pyemaps-2.10.0 → pyemaps-2.11.0}/diffract/powder_dec.py +0 -0
  86. {pyemaps-2.10.0 → pyemaps-2.11.0}/diffract/stereo_dec.py +0 -0
  87. {pyemaps-2.10.0 → pyemaps-2.11.0}/display.py +0 -0
  88. {pyemaps-2.10.0 → pyemaps-2.11.0}/dmreader.py +0 -0
  89. {pyemaps-2.10.0 → pyemaps-2.11.0}/emcontrols.py +0 -0
  90. {pyemaps-2.10.0 → pyemaps-2.11.0}/emdreader.py +0 -0
  91. {pyemaps-2.10.0 → pyemaps-2.11.0}/expimage.py +0 -0
  92. {pyemaps-2.10.0 → pyemaps-2.11.0}/fileutils.py +0 -0
  93. {pyemaps-2.10.0 → pyemaps-2.11.0}/kdiffs.py +0 -0
  94. {pyemaps-2.10.0 → pyemaps-2.11.0}/license-exception.txt +0 -0
  95. {pyemaps-2.10.0 → pyemaps-2.11.0}/license.txt +0 -0
  96. {pyemaps-2.10.0 → pyemaps-2.11.0}/mibreader.py +0 -0
  97. {pyemaps-2.10.0 → pyemaps-2.11.0}/mrcreader.py +0 -0
  98. {pyemaps-2.10.0 → pyemaps-2.11.0}/orientmap.py +0 -0
  99. {pyemaps-2.10.0 → pyemaps-2.11.0}/phasemap.py +0 -0
  100. {pyemaps-2.10.0 → pyemaps-2.11.0}/picreader.py +0 -0
  101. {pyemaps-2.10.0 → pyemaps-2.11.0}/pyemaps.egg-info/SOURCES.txt +0 -0
  102. {pyemaps-2.10.0 → pyemaps-2.11.0}/pyemaps.egg-info/dependency_links.txt +0 -0
  103. {pyemaps-2.10.0 → pyemaps-2.11.0}/pyemaps.egg-info/entry_points.txt +0 -0
  104. {pyemaps-2.10.0 → pyemaps-2.11.0}/pyemaps.egg-info/top_level.txt +0 -0
  105. {pyemaps-2.10.0 → pyemaps-2.11.0}/pyproject.toml +0 -0
  106. {pyemaps-2.10.0 → pyemaps-2.11.0}/readerbase.py +0 -0
  107. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/Al_COD_4004108.cif +0 -0
  108. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/Cu_COD_7101269.cif +0 -0
  109. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/Si_COD_2102763.cif +0 -0
  110. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/adf.py +0 -0
  111. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/al.img +0 -0
  112. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/al_cu_phasemap.py +0 -0
  113. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/al_dpgen.py +0 -0
  114. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/al_ediom.py +0 -0
  115. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/al_orientmap.py +0 -0
  116. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/convert_image.py +0 -0
  117. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/crystal_imaging.py +0 -0
  118. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/crystal_thickness.py +0 -0
  119. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/ctf.py +0 -0
  120. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/dm_diff.py +0 -0
  121. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/hrem.py +0 -0
  122. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/mask.im3 +0 -0
  123. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/powder.py +0 -0
  124. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/raw.img +0 -0
  125. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/ronchigram.py +0 -0
  126. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/si_bloch.py +0 -0
  127. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/si_constructor.py +0 -0
  128. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/si_csf.py +0 -0
  129. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/si_dif.py +0 -0
  130. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/si_lacbed.py +0 -0
  131. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/si_pyemaps.py +0 -0
  132. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/si_scm.py +0 -0
  133. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/si_stereo.py +0 -0
  134. {pyemaps-2.10.0 → pyemaps-2.11.0}/samples/stem_probe.py +0 -0
  135. {pyemaps-2.10.0 → pyemaps-2.11.0}/scattering/__init__.py +0 -0
  136. {pyemaps-2.10.0 → pyemaps-2.11.0}/scattering/sct_dec.py +0 -0
  137. {pyemaps-2.10.0 → pyemaps-2.11.0}/setup.cfg +0 -0
  138. {pyemaps-2.10.0 → pyemaps-2.11.0}/spg/__init__.py +0 -0
  139. {pyemaps-2.10.0 → pyemaps-2.11.0}/spg/spg_dec.py +0 -0
  140. {pyemaps-2.10.0 → pyemaps-2.11.0}/tiffreader.py +0 -0
  141. {pyemaps-2.10.0 → pyemaps-2.11.0}/xtal.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyemaps
3
- Version: 2.10.0
3
+ Version: 2.11.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.7.0
27
+ Requires-Dist: emaps>=2.8.0
28
28
  Requires-Dist: numpy>=2.0
29
29
  Requires-Dist: matplotlib>=3.8.4
30
30
  Provides-Extra: emd
@@ -61,7 +61,8 @@ kinematical and dynamical electron diffraction described by J. C. H. Spence and
61
61
 
62
62
 
63
63
  ## Features
64
64
 
65
65
 
66
66
 
67
- The base features are free, under the GNU General Public License v3.0:
68
-
67
+ **The core features are free, with no license, no sign-up and no time limit**, under the GNU
68
+
69
+ General Public License v3.0:
70
+
69
71
 
70
72
 
71
73
  - **Crystallography**
72
74
 
73
75
  - Crystal construction, from your own data or the built-in crystal library
74
76
 
@@ -85,12 +86,17 @@ The base features are free, under the GNU General Public License v3.0:
85
86
  - Contrast transfer functions, with their coherence envelopes
86
87
 
87
88
  - HREM images of thin samples
88
89
 
89
90
 
90
91
 
91
- The extended 4D-STEM features need a license:
92
-
92
+ **The advanced features need a license, and you can try them all free for 7 days** with
93
+
94
+ `pyemaps -l trial`:
95
+
93
96
 
94
97
 
95
- - Building and searching diffraction pattern databases
96
-
97
- - Indexing experimental diffraction patterns
98
-
99
- - Annular bright and dark field images
100
-
101
- - Masked images
102
-
98
+ - **4D-STEM analysis**: indexing experimental diffraction patterns, orientation and phase maps,
99
+
100
+ annular bright and dark field and masked images, and averaging, comparing, grouping and
101
+
102
+ transforming patterns
103
+
104
+ - **Diffraction pattern databases**: building and searching them
105
+
106
+ - **Multislice** simulations of thick crystals: exit waves and Ronchigrams
107
+
108
+
109
+
110
+ [Free and licensed features](https://emlab-solutions.github.io/pyemaps/free_and_licensed.html)
111
+
112
+ has the details.
113
+
103
114
 
104
115
 
105
116
  Reading experimental patterns is free: TIFF, Gatan DigitalMicrograph (`.dm3`, `.dm4`), MRC,
106
117
 
107
118
  Quantum Detectors Merlin (`.mib`), PNG, BMP, JPEG and NumPy files, single images, stacks and
108
119
 
@@ -161,8 +167,9 @@ pyEMAPS is free software under the
161
167
  [GNU General Public License v3.0 or later](https://emlab-solutions.github.io/pyemaps/license.html),
162
168
 
163
169
  for personal and commercial use, with a linking exception
164
170
 
165
171
  ([license-exception.txt](https://github.com/emlab-solutions/pyemaps/blob/main/license-exception.txt))
166
172
 
167
- that allows its use with emaps, the proprietary simulation engine it runs on. emaps' 4D-STEM
168
-
169
- features need a license:
170
-
173
+ that allows its use with emaps, the proprietary simulation engine it runs on. The core features
174
+
175
+ need no license. The advanced features (4D-STEM analysis, diffraction pattern databases and
176
+
177
+ multislice) need one, and you can try them free for 7 days:
178
+
171
179
 
172
180
 
173
181
  - `pyemaps --license trial` activates a 7-day trial license. It needs an internet connection.
174
182
 
175
183
  - `pyemaps --license <token>` activates a trial or production license with a license activation
176
184
 
@@ -22,7 +22,8 @@ kinematical and dynamical electron diffraction described by J. C. H. Spence and
22
22
 
23
23
  ## Features
24
24
 
25
- The base features are free, under the GNU General Public License v3.0:
25
+ **The core features are free, with no license, no sign-up and no time limit**, under the GNU
26
+ General Public License v3.0:
26
27
 
27
28
  - **Crystallography**
28
29
  - Crystal construction, from your own data or the built-in crystal library
@@ -46,12 +47,17 @@ The base features are free, under the GNU General Public License v3.0:
46
47
  - Contrast transfer functions, with their coherence envelopes
47
48
  - HREM images of thin samples
48
49
 
49
- The extended 4D-STEM features need a license:
50
+ **The advanced features need a license, and you can try them all free for 7 days** with
51
+ `pyemaps -l trial`:
50
52
 
51
- - Building and searching diffraction pattern databases
52
- - Indexing experimental diffraction patterns
53
- - Annular bright and dark field images
54
- - Masked images
53
+ - **4D-STEM analysis**: indexing experimental diffraction patterns, orientation and phase maps,
54
+ annular bright and dark field and masked images, and averaging, comparing, grouping and
55
+ transforming patterns
56
+ - **Diffraction pattern databases**: building and searching them
57
+ - **Multislice** simulations of thick crystals: exit waves and Ronchigrams
58
+
59
+ [Free and licensed features](https://emlab-solutions.github.io/pyemaps/free_and_licensed.html)
60
+ has the details.
55
61
 
56
62
  Reading experimental patterns is free: TIFF, Gatan DigitalMicrograph (`.dm3`, `.dm4`), MRC,
57
63
  Quantum Detectors Merlin (`.mib`), PNG, BMP, JPEG and NumPy files, single images, stacks and
@@ -122,8 +128,9 @@ pyEMAPS is free software under the
122
128
  [GNU General Public License v3.0 or later](https://emlab-solutions.github.io/pyemaps/license.html),
123
129
  for personal and commercial use, with a linking exception
124
130
  ([license-exception.txt](https://github.com/emlab-solutions/pyemaps/blob/main/license-exception.txt))
125
- that allows its use with emaps, the proprietary simulation engine it runs on. emaps' 4D-STEM
126
- features need a license:
131
+ that allows its use with emaps, the proprietary simulation engine it runs on. The core features
132
+ need no license. The advanced features (4D-STEM analysis, diffraction pattern databases and
133
+ multislice) need one, and you can try them free for 7 days:
127
134
 
128
135
  - `pyemaps --license trial` activates a 7-day trial license. It needs an internet connection.
129
136
  - `pyemaps --license <token>` activates a trial or production license with a license activation
@@ -0,0 +1 @@
1
+ __version__ = "2.11.0"
@@ -15,25 +15,47 @@ says how long it will take before it starts.
15
15
  The memory figures follow the backend's allocations:
16
16
 
17
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;
18
+ * at each sampling point, for each thread working on one, with N strong beams: the strong-beam
19
+ matrix and the weak beams' correction, 24 x N**2 bytes, plus 16 KB per strong beam for the
20
+ correction's working blocks; another 8 x N**2 for the eigenvectors and their inverse when the
21
+ point is solved as an eigenproblem; and the math library's working memory, about 64 MB
22
+ (80 MB for an eigenproblem), measured at 565 to 1,038 strong beams and taken to shrink in
23
+ proportion below 500;
20
24
  * the images, 4 bytes per pixel.
25
+
26
+ emaps from 2.8.0 solves each sampling point of the images whichever way is cheaper: by
27
+ propagating the beams through the thicknesses (Chebyshev expansion), or as an eigenproblem.
21
28
  '''
22
29
 
23
30
  import os
24
31
  import sys
25
32
 
26
33
  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
34
  PIXEL_BYTES = 4 # float32 images
29
35
 
36
+ # How the timing point was solved: emaps' image_pilot returns EIGENPROBLEM or PROPAGATED;
37
+ # SCATTERING_MATRIX is the stand-in timing point for emaps before 2.8.0
38
+ SCATTERING_MATRIX, EIGENPROBLEM, PROPAGATED = 0, 1, 2
39
+
40
+ # For each thread working on a sampling point of N strong beams (measured with emaps 2.8.0 on
41
+ # paracetamol forms I and II and BiMnO3, 565 to 1,038 strong beams, 3 to 12 threads)
42
+ PROPAGATION_BYTES = 24 # bytes per N**2: the strong-beam matrix, the weak beams' correction
43
+ EIGEN_BYTES = 32 # bytes per N**2: those, the eigenvectors and their inverse
44
+ CORRECTION_BYTES = 16 * 1024 # bytes per strong beam: the correction's working blocks
45
+ LIBRARY_BYTES = {PROPAGATED: 64 * 1024**2, EIGENPROBLEM: 80 * 1024**2}
46
+ LIBRARY_NDIAG = 500 # below this many strong beams, LIBRARY_BYTES shrinks in proportion
47
+
30
48
  # Memory use above this fraction of the free memory gets a warning
31
49
  MEMORY_WARN_FRACTION = 0.5
32
50
 
33
51
  # 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
52
+ # backend does with all threads. Run side by side, on a 6-core PC, the sampling points then
53
+ # took 0.35 to 0.7 times as long each when solved as eigenproblems (565 to 1,038 strong beams),
54
+ # and 0.75 to 0.97 times as long when propagated, since they then share the memory bandwidth.
55
+ # With the factors below, and the timing point's own time, the estimates for paracetamol forms
56
+ # I and II and BiMnO3 came within 15% of the run. Before emaps 2.8.0 the timing point solved
57
+ # the eigenproblem's scattering matrix: 0.35 to 0.5.
58
+ PILOT_FACTORS = {SCATTERING_MATRIX: 0.5, EIGENPROBLEM: 0.75, PROPAGATED: 1.0}
37
59
 
38
60
  # Runs estimated to take longer than this get a warning
39
61
  LONG_RUN_SECONDS = 60
@@ -86,9 +108,21 @@ def beam_matrix_bytes(nbeams):
86
108
  return BEAM_MATRIX_BYTES * nbeams * nbeams
87
109
 
88
110
 
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
111
+ def images_bytes(ndiag, threads, det_size, nslices, propagated=False):
112
+ '''
113
+ Memory the images need: the sampling points solved at once, propagated or as eigenproblems,
114
+ and the images themselves.
115
+ '''
116
+ method = PROPAGATED if propagated else EIGENPROBLEM
117
+ per_n2 = PROPAGATION_BYTES if propagated else EIGEN_BYTES
118
+ library = LIBRARY_BYTES[method] * min(1.0, ndiag / LIBRARY_NDIAG)
119
+ point = per_n2 * ndiag * ndiag + CORRECTION_BYTES * ndiag + library
120
+ return int(point * threads) + PIXEL_BYTES * det_size * det_size * nslices
121
+
122
+
123
+ def pilot_factor(method):
124
+ '''How much shorter, each, the sampling points take side by side than the timing point.'''
125
+ return PILOT_FACTORS.get(method, PILOT_FACTORS[EIGENPROBLEM])
92
126
 
93
127
 
94
128
  def gb(nbytes):
@@ -246,20 +246,42 @@ def add_bloch(target):
246
246
  self.session_controls=em_controls
247
247
  return nsampling, sp
248
248
 
249
- def _checkBlochImages(self, det_size, nslices):
249
+ def _timeBlochPoint(thicknesses):
250
+ '''
251
+ Solve the centre sampling point on its own, as the images will solve it: (method,
252
+ seconds), or (None, None) if that failed. With emaps before 2.8.0, which has no such
253
+ timing point, the eigenproblem's scattering matrix stands in.
254
+ '''
255
+ start = time.perf_counter()
256
+ if hasattr(bloch, 'image_pilot'):
257
+ method, ret = bloch.image_pilot(farray(np.array(thicknesses), dtype=np.int32))
258
+ else:
259
+ _, ret = bloch.compute_scm([0, 0])
260
+ method = _res.SCATTERING_MATRIX
261
+ seconds = time.perf_counter() - start
262
+ return (int(method), seconds) if ret == 0 else (None, None)
263
+
264
+ def _checkBlochImages(self, det_size, nslices, thicknesses):
250
265
  """
251
266
  Before the session's images are made: raise BlochError if they need more memory than is
252
267
  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.
268
+ one sampling point on its own, as the images will solve it (about 1% of the work), and
269
+ scaling to all of them; only when at least PILOT_MIN_NDIAG (400) beams are strong, since
270
+ smaller runs are short. That point also says how the images are solved: by propagating
271
+ the beams through the thicknesses, or as an eigenproblem, which needs more memory.
255
272
  """
256
273
  ndiag, ntilt = int(bloch.ndiag_max), int(bloch.ntilt)
257
274
  threads = min(_res.openmp_threads(), max(ntilt, 1))
258
- need, free = _res.images_bytes(ndiag, threads, det_size, nslices), _res.available_memory()
275
+ method, seconds = None, None
276
+ if ndiag >= _res.PILOT_MIN_NDIAG:
277
+ method, seconds = _timeBlochPoint(thicknesses)
278
+ propagated = method == _res.PROPAGATED
279
+ need = _res.images_bytes(ndiag, threads, det_size, nslices, propagated)
280
+ free = _res.available_memory()
259
281
  if free is not None and need > free:
260
282
  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 '
283
+ raise BlochError(f'The images need {_res.gb(need)} of memory ({ndiag:,} strong beams '
284
+ f'on {threads} threads, and {images} of '
263
285
  f'{det_size} x {det_size}), and this computer has {_res.gb(free)} '
264
286
  f'free. Lower omega, gmax or the excitation error limits, or make '
265
287
  f'fewer or smaller images, and retry')
@@ -267,14 +289,12 @@ def add_bloch(target):
267
289
  warnings.warn(f'The images need {_res.gb(need)} of memory, more than half of the '
268
290
  f'{_res.gb(free)} free; the computer may slow down.', stacklevel=3)
269
291
 
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:
292
+ if seconds is None:
293
+ return # a short run, not timed
294
+ seconds *= _res.pilot_factor(method) * ntilt
295
+ if seconds > _res.LONG_RUN_SECONDS:
276
296
  warnings.warn(f'These Bloch images will take {_res.duration(seconds)} on this '
277
- f'computer: {ndiag:,} beams are diagonalized at each of {ntilt} '
297
+ f'computer: {ndiag:,} strong beams at each of {ntilt} '
278
298
  f'sampling points. To shorten it, lower sampling (the time grows with '
279
299
  f'its square), omega, or gmax in em_controls.', stacklevel=3)
280
300
 
@@ -355,7 +375,8 @@ def add_bloch(target):
355
375
  if ndep > MAX_DEPTH:
356
376
  raise BlochListError(f'Number of sample thickness cannot exceed {MAX_DEPTH}')
357
377
 
358
- self._checkBlochImages(det_size, ndep * (bloch.getncalcbeams() if nType == TY_LACBED else 1))
378
+ self._checkBlochImages(det_size, ndep * (bloch.getncalcbeams() if nType == TY_LACBED else 1),
379
+ thlist)
359
380
 
360
381
  # save the input as optional control attributes
361
382
  imgfn =''
@@ -138,12 +138,11 @@ def add_dpgen(target):
138
138
  #release the memory
139
139
  dpgen.cleanup()
140
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.')
141
+ if ret in (-5, -7):
142
+ # -5 no license, -7 expired (a trial that has ended, from emaps 2.8.0)
143
+ from ..errors import LicenseError, license_message, LICENSE_NONE, LICENSE_EXPIRED
144
+ raise LicenseError(license_message('Diffraction pattern database generation',
145
+ LICENSE_EXPIRED if ret == -7 else LICENSE_NONE))
147
146
  if ret != 0:
148
147
  print(f'Error generating diffraction patterns for {self.name}')
149
148
  return -1, final_fp
@@ -100,7 +100,10 @@ def add_mxtal(target):
100
100
  units. Defaults to ``[[0, 0, 0], [3, 3, 3]]``.
101
101
  :type cellbox: list or array, optional
102
102
  :param xz: two real-space directions, ``[x_direction, z_direction]``, to align with the
103
- output's x and z axes. Defaults to ``[[1, 0, 0], [0, 0, 1]]``.
103
+ output's x and z axes. Defaults to ``[[1, 0, 0], [0, 0, 1]]``. z follows
104
+ *z_direction*. If *x_direction* isn't perpendicular to it, as with the default in a
105
+ monoclinic or triclinic cell, x is the part of *x_direction* perpendicular to z.
106
+ Before emaps 2.8.0, the structure came out sheared instead.
104
107
  :type xz: list or array, optional
105
108
  :param orShift: shift added to the atom positions in cell coordinates, before they're
106
109
  oriented. Defaults to ``[0, 0, 0]``.
@@ -222,14 +222,41 @@ class XDPImageError(Exception):
222
222
  super().__init__(self.message)
223
223
 
224
224
 
225
+ # Why an advanced feature can't run: no license, an expired one (a trial that has ended), or one
226
+ # that couldn't be read
227
+ LICENSE_NONE, LICENSE_EXPIRED, LICENSE_UNREADABLE = 'none', 'expired', 'unreadable'
228
+
229
+
230
+ def license_message(feature, state):
231
+ '''
232
+ The message for an advanced feature that can't run for want of a license. *feature* names
233
+ it as a sentence starts ("Multislice simulation"); *state* is ``LICENSE_NONE``,
234
+ ``LICENSE_EXPIRED`` or ``LICENSE_UNREADABLE``. Every advanced feature says the same thing,
235
+ and says that the core features need no license.
236
+ '''
237
+ if state == LICENSE_EXPIRED:
238
+ return (f'Your free 7-day pyEMAPS trial has ended, and {feature[:1].lower()}{feature[1:]} is '
239
+ 'an advanced feature. To keep using it, get a license from '
240
+ 'support@emlabsoftware.com, then run "pyemaps -l <license token>". The core '
241
+ 'features keep working without a license.')
242
+ if state == LICENSE_UNREADABLE:
243
+ return (f'{feature} is an advanced feature, and pyEMAPS could not read its license. Run '
244
+ '"pyemaps -l info" to see it, and contact support@emlabsoftware.com if this '
245
+ 'persists.')
246
+ return (f'{feature} is an advanced feature, and no pyEMAPS license is active. Try it free '
247
+ 'for 7 days: run "pyemaps -l trial" (it needs an internet connection once). The core '
248
+ 'features need no license.')
249
+
250
+
225
251
  class LicenseError(Exception):
226
252
  """
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
253
+ Raised when an advanced feature is used without an active pyEMAPS license, after a trial
254
+ has ended, or when the feature isn't in this emaps package: the multislice simulations of
255
+ :py:class:`~pyemaps.probe.Probe` (:py:meth:`~pyemaps.probe.Probe.crystal_exit_wave` and
230
256
  :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.
257
+ generation (:py:meth:`~pyemaps.crystals.Crystal.generateDPDB`). The message says what to do:
258
+ ``pyemaps -l trial`` starts a free 7-day trial, and support@emlabsoftware.com has licenses.
259
+ The 4D-STEM features raise :py:class:`XDPImageError` with the same message.
233
260
  """
234
261
  def __init__(self, message=''):
235
262
  self.message = str(f'{message}')