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 | os.PathLike, optional) – The director to use for temporary storage of the bunch coordinates on each MPI rank (default: “/tmp”).

  • 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: True).

Return type

orbit.bunch_utils.serialize.BunchDict | None

Note

Take care that the temporary files are created in a directory which all MPI ranks have write access.

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.

Parameters
  • bunch (Bunch) –

  • output_dir (str | os.PathLike) –

  • return_memmap (bool) –