Skip to main content

lwbgt

lwbgt is a stable, low-level C/FFI computational kernel for Liljegren outdoor WBGT. Derived from the Liljegren WBGT v1.1 C implementation, it preserves the original scalar ABI and documented numerical behaviour while removing demonstrably repeated or dead work. It is intended to be embedded as a numerical backend by higher-level scientific packages, services, and high-throughput data pipelines.

Python is an official, dependency-free ctypes binding to that same native kernel. Install a self-contained binary wheel with pip install lwbgt. Input units are explicit in field names and are never converted implicitly. The package intentionally does not add dataframe/xarray models, meteorological preprocessing, classifications, advisory policy, or alternate WBGT methods. For those higher-level workflows, consider pywbgt or thermofeel.

Release status: v0.3.0. v0.1.0 is the frozen scalar-compatibility release. Its complete permitted optimization set measures 1.316× on the primary GCC 13 benchmark and 1.289× in the GCC 16.2 container. The v0.2.0 position-independent static build measures 1.249× on the GCC 13 host. All three results exceed the mandatory 1.20× gate with exact compatibility. These are narrowly supported throughput measurements on the documented environments and workloads, not broader portability claims.

It is not affiliated with or endorsed by the original authors, UChicago Argonne, or the U.S. Department of Energy.

This distribution contains a modified Liljegren WBGT v1.1 derivative. Binary and source redistributions must retain the UChicago Argonne/Department of Energy acknowledgement in NOTICE and comply with LICENSING.md.

Python installation and quick start

python -m pip install lwbgt
from lwbgt import Input, calculate, esat

weather = Input(
    year=2024, month=4, day=15, hour=14, minute=30,
    gmt_offset_hours=8, averaging_minutes=60, urban=1,
    latitude_deg_north=1.3521, longitude_deg_east=103.8198,
    solar_w_m2=742.0, pressure_hpa=1008.4,
    air_temperature_c=32.1, relative_humidity_percent=68.0,
    wind_speed_m_s=2.8, wind_height_m=10.0,
    vertical_temperature_difference_c=-0.4,
)
result = calculate(weather)
assert result.status == 0
print(result.wbgt_c)
print(esat(273.15, phase=0))

Batch calculation uses the native serial batch entry point rather than a Python loop:

from lwbgt import calculate_batch

results = calculate_batch([weather, weather])

Input and Result are immutable typed records. Their complete field names, units, solver status, and -9999 failure convention map directly to ABI v1; see ABI.md. No third-party Python runtime dependency is required.

Purpose

lwbgt owns the numerical Liljegren calculation, stable C/FFI contracts, reproducible compatibility evidence, and low-level static/shared-library distribution. Higher-level callers own table and dataframe APIs, meteorological data ingestion, unit conversion beyond the documented ABI, missing-data policy, additional domain validation, classification and advisory systems, orchestration and parallelism, and application-specific defaults. This narrow boundary is intentional.

Applications / research pipelines
              |
      Python / R / Julia / services
              |
            lwbgt
              |
   Liljegren WBGT numerical model

When to use lwbgt

Use lwbgt when you need a stable C or FFI Liljegren backend; behaviour anchored to the original Liljegren C implementation; an embedded WBGT kernel for another package or service; high-volume calculation with preprocessing kept outside the kernel; or an auditable, reference-compatible numerical backend within the documented compatibility scope.

When not to use lwbgt directly

A higher-level package is more appropriate when the primary requirement is dataframe-oriented ergonomics, automatic weather-data preprocessing, policy or heat-risk classifications, a batteries-included Python/R/Julia API, or GPU/JAX execution.

Native build and install

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
ctest --test-dir build --output-on-failure
cmake --install build --prefix /desired/prefix

The build produces liblwbgt.a and a versioned shared library and installs lwbgt.h, CMake package metadata, and pkg-config metadata. Core compilation is GNU89 with -fno-fast-math -ffp-contract=off -fno-strict-aliasing; LTO and architecture-specific flags are not enabled. GCC, Clang/AppleClang, and MinGW GCC are supported; MSVC cannot compile the preserved K&R source.

