yt.frontends.ramses.field_handlers module

class yt.frontends.ramses.field_handlers.FieldFileHandler(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], ...] | None = None
config_field: str | None = None
abstract classmethod detect_fields(ds)[source]

Called once to setup the fields of this type

It should set the following static variables:

  • parameters: dictionary

    Dictionary containing the variables. The keys should match those of cls.attrs

  • field_list: list of (ftype, fname)

    The list of the field present in the file

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
ftype: str | None = None
classmethod get_detected_fields(ds)[source]

Get the detected fields from the registry.

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 = None
property level_count

Return the number of cells per level.

classmethod load_fields_from_yt_config() list[str][source]
property offset

Compute the offsets of the fields.

By default, it skips the header (as defined by cls.attrs) and computes the offset at each level.

It should be generic enough for most of the cases, but if the structure of your fluid file is non-canonical, change this.

classmethod purge_detected_fields(ds)[source]

Purge the registry.

This should be called on dataset creation to force the field detection to be called.

classmethod set_detected_fields(ds, fields)[source]

Store the detected fields into the registry.

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.field_handlers.GravFieldFileHandler(domain)[source]

Bases: FieldFileHandler

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], ...] | None = (('ncpu', 1, 'i'), ('nvar', 1, 'i'), ('nlevelmax', 1, 'i'), ('nboundary', 1, 'i'))
config_field: str | None = 'ramses-grav'
classmethod detect_fields(ds)[source]

Called once to setup the fields of this type

It should set the following static variables:

  • parameters: dictionary

    Dictionary containing the variables. The keys should match those of cls.attrs

  • field_list: list of (ftype, fname)

    The list of the field present in the file

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 = 'grav_{iout:05d}.out{icpu:05d}'
ftype: str | None = 'gravity'
classmethod get_detected_fields(ds)

Get the detected fields from the registry.

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 = None
property level_count

Return the number of cells per level.

classmethod load_fields_from_yt_config() list[str]
property offset

Compute the offsets of the fields.

By default, it skips the header (as defined by cls.attrs) and computes the offset at each level.

It should be generic enough for most of the cases, but if the structure of your fluid file is non-canonical, change this.

classmethod purge_detected_fields(ds)

Purge the registry.

This should be called on dataset creation to force the field detection to be called.

classmethod set_detected_fields(ds, fields)

Store the detected fields into the registry.

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.field_handlers.HandlerMixin[source]

Bases: object

This contains all the shared methods to handle RAMSES files.

This is not supposed to be user-facing.

classmethod any_exist(ds)[source]

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.

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.

setup_handler(domain)[source]

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.field_handlers.HydroFieldFileHandler(domain)[source]

Bases: FieldFileHandler

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], ...] | None = (('ncpu', 1, 'i'), ('nvar', 1, 'i'), ('ndim', 1, 'i'), ('nlevelmax', 1, 'i'), ('nboundary', 1, 'i'), ('gamma', 1, 'd'))
config_field: str | None = 'ramses-hydro'
classmethod detect_fields(ds)[source]

Called once to setup the fields of this type

It should set the following static variables:

  • parameters: dictionary

    Dictionary containing the variables. The keys should match those of cls.attrs

  • field_list: list of (ftype, fname)

    The list of the field present in the file

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 = 'hydro_file_descriptor.txt'
fname: str | None = 'hydro_{iout:05d}.out{icpu:05d}'
ftype: str | None = 'ramses'
classmethod get_detected_fields(ds)

Get the detected fields from the registry.

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 = None
property level_count

Return the number of cells per level.

classmethod load_fields_from_yt_config() list[str]
property offset

Compute the offsets of the fields.

By default, it skips the header (as defined by cls.attrs) and computes the offset at each level.

It should be generic enough for most of the cases, but if the structure of your fluid file is non-canonical, change this.

classmethod purge_detected_fields(ds)

Purge the registry.

This should be called on dataset creation to force the field detection to be called.

classmethod set_detected_fields(ds, fields)

Store the detected fields into the registry.

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.field_handlers.RTFieldFileHandler(domain)[source]

Bases: FieldFileHandler

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], ...] | None = (('ncpu', 1, 'i'), ('nvar', 1, 'i'), ('ndim', 1, 'i'), ('nlevelmax', 1, 'i'), ('nboundary', 1, 'i'), ('gamma', 1, 'd'))
config_field: str | None = 'ramses-rt'
classmethod detect_fields(ds)[source]

Called once to setup the fields of this type

It should set the following static variables:

  • parameters: dictionary

    Dictionary containing the variables. The keys should match those of cls.attrs

  • field_list: list of (ftype, fname)

    The list of the field present in the file

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 = 'rt_file_descriptor.txt'
fname: str | None = 'rt_{iout:05d}.out{icpu:05d}'
ftype: str | None = 'ramses-rt'
classmethod get_detected_fields(ds)

Get the detected fields from the registry.

classmethod get_rt_parameters(ds)[source]
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 = None
property level_count

Return the number of cells per level.

classmethod load_fields_from_yt_config() list[str]
property offset

Compute the offsets of the fields.

By default, it skips the header (as defined by cls.attrs) and computes the offset at each level.

It should be generic enough for most of the cases, but if the structure of your fluid file is non-canonical, change this.

classmethod purge_detected_fields(ds)

Purge the registry.

This should be called on dataset creation to force the field detection to be called.

classmethod set_detected_fields(ds, fields)

Store the detected fields into the registry.

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.field_handlers.get_field_handlers()[source]
yt.frontends.ramses.field_handlers.register_field_handler(ph)[source]