yt.frontends.ramses.particle_handlers module

class yt.frontends.ramses.particle_handlers.DefaultParticleFileHandler(domain)[source]

Bases: ParticleFileHandler

classmethod any_exist(ds)

This function should return True if the kind of particle represented by the class exists in the dataset. It takes as argument the class itself -not an instance- and a dataset.

Parameters:

ds (a Ramses Dataset) –

Note

This function is usually called once at the initialization of the RAMSES Dataset structure to determine if the particle type (e.g. regular particles) exists.

attrs: tuple[tuple[str, int, str], ...] = (('ncpu', 1, 'i'), ('ndim', 1, 'i'), ('npart', 1, 'i'), ('localseed', -1, 'i'), ('nstar_tot', 1, 'i'), ('mstar_tot', 1, 'd'), ('mstar_lost', 1, 'd'), ('nsink', 1, 'i'))
config_field: str | None = 'ramses-particles'
property exists

This function should return True if the file the instance exists. It is called for each file of the type found on the disk.

By default, it just returns whether the file exists. Override it for more complex cases.

field_offsets = None
field_types = None
file_descriptor: str | None = 'part_file_descriptor.txt'
fname: str | None = 'part_{iout:05d}.out{icpu:05d}'
property has_descriptor

This function should return True if a file descriptor exists.

By default, it just returns whether the file exists. Override it for more complex cases.

known_fields: list[tuple[str, str]] | None = [('particle_position_x', 'd'), ('particle_position_y', 'd'), ('particle_position_z', 'd'), ('particle_velocity_x', 'd'), ('particle_velocity_y', 'd'), ('particle_velocity_z', 'd'), ('particle_mass', 'd'), ('particle_identity', 'i'), ('particle_refinement_level', 'i')]
local_particle_count = None
ptype: str | None = 'io'
read_header()[source]

This function is called once per file. It should:

  • read the header of the file and store any relevant information

  • detect the fields in the file

  • compute the offsets (location in the file) of each field

It is in charge of setting self.field_offsets and self.field_types.

  • field_offsets: dictionary: tuple -> integer

    A dictionary that maps (type, field_name) to their location in the file (integer)

  • field_types: dictionary: tuple -> character

    A dictionary that maps (type, field_name) to their type (character), following Python’s struct convention.

reader(subset, fields, count)

General file handler for binary file, called by _read_particle_subset

Parameters:
  • particle (ParticleFileHandler) – the particle class we want to read

  • subset (RAMSESDomainSubset) – A RAMSES domain subset object

  • fields (list of tuple) – The fields to read

  • count (integer) – The number of elements to count

setup_handler(domain)

Initialize an instance of the class. This automatically sets the full path to the file. This is not intended to be overridden in most cases.

If you need more flexibility, rewrite this function to your need in the inherited class.

class yt.frontends.ramses.particle_handlers.ParticleFileHandler(domain)[source]

Bases: ABC, HandlerMixin

Abstract class to handle particles in RAMSES. Each instance represents a single file (one domain).

To add support to a new particle file, inherit from this class and implement all functions containing a NotImplementedError.

See SinkParticleFileHandler for an example implementation.

classmethod any_exist(ds)

This function should return True if the kind of particle represented by the class exists in the dataset. It takes as argument the class itself -not an instance- and a dataset.

Parameters:

ds (a Ramses Dataset) –

Note

This function is usually called once at the initialization of the RAMSES Dataset structure to determine if the particle type (e.g. regular particles) exists.

attrs: tuple[tuple[str, int, str], ...]
config_field: str | None = None
property exists

This function should return True if the file the instance exists. It is called for each file of the type found on the disk.

By default, it just returns whether the file exists. Override it for more complex cases.

field_offsets = None
field_types = None
file_descriptor: str | None = None
fname: str | None = None
property has_descriptor

This function should return True if a file descriptor exists.

By default, it just returns whether the file exists. Override it for more complex cases.

known_fields: list[tuple[str, str]] | None = None
local_particle_count = None
ptype: str | None = None
abstract read_header()[source]

This function is called once per file. It should:

  • read the header of the file and store any relevant information

  • detect the fields in the file

  • compute the offsets (location in the file) of each field

It is in charge of setting self.field_offsets and self.field_types.

  • field_offsets: dictionary: tuple -> integer

    A dictionary that maps (type, field_name) to their location in the file (integer)

  • field_types: dictionary: tuple -> character

    A dictionary that maps (type, field_name) to their type (character), following Python’s struct convention.

setup_handler(domain)

Initialize an instance of the class. This automatically sets the full path to the file. This is not intended to be overridden in most cases.

If you need more flexibility, rewrite this function to your need in the inherited class.

class yt.frontends.ramses.particle_handlers.SinkParticleFileHandler(domain)[source]

Bases: ParticleFileHandler

Handle sink files

classmethod any_exist(ds)

This function should return True if the kind of particle represented by the class exists in the dataset. It takes as argument the class itself -not an instance- and a dataset.

Parameters:

ds (a Ramses Dataset) –

