Skip to content

Commit

Permalink
Merge pull request #183 from seismic-anisotropy/add-h5part-reader-pro…
Browse files Browse the repository at this point in the history
…gress

style: Add tqdm progress bar to h5part extractor
  • Loading branch information
Patol75 authored Mar 28, 2024
2 parents 5ac42b1 + 7cb58c3 commit 77bbf12
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies = [
"matplotlib", # Plotting library, The.
"cmcrameri", # Matplotlib colormaps using the palettes designed by Fabio Crameri.
"h5py", # For reading Fluidity .h5part files.
"tqdm", # For progress bars (for long-running CLI scripts)
]

[project.optional-dependencies]
Expand Down
5 changes: 4 additions & 1 deletion src/pydrex/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import meshio
import numpy as np
import yaml
from tqdm import tqdm

from pydrex import core as _core
from pydrex import exceptions as _err
Expand Down Expand Up @@ -80,7 +81,9 @@ def extract_h5part(file, phase, fabric, n_grains, output):
fractions = np.empty((n_timesteps, n_grains))

strains = np.zeros(n_timesteps)
for t, k in enumerate(steps):
for t, k in enumerate(
tqdm(steps, desc=f"Extracting particle {particle_id}")
):
# Extract particle position.
x[t] = f[f"{k}/x"][particle_id - 1]
y[t] = f[f"{k}/y"][particle_id - 1]
Expand Down

0 comments on commit 77bbf12

Please sign in to comment.