foundryts.functions.unit_conversion¶
foundryts.functions.unit_conversion(from_unit, to_unit)¶
Returns a function that converts all values in a single time series from the specified unit value to the specified unit.
The unit passed can either be a value from Unit or a valid Alias from the list of available units and
conversions below:
Length
| Unit | Alias | Names |
|---|---|---|
| m | meter | Meter |
| cm | centimeter | Centimeter |
| mm | millimeter | Millimeter |
| μm | micron, micrometer | Micrometer |
| nm | nanometer | Nanometer |
| angstrom | Angstrom | |
| km | kilometer | Kilometer |
| in | inch | Inch |
| ft | foot | Foot |
| yd | yard | Yard |
| mi | mile | Mile |
Temperature Units
| Unit | Alias | Names |
|---|---|---|
| °C | Celsius | Celsius |
| K | kelvin | Kelvin |
| °F | Fahrenheit | Fahrenheit |
| °R | °Ra, rankine | Rankine |
Pressure Units
| Unit | Alias | Names |
|---|---|---|
| Pa | n/m2, pascal | Pascal |
| hPa | hectopascal | Hectopascal |
| kPa | kPaa, kilopascal | Kilopascal |
| kPag | Kilopascal gauge |
|
| atm | Atmosphere | |
| bar | bara | Bar |
| barg | Bar gauge | |
| fth2o | Foot of Water Column |
|
| inh2o | Inches of water |
|
| inhg | Inch of Mercury |
|
| Torr | mmhg | Torr (mmhg) |
| mTorr | Millitorr | |
| psi | psia | Pound-force per square inch |
| psig | Pound-force per square inch gauge |
Time Units
| Unit | Alias | Names |
|---|---|---|
| s | second | Second |
| ms | millisecond | Millisecond |
| μs | microsecond | Microsecond |
| ns | nanosecond | Nanosecond |
| min | minute | Minute |
| hr | hour | Hour |
Mass Units
| Unit | Alias | Names |
|---|---|---|
| kg | kilogram | Kilogram |
| g | gram | Gram |
| lb | pound | Pound |
Contact your service administrator to access and extend the list of units and conversions for your deployment.
- Parameters:
- from_unit (str) – Original unit to convert values from.
- to_unit (str) – Desired unit to convert values to.
- Returns: A function that accepts a single time series as input and returns the time series with values converted to the specified unit.
- Return type:
(
FunctionNode) ->FunctionNode
Dataframe schema¶
| Column name | Type | Description |
|---|---|---|
| timestamp | pandas.Timestamp | Timestamp of the point |
| value | float | Value of the point |
:::callout{theme="warning" title="Note"} This function is only applicable to numeric series. :::
Examples¶
>>> series = F.points(
... (1, 8.0),
... (101, 4.0),
... (200, 2.0),
... (201, 1.0),
... (299, 35.0),
... (300, 16.0),
... (1000, 64.0),
... name="series",
... )
>>> series.to_pandas()
timestamp value
0 1970-01-01 00:00:00.000000001 8.0
1 1970-01-01 00:00:00.000000101 4.0
2 1970-01-01 00:00:00.000000200 2.0
3 1970-01-01 00:00:00.000000201 1.0
4 1970-01-01 00:00:00.000000299 35.0
5 1970-01-01 00:00:00.000000300 16.0
6 1970-01-01 00:00:00.000001000 64.0
>>> unit_converted = F.unit_conversion("m", "mm")(series)
>>> unit_converted.to_pandas()
timestamp value
0 1970-01-01 00:00:00.000000001 8000.0
1 1970-01-01 00:00:00.000000101 4000.0
2 1970-01-01 00:00:00.000000200 2000.0
3 1970-01-01 00:00:00.000000201 1000.0
4 1970-01-01 00:00:00.000000299 35000.0
5 1970-01-01 00:00:00.000000300 16000.0
6 1970-01-01 00:00:00.000001000 64000.0
中文翻译¶
foundryts.functions.unit_conversion¶
foundryts.functions.unit_conversion(from_unit, to_unit)¶
返回一个函数,该函数将单个时间序列中的所有值从指定的原始单位转换为指定的目标单位。
传入的单位可以是 Unit 中的值,也可以是下方可用单位及转换列表中的有效 Alias(别名):
长度单位(Length)
| 单位(Unit) | 别名(Alias) | 名称(Names) |
|---|---|---|
| m | meter | Meter |
| cm | centimeter | Centimeter |
| mm | millimeter | Millimeter |
| μm | micron, micrometer | Micrometer |
| nm | nanometer | Nanometer |
| angstrom | Angstrom | |
| km | kilometer | Kilometer |
| in | inch | Inch |
| ft | foot | Foot |
| yd | yard | Yard |
| mi | mile | Mile |
温度单位(Temperature Units)
| 单位(Unit) | 别名(Alias) | 名称(Names) |
|---|---|---|
| °C | Celsius | Celsius |
| K | kelvin | Kelvin |
| °F | Fahrenheit | Fahrenheit |
| °R | °Ra, rankine | Rankine |
压力单位(Pressure Units)
| 单位(Unit) | 别名(Alias) | 名称(Names) |
|---|---|---|
| Pa | n/m2, pascal | Pascal |
| hPa | hectopascal | Hectopascal |
| kPa | kPaa, kilopascal | Kilopascal |
| kPag | Kilopascal gauge(表压) |
|
| atm | Atmosphere | |
| bar | bara | Bar |
| barg | Bar gauge(表压) | |
| fth2o | Foot of Water Column(英尺水柱) |
|
| inh2o | Inches of water(英寸水柱) |
|
| inhg | Inch of Mercury(英寸汞柱) |
|
| Torr | mmhg | Torr (mmhg) |
| mTorr | Millitorr | |
| psi | psia | Pound-force per square inch |
| psig | Pound-force per square inch gauge(表压) |
时间单位(Time Units)
| 单位(Unit) | 别名(Alias) | 名称(Names) |
|---|---|---|
| s | second | Second |
| ms | millisecond | Millisecond |
| μs | microsecond | Microsecond |
| ns | nanosecond | Nanosecond |
| min | minute | Minute |
| hr | hour | Hour |
质量单位(Mass Units)
| 单位(Unit) | 别名(Alias) | 名称(Names) |
|---|---|---|
| kg | kilogram | Kilogram |
| g | gram | Gram |
| lb | pound | Pound |
请联系您的服务管理员,以访问和扩展您部署环境中的单位及转换列表。
- 参数:
- from_unit (str) – 要转换的原始单位。
- to_unit (str) – 要转换到的目标单位。
- 返回值: 一个函数,接受单个时间序列作为输入,并返回值已转换为指定单位的时间序列。
- 返回类型:
(
FunctionNode) ->FunctionNode
数据框模式(Dataframe schema)¶
| 列名(Column name) | 类型(Type) | 描述(Description) |
|---|---|---|
| timestamp | pandas.Timestamp | 数据点的时间戳 |
| value | float | 数据点的值 |
:::callout{theme="warning" title="注意"} 此函数仅适用于数值型序列。 :::
示例(Examples)¶
>>> series = F.points(
... (1, 8.0),
... (101, 4.0),
... (200, 2.0),
... (201, 1.0),
... (299, 35.0),
... (300, 16.0),
... (1000, 64.0),
... name="series",
... )
>>> series.to_pandas()
timestamp value
0 1970-01-01 00:00:00.000000001 8.0
1 1970-01-01 00:00:00.000000101 4.0
2 1970-01-01 00:00:00.000000200 2.0
3 1970-01-01 00:00:00.000000201 1.0
4 1970-01-01 00:00:00.000000299 35.0
5 1970-01-01 00:00:00.000000300 16.0
6 1970-01-01 00:00:00.000001000 64.0
>>> unit_converted = F.unit_conversion("m", "mm")(series)
>>> unit_converted.to_pandas()
timestamp value
0 1970-01-01 00:00:00.000000001 8000.0
1 1970-01-01 00:00:00.000000101 4000.0
2 1970-01-01 00:00:00.000000200 2000.0
3 1970-01-01 00:00:00.000000201 1000.0
4 1970-01-01 00:00:00.000000299 35000.0
5 1970-01-01 00:00:00.000000300 16000.0
6 1970-01-01 00:00:00.000001000 64000.0