radis.phys.units_astropy moduleΒΆ


convert_and_strip_units(quantity, output_unit=None, digit=10)[source]ΒΆ

Strips units and return the numerical value.

Parameters
  • quantity (int or float or list or None or Quantity) – Numerical quantity. Pass it without including units if default units are intended.

  • output_unit (UnitBase or Quantity) – The default units in which the quantity is to be converted before extracting the value.

Other Parameters

round (int) – round to that number of digit after conversion. Default 10. Set to None to disable.

Returns

The numerical value extracted from quantity

Return type

int or float or None or ndarray

Examples

>>> convert_and_strip_units(4.5 * u.um, u.nm)
<<< 4500.0
>>> convert_and_strip_units(200000 * (u.m)**-1, 1/u.cm)
<<< 2000.0
Raises

TypeError – Raised when quantity is a astropy.units quantity and output_unit is None.