Note

This function is usually called once at the initialization of the RAMSES Dataset structure to determine if the particle type (e.g. regular particles) exists.

attrs: tuple[tuple[str, int, str], ...] = (('nsink', 1, 'i'), ('nindsink', 1, 'i'))
config_field: str | None = 'ramses-sink-particles'
property exists

This function should return True if the file the instance exists. It is called for each file of the type found on the disk.

By default, it just returns whether the file exists. Override it for more complex cases.

field_offsets = None
field_types = None
file_descriptor: str | None = 'sink_file_descriptor.txt'
fname: str | None = 'sink_{iout:05d}.out{icpu:05d}'
property has_descriptor

This function should return True if a file descriptor exists.

By default, it just returns whether the file exists. Override it for more complex cases.

known_fields: list[tuple[str, str]] | None = [('particle_identifier', 'i'), ('particle_mass', 'd'), ('particle_position_x', 'd'), ('particle_position_y', 'd'), ('particle_position_z', 'd'), ('particle_velocity_x', 'd'), ('particle_velocity_y', 'd'), ('particle_velocity_z', 'd'), ('particle_birth_time', 'd'), ('BH_real_accretion', 'd'), ('BH_bondi_accretion', 'd'), ('BH_eddington_accretion', 'd'), ('BH_esave', 'd'), ('gas_spin_x', 'd'), ('gas_spin_y', 'd'), ('gas_spin_z', 'd'), ('BH_spin_x', 'd'), ('BH_spin_y', 'd'), ('BH_spin_z', 'd'), ('BH_spin', 'd'), ('BH_efficiency', 'd')]
local_particle_count = None
ptype: str | None = 'sink'
read_header()[source]

This function is called once per file. It should:

  • read the header of the file and store any relevant information

  • detect the fields in the file

  • compute the offsets (location in the file) of each field

It is in charge of setting self.field_offsets and self.field_types.

  • field_offsets: dictionary: tuple -> integer

    A dictionary that maps (type, field_name) to their location in the file (integer)

  • field_types: dictionary: tuple -> character

    A dictionary that maps (type, field_name) to their type (character), following Python’s struct convention.

reader(subset, fields, count)

General file handler for binary file, called by _read_particle_subset

Parameters:
  • particle (ParticleFileHandler) – the particle class we want to read

  • subset (RAMSESDomainSubset) – A RAMSES domain subset object

  • fields (list of tuple) – The fields to read

  • count (integer) – The number of elements to count

setup_handler(domain)

Initialize an instance of the class. This automatically sets the full path to the file. This is not intended to be overridden in most cases.

If you need more flexibility, rewrite this function to your need in the inherited class.

class yt.frontends.ramses.particle_handlers.SinkParticleFileHandlerCsv(domain)[source]

Bases: ParticleFileHandler

Handle sink files from a csv file, the format from the sink particle in ramses

classmethod any_exist(ds)

This function should return True if the kind of particle represented by the class exists in the dataset. It takes as argument the class itself -not an instance- and a dataset.

Parameters:

ds (a Ramses Dataset) –

Note

This function is usually called once at the initialization of the RAMSES Dataset structure to determine if the particle type (e.g. regular particles) exists.

attrs: tuple[tuple[str, int, str], ...] = (('nsink', 1, 'i'), ('nindsink', 1, 'i'))
config_field: str | None = 'ramses-sink-particles'
property exists

This function should return True if the file the instance exists. It is called for each file of the type found on the disk.

By default, it just returns whether the file exists. Override it for more complex cases.

field_offsets = None
field_types = None
file_descriptor: str | None = None
fname: str | None = 'sink_{iout:05d}.csv'
property has_descriptor

This function should return True if a file descriptor exists.

By default, it just returns whether the file exists. Override it for more complex cases.

known_fields: list[tuple[str, str]] | None = None
local_particle_count = None
ptype: str | None = 'sink_csv'
read_header()[source]

This function is called once per file. It should:

  • read the header of the file and store any relevant information

  • detect the fields in the file

  • compute the offsets (location in the file) of each field

It is in charge of setting self.field_offsets and self.field_types.

  • field_offsets: dictionary: tuple -> integer

    A dictionary that maps (type, field_name) to their location in the file (integer)

  • field_types: dictionary: tuple -> character

    A dictionary that maps (type, field_name) to their type (character), following Python’s struct convention.

reader(subset, fields, count)

General file handler for csv file, called by _read_particle_subset

Parameters:
  • particle (ParticleFileHandler) – the particle class we want to read

  • subset (RAMSESDomainSubset) – A RAMSES domain subset object

  • fields (list of tuple) – The fields to read

  • count (integer) – The number of elements to count

setup_handler(domain)

Initialize an instance of the class. This automatically sets the full path to the file. This is not intended to be overridden in most cases.

If you need more flexibility, rewrite this function to your need in the inherited class.

yt.frontends.ramses.particle_handlers.get_particle_handlers()[source]
yt.frontends.ramses.particle_handlers.register_particle_handler(ph)[source]