Skip to content

Commit a28eda5

Browse files
committed
Add simple progress bar
1 parent 275750c commit a28eda5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

diffsims/generators/simulation_generator.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"""Kinematic Diffraction Simulation Generator."""
2020

2121
from typing import Union, Sequence
22+
2223
import numpy as np
24+
from tqdm import tqdm
2325

2426
from orix.quaternion import Rotation
2527
from orix.crystal_map import Phase
@@ -139,6 +141,7 @@ def calculate_diffraction2d(
139141
max_excitation_error: float = 1e-2,
140142
shape_factor_width: float = None,
141143
debye_waller_factors: dict = None,
144+
show_progressbar: bool = False,
142145
):
143146
"""Calculates the diffraction pattern for one or more phases given a list
144147
of rotations for each phase.
@@ -166,6 +169,8 @@ def calculate_diffraction2d(
166169
control. If not set will be set equal to max_excitation_error.
167170
debye_waller_factors
168171
Maps element names to their temperature-dependent Debye-Waller factors.
172+
show_progressbar
173+
If True, display a progressbar. Defaults to False
169174
170175
Returns
171176
-------
@@ -196,7 +201,13 @@ def calculate_diffraction2d(
196201
include_zero_vector=with_direct_beam,
197202
)
198203
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:
200211
# Calculate the reciprocal lattice vectors that intersect the Ewald sphere.
201212
(
202213
intersected_vectors,

0 commit comments

Comments
 (0)