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'))¶
- property birth_file_fname¶
- 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.
- handle_field(field: tuple[str, str], data_dict: dict[tuple[str, str], ndarray])[source]¶
This function allows custom code to be called to handle special cases, such as the particle birth time.
It updates the data_dict dictionary with the new data.
- property has_birth_file¶
- 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[FieldKey] = [('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')]¶
- 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
- 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.
- 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.
- handle_field(field: tuple[str, str], data_dict: dict[tuple[str, str], ndarray])[source]¶
This function allows custom code to be called to handle special cases, such as the particle birth time.
It updates the data_dict dictionary with the new data.
- 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.
- 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.
- reader: Callable[[ParticleFileHandler, RAMSESDomainSubset, list[tuple[str, str]], int], dict[tuple[str, str], ndarray]]¶
- 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.
- 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.
- handle_field(field: tuple[str, str], data_dict: dict[tuple[str, str], ndarray])¶
This function allows custom code to be called to handle special cases, such as the particle birth time.
It updates the data_dict dictionary with the new data.
- 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[FieldKey] = [('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')]¶
- 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
- 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.
- 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.
- handle_field(field: tuple[str, str], data_dict: dict[tuple[str, str], ndarray])[source]¶
This function allows custom code to be called to handle special cases, such as the particle birth time.
It updates the data_dict dictionary with the new data.
- 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.
- 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
- 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.