unitcorn 0.9.0__py3-none-any.whl

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.

Potentially problematic release.


This version of unitcorn might be problematic. Click here for more details.

Files changed (59) hide show
  1. unitcorn/__init__.py +110 -0
  2. unitcorn/airQuality/__init__.py +99 -0
  3. unitcorn/area/__init__.py +3 -0
  4. unitcorn/area/area.py +103 -0
  5. unitcorn/base/Decorators.py +72 -0
  6. unitcorn/base/Registry.py +75 -0
  7. unitcorn/base/SmartBases.py +26 -0
  8. unitcorn/base/_Algebra.py +205 -0
  9. unitcorn/base/_Measurement.py +1122 -0
  10. unitcorn/base/_ScalingMeasurement.py +398 -0
  11. unitcorn/base/_SmartFloat.py +1635 -0
  12. unitcorn/base/__init__.py +6 -0
  13. unitcorn/config/__init__.py +318 -0
  14. unitcorn/config/__main__.py +8 -0
  15. unitcorn/config/si.toml +53 -0
  16. unitcorn/config/template.toml +146 -0
  17. unitcorn/config/us.toml +53 -0
  18. unitcorn/defaults/WeatherFlow/__init__.py +176 -0
  19. unitcorn/defaults/__init__.py +1 -0
  20. unitcorn/derived/__init__.py +16 -0
  21. unitcorn/derived/density.py +26 -0
  22. unitcorn/derived/partsPer.py +96 -0
  23. unitcorn/derived/precipitation.py +96 -0
  24. unitcorn/derived/rate.py +80 -0
  25. unitcorn/derived/volume.py +122 -0
  26. unitcorn/derived/wind.py +54 -0
  27. unitcorn/digital/__init__.py +21 -0
  28. unitcorn/energy/__init__.py +4 -0
  29. unitcorn/energy/energy.py +120 -0
  30. unitcorn/energy/power.py +83 -0
  31. unitcorn/errors/Conversion.py +12 -0
  32. unitcorn/errors/Unit.py +4 -0
  33. unitcorn/errors/__init__.py +7 -0
  34. unitcorn/length/__init__.py +19 -0
  35. unitcorn/length/imperial.py +46 -0
  36. unitcorn/length/length.py +74 -0
  37. unitcorn/length/metric.py +56 -0
  38. unitcorn/mass/__init__.py +15 -0
  39. unitcorn/mass/imperial.py +47 -0
  40. unitcorn/mass/mass.py +57 -0
  41. unitcorn/mass/metric.py +47 -0
  42. unitcorn/others/__init__.py +338 -0
  43. unitcorn/others/light.py +51 -0
  44. unitcorn/pressure/__init__.py +3 -0
  45. unitcorn/pressure/pressure.py +189 -0
  46. unitcorn/py.typed +0 -0
  47. unitcorn/temperature/__init__.py +19 -0
  48. unitcorn/temperature/celsius.py +23 -0
  49. unitcorn/temperature/change.py +156 -0
  50. unitcorn/temperature/fahrenheit.py +24 -0
  51. unitcorn/temperature/kelvin.py +25 -0
  52. unitcorn/temperature/temperature.py +154 -0
  53. unitcorn/time_/__init__.py +1 -0
  54. unitcorn/time_/time.py +387 -0
  55. unitcorn/utils.py +399 -0
  56. unitcorn-0.9.0.dist-info/METADATA +536 -0
  57. unitcorn-0.9.0.dist-info/RECORD +59 -0
  58. unitcorn-0.9.0.dist-info/WHEEL +4 -0
  59. unitcorn-0.9.0.dist-info/licenses/LICENSE.txt +17 -0
