fields.mixins.components.FieldComponentCoreMixin.convert_to_units#

FieldComponentCoreMixin.convert_to_units(units: str | Unit, equivalence: str | None = None, **kwargs)[source]#

Convert the component’s buffer to the specified units (in-place).

This operation modifies the underlying buffer directly and permanently converts all data to the given units. This is only valid if the buffer supports in-place unit reassignment or conversion.

Parameters:
  • units (str or unyt.Unit) – Target units to convert the buffer to.

  • equivalence (str, optional) – Optional equivalence name (e.g., “mass_energy”).

  • **kwargs – Additional keyword arguments passed to the equivalence logic.

Raises:
  • UnitConversionError – If the conversion is invalid or dimensionally inconsistent.

  • NotImplementedError – If the buffer does not support unit conversion.