PyMSES

Table Of Contents

Previous topic

Utilities package

Next topic

Geometrical region module

This Page

Dimensional physical constants

pymses.utils.constants — physical units and constants module

class Unit(dims, val)

Bases: object

Dimensional physical unit class

Parameters :

dims : 6-tuple of int

dimension of the unit object expressed in the international system units (m, kg, s, K, h, T)

val : float

value of the unit object (in ISU)

Examples

>>> V_km_s = Unit((1,0,-1,0,0), 1000.0)
>>> print "1.0 km/s = %.1e m/h"%(V_km_s.express(m/hour))
1.0 km/s = 3.6e+06 m/h
express(unit)

Unit conversion method. Gives the conversion factor of this Unit object expressed into another (dimension-compatible) given unit.

Checks that :

  • the unit param. is also a Unit instance
  • the unit param. is dimension-compatible
Parameters :

unit : Unit object

unit in which the conversion is made

Returns :

fact : float

conversion factor of itself expressed in unit

Examples

Conversion of a kpc expressed in light-years :

>>> factor = kpc.express(ly)
>>> print "1 kpc = %f ly"%factor
1 kpc = 3261.563163 ly

Conversion of 1 M_{\odot} into kilometers :

>>> print Msun.express(km)
ValueError: Incompatible dimensions between (1.9889e+30 kg) and (1000.0 m)
list_all()

Print all available constants list:

none, m, cm, km, pc, au, kpc, Mpc, Gpc, kg, g, mH, Msun, s, hour, day, year, Myr, Gyr, N, dyne, K, J, W, erg, eV, G, kB, c, ly, H, rhoc, H_cc, h, sigmaSB, a_R, T, Gauss, uGauss