get_physical_type#
- astropy.units.physical.get_physical_type(obj)[source]#
Return the physical type that corresponds to a unit (or another physical type representation).
- Parameters:
- objastropy:quantity-like or
PhysicalType
astropy:-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 aQuantity
(such as a number or array), a string that contains a name of a physical type, or aPhysicalType
instance.
- objastropy:quantity-like or
- Returns:
PhysicalType
A representation of the physical type(s) of the unit.
Notes
For a list of physical types, see
astropy.units.physical
.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')