pisces.extensions.simulation.gadget.particles.GadgetParticleDataset.__init__#
- GadgetParticleDataset.__init__(path: str | Path, mode='r+')#
Initialize a
ParticleDataset
from a file on disk.This constructor opens the specified HDF5 file and validates the global metadata to ensure that it conforms to the expected format / structure.
- Parameters:
path (
str
orPath
) – The path to the HDF5 file containing the particle data. This can be a string or apathlib.Path
object. If the path does not exist, a FileNotFoundError is raised.mode (
str
, optional) –The mode in which to open the HDF5 file. Defaults to “r+” (read/write mode).
The available modes are:
”r”: Read-only mode. The file must exist.
”r+”: Read/write mode. The file must exist.
”w”: Write mode. Creates a new file or truncates an existing file.
”w-”: Write mode, but fails if the file already exists.
”x”: Exclusive creation mode. Fails if the file already exists.
Notes
At this level, initialization consists of only the following 4 steps:
Set the path to the HDF5 file and check that it exists.
Open the HDF5 file in the specified mode and create the handle reference to the file.
Load the global metadata from the file using the serializer.
Validate the dataset structure by calling the
.__validate__
method.
Subclasses may extend this behavior to include custom behavior beyond this. Additionally, the
.__post_init__
method is called after initialization, allowing for further customization or setup that is specific to the subclass.