Installed CMake consumers can select lwbgt::static or lwbgt::shared after find_package(lwbgt CONFIG REQUIRED).

Supported API and compatibility contract

ABI.md defines the authoritative layouts, units, error behavior, concurrency rules, symbol surface, and compatibility policy.

The legacy calc_wbgt and esat declarations in include/lwbgt.h remain the permanent scalar compatibility ABI. Scalar floating-point arguments use double at the ABI boundary because the original K&R float parameters undergo default argument promotion; output pointers remain float *.

The v1 FFI ABI adds fixed-layout lwbgt_input_v1 and lwbgt_output_v1 structures and lwbgt_calc_batch_v1. The batch call executes scalar calls in input order. It returns the supplied wind as the effective 2-m wind when no height conversion is needed, avoiding the legacy scalar routine's untouched output-pointer behavior. It performs no allocation, retains no caller pointers, and introduces no domain validation, clamping, unit conversion, or missing-value policy beyond inherited scalar behaviour. Input and output arrays must not overlap. Independent calls using separate buffers are thread-safe; a single batch call is serial.

The shared library exports only calc_wbgt, esat, and lwbgt_calc_batch_v1. The static archive retains global helper symbols inherited from the source implementation; they remain unsupported implementation details. The exported-symbol review is recorded in tests/API.md.

The maintained Python package and minimal R and Julia examples demonstrate the intended integration pattern: higher-level packages can bind the stable ABI while owning their user-facing policies. The R and Julia examples are tested interoperability examples, not registry packages, and no compatibility claim is made for third-party wrappers.

The exact upstream source is retained unmodified at upstream/wbgt.c.original. src/wbgt.c is the modified derivative maintained by Yifei/HeatStressDev. HeatStressBench's frozen liljegren-c target remains the oracle and is not replaced or relabelled.

Numerical provenance and the exact-compatibility scope are documented in ABI.md, UPSTREAM.md, and the retained test evidence.

For matched compilers and floating-point flags, the acceptance policy is exact 32-bit equality for return status, estimated wind speed, Tg, Tnwb, Tpsy, WBGT, and esat. The deterministic 454-case suite produces the same 087532603ebd6d3addad5bec4d99290eb3f1a9ed82bdfb141d5e9708194235ff probe hash with GCC 13.3.0 and GCC 16.2.0.

Evidence

Environment Exact result Median overall speedup Release gate
Linux x86-64, GCC 13.3.0 bit-identical 1.316× passed
Linux x86-64 container, GCC 16.2.0 bit-identical 1.289× passed
Linux x86-64, GCC 13.3.0, v0.2.0 PIC build bit-identical 1.249× passed

Every v0.1.0 benchmark cohort exceeds 1.25×. The v0.2.0 PIC build passes the unchanged overall and per-cohort gates, with a 1.210× slowest measured cohort. Detailed host results, hardware, flags, datasets, warm-up, CPU-affinity policy, repetitions, medians, and dispersion are under benchmarks/. HeatStressBench adapter evidence is under tests/.

Licence and provenance

Project-authored files are licensed under Apache-2.0. The retained upstream source and modified derivative remain under the UChicago Argonne Liljegren WBGT v1.1 terms. LICENSING.md defines the file-level boundary and redistribution requirements.

UPSTREAM.md records the repository, pinned commit, blob, import date, and relationship to HeatStressBench. The complete upstream source licence is in LICENSES/LicenseRef-UChicago-Argonne-WBGT-1.1.txt; the required Argonne/Department of Energy acknowledgement is in NOTICE.

Explicit non-goals

This release adds no high-level dataframe/xarray API, unit conversion, meteorological ingestion, dew-point policy, classification thresholds, alternate solver, precision change, new physics, cache, parallelism, OpenMP, SIMD, GPU path, or fast-math mode.

Download files

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

Source Distribution

lwbgt-0.3.0.tar.gz (79.8 kB view details)

Uploaded Source

Built Distributions

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

lwbgt-0.3.0-py3-none-win_amd64.whl (30.1 kB view details)

Uploaded Python 3Windows x86-64

