forked from os-climate/ITR
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathosc_units.py
43 lines (35 loc) · 1.16 KB
/
osc_units.py
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
"""
This module handles initialization of pint functionality
"""
from pint import set_application_registry
from pint_pandas import PintArray, PintType
from openscm_units import unit_registry
# openscm_units doesn't make it easy to set preprocessors. This is one way to do it.
unit_registry.preprocessors=[
lambda s1: s1.replace('BoE', 'boe'),
]
PintType.ureg = unit_registry
ureg = unit_registry
set_application_registry(ureg)
Q_ = ureg.Quantity
PA_ = PintArray
ureg.define("CO2e = CO2 = CO2eq = CO2_eq")
ureg.define("Fe_ton = [produced_ton]")
ureg.define("passenger = [passenger_unit]")
# These are for later
ureg.define('fraction = [] = frac')
ureg.define('percent = 1e-2 frac = pct = percentage')
ureg.define('ppm = 1e-6 fraction')
ureg.define("USD = [currency]")
ureg.define("EUR = nan USD")
ureg.define("JPY = nan USD")
ureg.define("btu = Btu")
ureg.define("boe = 5.712 GJ")
ureg.define("mboe = 1e3 boe")
ureg.define("mmboe = 1e6 boe")
# These are for later still
# ureg.define("HFC = [ HFC_emissions ]")
# ureg.define("PFC = [ PFC_emissions ]")
# ureg.define("mercury = Hg = Mercury")
# ureg.define("mercure = Hg = Mercury")
# ureg.define("PM10 = [ PM10_emissions ]")