# yt.fields.derived_field module¶

Derived field base class.

class yt.fields.derived_field.DerivedField(name, sampling_type, function, units=None, take_log=True, validators=None, particle_type=None, vector_field=False, display_field=True, not_in_all=False, display_name=None, output_units=None, dimensions=None, ds=None, nodal_flag=None)[source]

Bases: object

This is the base class used to describe a cell-by-cell derived field.

Parameters: name (str) – is the name of the field. function (callable) – A function handle that defines the field. Should accept arguments (field, data) units (str) – A plain text string encoding the unit, or a query to a unit system of a dataset. Powers must be in python syntax (** instead of ^). If set to “auto” the units will be inferred from the units of the return value of the field function, and the dimensions keyword must also be set (see below). take_log (bool) – Describes whether the field should be logged validators (list) – A list of FieldValidator objects sampling_type (string, default = "cell") – How is the field sampled? This can be one of the following options at present: “cell” (cell-centered), “discrete” (or “particle”) for discretely sampled data. particle_type (bool) – (Deprecated) Is this a particle (1D) field? This is deprecated. Use sampling_type = “discrete” or sampling_type = “particle”. This will override sampling_type. vector_field (bool) – Describes the dimensionality of the field. Currently unused. display_field (bool) – Governs its appearance in the dropdowns in Reason not_in_all (bool) – Used for baryon fields from the data that are not in all the grids display_name (str) – A name used in the plots output_units (str) – For fields that exist on disk, which we may want to convert to other fields or that get aliased to themselves, we can specify a different desired output unit than the unit found on disk. dimensions (str or object from yt.units.dimensions) – The dimensions of the field, only needed if units=”auto” and only used for error checking. nodal_flag (array-like with three components) – This describes how the field is centered within a cell. If nodal_flag is [0, 0, 0], then the field is cell-centered. If any of the components of nodal_flag are 1, then the field is nodal in that direction, meaning it is defined at the lo and hi sides of the cell rather than at the center. For example, a field with nodal_flag = [1, 0, 0] would be defined at the middle of the 2 x-faces of each cell. nodal_flag = [0, 1, 1] would mean the that the field defined at the centers of the 4 edges that are normal to the x axis, while nodal_flag = [1, 1, 1] would be defined at the 8 cell corners.
check_available(data)[source]

This raises an exception of the appropriate type if the set of validation mechanisms are not met, and otherwise returns True.

get_dependencies(*args, **kwargs)[source]

This returns a list of names of fields that this field depends on.

get_label(projected=False)[source]

Return a data label for the given field, including units.

get_latex_display_name()[source]
get_projected_units()[source]
get_source()[source]

Return a string containing the source of the function (if possible.)

get_units()[source]
particle_type
unit_registry(data)[source]
class yt.fields.derived_field.FieldValidator[source]

Bases: object

yt.fields.derived_field.NullFunc(field, data)[source]
yt.fields.derived_field.TranslationFunc(field_name)[source]
class yt.fields.derived_field.ValidateDataField(field)[source]
class yt.fields.derived_field.ValidateGridType[source]
class yt.fields.derived_field.ValidateParameter(parameters, parameter_values=None)[source]
class yt.fields.derived_field.ValidateProperty(prop)[source]
class yt.fields.derived_field.ValidateSpatial(ghost_zones=0, fields=None)[source]