ensure_unit

gunagala.utils.ensure_unit(arg, unit)[source]

Ensures that the argument has the requested units, performing conversions as necessary.

Parameters:
arg : astropy.units.Quantity or compatible

Argument to be coerced into the requested units. Can be an astropy.units.Quantity instance or any numeric type or sequence that is compatible with the Quantity constructor (e.g. a numpy.array, list of float, etc.).

unit : astropy.units.Unit

Requested units.

Returns:
arg : astropy.units.Quantity

arg as an astropy.units.Quantity with units of unit.