Skip to content

ParticleGroup.from_hdf5 - #156

Open
electronsandstuff wants to merge 24 commits into
ChristopherMayes:masterfrom
electronsandstuff:pierce/from_hdf5
Open

ParticleGroup.from_hdf5#156
electronsandstuff wants to merge 24 commits into
ChristopherMayes:masterfrom
electronsandstuff:pierce/from_hdf5

Conversation

@electronsandstuff

@electronsandstuff electronsandstuff commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Per discussion with @ChristopherMayes, this PR adds a new method .from_hdf5 to ParticleGroup with a time_offset argument. Additional cleanup is performed.

  • Add pre-commit to conda env
  • Add .vscode to .gitignore
  • Add unit tests for all existing input types for __init__ argument h5
    • Path, h5py.File, h5py.Group, "legacy" group with no species
  • New exceptions.py with custom BeamPhysics exceptions for HDF5 file load errors
  • load_bunch_data and __init__ are broken into methods to handle each atomic part of loading the only species in the only iteration of a particle group.
    • load_species_data gets the array dict from one species
    • _only_species_group loads the only species in the OpenPMD iteration passed to it (or passes through to handle "legacy" version w/o species)
    • _only_iteration_group gets the only iteration, raising on none or multiple. Handles files, groups, paths.
    • _only_iteration_only_species_group handles the file loading, existing behavior of passing through raw species group.
  • Move load_bunch_data to readers.py and keep import there for legacy support
  • Time offset loading methods
    • load_time_offset to load from an open species group
    • load_only_time_offset loads from only species from only iteration with same input semantics as .from_hdf5
  • Add t_offset to ParticleGroupt.write
  • Updated documentation
    • docs/examples/write_examples.ipynb updated to use read w/o time offset
    • docs/examples/read_examples.ipynb demostrates .from_hdf5 and time offset methods
    • New docs/api/readers.md

Note: this PR also includes the changes noted in #152. It was intended as a stacked PR, but due to working out of a fork is set up to target main instead and will supersede it.

@electronsandstuff
electronsandstuff marked this pull request as ready for review August 25, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant