Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added sorting of trajectories according to stepid #218

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion aiida_cp2k/utils/datatype_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,21 @@ def _merge_trajectories_into_dictionary(*trajectories, unique_stepids=False):
)
final_trajectory_dict[array_name] = merged_array

# reorder arrays to have the same order as in the original whole trajectory
try:
stepids = final_trajectory_dict["stepids"]
except KeyError:
stepids = np.concatenate([traj.get_stepids() for traj in trajectories], axis=0)
sorted_indices = np.argsort(stepids)
for array_name in array_names:
final_trajectory_dict[array_name] = final_trajectory_dict[array_name][
sorted_indices
]

# If unique_stepids is True, we only keep the unique stepids.
# The other arrays are then also reduced to the unique stepids.
if unique_stepids:
stepids = np.concatenate([traj.get_stepids() for traj in trajectories], axis=0)
# stepids = np.concatenate([traj.get_stepids() for traj in trajectories], axis=0)
final_trajectory_dict["stepids"], unique_indices = np.unique(
stepids, return_index=True
)
Expand Down
Loading