pyemaps 2.9.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.
- {pyemaps-2.9.0/pyemaps.egg-info → pyemaps-2.11.0}/PKG-INFO +58 -20
- {pyemaps-2.9.0 → pyemaps-2.11.0}/README.md +28 -9
- pyemaps-2.11.0/__version__.py +1 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/crystals.py +22 -0
- pyemaps-2.11.0/diffract/_resources.py +144 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/diffract/bloch_dec.py +102 -9
- {pyemaps-2.9.0 → pyemaps-2.11.0}/diffract/dpgen_dec.py +6 -7
- {pyemaps-2.9.0 → pyemaps-2.11.0}/diffract/mxtal_dec.py +5 -2
- {pyemaps-2.9.0 → pyemaps-2.11.0}/emcontrols.py +0 -2
- {pyemaps-2.9.0 → pyemaps-2.11.0}/errors.py +32 -5
- {pyemaps-2.9.0 → pyemaps-2.11.0}/fileutils.py +90 -59
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/adf.ipynb +97 -91
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/al_cu_phasemap.ipynb +65 -58
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/al_ediom.ipynb +40 -40
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/al_orientmap.ipynb +128 -72
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/powder.ipynb +33 -33
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/probe.ipynb +61 -61
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/si_bloch.ipynb +54 -54
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/si_constructor.ipynb +34 -34
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/si_csf.ipynb +49 -49
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/si_dif.ipynb +66 -66
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/si_lacbed.ipynb +46 -46
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/si_multislice.ipynb +42 -48
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/si_scm.ipynb +53 -53
- {pyemaps-2.9.0 → pyemaps-2.11.0}/notebooks/si_stereo.ipynb +34 -34
- {pyemaps-2.9.0 → pyemaps-2.11.0}/probe.py +55 -6
- {pyemaps-2.9.0 → pyemaps-2.11.0/pyemaps.egg-info}/PKG-INFO +58 -20
- {pyemaps-2.9.0 → pyemaps-2.11.0}/pyemaps.egg-info/SOURCES.txt +2 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/pyemaps.egg-info/requires.txt +1 -1
- {pyemaps-2.9.0 → pyemaps-2.11.0}/setup.py +3 -2
- {pyemaps-2.9.0 → pyemaps-2.11.0}/stackimg.py +26 -40
- {pyemaps-2.9.0 → pyemaps-2.11.0}/xtal.py +2 -2
- pyemaps-2.9.0/__version__.py +0 -1
- {pyemaps-2.9.0 → pyemaps-2.11.0}/COPYING +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/MANIFEST.in +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/__config__.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/__init__.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/__main__.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Aluminium.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/AluminiumOxide.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Aluminium_FCC.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/BariumTitanate_180k.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/BariumTitanate_270k.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/BariumTitanate_Tetra.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/BiMnO3.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Boron_Tetra.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/CadmiumSelenide_Hex.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/CadmiumSulfide_Cubic.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/CadmiumSulfide_Hex.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Chromium_BCC.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/CoSb3_Skutterudite.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/CopperOxide.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Copper_FCC.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Cu2O_Cuprite.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Diamond.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/ErbiumPyrogermanate.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/FePd_Tetra.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/FeS2_Pyrite.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/GalliumAntimonide.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/GalliumArsenide.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/GalliumNitride.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Germanium.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Gold_FCC.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/IndiumArsenide.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/LaMnO3.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/LeadZirconateTitanate.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Li2MnO3.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/NaFeO2.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Nb3Sn.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Pentacene.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/SiAlONa.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Silicon.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/StrontiumTitanate.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/TelluriumDioxide.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/TinDioxide_RT.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/TitaniumDioxide_Anatase.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/TitaniumDioxide_Rutile.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/TungstenDiselenide.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/VanadiumDioxide_RT.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/ZincOxide.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/Zinc_HCP.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/ZirconiumNitride.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cdata/limno2.xtl +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/cifreader.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/ddiffs.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/diffract/__init__.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/diffract/csf_dec.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/diffract/dif_dec.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/diffract/powder_dec.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/diffract/stereo_dec.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/display.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/dmreader.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/emdreader.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/expimage.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/kdiffs.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/license-exception.txt +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/license.txt +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/mibreader.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/mrcreader.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/orientmap.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/phasemap.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/picreader.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/pyemaps.egg-info/dependency_links.txt +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/pyemaps.egg-info/entry_points.txt +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/pyemaps.egg-info/top_level.txt +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/pyproject.toml +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/readerbase.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/Al_COD_4004108.cif +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/Cu_COD_7101269.cif +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/Si_COD_2102763.cif +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/adf.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/al.img +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/al_cu_phasemap.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/al_dpgen.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/al_ediom.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/al_orientmap.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/convert_image.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/crystal_imaging.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/crystal_thickness.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/ctf.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/dm_diff.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/hrem.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/mask.im3 +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/powder.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/raw.img +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/ronchigram.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/si_bloch.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/si_constructor.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/si_csf.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/si_dif.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/si_lacbed.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/si_pyemaps.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/si_scm.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/si_stereo.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/samples/stem_probe.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/scattering/__init__.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/scattering/sct_dec.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/setup.cfg +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/spg/__init__.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/spg/spg_dec.py +0 -0
- {pyemaps-2.9.0 → pyemaps-2.11.0}/tiffreader.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyemaps
|
|
3
|
-
Version: 2.
|
|
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.
|
|
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
|
|
@@ -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,9 +52,17 @@ 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
|
-
The
|
|
61
|
-
|
|
76
|
+
**The core features are free, with no license, no sign-up and no time limit**, under the GNU
|
|
77
|
+
|
|
78
|
+
General Public License v3.0:
|
|
79
|
+
|
|
62
80
|
|
|
63
81
|
|
|
64
82
|
- **Crystallography**
|
|
65
83
|
|
|
66
84
|
- Crystal construction, from your own data or the built-in crystal library
|
|
67
85
|
|
|
@@ -76,12 +86,17 @@ The base features are free, under the GNU General Public License v3.0:
|
|
|
76
86
|
- Contrast transfer functions, with their coherence envelopes
|
|
77
87
|
|
|
78
88
|
- HREM images of thin samples
|
|
79
89
|
|
|
80
90
|
|
|
81
91
|
|
|
82
|
-
The
|
|
83
|
-
|
|
92
|
+
**The advanced features need a license, and you can try them all free for 7 days** with
|
|
93
|
+
|
|
94
|
+
`pyemaps -l trial`:
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
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
|
+
|
|
84
108
|
|
|
85
109
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
- Annular bright and dark field images
|
|
91
|
-
|
|
92
|
-
- Masked images
|
|
93
|
-
|
|
110
|
+
[Free and licensed features](https://emlab-solutions.github.io/pyemaps/free_and_licensed.html)
|
|
111
|
+
|
|
112
|
+
has the details.
|
|
113
|
+
|
|
94
114
|
|
|
95
115
|
|
|
96
116
|
Reading experimental patterns is free: TIFF, Gatan DigitalMicrograph (`.dm3`, `.dm4`), MRC,
|
|
97
117
|
|
|
98
118
|
Quantum Detectors Merlin (`.mib`), PNG, BMP, JPEG and NumPy files, single images, stacks and
|
|
99
119
|
|
|
@@ -152,8 +167,9 @@ pyEMAPS is free software under the
|
|
|
152
167
|
[GNU General Public License v3.0 or later](https://emlab-solutions.github.io/pyemaps/license.html),
|
|
153
168
|
|
|
154
169
|
for personal and commercial use, with a linking exception
|
|
155
170
|
|
|
156
171
|
([license-exception.txt](https://github.com/emlab-solutions/pyemaps/blob/main/license-exception.txt))
|
|
157
172
|
|
|
158
|
-
that allows its use with emaps, the proprietary simulation engine it runs on.
|
|
159
|
-
|
|
160
|
-
features
|
|
161
|
-
|
|
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
|
+
|
|
162
179
|
|
|
163
180
|
|
|
164
181
|
- `pyemaps --license trial` activates a 7-day trial license. It needs an internet connection.
|
|
165
182
|
|
|
166
183
|
- `pyemaps --license <token>` activates a trial or production license with a license activation
|
|
167
184
|
|
|
@@ -178,10 +194,13 @@ tools to the education and research communities.
|
|
|
178
194
|
We're looking for experts in electron microscopy and crystallography, and Python enthusiasts, to
|
|
179
195
|
|
|
180
196
|
join the project. Contact us at support@emlabsoftware.com if you're interested.
|
|
181
197
|
|
|
182
198
|
|
|
183
199
|
|
|
200
|
+
- [CONTRIBUTING.md](https://github.com/emlab-solutions/pyemaps/blob/main/CONTRIBUTING.md)
|
|
201
|
+
|
|
202
|
+
explains how to report a bug, suggest an idea and contribute changes. For licenses and everything
|
|
203
|
+
|
|
204
|
+
else, see [Contact](https://emlab-solutions.github.io/pyemaps/contact.html).
|
|
205
|
+
|
|
184
206
|
- [DEVELOPMENT.md](https://github.com/emlab-solutions/pyemaps/blob/main/DEVELOPMENT.md)
|
|
185
207
|
|
|
186
208
|
explains how to build pyEMAPS, run its tests and build the documentation, and how we work.
|
|
187
209
|
|
|
188
210
|
- Please read and agree to our
|
|
189
211
|
|
|
190
|
-
[Contributor License Agreement](https://github.com/emlab-solutions/pyemaps/blob/main/
|
|
191
|
-
|
|
212
|
+
[Contributor License Agreement](https://github.com/emlab-solutions/pyemaps/blob/main/CLA.md)
|
|
213
|
+
|
|
192
214
|
before contributing.
|
|
193
215
|
|
|
194
216
|
- We follow the
|
|
195
217
|
|
|
196
218
|
[Contributor Covenant](https://www.contributor-covenant.org/version/2/0/code_of_conduct/) as our
|
|
197
219
|
|
|
@@ -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,9 +13,17 @@ 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
|
-
The
|
|
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:
|
|
17
27
|
|
|
18
28
|
- **Crystallography**
|
|
19
29
|
- Crystal construction, from your own data or the built-in crystal library
|
|
@@ -37,12 +47,17 @@ The base features are free, under the GNU General Public License v3.0:
|
|
|
37
47
|
- Contrast transfer functions, with their coherence envelopes
|
|
38
48
|
- HREM images of thin samples
|
|
39
49
|
|
|
40
|
-
The
|
|
50
|
+
**The advanced features need a license, and you can try them all free for 7 days** with
|
|
51
|
+
`pyemaps -l trial`:
|
|
52
|
+
|
|
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
|
|
41
58
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
- Annular bright and dark field images
|
|
45
|
-
- Masked images
|
|
59
|
+
[Free and licensed features](https://emlab-solutions.github.io/pyemaps/free_and_licensed.html)
|
|
60
|
+
has the details.
|
|
46
61
|
|
|
47
62
|
Reading experimental patterns is free: TIFF, Gatan DigitalMicrograph (`.dm3`, `.dm4`), MRC,
|
|
48
63
|
Quantum Detectors Merlin (`.mib`), PNG, BMP, JPEG and NumPy files, single images, stacks and
|
|
@@ -113,8 +128,9 @@ pyEMAPS is free software under the
|
|
|
113
128
|
[GNU General Public License v3.0 or later](https://emlab-solutions.github.io/pyemaps/license.html),
|
|
114
129
|
for personal and commercial use, with a linking exception
|
|
115
130
|
([license-exception.txt](https://github.com/emlab-solutions/pyemaps/blob/main/license-exception.txt))
|
|
116
|
-
that allows its use with emaps, the proprietary simulation engine it runs on.
|
|
117
|
-
features
|
|
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:
|
|
118
134
|
|
|
119
135
|
- `pyemaps --license trial` activates a 7-day trial license. It needs an internet connection.
|
|
120
136
|
- `pyemaps --license <token>` activates a trial or production license with a license activation
|
|
@@ -139,10 +155,13 @@ tools to the education and research communities.
|
|
|
139
155
|
We're looking for experts in electron microscopy and crystallography, and Python enthusiasts, to
|
|
140
156
|
join the project. Contact us at support@emlabsoftware.com if you're interested.
|
|
141
157
|
|
|
158
|
+
- [CONTRIBUTING.md](https://github.com/emlab-solutions/pyemaps/blob/main/CONTRIBUTING.md)
|
|
159
|
+
explains how to report a bug, suggest an idea and contribute changes. For licenses and everything
|
|
160
|
+
else, see [Contact](https://emlab-solutions.github.io/pyemaps/contact.html).
|
|
142
161
|
- [DEVELOPMENT.md](https://github.com/emlab-solutions/pyemaps/blob/main/DEVELOPMENT.md)
|
|
143
162
|
explains how to build pyEMAPS, run its tests and build the documentation, and how we work.
|
|
144
163
|
- Please read and agree to our
|
|
145
|
-
[Contributor License Agreement](https://github.com/emlab-solutions/pyemaps/blob/main/
|
|
164
|
+
[Contributor License Agreement](https://github.com/emlab-solutions/pyemaps/blob/main/CLA.md)
|
|
146
165
|
before contributing.
|
|
147
166
|
- We follow the
|
|
148
167
|
[Contributor Covenant](https://www.contributor-covenant.org/version/2/0/code_of_conduct/) as our
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "2.11.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,144 @@
|
|
|
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, 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;
|
|
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.
|
|
28
|
+
'''
|
|
29
|
+
|
|
30
|
+
import os
|
|
31
|
+
import sys
|
|
32
|
+
|
|
33
|
+
BEAM_MATRIX_BYTES = 8 # bytes per beam pair (COMPLEX)
|
|
34
|
+
PIXEL_BYTES = 4 # float32 images
|
|
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
|
+
|
|
48
|
+
# Memory use above this fraction of the free memory gets a warning
|
|
49
|
+
MEMORY_WARN_FRACTION = 0.5
|
|
50
|
+
|
|
51
|
+
# The images' run time is estimated from one sampling point solved on its own, which the
|
|
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}
|
|
59
|
+
|
|
60
|
+
# Runs estimated to take longer than this get a warning
|
|
61
|
+
LONG_RUN_SECONDS = 60
|
|
62
|
+
|
|
63
|
+
# The timing point is solved only when this many beams or more are diagonalized: below it, runs on
|
|
64
|
+
# a 6-core PC took under 10 seconds at the default sampling, and the point would cost up to 3%.
|
|
65
|
+
PILOT_MIN_NDIAG = 400
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def available_memory():
|
|
69
|
+
'''Free physical memory in bytes, or None if it can't be found.'''
|
|
70
|
+
if sys.platform == 'win32':
|
|
71
|
+
import ctypes
|
|
72
|
+
|
|
73
|
+
class _MemoryStatusEx(ctypes.Structure):
|
|
74
|
+
_fields_ = [('dwLength', ctypes.c_ulong), ('dwMemoryLoad', ctypes.c_ulong),
|
|
75
|
+
('ullTotalPhys', ctypes.c_ulonglong), ('ullAvailPhys', ctypes.c_ulonglong),
|
|
76
|
+
('ullTotalPageFile', ctypes.c_ulonglong),
|
|
77
|
+
('ullAvailPageFile', ctypes.c_ulonglong),
|
|
78
|
+
('ullTotalVirtual', ctypes.c_ulonglong),
|
|
79
|
+
('ullAvailVirtual', ctypes.c_ulonglong),
|
|
80
|
+
('ullAvailExtendedVirtual', ctypes.c_ulonglong)]
|
|
81
|
+
|
|
82
|
+
status = _MemoryStatusEx()
|
|
83
|
+
status.dwLength = ctypes.sizeof(_MemoryStatusEx)
|
|
84
|
+
try:
|
|
85
|
+
if ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(status)):
|
|
86
|
+
return int(status.ullAvailPhys)
|
|
87
|
+
except (AttributeError, OSError):
|
|
88
|
+
return None
|
|
89
|
+
return None
|
|
90
|
+
try:
|
|
91
|
+
return os.sysconf('SC_AVPHYS_PAGES') * os.sysconf('SC_PAGE_SIZE')
|
|
92
|
+
except (AttributeError, ValueError, OSError):
|
|
93
|
+
return None
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def openmp_threads():
|
|
97
|
+
'''The number of threads the backend's OpenMP loops use.'''
|
|
98
|
+
try:
|
|
99
|
+
n = int(os.environ.get('OMP_NUM_THREADS', '').split(',')[0])
|
|
100
|
+
if n > 0:
|
|
101
|
+
return n
|
|
102
|
+
except ValueError:
|
|
103
|
+
pass
|
|
104
|
+
return os.cpu_count() or 1
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def beam_matrix_bytes(nbeams):
|
|
108
|
+
return BEAM_MATRIX_BYTES * nbeams * nbeams
|
|
109
|
+
|
|
110
|
+
|
|
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])
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def gb(nbytes):
|
|
129
|
+
'''A memory size: "8.6 GB", "250 MB" below 1 GB, "4 KB" below 1 MB.'''
|
|
130
|
+
if nbytes < 1024**2:
|
|
131
|
+
return f'{max(1, round(nbytes / 1024))} KB'
|
|
132
|
+
if nbytes < 1024**3:
|
|
133
|
+
return f'{max(1, round(nbytes / 1024**2))} MB'
|
|
134
|
+
return f'{nbytes / 1024**3:.1f} GB'
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def duration(seconds):
|
|
138
|
+
'''A rough duration: "about 3 minutes", "about 1.5 hours".'''
|
|
139
|
+
if seconds < 90:
|
|
140
|
+
n = max(1, round(seconds))
|
|
141
|
+
return f'about {n} second{"" if n == 1 else "s"}'
|
|
142
|
+
if seconds < 5400:
|
|
143
|
+
return f'about {round(seconds / 60)} minutes'
|
|
144
|
+
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,
|
|
132
|
-
|
|
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,59 @@ def add_bloch(target):
|
|
|
220
246
|
self.session_controls=em_controls
|
|
221
247
|
return nsampling, sp
|
|
222
248
|
|
|
223
|
-
def
|
|
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):
|
|
265
|
+
"""
|
|
266
|
+
Before the session's images are made: raise BlochError if they need more memory than is
|
|
267
|
+
free, and warn if they will take long. The time is measured on this computer, by solving
|
|
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.
|
|
272
|
+
"""
|
|
273
|
+
ndiag, ntilt = int(bloch.ndiag_max), int(bloch.ntilt)
|
|
274
|
+
threads = min(_res.openmp_threads(), max(ntilt, 1))
|
|
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()
|
|
281
|
+
if free is not None and need > free:
|
|
282
|
+
images = f'{nslices:,} image' + ('' if nslices == 1 else 's')
|
|
283
|
+
raise BlochError(f'The images need {_res.gb(need)} of memory ({ndiag:,} strong beams '
|
|
284
|
+
f'on {threads} threads, and {images} of '
|
|
285
|
+
f'{det_size} x {det_size}), and this computer has {_res.gb(free)} '
|
|
286
|
+
f'free. Lower omega, gmax or the excitation error limits, or make '
|
|
287
|
+
f'fewer or smaller images, and retry')
|
|
288
|
+
if free is not None and need > _res.MEMORY_WARN_FRACTION * free:
|
|
289
|
+
warnings.warn(f'The images need {_res.gb(need)} of memory, more than half of the '
|
|
290
|
+
f'{_res.gb(free)} free; the computer may slow down.', stacklevel=3)
|
|
291
|
+
|
|
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:
|
|
296
|
+
warnings.warn(f'These Bloch images will take {_res.duration(seconds)} on this '
|
|
297
|
+
f'computer: {ndiag:,} strong beams at each of {ntilt} '
|
|
298
|
+
f'sampling points. To shorten it, lower sampling (the time grows with '
|
|
299
|
+
f'its square), omega, or gmax in em_controls.', stacklevel=3)
|
|
300
|
+
|
|
301
|
+
def getBlochImages(self,
|
|
224
302
|
sample_thickness = DEF_THICKNESS,
|
|
225
303
|
pix_size = DEF_PIXSIZE,
|
|
226
304
|
det_size = DEF_DETSIZE,
|
|
@@ -250,7 +328,8 @@ def add_bloch(target):
|
|
|
250
328
|
:rtype: :py:class:`~pyemaps.ddiffs.BlochImgs`
|
|
251
329
|
:raise ~pyemaps.errors.BlochListError: if *sample_thickness*, *pix_size* or *det_size* is invalid, or there
|
|
252
330
|
are too many thicknesses.
|
|
253
|
-
:raise ~pyemaps.errors.BlochError: if the images
|
|
331
|
+
:raise ~pyemaps.errors.BlochError: if the images need more memory than is free, they can't be made, or
|
|
332
|
+
the file can't be written.
|
|
254
333
|
|
|
255
334
|
.. warning::
|
|
256
335
|
|
|
@@ -260,6 +339,11 @@ def add_bloch(target):
|
|
|
260
339
|
- the detector size *det_size*: 256 instead of the default 512, for example, uses a
|
|
261
340
|
quarter of the image memory;
|
|
262
341
|
- the number of sampling points *sampling*.
|
|
342
|
+
|
|
343
|
+
Before making the images, pyEMAPS checks that they fit in the free memory. When 400
|
|
344
|
+
or more beams are diagonalized, it also times one sampling point on this computer, and
|
|
345
|
+
if the images will take more than a minute, a Python warning says roughly how long. The time grows with the square of *sampling*
|
|
346
|
+
and steeply with the number of beams diagonalized, which *omega* and *gmax* set.
|
|
263
347
|
"""
|
|
264
348
|
from copy import deepcopy
|
|
265
349
|
|
|
@@ -291,6 +375,9 @@ def add_bloch(target):
|
|
|
291
375
|
if ndep > MAX_DEPTH:
|
|
292
376
|
raise BlochListError(f'Number of sample thickness cannot exceed {MAX_DEPTH}')
|
|
293
377
|
|
|
378
|
+
self._checkBlochImages(det_size, ndep * (bloch.getncalcbeams() if nType == TY_LACBED else 1),
|
|
379
|
+
thlist)
|
|
380
|
+
|
|
294
381
|
# save the input as optional control attributes
|
|
295
382
|
imgfn =''
|
|
296
383
|
if bSave:
|
|
@@ -591,7 +678,8 @@ def add_bloch(target):
|
|
|
591
678
|
:type bSave: bool, optional
|
|
592
679
|
:return: the images, each with the controls and thickness it was made with.
|
|
593
680
|
:rtype: :py:class:`~pyemaps.ddiffs.BlochImgs`
|
|
594
|
-
:raise ~pyemaps.errors.BlochError: if an input is invalid
|
|
681
|
+
:raise ~pyemaps.errors.BlochError: if an input is invalid, the run needs more memory than is free, or
|
|
682
|
+
the simulation fails.
|
|
595
683
|
:raise ~pyemaps.errors.BlochListError: if *sample_thickness*, *pix_size* or *det_size* is invalid.
|
|
596
684
|
|
|
597
685
|
.. warning::
|
|
@@ -602,6 +690,10 @@ def add_bloch(target):
|
|
|
602
690
|
- the detector size *det_size*: 256 instead of the default 512, for example, uses a
|
|
603
691
|
quarter of the image memory;
|
|
604
692
|
- the number of sampling points *sampling*.
|
|
693
|
+
|
|
694
|
+
The run stops with a ``BlochError`` before allocating memory that isn't free, and a
|
|
695
|
+
Python warning says if the images will take more than a minute, timed on this
|
|
696
|
+
computer (see :py:meth:`~pyemaps.crystals.Crystal.getBlochImages`).
|
|
605
697
|
"""
|
|
606
698
|
try:
|
|
607
699
|
|
|
@@ -654,6 +746,7 @@ def add_bloch(target):
|
|
|
654
746
|
target.getSCMatrix = getSCMatrix
|
|
655
747
|
target.getBlochImages = getBlochImages
|
|
656
748
|
target.getCalculatedBeams = getCalculatedBeams
|
|
749
|
+
target._checkBlochImages = _checkBlochImages
|
|
657
750
|
# target.getLACBEDImage = getLACBEDImage
|
|
658
751
|
# ---These calls must be between beginBloch and endBloch calls
|
|
659
752
|
|
|
@@ -87,7 +87,7 @@ def add_dpgen(target):
|
|
|
87
87
|
:raise ~pyemaps.errors.LicenseError: without an active pyEMAPS license (emaps 2.6.0
|
|
88
88
|
and later).
|
|
89
89
|
|
|
90
|
-
.. image:: https://
|
|
90
|
+
.. image:: https://raw.githubusercontent.com/emlab-solutions/imagepypy/main/stereoprojectionmap.png
|
|
91
91
|
:width: 75%
|
|
92
92
|
:align: center
|
|
93
93
|
"""
|
|
@@ -138,12 +138,11 @@ def add_dpgen(target):
|
|
|
138
138
|
#release the memory
|
|
139
139
|
dpgen.cleanup()
|
|
140
140
|
|
|
141
|
-
if ret
|
|
142
|
-
from
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
|
@@ -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://
|
|
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
|
|
@@ -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]``.
|
|
@@ -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.
|