Gadget4ParticleDataset#
- class pisces.particles.gadget.Gadget4ParticleDataset(path: str | Path, mode='r+')[source]#
Representation of a Gadget-4 style particle dataset.
This class specializes
GadgetLikeParticleDatasetfor the conventions of Gadget-4 HDF5 initial conditions and snapshots. It defines the expected header structure, field names, and dataset generation logic for creating valid Gadget-4–compatible files.Methods
__init__(path[, mode])Initialize a
ParticleDatasetfrom 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, ...[, ntypes, ...])Build a new Gadget-4 particle dataset.
concatenate_inplace(*others[, groups])Concatenate another
ParticleDatasetinto 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.
generate_file_skeleton(path, ...)Generate the basic file skeleton for a Gadget-like particle dataset.
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 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 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
List of all fields (datasets) available in the dataset, in dot notation.
Global metadata attributes at the root level of the HDF5 file.
The HDF5 file handle for the particle dataset.
Retrieve the attributes of the
Headergroup as a dictionary.Access the
Headergroup of the Gadget particle dataset.Number of particles in each particle group.
Names of all particle groups present in the dataset.
The path to the HDF5 file containing the particle dataset.
Total number of particles across all particle groups.