lwbgt-0.3.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (23.7 kB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

lwbgt-0.3.0-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl (23.4 kB view details)

Uploaded Python 3manylinux: glibc 2.12+ x86-64manylinux: glibc 2.28+ x86-64

lwbgt-0.3.0-py3-none-macosx_11_0_arm64.whl (22.8 kB view details)

Uploaded Python 3macOS 11.0+ ARM64

lwbgt-0.3.0-py3-none-macosx_10_9_x86_64.whl (22.1 kB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file lwbgt-0.3.0.tar.gz.

File metadata

  • Download URL: lwbgt-0.3.0.tar.gz
  • Upload date:
  • Size: 79.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lwbgt-0.3.0.tar.gz
Algorithm Hash digest
SHA256 4e44c21c490baae752b129f8389bdc77d4b15983001f3ca0a507940f0a58a4dd
MD5 192eaeec92d2a3a7f975a9883c8e57af
BLAKE2b-256 f329e1a9cc351d0fafd94eaca3d1a12f559cd785f242032e907647bbb76399be

See more details on using hashes here.

Provenance

The following attestation bundles were made for lwbgt-0.3.0.tar.gz:

Publisher: release.yml on zyf0717/lwbgt

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

File details

Details for the file lwbgt-0.3.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: lwbgt-0.3.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lwbgt-0.3.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 20bd091b5223e234174dbaaa633757ed06cfbc5c544dc172faca14d927f712e2
MD5 4243f44c86a850962b64dfcc0f6fe1f7
BLAKE2b-256 ff1b45448f87d5b9a63106cf90e41f9a261a7b5bc92e58995211505deb8cce65

See more details on using hashes here.

Provenance

The following attestation bundles were made for lwbgt-0.3.0-py3-none-win_amd64.whl:

Publisher: release.yml on zyf0717/lwbgt

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

File details

Details for the file lwbgt-0.3.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for lwbgt-0.3.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6e77b4455deb2329448e8bcfabf1c5e17ad2b1524ad0613d7fb9118de2eb2e67
MD5 a68ef817025ec8fb1b0156511e5f97e6
BLAKE2b-256 815ef28e93a09c7884a0fa77e0f2795e9a0d7ae61b9c3c644efb1a850b45bd42

See more details on using hashes here.

Provenance

The following attestation bundles were made for lwbgt-0.3.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release.yml on zyf0717/lwbgt

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

File details

Details for the file lwbgt-0.3.0-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for lwbgt-0.3.0-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e462cbe78bcce90f0a71555db560c92b88ba444c1e9763c55f8bc8c40a64c83c
MD5 6f261c89fc5ced13727bf1e590a929ee
BLAKE2b-256 a45c182ced1530d70fd3b20918f9b719dc9e28237c6a6353279712b5b63f1e8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for lwbgt-0.3.0-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on zyf0717/lwbgt

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

File details

Details for the file lwbgt-0.3.0-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: lwbgt-0.3.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lwbgt-0.3.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 00303437fb1e7ee231b32730ba0974ad856d7cde7c5ea8332c40f95628124e37
MD5 4da6b9d0cab6ca21af41bf0382651700
BLAKE2b-256 1b631f879757ff6c60ada01b49e89792d782fab4d105154afc3d7ed690e71af0

See more details on using hashes here.

Provenance

The following attestation bundles were made for lwbgt-0.3.0-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on zyf0717/lwbgt

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

File details

Details for the file lwbgt-0.3.0-py3-none-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: lwbgt-0.3.0-py3-none-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for lwbgt-0.3.0-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b02021fa9e689d739421d0bc0813837fbbe3993276e1263fa8e62a9a5d90a26f
MD5 0d17e963787bbcfa92c3095884714f8f
BLAKE2b-256 11bad27f4fe9fce0bf36015f7f28c7efadd4c66078603982eb1beee858388844

See more details on using hashes here.

Provenance

The following attestation bundles were made for lwbgt-0.3.0-py3-none-macosx_10_9_x86_64.whl:

Publisher: release.yml on zyf0717/lwbgt

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

Release history Release notifications | RSS feed

This release

0.3.0 This release

6 files

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