Skip to main content

Tools for working with common Passive House unit types

Project description

PH-Units:

A package for converting common Passive House unit types (IP | SI).

Usage:

The most basic usage is a simple conversion from one known unit to another:

>>> from ph_units.converter import convert
>>> # Convert 12.45 meters to feet...
>>> convert(12.45, "M", "FT") -> 40.85 # FT

The package also has a parser which can take simple text in the format: "{value} {unit}" and will split apart the text into a numeric part and a unit part:

>>> from ph_units.parser import parse_input
>>> val, unit = parse_input("0.17 BTU/HR-FT2-F")
>>> val  # 0.17
>>> unit # 'BTU/HR-FT2-F'

The results of the parser can then be fed into the converter

>>> from ph_units.converter import convert
>>> convert(val, "W/MK", unit) -> 0.098 # BTU/HR-FT2-F

Unit Types Supported:

  • area (M2, FT2)
  • density (KG/M3, LB/FT3)
  • emissions factors (G/KWH)
  • energy (Wh/M3, Wh/M2, kW/M2, kBtu/ft2, Btu/ft2)
  • envelope (U-Value, R-Value)
  • length (M, CM, MM, IN, FT)
  • moisture vapor resistance (MNS/G, PERM-IN)
  • power (kW, W, W/M2, W/ft2, W/cfm, Btu/h-ft2, Btu/h)
  • speed (m/d, m/s, m/h, ft/s, ft/d)
  • temperature (C, F)
  • volume flow (M3/HR, CFM)
  • volume (M2, FT3, LITER, GALLON)

Adding New Units:

The conversion factors used are stored as types in the ph_units.unit_types directory. Note that the types also allow for common 'alias' descriptions ie: 'feet' can be denoted as "FT", "ft." or even the symbol '

The Unit Type:

The package also includes a new Unit type which subclasses from float but also retains the unit-type information. This allows for easy conversion between units. For example:

>>> from ph_units.unit_type import Unit
>>> a_meter_value = Unit(1.0, "M")
>>> print(a_meter_value)
>>> "1.0 (M)"
>>> a_foot_value = a_meter_value.as_a("FT")
>>> print(a_foot_value)
>>> "3.281(FT)"

This Unit type supports basic mathematical operations like addition and subtraction, as well as unit-related operations like 'inversion'.

The Unit type also supports serialization and deserialization to and from JSON. Additionally, the Unit type can be used as a dataclass field type and should serialize properly when dataclass as_dict is called on the parent object.


Tests versions IronPython

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ph_units-1.5.34.tar.gz (77.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ph_units-1.5.34-py2.py3-none-any.whl (32.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ph_units-1.5.34.tar.gz.

File metadata

  • Download URL: ph_units-1.5.34.tar.gz
  • Upload date:
  • Size: 77.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ph_units-1.5.34.tar.gz
Algorithm Hash digest
SHA256 b094152f200fdff341115b14c21f40251d906659da53bea018eb856daf583fc8
MD5 1b548fc4102a4d707f348b1363fba70b
BLAKE2b-256 0cbc32efc589ff405b76db104c974e10ed23a6fd66e4d306a2146ae54c42ea3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ph_units-1.5.34.tar.gz:

Publisher: ci.yml on PH-Tools/PH_units

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ph_units-1.5.34-py2.py3-none-any.whl.

File metadata

  • Download URL: ph_units-1.5.34-py2.py3-none-any.whl
  • Upload date:
  • Size: 32.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ph_units-1.5.34-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 135584a99ba78be8d379f8b499c9bd55094af8e574abc12f306a09305ce155d6
MD5 621c684270a0bd5c84fd2dc76f9cab4f
BLAKE2b-256 c6fd183ffc7272490cdf0ca5999d68ebd492d0feec9e968c1e1c6392c3759de2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ph_units-1.5.34-py2.py3-none-any.whl:

Publisher: ci.yml on PH-Tools/PH_units

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page