@@ -0,0 +1,176 @@
1
+
2
+ from ...others import Direction, Voltage, LightningStrike, Humidity
3
+ from ...others.light import UVI, Lux, RadiantFlux
4
+ from ...time_ import *
5
+ from ...pressure import Millibar
6
+ from ...derived import Wind, Precipitation
7
+ from ...derived.precipitation import Daily as PrecipitationDaily, Hourly as PrecipitationHourly, Minutely as PrecipitationMinutely
8
+ from ...temperature import Celsius
9
+ from ...length import Kilometer, Meter, Millimeter
10
+ from ...various import RSSI
11
+ from enum import Flag as _Flag
12
+
13
+
14
+ class SensorStatus(_Flag):
15
+ OK = 0b000000000
16
+ LightningFailed = 0b000000001
17
+ LightningNoise = 0b000000010
18
+ LightningDisturbance = 0b000000100
19
+ PressureFailed = 0b000001000
20
+ TemperatureFailed = 0b000010000
21
+ RHFailed = 0b000100000
22
+ WindFailed = 0b001000000
23
+ PrecipitationFailed = 0b010000000
24
+ LightFailed = 0b100000000
25
+
26
+
27
+ class Debug(_Flag):
28
+ Disabled = 0
29
+ Enabled = 1
30
+
31
+
32
+ class ResetFlags(_Flag):
33
+ BOR = 'Brownout'
34
+ PIN = 'PIN'
35
+ POR = 'Power'
36
+ SFT = 'Software'
37
+ WDG = 'Watchdog'
38
+ WWD = 'WindowWatchdog'
39
+ LPW = 'LowPower'
40
+
41
+
42
+ UDPClasses = {
43
+ 'time': int,
44
+ 'lullSpeed': 'Wind',
45
+ 'windSpeed': 'Wind',
46
+ 'gustSpeed': 'Wind',
47
+ 'speed': 'Wind',
48
+ 'direction': Direction,
49
+ 'windDirection': Direction,
50
+
51
+ 'windSampleInterval': Time.Second,
52
+ 'pressure': Millibar,
53
+ 'temperature': Celsius,
54
+ 'humidity': Humidity,
55
+
56
+ 'illuminance': Lux,
57
+ 'uvi': UVI,
58
+ 'irradiance': RadiantFlux,
59
+
60
+ 'precipitationRate': 'Precipitation',
61
+ 'precipitationDaily': 'PrecipitationDaily',
62
+ 'precipitationType': Precipitation.Type,
63
+
64
+ 'distance': Kilometer,
65
+ 'lightningLastDistance': Kilometer,
66
+ 'lightning': LightningStrike,
67
+ 'lightningEnergy': int,
68
+
69
+ 'battery': Voltage,
70
+ 'reportInterval': Time.Minute,
71
+ 'Wind': (Wind, Meter, Time.Second),
72
+ 'Precipitation': (Precipitation.Hourly, Millimeter, Time.Minute),
73
+ 'PrecipitationDaily': (Precipitation.Daily, Millimeter, Time.Day),
74
+
75
+ 'deviceSerial': str,
76
+ 'hubSerial': str,
77
+ 'uptime': Time.Second,
78
+ 'firmware': int,
79
+ 'deviceRSSI': RSSI,
80
+ 'hubRSSI': RSSI,
81
+ 'sensorStatus': SensorStatus,
82
+ 'debug': Debug,
83
+ 'resetFlags': 'resetFlag',
84
+ 'resetFlag': ResetFlags,
85
+ }
86
+
87
+ '''
88
+ Sky
89
+ 0 Time Epoch Seconds
90
+ 1 Illuminance Lux
91
+ 2 UV Index
92
+ 3 Rain amount over previous minute mm
93
+ 4 Wind Lull (minimum 3 second sample) m/s
94
+ 5 Wind Avg (average over report interval) m/s
95
+ 6 Wind Gust (maximum 3 second sample) m/s
96
+ 7 Wind Direction Degrees
97
+ 8 Battery Volts
98
+ 9 Report Interval Minutes
99
+ 10 Solar Radiation W/m^2
100
+ 11 Local Day Rain Accumulation mm
101
+ 12 Precipitation Type 0 = none, 1 = rain, 2 = hail
102
+ 13 Wind Sample Interval seconds
103
+
104
+ Air
105
+ 0 Time Epoch Seconds
106
+ 1 Station Pressure MB
107
+ 2 Air Temperature C
108
+ 3 Relative Humidity %
109
+ 4 Lightning Strike Count
110
+ 5 Lightning Strike Avg Distance km
111
+ 6 Battery
112
+ 7 Report Interval Minutes
113
+
114
+ Tempest
115
+ 0 Time Epoch Seconds
116
+ 1 Wind Lull (minimum 3 second sample) m/s
117
+ 2 Wind Avg (average over report interval) m/s
118
+ 3 Wind Gust (maximum 3 second sample) m/s
119
+ 4 Wind Direction Degrees
120
+ 5 Wind Sample Interval seconds
121
+ 6 Station Pressure MB
122
+ 7 Air Temperature C
123
+ 8 Relative Humidity %
124
+ 9 Illuminance Lux
125
+ 10 UV Index
126
+ 11 Solar Radiation W/m^2
127
+ 12 Rain amount over previous minute mm
128
+ 13 Precipitation Type 0 = none, 1 = rain, 2 = hail, 3 = rain + hail (experimental)
129
+ 14 Lightning Strike Avg Distance km
130
+ 15 Lightning Strike Count
131
+ 16 Battery Volts
132
+ 17 Report Interval Minutes
133
+
134
+ '''
135
+
136
+
137
+ class UDP:
138
+ # __slots__ = ['messageTypes', 'Message', 'Wind', 'Event', 'ObservationSet', 'Status', 'Device', 'Hub']
139
+
140
+ messageTypes = {
141
+ 'air': 'obs_air',
142
+ 'sky': 'obs_sky',
143
+ 'tempest': 'obs_st',
144
+
145
+ 'obs_st': ['time', 'lullSpeed', 'windSpeed', 'gustSpeed', 'windDirection',
146
+ 'windSampleInterval', 'pressure', 'temperature', 'humidity',
147
+ 'illuminance', 'uvi', 'irradiance', 'precipitationRate',
148
+ 'precipitationType', 'lightningLastDistance', 'lightning',
149
+ 'battery', 'reportInterval'],
150
+
151
+ 'obs_sky': ['time', 'illuminance', 'uvi', 'precipitationHourlyRaw', 'lullSpeed',
152
+ 'windSpeed', 'gustSpeed', 'windDirection', 'battery', 'reportInterval',
153
+ 'irradiance', 'precipitationDaily', 'precipitationType', 'windSampleInterval'],
154
+
155
+ 'obs_air': ['time', 'pressure', 'temperature', 'humidity', 'lightning', 'lightningLastDistance',
156
+ 'battery', 'reportInterval'],
157
+
158
+ 'wind': 'rapid_wind',
159
+ 'rain': 'evt_precip',
160
+ 'lightning': 'evt_strike',
161
+
162
+ 'rapid_wind': ['time', 'speed', 'direction'],
163
+
164
+ 'evt_strike': ['time', 'distance', 'energy'],
165
+
166
+ 'evt_precip': ['time']
167
+ }
168
+
169
+ Message = {'serial_number': str, 'hub_sn': str, 'type': str}
170
+ Wind = {**Message, 'ob': list}
171
+ Event = {**Message, 'evt': list}
172
+ ObservationSet = {**Message, 'obs': list}
173
+
174
+ Status = {'serial_number': str, 'type': str, 'timestamp': int, 'uptime': Time.Second, 'firmware_revision': int, 'rssi': RSSI}
175
+ Device = {**Status, 'hub_sn': str, 'voltage': Voltage, 'hub_rssi': RSSI, 'sensor_status': SensorStatus, 'debug': Debug}
176
+ Hub = {**Status, 'reset_flags': ResetFlags, 'radio_stats': list}
@@ -0,0 +1 @@
1
+ from . import WeatherFlow
@@ -0,0 +1,16 @@
1
+ from ..length import Length
2
+ from ..mass import Mass
3
+ from .. import Time
4
+ from .. import DerivedMeasurement
5
+ from .. import Direction
6
+ from .. import Measurement
7
+ from .. import ScalingMeasurement
8
+
9
+ from .rate import DistanceOverTime
10
+ from .wind import Wind
11
+ from .precipitation import Precipitation
12
+ from .volume import Volume
13
+ from .density import Density
14
+ from .partsPer import PartsPer
15
+
16
+ __all__ = ['Volume', 'DistanceOverTime', 'Precipitation', 'Density', 'PartsPer', 'Wind']
@@ -0,0 +1,26 @@
1
+ from ..base.Decorators import UnitType
2
+ from . import Length, Mass, DerivedMeasurement, Volume
3
+
4
+ __all__ = ['Density']
5
+
6
+
7
+ @UnitType
8
+ class Density(DerivedMeasurement, min=0, numerator=Mass, denominator=Volume):
9
+ _id = 'density'
10
+
11
+ def __new__(cls, numerator: Mass, denominator: Volume = 1, *args, **kwargs):
12
+ if not isinstance(denominator, Volume) and isinstance(denominator, Length):
13
+ denominator = Volume.compatibleUnits[denominator.unit](denominator)
14
+ return super().__new__(cls, numerator, denominator, *args, **kwargs)
15
+
16
+ @property
17
+ def localize(self):
18
+ self.unit
19
+ return super().localize
20
+
21
+ @property
22
+ def unit(self):
23
+ return super().unit
24
+
25
+ def __class_getitem__(cls, item):
26
+ return super().__class_getitem__(item)
@@ -0,0 +1,96 @@
1
+ from ..base.Decorators import UnitType
2
+ from ..base import Scale
3
+ from . import ScalingMeasurement
4
+
5
+ __all__ = ['PartsPer']
6
+
7
+
8
+ @UnitType
9
+ class PartsPer(ScalingMeasurement, baseClass='Hundred'):
10
+ _precision = 0
11
+
12
+ class _Scale(Scale):
13
+ Hundred = 100
14
+ Thousand = 10
15
+ TenThousand = 10
16
+ HundredThousand = 10
17
+ Million = 10
18
+ Billion = 1000
19
+ Trillion = 1000
20
+ Base = 'Hundred'
21
+ Precent = 100.
22
+
23
+ @property
24
+ def hundred(self):
25
+ return Hundred(self)
26
+ precent=hundred
27
+
28
+ @property
29
+ def thousand(self):
30
+ return Thousand(self)
31
+
32
+ @property
33
+ def tenThousand(self):
34
+ return TenThousand(self)
35
+
36
+ @property
37
+ def hundredThousand(self):
38
+ return HundredThousand(self)
39
+
40
+ @property
41
+ def million(self):
42
+ return Million(self)
43
+ ppm = million
44
+
45
+ @property
46
+ def billion(self):
47
+ return Billion(self)
48
+ ppb = billion
49
+
50
+ @property
51
+ def trillion(self):
52
+ return Trillion(self)
53
+ ppt = trillion
54
+
55
+
56
+ class Hundred(PartsPer):
57
+ _precision = 2
58
+ _digit_budget = 3
59
+ _unit = '%'
60
+
61
+
62
+ Percent = Hundred
63
+
64
+
65
+ class Thousand(PartsPer):
66
+ _unit = '‰'
67
+
68
+
69
+ class TenThousand(PartsPer):
70
+ _unit = '‱'
71
+
72
+
73
+ class HundredThousand(PartsPer):
74
+ _unit = 'pcm'
75
+
76
+
77
+ class Million(PartsPer):
78
+ _unit = 'ppm'
79
+
80
+
81
+ class Billion(PartsPer):
82
+ _unit = 'ppb'
83
+
84
+
85
+ class Trillion(PartsPer):
86
+ _unit = 'ppt'
87
+
88
+
89
+ PartsPer.Hunderd = Hundred
90
+ PartsPer.Precent = Hundred
91
+ PartsPer.Thousand = Thousand
92
+ PartsPer.TenThousand = TenThousand
93
+ PartsPer.HundredThousand = HundredThousand
94
+ PartsPer.Million = Million
95
+ PartsPer.Billion = Billion
96
+ PartsPer.Trillion = Trillion
@@ -0,0 +1,96 @@
1
+ from enum import Enum
2
+ from typing import SupportsAbs
3
+
4
+ from ..base.Decorators import UnitType
5
+ from . import Length, Time, DistanceOverTime
6
+
7
+ __all__ = ['Precipitation']
8
+
9
+
10
+ class Precipitation:
11
+ class Type(Enum):
12
+ NONE = 0
13
+ Rain = 1
14
+ Hail = 2
15
+ Sleet = 3
16
+ Snow = 4
17
+
18
+
19
+ @UnitType
20
+ class PrecipitationRate(DistanceOverTime, Precipitation, limit=(0.0, None)):
21
+ Daily: type
22
+ Hourly: type
23
+ Minutely: type
24
+
25
+ def __new__(cls, numerator: Length, denominator: int = None, *args, **kwargs):
26
+ if isinstance(denominator, SupportsAbs):
27
+ denominator = abs(denominator)
28
+ return super().__new__(cls, numerator, denominator, *args, **kwargs)
29
+
30
+ def __init__(self, numerator: Length, denominator: int = None, *args, **kwargs):
31
+ if isinstance(denominator, int):
32
+ denominator = Time.Hour(denominator)
33
+ DistanceOverTime.__init__(self, numerator, denominator, *args, **kwargs)
34
+
35
+ @property
36
+ def fth(self):
37
+ return Hourly(self._numerator.foot, self._denominator.hour)
38
+
39
+ @property
40
+ def inh(self):
41
+ return Hourly(self._numerator.inch, self._denominator.hour)
42
+
43
+ @property
44
+ def ins(self):
45
+ return PrecipitationRate(self._numerator.inch, self._denominator.second)
46
+
47
+ @property
48
+ def mmh(self):
49
+ return Hourly(self._numerator.millimeter, self._denominator.hour)
50
+
51
+ @property
52
+ def mms(self):
53
+ return PrecipitationRate(self._numerator.millimeter, self._denominator.second)
54
+
55
+ @property
56
+ def cmh(self):
57
+ return Hourly(self._numerator.centimeter, self._denominator.hour)
58
+
59
+ @property
60
+ def mh(self):
61
+ return Hourly(self._numerator.meter, self._denominator.hour)
62
+
63
+ @property
64
+ def daily(self):
65
+ return Daily(self._numerator, self._denominator)
66
+
67
+ @property
68
+ def hourly(self):
69
+ return Hourly(self._numerator, self._denominator)
70
+
71
+ @property
72
+ def minutely(self):
73
+ return Minutely(self._numerator, self._denominator)
74
+
75
+ @property
76
+ def secondly(self):
77
+ return Secondly(self.numerator, self.denominator)
78
+
79
+
80
+ class Daily(PrecipitationRate, denominator=Time.Day): ...
81
+
82
+
83
+ class Hourly(PrecipitationRate, denominator=Time.Hour): ...
84
+
85
+
86
+ class Minutely(PrecipitationRate, denominator=Time.Minute): ...
87
+
88
+
89
+ class Secondly(PrecipitationRate, denominator=Time.Second): ...
90
+
91
+
92
+ Precipitation.Rate = PrecipitationRate
93
+ Precipitation.Daily = Daily
94
+ Precipitation.Hourly = Hourly
95
+ Precipitation.Minutely = Minutely
96
+ Precipitation.Secondly = Secondly
@@ -0,0 +1,80 @@
1
+ from datetime import timedelta as _td
2
+
3
+ __all__ = ['DistanceOverTime']
4
+
5
+ from ..base.Decorators import UnitType
6
+ from . import Length, Time, DerivedMeasurement
7
+
8
+
9
+ @UnitType
10
+ class DistanceOverTime(DerivedMeasurement, numerator=Length, denominator=Time):
11
+
12
+ def __new__(cls, numerator: Length, denominator: Time = None, *args, **kwargs):
13
+ if isinstance(denominator, _td):
14
+ denominator = Time.Second(denominator.total_seconds())
15
+ return super().__new__(cls, numerator, denominator, *args, **kwargs)
16
+
17
+ def __init__(self, numerator: Length, denominator: Time = None, *args, **kwargs):
18
+ if isinstance(denominator, _td):
19
+ denominator = Time.Second(denominator.total_seconds())
20
+ super().__init__(numerator, denominator, *args, **kwargs)
21
+
22
+ @property
23
+ def fts(self):
24
+ return DistanceOverTime(self._numerator.ft, self._denominator.s)
25
+
26
+ @property
27
+ def mih(self):
28
+ converted = MilesPerHour(self._numerator.mi, self._denominator.hr)
29
+ return converted
30
+
31
+ @property
32
+ def inh(self):
33
+ return DistanceOverTime(self._numerator.inch, self._denominator.hr)
34
+
35
+ @property
36
+ def ms(self):
37
+ return DistanceOverTime(self._numerator.m, self._denominator.s)
38
+
39
+ @property
40
+ def mh(self):
41
+ return DistanceOverTime(self._numerator.m, self._denominator.hr)
42
+
43
+ @property
44
+ def kmh(self):
45
+ return DistanceOverTime(self._numerator.km, self._denominator.hr)
46
+
47
+ @property
48
+ def mmh(self):
49
+ return DistanceOverTime(self._numerator.mm, self._denominator.hr)
50
+
51
+ mph = mih
52
+ fps = fts
53
+
54
+
55
+ class PerSecond(DistanceOverTime, numerator=Length, denominator=Time.Second):
56
+ ...
57
+
58
+
59
+ class PerMinute(DistanceOverTime, numerator=Length, denominator=Time.Minute):
60
+ ...
61
+
62
+
63
+ class PerHour(DistanceOverTime, numerator=Length, denominator=Time.Hour):
64
+ ...
65
+
66
+
67
+ class MilesPerHour(PerHour, numerator=Length.Mile, unit='mph'):
68
+ ...
69
+
70
+
71
+ class MetersPerSecond(PerSecond, numerator=Length.Meter):
72
+ ...
73
+
74
+
75
+ DistanceOverTime.PerSecond = PerSecond
76
+ DistanceOverTime.PerMinute = PerMinute
77
+ DistanceOverTime.PerHour = PerHour
78
+ DistanceOverTime.MilesPerHour = MilesPerHour
79
+ DistanceOverTime.MetersPerSecond = MetersPerSecond
80
+ DistanceOverTime.MetersPerHour = MetersPerSecond
@@ -0,0 +1,122 @@
1
+ from typing import Union
2
+
3
+ from ..base.Decorators import UnitType
4
+ from . import Measurement, Length
5
+
6
+ __all__ = ['Volume']
7
+
8
+
9
+ @UnitType
10
+ class Volume(Measurement):
11
+ CubicFoot: type
12
+ CubicMeter: type
13
+
14
+ _x: Length
15
+ _y: Length
16
+ _z: Length
17
+ _unitClass = Length
18
+ _cube: bool
19
+
20
+ def __init__(self, x: Union[Length, int, float], y: Union[Length, int, float] = None, z: Union[Length, int, float] = None):
21
+ if isinstance(x, Volume):
22
+ y = x.y
23
+ z = x.z
24
+ x = x.x
25
+ if not (y and z):
26
+ x = float(x)
27
+ x **= 1./3.
28
+ y = x
29
+ z = x
30
+ self._x = self._unitClass(x)
31
+ self._y = self._unitClass(y)
32
+ self._z = self._unitClass(z)
33
+ float.__init__(x*y*z)
34
+
35
+ def __new__(cls, x: Length, y: Length = None, z: Length = None):
36
+ if isinstance(x, Volume):
37
+ y = x.y
38
+ z = x.z
39
+ x = x.x
40
+ if not (y and z):
41
+ x = float(x)
42
+ x **= 1./3.
43
+ y = x
44
+ z = x
45
+ x = cls._unitClass(x)
46
+ y = cls._unitClass(y)
47
+ z = cls._unitClass(z)
48
+ value = float(x)*float(y)*float(z)
49
+ return float.__new__(cls, value)
50
+
51
+ @property
52
+ def width(self) -> Length:
53
+ return self._x
54
+
55
+ @property
56
+ def length(self) -> Length:
57
+ return self._y
58
+
59
+ @property
60
+ def depth(self) -> Length:
61
+ return self._z
62
+
63
+ @property
64
+ def unit(self) -> str:
65
+ return self._x.unit + "³"
66
+
67
+ def scale(self, value: float):
68
+ x = self._x * value
69
+ y = self._y * value
70
+ z = self._z * value
71
+ return x, y, z
72
+
73
+ @property
74
+ def x(self):
75
+ return self._x
76
+
77
+ @property
78
+ def y(self):
79
+ return self._y
80
+
81
+ @property
82
+ def z(self):
83
+ return self._z
84
+
85
+ # class CubicMeter(Volume, Length.Meter, unit='m³', aliases=('m3', 'm^3', 'm'), dimension=(Length, Length, Length)):
86
+ # _x: Length.Meter
87
+ # _y: Length.Meter
88
+ # _z: Length.Meter
89
+ # _unitClass = Length.Meter
90
+ #
91
+ # @property
92
+ # def ft(self):
93
+ # x = self._x.ft
94
+ # y = self._y.ft
95
+ # z = self._z.ft
96
+ # return CubicFoot(x, y, z)
97
+ #
98
+ # @property
99
+ # def m(self):
100
+ # return self
101
+ #
102
+ #
103
+ # class CubicFoot(Volume, Length.Foot, unit='ft³', aliases=('ft3', 'ft^3', 'ft'), dimension=(Length, Length, Length)):
104
+ # _x: Length.Foot
105
+ # _y: Length.Foot
106
+ # _z: Length.Foot
107
+ # _unitClass = Length.Foot
108
+ #
109
+ # @property
110
+ # def ft(self):
111
+ # return self
112
+ #
113
+ # @property
114
+ # def m(self):
115
+ # x = self._x.m
116
+ # y = self._y.m
117
+ # z = self._z.m
118
+ # return CubicMeter(x, y, z)
119
+ #
120
+ #
121
+ # Volume.CubicMeter = CubicMeter
122
+ # Volume.CubicFoot = CubicFoot
@@ -0,0 +1,54 @@
1
+ from ..base.Decorators import UnitType
2
+ from . import Length, Time, DistanceOverTime, Direction
3
+
4
+ __all__ = ['Wind']
5
+
6
+
7
+ @UnitType
8
+ class Wind(DistanceOverTime):
9
+ # TODO: Add support for setting both speed and direction
10
+ __direction: Direction = None
11
+
12
+ @property
13
+ def direction(self):
14
+ return self.__direction
15
+
16
+ @direction.setter
17
+ def direction(self, value):
18
+ if not isinstance(value, Direction) and isinstance(value, (float, int)):
19
+ value = Direction(value)
20
+ self.__direction = value
21
+
22
+
23
+ class PerSecond(Wind, DistanceOverTime.PerSecond):
24
+ ...
25
+
26
+
27
+ class PerMinute(Wind, DistanceOverTime.PerMinute):
28
+ ...
29
+
30
+
31
+ class PerHour(Wind, DistanceOverTime.PerHour):
32
+ ...
33
+
34
+
35
+ class MilesPerHour(Wind, DistanceOverTime.MilesPerHour):
36
+ ...
37
+
38
+
39
+ class MetersPerSecond(Wind, DistanceOverTime.MetersPerSecond):
40
+ ...
41
+
42
+
43
+ # Attach the concrete units to Wind, the same way rate.py attaches its own.
44
+ # Without this, `Wind.MilesPerHour` resolves by ordinary inheritance to
45
+ # DistanceOverTime's class, whose type is 'Distance Over Time' rather than
46
+ # 'Wind'. Localization looks the unit type up in the config by that name, so
47
+ # it found no `wind` key, returned None, and every wind reading stayed in its
48
+ # source unit - a `wind = mph` config still displayed m/s.
49
+ Wind.PerSecond = PerSecond
50
+ Wind.PerMinute = PerMinute
51
+ Wind.PerHour = PerHour
52
+ Wind.MilesPerHour = MilesPerHour
53
+ Wind.MetersPerSecond = MetersPerSecond
54
+ Wind.MetersPerHour = MetersPerSecond
@@ -0,0 +1,21 @@
1
+ __all__ = ['RSSI']
2
+
3
+ from ..base.Decorators import UnitType
4
+ from ..base import Measurement
5
+
6
+
7
+ @UnitType
8
+ class RSSI(Measurement):
9
+ _unit = 'dBm'
10
+ _strings = ['Perfect', 'Great', 'Good', 'Bad', 'None']
11
+ _values = [-30, -67, -70, -80, -90]
12
+ _precision = 0
13
+ _digit_budget = 2
14
+
15
+ @property
16
+ def string(self):
17
+ v = int(self)
18
+ i = 0
19
+ while i < len(self._values) - 1 and v < self._values[i]:
20
+ i += 1
21
+ return self._strings[i]
@@ -0,0 +1,4 @@
1
+ from .energy import *
2
+ from .power import *
3
+
4
+ __all__ = ['Energy', 'Power']