pyphot.ezunits package#

Submodules#

pyphot.ezunits.pint module#

pint#

Pint is Python module/package to define, operate and manipulate physical quantities: the product of a numerical value and a unit of measurement. It allows arithmetic operations between them and conversions from and to different units.

copyright:

2012 by Hernan E. Grecco.

license:

BSD, see LICENSE for more details.

class AliasDict[source]#

Bases: dict

__init__(*args, **kwargs)[source]#
add_alias(key, value, preferred=False)[source]#
get_aliased(key)[source]#
exception DimensionalityError[source]#

Bases: ValueError

Raised when trying to convert between incompatible units.

__init__(units1, units2, dim1=None, dim2=None)[source]#
exception UndefinedUnitError[source]#

Bases: ValueError

Raised when the units are not defined in the unit registry.

__init__(unit_names)[source]#
class UnitRegistry[source]#

Bases: object

The unit registry stores the definitions and relationships between units.

Parameters:
  • filename – path of the units definition file to load. Empty to load the default definition file. None to leave the UnitRegistry empty.

  • force_ndarray – convert any input, scalar or not to a numpy.ndarray.

__init__(filename='', force_ndarray=False)[source]#
add_from_file(filename)[source]#

Add units and prefixes defined in a definition text file.

add_prefix(name, value, aliases=())[source]#

Add prefix to the registry.

add_unit(name, value, aliases=(), **modifiers)[source]#

Add unit to the registry.

get_alias(name)[source]#

Return the preferred alias for a unit

class UnitsContainer[source]#

Bases: dict

The UnitsContainer stores the product of units and their respective exponent and implements the corresponding operations

__init__(*args, **kwargs)[source]#
add(key, value)[source]#
converter_from_reference(scale, offset, log_base)[source]#
converter_to_reference(scale, offset, log_base)[source]#

Module contents#

pint#

Pint is Python module/package to define, operate and manipulate physical quantities: the product of a numerical value and a unit of measurement. It allows arithmetic operations between them and conversions from and to different units.

copyright:
  1. 2012 by Hernan E. Grecco.

license:

BSD, see LICENSE for more details.

exception DimensionalityError[source]#

Bases: ValueError

Raised when trying to convert between incompatible units.

__init__(units1, units2, dim1=None, dim2=None)[source]#
exception UndefinedUnitError[source]#

Bases: ValueError

Raised when the units are not defined in the unit registry.

__init__(unit_names)[source]#
class UnitRegistry[source]#

Bases: object

The unit registry stores the definitions and relationships between units.

Parameters:
  • filename – path of the units definition file to load. Empty to load the default definition file. None to leave the UnitRegistry empty.

  • force_ndarray – convert any input, scalar or not to a numpy.ndarray.

__init__(filename='', force_ndarray=False)[source]#
add_from_file(filename)[source]#

Add units and prefixes defined in a definition text file.

add_prefix(name, value, aliases=())[source]#

Add prefix to the registry.

add_unit(name, value, aliases=(), **modifiers)[source]#

Add unit to the registry.

get_alias(name)[source]#

Return the preferred alias for a unit

class UnitsContainer[source]#

Bases: dict

The UnitsContainer stores the product of units and their respective exponent and implements the corresponding operations

__init__(*args, **kwargs)[source]#
add(key, value)[source]#
hasUnit(val)[source]#