collect_bunch#
- orbit.bunch_utils.collect_bunch(bunch, output_dir='/tmp', return_memmap=True)[source]#
Collects attributes from a PyOrbit Bunch across all MPI ranks and returns it as a dictionary.
- Parameters
bunch (Bunch) – The PyOrbit::Bunch object from which to collect attributes.
output_dir (str | pathlib.Path, optional) – The director to use for temporary storage of the bunch coordinates on each MPI rank. If None, the bunch will be stored in “/tmp”. Note: take care that the temporary files are created in a directory where all MPI ranks have write access.
return_memmap (bool, optional) – Return the bunch coordinates as a memory-mapped NumPy array, otherwise the entire array is copied into RAM and returned as normal NDArray. Default is True.
- Returns
A dictionary containing the collected bunch attributes. Returns None if not on the root MPI rank or if the global bunch size is 0.
- Return type
BunchDict | None
- Raises
FileNotFoundError – If the temporary files created by non-root MPI ranks could not be found by the root rank during the collection process.