forked from astropy/astropy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunits.py
More file actions
48 lines (36 loc) · 1.82 KB
/
Copy pathunits.py
File metadata and controls
48 lines (36 loc) · 1.82 KB
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
# -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package defines units that can also be used as functions of other units.
If called, their arguments are used to initialize the corresponding function
unit (e.g., ``u.mag(u.ct/u.s)``). Note that the prefixed versions cannot be
called, as it would be unclear what, e.g., ``u.mmag(u.ct/u.s)`` would mean.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from ..core import _add_prefixes
from .mixin import RegularFunctionUnit, IrreducibleFunctionUnit
_ns = globals()
###########################################################################
# Logarithmic units
# These calls are what core.def_unit would do, but we need to use the callable
# unit versions. The actual function unit classes get added in logarithmic.
dex = IrreducibleFunctionUnit(['dex'], namespace=_ns,
doc="Dex: Base 10 logarithmic unit")
dB = RegularFunctionUnit(['dB', 'decibel'], 0.1 * dex, namespace=_ns,
doc="Decibel: ten per base 10 logarithmic unit")
mag = RegularFunctionUnit(['mag'], -0.4 * dex, namespace=_ns,
doc=("Astronomical magnitude: "
"-2.5 per base 10 logarithmic unit"))
_add_prefixes(mag, namespace=_ns, prefixes=True)
###########################################################################
# CLEANUP
del RegularFunctionUnit
del IrreducibleFunctionUnit
###########################################################################
# DOCSTRING
# This generates a docstring for this module that describes all of the
# standard units defined here.
from ..utils import generate_unit_summary as _generate_unit_summary
if __doc__ is not None:
__doc__ += _generate_unit_summary(globals())