fields.buffers.base.BufferBase.convert_to_units#

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

Convert this buffer’s data to the specified physical units (in-place).

This operation replaces the buffer’s internal data with a unit-converted equivalent. It modifies the object directly.

Not all buffer classes support in-place unit assignment. Subclasses that do not should override this method to raise an appropriate error.

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

  • equivalence (str, optional) – Unit equivalence to apply during conversion (e.g., “mass_energy”).

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

Raises:
  • UnitConversionError – If the conversion is not dimensionally consistent.

  • NotImplementedError – If the subclass does not support in-place unit modification.

Notes

If the buffer’s units are None, this method assigns the new units directly without modifying data. Otherwise, it performs a physical conversion.