corva-unit-converter 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- corva-unit-converter-0.1.0/PKG-INFO +88 -0
- corva-unit-converter-0.1.0/README.md +69 -0
- corva-unit-converter-0.1.0/pyproject.toml +3 -0
- corva-unit-converter-0.1.0/setup.cfg +4 -0
- corva-unit-converter-0.1.0/setup.py +40 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/__init__.py +0 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/constants.py +2 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/converter.py +114 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/__init__.py +69 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/acoustic_slowness.py +43 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/angle.py +74 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/angle_per_length.py +64 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/angular_velocity.py +110 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/area.py +130 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/current.py +39 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/density.py +154 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/digital.py +100 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/energy.py +75 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/force.py +121 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/gas_concentration.py +84 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/gas_volume.py +229 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/inverse_pressure.py +75 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/length.py +92 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/length_per_angle.py +53 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/mass.py +97 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/mass_flow_rate.py +251 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/mpl.py +54 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/parts_per.py +49 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/permiability.py +43 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/porosity.py +55 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/power.py +53 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/pressure.py +174 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/pressure_gradient.py +53 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/revolution_per_volume.py +42 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/speed.py +119 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/temperature.py +57 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/time.py +125 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/torque.py +75 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/voltage.py +39 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/volume_concentration.py +42 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/definitions/volume_flow_rate.py +460 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter/helpers.py +7 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter.egg-info/PKG-INFO +88 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter.egg-info/SOURCES.txt +71 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter.egg-info/dependency_links.txt +1 -0
- corva-unit-converter-0.1.0/src/corva_unit_converter.egg-info/top_level.txt +2 -0
- corva-unit-converter-0.1.0/src/version.py +1 -0
- corva-unit-converter-0.1.0/tests/test_acoustic_slowness.py +11 -0
- corva-unit-converter-0.1.0/tests/test_angle.py +13 -0
- corva-unit-converter-0.1.0/tests/test_angle_per_length.py +13 -0
- corva-unit-converter-0.1.0/tests/test_angular_velocity.py +24 -0
- corva-unit-converter-0.1.0/tests/test_area.py +11 -0
- corva-unit-converter-0.1.0/tests/test_density.py +23 -0
- corva-unit-converter-0.1.0/tests/test_force.py +13 -0
- corva-unit-converter-0.1.0/tests/test_gas_concentration.py +17 -0
- corva-unit-converter-0.1.0/tests/test_gas_volume.py +13 -0
- corva-unit-converter-0.1.0/tests/test_inverse_pressure.py +11 -0
- corva-unit-converter-0.1.0/tests/test_length.py +18 -0
- corva-unit-converter-0.1.0/tests/test_length_per_angle.py +13 -0
- corva-unit-converter-0.1.0/tests/test_mass.py +11 -0
- corva-unit-converter-0.1.0/tests/test_mass_flow_rate.py +13 -0
- corva-unit-converter-0.1.0/tests/test_mpl.py +11 -0
- corva-unit-converter-0.1.0/tests/test_porosity.py +11 -0
- corva-unit-converter-0.1.0/tests/test_power.py +12 -0
- corva-unit-converter-0.1.0/tests/test_pressure.py +16 -0
- corva-unit-converter-0.1.0/tests/test_pressure_gradient.py +13 -0
- corva-unit-converter-0.1.0/tests/test_revolution_per_volume.py +11 -0
- corva-unit-converter-0.1.0/tests/test_speed.py +15 -0
- corva-unit-converter-0.1.0/tests/test_temperature.py +15 -0
- corva-unit-converter-0.1.0/tests/test_time.py +11 -0
- corva-unit-converter-0.1.0/tests/test_torque.py +14 -0
- corva-unit-converter-0.1.0/tests/test_volume_concentration.py +11 -0
- corva-unit-converter-0.1.0/tests/test_volume_flow_rate.py +11 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: corva-unit-converter
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Unit converter for O&G(and other) units
|
|
5
|
+
Home-page: https://github.com/corva-ai/corva-convert-units-py
|
|
6
|
+
Author: Yuliya Klimushina
|
|
7
|
+
Author-email: yuliya.klimushina@corva.ai
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: corva,unit converter
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
17
|
+
Requires-Python: >=3.8, <4.0
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# Units Converter
|
|
21
|
+
|
|
22
|
+
Library for converting between quantities in different units(including units specific to O&G).
|
|
23
|
+
|
|
24
|
+
This is a python version of the existing javascript app.
|
|
25
|
+
Credit goes to the creator and contributors of the original version https://github.com/corva-ai/corva-convert-units,
|
|
26
|
+
which is a fork of https://github.com/convert-units/convert-units.
|
|
27
|
+
|
|
28
|
+
# Installation
|
|
29
|
+
|
|
30
|
+
```shell
|
|
31
|
+
pip install corva-unit-converter
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
# Usage:
|
|
35
|
+
|
|
36
|
+
Imperial to metric:
|
|
37
|
+
|
|
38
|
+
from corva_unit_converter.converter import Converter
|
|
39
|
+
converter = Converter()
|
|
40
|
+
length_meters = converter.convert(unit_from="ft", unit_to="m", value=1)
|
|
41
|
+
|
|
42
|
+
Metric to imperial:
|
|
43
|
+
|
|
44
|
+
from corva_unit_converter.converter import Converter
|
|
45
|
+
converter = Converter()
|
|
46
|
+
torque_ft_lbf = converter.convert(unit_from="Nm", unit_to="ft-lbf", value=1)
|
|
47
|
+
|
|
48
|
+
Metric to metric:
|
|
49
|
+
|
|
50
|
+
from corva_unit_converter.converter import Converter
|
|
51
|
+
converter = Converter()
|
|
52
|
+
mass_grams = converter.convert(unit_from="kg", unit_to="g", value=1)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# Testing
|
|
56
|
+
|
|
57
|
+
1. Create virtualenv via your favourite tool, for example
|
|
58
|
+
```shell
|
|
59
|
+
python3 -m venv venv
|
|
60
|
+
source venv/bin/activate
|
|
61
|
+
```
|
|
62
|
+
2. Install all requirements:
|
|
63
|
+
```shell
|
|
64
|
+
pip install -r requirements.txt && pip install -r requirements-test.txt
|
|
65
|
+
```
|
|
66
|
+
3. Run tests with coverage:
|
|
67
|
+
```shell
|
|
68
|
+
make coverage
|
|
69
|
+
```
|
|
70
|
+
or tests without coverage:
|
|
71
|
+
```shell
|
|
72
|
+
make test
|
|
73
|
+
```
|
|
74
|
+
Linters are available through
|
|
75
|
+
```shell
|
|
76
|
+
make lint
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
# License
|
|
80
|
+
This project is licensed under the terms of the MIT license.
|
|
81
|
+
|
|
82
|
+
Copyright (c) 2013-2017 Ben Ng and Contributors, http://benng.me
|
|
83
|
+
|
|
84
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
85
|
+
|
|
86
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
87
|
+
|
|
88
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Units Converter
|
|
2
|
+
|
|
3
|
+
Library for converting between quantities in different units(including units specific to O&G).
|
|
4
|
+
|
|
5
|
+
This is a python version of the existing javascript app.
|
|
6
|
+
Credit goes to the creator and contributors of the original version https://github.com/corva-ai/corva-convert-units,
|
|
7
|
+
which is a fork of https://github.com/convert-units/convert-units.
|
|
8
|
+
|
|
9
|
+
# Installation
|
|
10
|
+
|
|
11
|
+
```shell
|
|
12
|
+
pip install corva-unit-converter
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
# Usage:
|
|
16
|
+
|
|
17
|
+
Imperial to metric:
|
|
18
|
+
|
|
19
|
+
from corva_unit_converter.converter import Converter
|
|
20
|
+
converter = Converter()
|
|
21
|
+
length_meters = converter.convert(unit_from="ft", unit_to="m", value=1)
|
|
22
|
+
|
|
23
|
+
Metric to imperial:
|
|
24
|
+
|
|
25
|
+
from corva_unit_converter.converter import Converter
|
|
26
|
+
converter = Converter()
|
|
27
|
+
torque_ft_lbf = converter.convert(unit_from="Nm", unit_to="ft-lbf", value=1)
|
|
28
|
+
|
|
29
|
+
Metric to metric:
|
|
30
|
+
|
|
31
|
+
from corva_unit_converter.converter import Converter
|
|
32
|
+
converter = Converter()
|
|
33
|
+
mass_grams = converter.convert(unit_from="kg", unit_to="g", value=1)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# Testing
|
|
37
|
+
|
|
38
|
+
1. Create virtualenv via your favourite tool, for example
|
|
39
|
+
```shell
|
|
40
|
+
python3 -m venv venv
|
|
41
|
+
source venv/bin/activate
|
|
42
|
+
```
|
|
43
|
+
2. Install all requirements:
|
|
44
|
+
```shell
|
|
45
|
+
pip install -r requirements.txt && pip install -r requirements-test.txt
|
|
46
|
+
```
|
|
47
|
+
3. Run tests with coverage:
|
|
48
|
+
```shell
|
|
49
|
+
make coverage
|
|
50
|
+
```
|
|
51
|
+
or tests without coverage:
|
|
52
|
+
```shell
|
|
53
|
+
make test
|
|
54
|
+
```
|
|
55
|
+
Linters are available through
|
|
56
|
+
```shell
|
|
57
|
+
make lint
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
# License
|
|
61
|
+
This project is licensed under the terms of the MIT license.
|
|
62
|
+
|
|
63
|
+
Copyright (c) 2013-2017 Ben Ng and Contributors, http://benng.me
|
|
64
|
+
|
|
65
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
66
|
+
|
|
67
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
68
|
+
|
|
69
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import pathlib
|
|
2
|
+
from importlib import machinery
|
|
3
|
+
|
|
4
|
+
import setuptools
|
|
5
|
+
|
|
6
|
+
ROOT = pathlib.Path(__file__).parent
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
VERSION = str(
|
|
10
|
+
machinery.SourceFileLoader('version', 'src/version.py').load_module().VERSION
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
CLASSIFIERS = [
|
|
14
|
+
'Development Status :: 4 - Beta',
|
|
15
|
+
'Intended Audience :: Developers',
|
|
16
|
+
'Operating System :: OS Independent',
|
|
17
|
+
'Programming Language :: Python',
|
|
18
|
+
'Programming Language :: Python :: 3',
|
|
19
|
+
'Programming Language :: Python :: 3.8',
|
|
20
|
+
'Topic :: Software Development :: Libraries',
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
setuptools.setup(
|
|
24
|
+
name="corva-unit-converter",
|
|
25
|
+
author="Yuliya Klimushina",
|
|
26
|
+
author_email="yuliya.klimushina@corva.ai",
|
|
27
|
+
url="https://github.com/corva-ai/corva-convert-units-py",
|
|
28
|
+
version=VERSION,
|
|
29
|
+
classifiers=CLASSIFIERS,
|
|
30
|
+
description="Unit converter for O&G(and other) units",
|
|
31
|
+
long_description=open("README.md").read(),
|
|
32
|
+
long_description_content_type="text/markdown",
|
|
33
|
+
keywords="corva, unit converter",
|
|
34
|
+
py_modules=[file.stem for file in pathlib.Path("src").glob("*.py")],
|
|
35
|
+
packages=setuptools.find_packages("src"),
|
|
36
|
+
package_dir={"": "src"},
|
|
37
|
+
install_requires=[],
|
|
38
|
+
python_requires=">=3.8, <4.0",
|
|
39
|
+
license="MIT",
|
|
40
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from typing import Dict, Union
|
|
3
|
+
|
|
4
|
+
from . import definitions
|
|
5
|
+
|
|
6
|
+
measures = {
|
|
7
|
+
"acoustic_slowness": definitions.acoustic_slowness.rule,
|
|
8
|
+
"angle": definitions.angle.rule,
|
|
9
|
+
"angle_per_length": definitions.angle_per_length.rule,
|
|
10
|
+
"angular_velocity": definitions.angular_velocity.rule,
|
|
11
|
+
"area": definitions.area.rule,
|
|
12
|
+
"density": definitions.density.rule,
|
|
13
|
+
"energy": definitions.torque.rule,
|
|
14
|
+
"force": definitions.force.rule,
|
|
15
|
+
"gas_concentration": definitions.gas_concentration.rule,
|
|
16
|
+
"gas_volume": definitions.inverse_pressure.rule,
|
|
17
|
+
"inverse_pressure": definitions.gas_volume.rule,
|
|
18
|
+
"length": definitions.length.rule,
|
|
19
|
+
"length_per_angle": definitions.length_per_angle.rule,
|
|
20
|
+
"mass": definitions.mass.rule,
|
|
21
|
+
"mass_flow_rate": definitions.mass_flow_rate.rule,
|
|
22
|
+
"mpl": definitions.mpl.rule,
|
|
23
|
+
"porosity": definitions.porosity.rule,
|
|
24
|
+
"power": definitions.power.rule,
|
|
25
|
+
"pressure": definitions.pressure.rule,
|
|
26
|
+
"pressure_gradient": definitions.pressure_gradient.rule,
|
|
27
|
+
"revolution_per_volume": definitions.revolution_per_volume.rule,
|
|
28
|
+
"speed": definitions.speed.rule,
|
|
29
|
+
"temperature": definitions.temperature.rule,
|
|
30
|
+
"time": definitions.time.rule,
|
|
31
|
+
"torque": definitions.torque.rule,
|
|
32
|
+
"volume_concentration": definitions.volume_concentration.rule,
|
|
33
|
+
"volume_flow_rate": definitions.volume_flow_rate.rule,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def map_aliases_to_unit(measure, excluded_units):
|
|
38
|
+
return [{alias: unit} for unit in measure if unit not in excluded_units
|
|
39
|
+
for alias in measure[unit].get('aliases') or [unit]]
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def get_unit_for_alias(alias, measure):
|
|
43
|
+
mapping = map_aliases_to_unit(measure, [])
|
|
44
|
+
new_unit = [unit for item in mapping for key, unit in item.items() if key == alias]
|
|
45
|
+
return new_unit[0] if new_unit else None
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class Converter:
|
|
49
|
+
def __init__(self):
|
|
50
|
+
self.origin = {}
|
|
51
|
+
self.destination = {}
|
|
52
|
+
|
|
53
|
+
def get_unit_definition(self, source, unit):
|
|
54
|
+
definition = source.get(unit)
|
|
55
|
+
if not definition:
|
|
56
|
+
definition = self.get_unit(unit)
|
|
57
|
+
if not definition:
|
|
58
|
+
logging.info(f"{unit=} not found")
|
|
59
|
+
return
|
|
60
|
+
return definition
|
|
61
|
+
|
|
62
|
+
def convert(self, unit_from: str, unit_to: str, # noqa: CCR001, CFQ004
|
|
63
|
+
value: Union[int, float]):
|
|
64
|
+
"""Main function"""
|
|
65
|
+
origin = self.get_unit_definition(source=self.origin, unit=unit_from)
|
|
66
|
+
destination = self.get_unit_definition(source=self.destination, unit=unit_to)
|
|
67
|
+
|
|
68
|
+
if not origin or not destination:
|
|
69
|
+
return
|
|
70
|
+
|
|
71
|
+
# Don't change the value if origin and destination are the same
|
|
72
|
+
if origin["abbr"] == destination["abbr"]:
|
|
73
|
+
return value
|
|
74
|
+
|
|
75
|
+
# Convert from the source value to its anchor inside the system
|
|
76
|
+
result = value * origin["unit"]["to_anchor"]
|
|
77
|
+
|
|
78
|
+
# for some units it's a simple shift (e.g. C to K)
|
|
79
|
+
if "anchor_shift" in origin["unit"]:
|
|
80
|
+
result -= origin["unit"]["anchor_shift"]
|
|
81
|
+
|
|
82
|
+
# Convert from one system to another
|
|
83
|
+
if origin["system"] != destination["system"]:
|
|
84
|
+
# Convert through transformation
|
|
85
|
+
transform = measures[origin["measure"]]["_anchors"][origin["system"]].get("transform")
|
|
86
|
+
if transform and callable(transform):
|
|
87
|
+
result = transform(result)
|
|
88
|
+
|
|
89
|
+
# Convert through the anchor ratio
|
|
90
|
+
result *= measures[origin["measure"]]["_anchors"][origin["system"]]["ratio"]
|
|
91
|
+
|
|
92
|
+
# Apply shift after transformation for F to K
|
|
93
|
+
if "anchor_shift" in destination["unit"]:
|
|
94
|
+
result += destination["unit"]["anchor_shift"]
|
|
95
|
+
|
|
96
|
+
# Convert to another unit inside the destination system
|
|
97
|
+
return result / destination["unit"]["to_anchor"]
|
|
98
|
+
|
|
99
|
+
@staticmethod
|
|
100
|
+
def get_unit(abbr) -> Dict: # noqa: CCR001
|
|
101
|
+
for measure, systems in measures.items():
|
|
102
|
+
for system, units in systems.items():
|
|
103
|
+
if system == "_anchors":
|
|
104
|
+
break
|
|
105
|
+
new_abbr = get_unit_for_alias(abbr, units) or abbr
|
|
106
|
+
for test_abbr, unit in units.items():
|
|
107
|
+
if test_abbr == new_abbr:
|
|
108
|
+
return {
|
|
109
|
+
"abbr": new_abbr,
|
|
110
|
+
"measure": measure,
|
|
111
|
+
"system": system,
|
|
112
|
+
"unit": unit
|
|
113
|
+
}
|
|
114
|
+
return {}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from . import (
|
|
2
|
+
acoustic_slowness,
|
|
3
|
+
angle,
|
|
4
|
+
angle_per_length,
|
|
5
|
+
angular_velocity,
|
|
6
|
+
area,
|
|
7
|
+
current,
|
|
8
|
+
density,
|
|
9
|
+
digital,
|
|
10
|
+
energy,
|
|
11
|
+
force,
|
|
12
|
+
gas_concentration,
|
|
13
|
+
gas_volume,
|
|
14
|
+
inverse_pressure,
|
|
15
|
+
length,
|
|
16
|
+
length_per_angle,
|
|
17
|
+
mass,
|
|
18
|
+
mass_flow_rate,
|
|
19
|
+
mpl,
|
|
20
|
+
parts_per,
|
|
21
|
+
permiability,
|
|
22
|
+
porosity,
|
|
23
|
+
power,
|
|
24
|
+
pressure,
|
|
25
|
+
pressure_gradient,
|
|
26
|
+
revolution_per_volume,
|
|
27
|
+
speed,
|
|
28
|
+
temperature,
|
|
29
|
+
time,
|
|
30
|
+
torque,
|
|
31
|
+
voltage,
|
|
32
|
+
volume_concentration,
|
|
33
|
+
volume_flow_rate,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
"acoustic_slowness",
|
|
38
|
+
"angle",
|
|
39
|
+
"angle_per_length",
|
|
40
|
+
"angular_velocity",
|
|
41
|
+
"area",
|
|
42
|
+
"current",
|
|
43
|
+
"density",
|
|
44
|
+
"digital",
|
|
45
|
+
"energy",
|
|
46
|
+
"force",
|
|
47
|
+
"gas_concentration",
|
|
48
|
+
"gas_volume",
|
|
49
|
+
"inverse_pressure",
|
|
50
|
+
"length",
|
|
51
|
+
"length_per_angle",
|
|
52
|
+
"mass",
|
|
53
|
+
"mass_flow_rate",
|
|
54
|
+
"mpl",
|
|
55
|
+
"parts_per",
|
|
56
|
+
"permiability",
|
|
57
|
+
"porosity",
|
|
58
|
+
"power",
|
|
59
|
+
"pressure",
|
|
60
|
+
"pressure_gradient",
|
|
61
|
+
"revolution_per_volume",
|
|
62
|
+
"speed",
|
|
63
|
+
"temperature",
|
|
64
|
+
"time",
|
|
65
|
+
"torque",
|
|
66
|
+
"voltage",
|
|
67
|
+
"volume_concentration",
|
|
68
|
+
"volume_flow_rate"
|
|
69
|
+
]
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
metric = {
|
|
2
|
+
"us/m": {
|
|
3
|
+
"name": {
|
|
4
|
+
"singular": "us/m",
|
|
5
|
+
"plural": "us/m",
|
|
6
|
+
"display": "us/m"
|
|
7
|
+
},
|
|
8
|
+
"to_anchor": 1,
|
|
9
|
+
"aliases": [
|
|
10
|
+
"us/m"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
imperial = {
|
|
16
|
+
"us/ft": {
|
|
17
|
+
"name": {
|
|
18
|
+
"singular": "us/ft",
|
|
19
|
+
"plural": "us/ft",
|
|
20
|
+
"display": "us/ft"
|
|
21
|
+
},
|
|
22
|
+
"to_anchor": 1,
|
|
23
|
+
"aliases": [
|
|
24
|
+
"us/f",
|
|
25
|
+
"us/ft"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
rule = {
|
|
31
|
+
"metric": metric,
|
|
32
|
+
"imperial": imperial,
|
|
33
|
+
"_anchors": {
|
|
34
|
+
"metric": {
|
|
35
|
+
"unit": "us/m",
|
|
36
|
+
"ratio": 1 / 3.28084
|
|
37
|
+
},
|
|
38
|
+
"imperial": {
|
|
39
|
+
"unit": "us/ft",
|
|
40
|
+
"ratio": 3.28084
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
from math import pi
|
|
2
|
+
|
|
3
|
+
angle = {
|
|
4
|
+
"rad": {
|
|
5
|
+
"name": {
|
|
6
|
+
"singular": "radian",
|
|
7
|
+
"plural": "radians",
|
|
8
|
+
"display": "rad"
|
|
9
|
+
},
|
|
10
|
+
"to_anchor": 180/pi,
|
|
11
|
+
"aliases": [
|
|
12
|
+
"rad"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"deg": {
|
|
16
|
+
"name": {
|
|
17
|
+
"singular": "degree",
|
|
18
|
+
"plural": "degrees",
|
|
19
|
+
"display": "deg"
|
|
20
|
+
},
|
|
21
|
+
"to_anchor": 1,
|
|
22
|
+
"aliases": [
|
|
23
|
+
"deg"
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
"grad": {
|
|
27
|
+
"name": {
|
|
28
|
+
"singular": "gradian",
|
|
29
|
+
"plural": "gradians",
|
|
30
|
+
"display": "grad"
|
|
31
|
+
},
|
|
32
|
+
"to_anchor": 9/10,
|
|
33
|
+
"aliases": [
|
|
34
|
+
"grad"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"arcmin": {
|
|
38
|
+
"name": {
|
|
39
|
+
"singular": "arcminute",
|
|
40
|
+
"plural": "arcminutes",
|
|
41
|
+
"display": "acrmin"
|
|
42
|
+
},
|
|
43
|
+
"to_anchor": 1/60,
|
|
44
|
+
"aliases": [
|
|
45
|
+
"arcmin"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"arcsec": {
|
|
49
|
+
"name": {
|
|
50
|
+
"singular": "arcsecond",
|
|
51
|
+
"plural": "arcseconds",
|
|
52
|
+
"display": "arcsec"
|
|
53
|
+
},
|
|
54
|
+
"to_anchor": 1/3600,
|
|
55
|
+
"aliases": [
|
|
56
|
+
"arcsec"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
rule = {
|
|
62
|
+
"metric": angle,
|
|
63
|
+
"imperial": angle,
|
|
64
|
+
"_anchors": {
|
|
65
|
+
"metric": {
|
|
66
|
+
"unit": "deg",
|
|
67
|
+
"ratio": 1
|
|
68
|
+
},
|
|
69
|
+
"imperial": {
|
|
70
|
+
"unit": "deg",
|
|
71
|
+
"ratio": 1
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
metric = {
|
|
2
|
+
"dpm": {
|
|
3
|
+
"name": {
|
|
4
|
+
"singular": "degree per meter",
|
|
5
|
+
"plural": "degrees per meter",
|
|
6
|
+
"display": "°/m"
|
|
7
|
+
},
|
|
8
|
+
"to_anchor": 1,
|
|
9
|
+
"aliases": [
|
|
10
|
+
"dpm"
|
|
11
|
+
]
|
|
12
|
+
},
|
|
13
|
+
"dp30m": {
|
|
14
|
+
"name": {
|
|
15
|
+
"singular": "degree per 30m",
|
|
16
|
+
"plural": "degrees per 30m",
|
|
17
|
+
"display": "°/30m"
|
|
18
|
+
},
|
|
19
|
+
"to_anchor": 1/30,
|
|
20
|
+
"aliases": [
|
|
21
|
+
"dp30m"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
imperial = {
|
|
27
|
+
"dpf": {
|
|
28
|
+
"name": {
|
|
29
|
+
"singular": "degree per foot",
|
|
30
|
+
"plural": "degrees per feet",
|
|
31
|
+
"display": "°/ft"
|
|
32
|
+
},
|
|
33
|
+
"to_anchor": 1,
|
|
34
|
+
"aliases": [
|
|
35
|
+
"dpf"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"dp100f": {
|
|
39
|
+
"name": {
|
|
40
|
+
"singular": "degree per 100 foot",
|
|
41
|
+
"plural": "degrees per 100 feet",
|
|
42
|
+
"display": "°/100ft"
|
|
43
|
+
},
|
|
44
|
+
"to_anchor": 1/100,
|
|
45
|
+
"aliases": [
|
|
46
|
+
"dp100f"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
rule = {
|
|
52
|
+
"metric": metric,
|
|
53
|
+
"imperial": imperial,
|
|
54
|
+
"_anchors": {
|
|
55
|
+
"metric": {
|
|
56
|
+
"unit": "dpm",
|
|
57
|
+
"ratio": 1/3.28084
|
|
58
|
+
},
|
|
59
|
+
"imperial": {
|
|
60
|
+
"unit": "dpf",
|
|
61
|
+
"ratio": 3.28084
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# 1/s, rev/s, rpm, rph, rad/s, dega/s, dega/m, dega/h
|
|
2
|
+
# NOTE: "a" letter is added to degree to avoid confusion with temperature
|
|
3
|
+
#
|
|
4
|
+
# to_anchor values might be clearer but the base unit was defined as RPM
|
|
5
|
+
from math import pi
|
|
6
|
+
|
|
7
|
+
metric = {
|
|
8
|
+
"1/s": {
|
|
9
|
+
"name": {
|
|
10
|
+
"singular": "revolution per second",
|
|
11
|
+
"plural": "revolutions per second",
|
|
12
|
+
"display": "1/s"
|
|
13
|
+
},
|
|
14
|
+
"to_anchor": 60,
|
|
15
|
+
"aliases": [
|
|
16
|
+
"1/s"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"rev/s": {
|
|
20
|
+
"name": {
|
|
21
|
+
"singular": "revolution per second",
|
|
22
|
+
"plural": "revolutions per second",
|
|
23
|
+
"display": "1/s"
|
|
24
|
+
},
|
|
25
|
+
"to_anchor": 60,
|
|
26
|
+
"aliases": [
|
|
27
|
+
"rev/s"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"rpm": {
|
|
31
|
+
"name": {
|
|
32
|
+
"singular": "revolution per minute",
|
|
33
|
+
"plural": "revolutions per minute",
|
|
34
|
+
"display": "rpm"
|
|
35
|
+
},
|
|
36
|
+
"to_anchor": 1,
|
|
37
|
+
"aliases": [
|
|
38
|
+
"rpm"
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
"rph": {
|
|
42
|
+
"name": {
|
|
43
|
+
"singular": "revolution per hour",
|
|
44
|
+
"plural": "revolutions per hour",
|
|
45
|
+
"display": "rph"
|
|
46
|
+
},
|
|
47
|
+
"to_anchor": 1 / 60,
|
|
48
|
+
"aliases": [
|
|
49
|
+
"rph"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"radsec": {
|
|
53
|
+
"name": {
|
|
54
|
+
"singular": "radian per second",
|
|
55
|
+
"plural": "radians per second",
|
|
56
|
+
"display": "rad/sec"
|
|
57
|
+
},
|
|
58
|
+
"to_anchor": 60 / (2 * pi),
|
|
59
|
+
"aliases": [
|
|
60
|
+
"radsec", "rad/s", "rad/sec"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"dega/s": {
|
|
64
|
+
"name": {
|
|
65
|
+
"singular": "degree per second",
|
|
66
|
+
"plural": "degrees per second",
|
|
67
|
+
"display": "dega/s"
|
|
68
|
+
},
|
|
69
|
+
"to_anchor": 1 / 6,
|
|
70
|
+
"aliases": [
|
|
71
|
+
"dega/s"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"dega/m": {
|
|
75
|
+
"name": {
|
|
76
|
+
"singular": "degree per minute",
|
|
77
|
+
"plural": "degrees per minute",
|
|
78
|
+
"display": "dega/m"
|
|
79
|
+
},
|
|
80
|
+
"to_anchor": 1 / 360,
|
|
81
|
+
"aliases": [
|
|
82
|
+
"dega/m"
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
"dega/h": {
|
|
86
|
+
"name": {
|
|
87
|
+
"singular": "degree per hour",
|
|
88
|
+
"plural": "degrees per hour",
|
|
89
|
+
"display": "dega/h"
|
|
90
|
+
},
|
|
91
|
+
"to_anchor": (1 / 360) / 60,
|
|
92
|
+
"aliases": [
|
|
93
|
+
"dega/h"
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
rule = {
|
|
99
|
+
"metric": metric,
|
|
100
|
+
"_anchors": {
|
|
101
|
+
"metric": {
|
|
102
|
+
"unit": "rpm",
|
|
103
|
+
"ratio": 1
|
|
104
|
+
},
|
|
105
|
+
"imperial": {
|
|
106
|
+
"unit": "rpm",
|
|
107
|
+
"ratio": 1
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|