|
19 | 19 | """Kinematic Diffraction Simulation Generator.""" |
20 | 20 |
|
21 | 21 | from typing import Union, Sequence |
| 22 | + |
22 | 23 | import numpy as np |
| 24 | +from tqdm import tqdm |
23 | 25 |
|
24 | 26 | from orix.quaternion import Rotation |
25 | 27 | from orix.crystal_map import Phase |
@@ -139,6 +141,7 @@ def calculate_diffraction2d( |
139 | 141 | max_excitation_error: float = 1e-2, |
140 | 142 | shape_factor_width: float = None, |
141 | 143 | debye_waller_factors: dict = None, |
| 144 | + show_progressbar: bool = False, |
142 | 145 | ): |
143 | 146 | """Calculates the diffraction pattern for one or more phases given a list |
144 | 147 | of rotations for each phase. |
@@ -166,6 +169,8 @@ def calculate_diffraction2d( |
166 | 169 | control. If not set will be set equal to max_excitation_error. |
167 | 170 | debye_waller_factors |
168 | 171 | Maps element names to their temperature-dependent Debye-Waller factors. |
| 172 | + show_progressbar |
| 173 | + If True, display a progressbar. Defaults to False |
169 | 174 |
|
170 | 175 | Returns |
171 | 176 | ------- |
@@ -196,7 +201,13 @@ def calculate_diffraction2d( |
196 | 201 | include_zero_vector=with_direct_beam, |
197 | 202 | ) |
198 | 203 | phase_vectors = [] |
199 | | - for rot in rotate: |
| 204 | + |
| 205 | + # Progress bar setup |
| 206 | + rotate_iter = rotate |
| 207 | + if show_progressbar: |
| 208 | + rotate_iter = tqdm(rotate_iter, desc=p.name, total=rotate.size) |
| 209 | + |
| 210 | + for rot in rotate_iter: |
200 | 211 | # Calculate the reciprocal lattice vectors that intersect the Ewald sphere. |
201 | 212 | ( |
202 | 213 | intersected_vectors, |
|
0 commit comments