This package is based on the PhysicalQuantity package that is part of ScientificPython. It performs unit conversions.
This module provides a data type that represents a physical quantity together with its unit. It is possible to add and subtract these quantities if the units are compatible, and a quantity can be converted to another compatible unit. Multiplication, subtraction, and raising to integer powers is allowed without restriction, and the result will have the correct unit. A quantity can be raised to a non-integer power only if the result can be represented by integer powers of the base units.
The module provides a basic set of predefined physical quanitites in its built in library, however it also supports generation of personal libararies which can be saved and reused
Bases: dict
Dictionary storing numerical values
Constructor: NumberDict()
An instance of this class acts like an array of number with generalized (non-integer) indices. A value of zero is assumed for undefined entries. NumberDict instances support addition, and subtraction with other NumberDict instances, and multiplication and division by scalars.
Bases: object
Physical quantity with units
PhysicalQuantity instances allow addition, subtraction, multiplication, and division with each other as well as multiplication, division, and exponentiation with numbers. Addition and subtraction check that the units of the two operands are compatible and return the result in the units of the first operand.
Change the unit and adjust the value such that the combination is equivalent to the original one. The new unit must be compatible with the previous unit of the object.
@param unit: a unit @type unit: C{str} @raise TypeError: if the unit string is not a know unit or a unit incompatible with the current one
Converts the values of the PQ to the target_unit
Parsing Cosine
Return unit (string) of physical quantity.
Return value (float) of physical quantity (no unit).
@returns: the same quantity converted to base units, i.e. SI units in most cases @rtype: L{PhysicalQuantity}
Express the quantity in different units. If one unit is specified, a new PhysicalQuantity object is returned that expresses the quantity in that unit. If several units are specified, the return value is a tuple of PhysicalObject instances with with one element per unit such that the sum of all quantities in the tuple equals the the original quantity and all the values except for the last one are integers. This is used to convert to irregular unit systems like hour/minute/second.
@param units: one or several units @type units: C{str} or sequence of C{str} @returns: one or more physical quantities @rtype: L{PhysicalQuantity} or C{tuple} of L{PhysicalQuantity} @raises TypeError: if any of the specified units are not compatible with the original unit
@param unit: a unit @type unit: C{str} @returns: C{True} if the specified unit is compatible with the one of the quantity @rtype: C{bool}
Parsing Sine
Parsing Square Root
Parsing tangent
Bases: object
Physical unit
A physical unit is defined by a name (possibly composite), a scaling factor, and the exponentials of each of the SI base units that enter into it. Units can be multiplied, divided, and raised to integer powers.
@param other: another unit @type other: L{PhysicalUnit} @returns: the conversion factor from this unit to another unit @rtype: C{float} @raises TypeError: if the units are not compatible
@param other: another unit @type other: L{PhysicalUnit} @returns: the conversion factor and offset from this unit to another unit @rtype: (C{float}, C{float}) @raises TypeError: if the units are not compatible
Checks if this PQ is an Angle
@param other: another unit @type other: L{PhysicalUnit} @returns: C{True} if the units are compatible, i.e. if the powers of the base units are the same @rtype: C{bool}
Dimensionless PQ
Looks like it’s parsing fractions.
Sets the name
adding Offset Unit
adding Unit
Return the given value (given in units) converted to convunits.
makes the ConfigParser case sensitive
Imports a library