GadgetParticleDataset#

class pisces.extensions.simulation.gadget.particles.GadgetParticleDataset(path: str | Path, mode='r+')[source]#

Representation of a Gadget-compatible particle dataset.

This class provides a structured interface for building, reading, and manipulating HDF5 files that follow the Gadget-4 (and related Gadget-family) conventions for initial condition (IC) and snapshot particle data. It extends the generic ParticleDataset with Gadget-specific conventions.

Methods

__init__(path[, mode])

Initialize a ParticleDataset from a file on disk.

add_particle_field(group_name, field_name, data)

Add a new field (dataset) to an existing particle group.

add_particle_ids([groups, policy, overwrite])

Add unique particle IDs to specified groups.

add_particle_type(name, num_particles[, ...])

Add a new particle group to the dataset.

apply_linear_transformation(matrix[, ...])

Apply a linear transformation matrix to vector fields in specified particle groups.

build_particle_dataset(path, *args[, ...])

Create a new ParticleDataset HDF5 file with the given fields.

concatenate_inplace(*others[, groups])

Concatenate another ParticleDataset into this one, extending specified groups.

copy(output_path[, overwrite])

Create a full copy of this particle dataset at a new location.

cut_particles_to_bbox(bbox[, groups, center])

Cut out particles outside the specified bounding box.

delete_field_metadata_keys(group_name, ...)

Delete one or more metadata keys from a specific field in a particle group.

delete_global_metadata_keys(*keys)

Delete one or more metadata keys from the global metadata.

delete_group_metadata_keys(group_name, *keys)

Delete one or more metadata keys from a specific particle group.

extend_group(group_name, num_particles[, fields])

Extend a particle group by adding new particles and updating all fields.

get_field_metadata(group_name, field_name)

Get the metadata attributes for a specific field in a particle group.

get_field_units(group_name, field_name)

Get the units of a specific particle field.

get_global_metadata()

Get the global metadata attributes of the dataset.

get_group_metadata(group_name)

Get the metadata attributes for a specific particle group.

get_particle_field(group_name, field_name)

Get the particle field data as a unyt array.

get_particle_field_handle(group_name, field_name)

Get the HDF5 dataset handle for a specific field in a particle group.

get_particle_fields(fields)

Get multiple particle fields as a dictionary of unyt arrays.

get_particle_group_handle(group_name)

Get the HDF5 group handle for a specific particle group.

offset_particle_positions(offset[, groups])

Apply a constant offset to particle positions in specified groups.

offset_particle_velocities(offset[, groups])

Apply a constant offset to particle velocities in specified groups.

reduce_group(group_name, mask)

Reduce a particle group by applying a boolean mask.

reload_global_metadata()

Reload the global metadata from the HDF5 file.

remove_particle_field(group_name, field_name)

Remove a specific field from a particle group.

remove_particle_group(group_name)

Remove a particle group from the dataset.

rename_field(group_name, old_name, new_name)

Rename a field within a particle group.

reorient_particles(direction_vector, spin[, ...])

Reorient particles given a direction vector and spin angle.

rotate_particles(norm, angle[, groups, fields])

Rotate vector fields in specified particle groups around a given axis.

update_field_metadata(group_name, ...)

Update the metadata attributes for a specific field in a particle group.

update_global_metadata(metadata)

Update the global metadata attributes of the dataset.

update_group_metadata(group_name, metadata)

Update the metadata attributes for a specific particle group.

update_particle_ids([groups, policy])

Update (reset) particle IDs for groups that already have an ID field.

Attributes

fields

List of all fields (datasets) available in the dataset, in dot notation.

global_metadata

Global metadata attributes at the root level of the HDF5 file.

handle

The HDF5 file handle for the particle dataset.

header

Retrieve the attributes of the Header group as a dictionary.

header_handle

Access the Header group of the Gadget particle dataset.

num_particles

Number of particles in each particle group.

particle_groups

Names of all particle groups present in the dataset.

path

The path to the HDF5 file containing the particle dataset.

total_particles

Total number of particles across all particle groups.