get_physical_type

astropy.units.get_physical_type(obj)[source]

Return the physical type that corresponds to a unit (or another physical type representation).

Parameters:
objastropy:quantity-like or PhysicalTypeastropy:-like

An object that (implicitly or explicitly) has a corresponding physical type. This object may be a unit, a Quantity, an object that can be converted to a Quantity (such as a number or array), a string that contains a name of a physical type, or a PhysicalType instance.

Returns:
PhysicalType

A representation of the physical type(s) of the unit.

Examples

The physical type may be retrieved from a unit or a Quantity.

>>> import astropy.units as u
>>> u.get_physical_type(u.meter ** -2)
PhysicalType('column density')
>>> u.get_physical_type(0.62 * u.barn * u.Mpc)
PhysicalType('volume')

The physical type may also be retrieved by providing a str that contains the name of a physical type.

>>> u.get_physical_type("energy")
PhysicalType({'energy', 'torque', 'work'})

Numbers and arrays of numbers correspond to a dimensionless physical type.

>>> u.get_physical_type(1)
PhysicalType('dimensionless')