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

UnitAliasNames
mmeterMeter
cmcentimeterCentimeter
mmmillimeterMillimeter
μmmicron, micrometerMicrometer
nmnanometerNanometer
angstromAngstrom
kmkilometerKilometer
ininchInch
ftfootFoot
ydyardYard
mimileMile

Temperature Units

UnitAliasNames
°CCelsiusCelsius
KkelvinKelvin
°FFahrenheitFahrenheit
°R°Ra, rankineRankine

Pressure Units

UnitAliasNames
Pan/m2, pascalPascal
hPahectopascalHectopascal
kPakPaa, kilopascalKilopascal
kPagKilopascal
gauge
atmAtmosphere
barbaraBar
bargBar gauge
fth2oFoot of
Water Column
inh2oInches of
water
inhgInch of
Mercury
TorrmmhgTorr (mmhg)
mTorrMillitorr
psipsiaPound-force
per square
inch
psigPound-force
per square
inch gauge

Time Units

UnitAliasNames
ssecondSecond
msmillisecondMillisecond
μsmicrosecondMicrosecond
nsnanosecondNanosecond
minminuteMinute
hrhourHour

Mass Units

UnitAliasNames
kgkilogramKilogram
ggramGram
lbpoundPound

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 nameTypeDescription
timestamppandas.TimestampTimestamp of the point
valuefloatValue of the point
Note

This function is only applicable to numeric series.

Examples

Copied!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 >>> 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
Copied!
1 2 3 4 5 6 7 8 9 10 >>> 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