File: temperature.py

package info (click to toggle)
python-quantities 0.16.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 864 kB
  • sloc: python: 8,006; makefile: 72; sh: 3
file content (69 lines) | stat: -rw-r--r-- 1,631 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"""
"""

from ..unitquantity import UnitTemperature


K = degK = kelvin = Kelvin = UnitTemperature(
    'Kelvin',
    symbol='K',
    aliases=['degK', 'kelvin']
)
for prefix, symbolprefix, magnitude in (
        ('yotta', 'Y', 1e24),
        ('zetta', 'Z', 1e21),
        ('exa', 'E', 1e18),
        ('peta', 'P', 1e15),
        ('tera', 'T', 1e12),
        ('giga', 'G', 1e9),
        ('mega', 'M', 1e6),
        ('kilo', 'k', 1e3),
        ('hecto', 'h', 1e2),
        ('deka', 'da', 1e1),
        ('deci', 'd', 1e-1),
        ('centi', 'c', 1e-2),
        ('milli', 'm', 1e-3),
        ('micro', 'u', 1e-6),
        ('nano', 'n', 1e-9),
        ('pico', 'p', 1e-12),
        ('femto', 'f', 1e-15),
        ('atto', 'a', 1e-18),
        ('zepto', 'z', 1e-21),
        ('yocto', 'y', 1e-24),
):
    symbol = symbolprefix +'K'
    globals()[symbol] = UnitTemperature(
        prefix + 'kelvin',
        K*magnitude,
        symbol=symbol
    )

degR = rankine = Rankine = UnitTemperature(
    'Rankine',
    K/1.8,
    symbol='degR',
    u_symbol='°R',
    aliases=['rankine']
)
degC = celsius = Celsius = UnitTemperature(
    'Celsius',
    K,
    symbol='degC',
    u_symbol='°C',
    aliases=['celsius'],
    doc='''
    Unicode has special compatibility characters for ℃, but its use is
    discouraged by the unicode consortium.
    '''
)
degF = fahrenheit = Fahrenheit = UnitTemperature(
    'Fahrenheit',
    degR,
    symbol='degF',
    u_symbol='°F',
    aliases=['fahrenheit'],
    doc='''
    Unicode has special compatibility characters for ℉, but its use is
    discouraged by the unicode consortium.
    '''
)