Reference
1 Unit systems
units.read_xml([path])
-
Reads a units database in XML format and returns a unit system. If the path to the database is ommitted, the function reads the path specified in the environment variable
UDUNITS2_XML_PATH
; or, if unset, the default database. system:get_dimensionless_unit_one()
-
Returns the unit of dimension 1.
system:get_unit_by_name(s)
-
Returns the unit that matches the given name in a case-insensitive manner.
system:get_unit_by_symbol(s)
-
Returns the unit that matches the given symbol in a case-sensitive manner.
system:parse(s[, encoding])
-
Parses the given unit string and returns the corresponding unit. A second, optional argument
encoding
specifies the character encoding of the string.encoding
may be any of the following:- “ascii”;
- “iso_8859_1”;
- “latin1” (an alias of “iso_8859_1”);
- “utf8” (the default).
2 Units
x * unit
-
Returns a unit that equals
unit
scaled byx
. unit * x
-
Returns a unit that equals
unit
scaled byx
. unit1 * unit2
-
Returns a unit that equals the product of the two units.
x / unit
-
Returns a unit that equals the inverse of
unit
scaled byx
. unit / x
-
Returns a unit that equals
unit
scaled by the inverse ofx
. unit1 / unit2
-
Returns a unit that equals the quotient of the two units.
unit ^ n
-
Returns a unit that equals
unit
raised to the power ofn
. unit % x
-
Returns a unit that equals
unit
offset byx
. unit1 == unit2
-
Returns true if the two units belong to the same unit system and are equal; otherwise returns false.
tostring(unit)
-
Returns a string representation of
unit
in ASCII character encoding.