Skip to main content

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

Metadata

Release files for PH-units 1.5.23

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PH-units 1.5.23
File Size Uploaded Provenance Actions
ph_units-1.5.23.tar.gz 28.1 kB Without provenance Details for ph_units-1.5.23.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for PH-units 1.5.23
File Interpreter ABI Platform Actions
ph_units-1.5.23-py2.py3-none-any.whl Python 3, Python 2 none any Details for ph_units-1.5.23-py2.py3-none-any.whl

Total release size: 59.2 kB

Release files / ph_units-1.5.23.tar.gz

Download URL ph_units-1.5.23.tar.gz
Size 28.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d6b6f0846dbb955d16cb534cd2c0caf2ef6c3774ad21cb083280314f6622bebb
BLAKE2b-256 checksum
How to use checksums
3dc27d5abc09b76d54a812b93a4f126fccb10848a2d2691c4ad58e8a0de3e0a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.14

Release files / ph_units-1.5.23-py2.py3-none-any.whl

Download URL ph_units-1.5.23-py2.py3-none-any.whl
Size 31.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
dcfe4d5ce270c9749592844336ba3a5d8caec7ff28853d61eb6befd119fdc796
BLAKE2b-256 checksum
How to use checksums
918ceadb219a715938bf02ca857ac5aefad90d2974c1ccd804aa8a9e1a81a08f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.14

Security for PH-units 1.5.23

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.5.23 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page