metpy.units

Module to provide unit support.

This makes use of the pint library and sets up the default settings for good temperature support.

metpy.units.units

pint.UnitRegistry – The unit registry used throughout the package. Any use of units in MetPy should import this registry and use it to grab units.

metpy.units.atleast_1d(*arrs)

Convert inputs to arrays with at least one dimension

Scalars are converted to 1-dimensional arrays, whilst other higher-dimensional inputs are preserved. This is a thin wrapper around numpy.atleast_1d to preserve units.

Parameters:arrs (arbitrary positional arguments) – Input arrays to be converted if necessary
Returns:pint.Quantity – A single quantity or a list of quantities, matching the number of inputs.
metpy.units.atleast_2d(*arrs)

Convert inputs to arrays with at least two dimensions

Scalars and 1-dimensional arrays are converted to 2-dimensional arrays, whilst other higher-dimensional inputs are preserved. This is a thin wrapper around numpy.atleast_2d to preserve units.

Parameters:arrs (arbitrary positional arguments) – Input arrays to be converted if necessary
Returns:pint.Quantity – A single quantity or a list of quantities, matching the number of inputs.
metpy.units.concatenate(arrs, axis=0)

Concatenate multiple values into a new unitized object.

This is essentially a unit-aware version of numpy.concatenate. All items must be able to be converted to the same units. If an item has no units, it will be given those of the rest of the collection, without conversion. The first units found in the arguments is used as the final output units.

Parameters:
  • arrs (Sequence of arrays) – The items to be joined together
  • axis (integer, optional) – The array axis along which to join the arrays. Defaults to 0 (the first dimension)
Returns:

pint.Quantity – New container with the value passed in and units corresponding to the first item.