Skip to main content

lwbgt

PyPI CRAN R-universe

Native CI Wheel CI R package CI

lwbgt computes outdoor wet bulb globe temperature (WBGT) using the original Argonne Liljegren C calculation. One optimized C kernel serves the C/FFI, Python, R, Julia, and SwiftPM interfaces.

Compatibility and performance

Version: v1.1.0. Reference comparisons reproduce WBGT and its component temperatures bit for bit under matched compiler and floating-point settings. The v1 calculation remains the default throughout 1.x; future numerical revisions will use explicit versioned APIs while preserving v1. See the compatibility policy for the scope, documented corrections, and platform limits.

The kernel reuses intermediate results and avoids redundant work, preserving the original numerical precision. Our scalar benchmark measures about 1.6× the original throughput on one CPU. Performance depends on the compiler, hardware, and inputs.

Input assumptions

When some inputs are unavailable, use explicit, recorded assumptions. The library does not fill in defaults automatically.

Field Suggested assumption
pressure_hpa Prefer an estimate from site elevation. 1013.25 hPa is a sea-level screening assumption.
wind_height_m Use 10 only when the source specifies wind measured at 10 m; otherwise use instrument metadata.
vertical_temperature_difference_c 1 assumes a nighttime inversion. Only negative versus nonnegative matters.
urban Use 0 for rural or 1 for urban. If unknown, calculate both and retain the higher WBGT for screening.
averaging_minutes Use the source averaging interval; 0 is appropriate only for instantaneous or already centered observations.

Air temperature, humidity, wind speed, and daytime solar radiation have no general fallback. See the input guide for units, timestamp conventions, and when these assumptions affect the calculation.

Python

python -m pip install lwbgt
from lwbgt import Input, calculate, calculate_batch, 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=1,
)

result = calculate(weather)
assert result.status == 0
print(result.wbgt_c)

results = calculate_batch([weather, weather])
print(esat(273.15, phase=0))

Input and Result are immutable typed records. Field names, units, status codes, and failure behaviour are defined by the ABI contract. See the input assumptions before substituting unavailable observations.

R

Install from CRAN:

install.packages("lwbgt")

If CRAN is unavailable, use R-universe:

install.packages("lwbgt", repos = "https://zyf0717.r-universe.dev")
library(lwbgt)

weather <- lwbgt_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 = 1
)

result <- calculate(weather)
stopifnot(result$status == 0)
print(result$wbgt_c)
print(esat(273.15, phase = 0))

The R API provides lwbgt_input(), calculate(), and esat(). It returns ordinary data frames, recycles scalar constructor arguments, and isolates invalid or non-convergent rows. See the R quick start.

Julia

LWBGT lives in this repository's julia/ subdirectory and exposes Input, Result, calculate, calculate_batch, and esat through the native v1 ABI. Julia ≥1.10 is supported. The first binary-artifact release and General registration are pending; see the Julia guide for development installation and usage. Published releases will install the native library automatically, without a compiler or a separate JLL package.

SwiftPM

Add CLWBGT as a target dependency in Package.swift:

// swift-tools-version: 5.9
import PackageDescription

let package = Package(
    name: "WeatherService",
    dependencies: [
        .package(url: "https://github.com/zyf0717/lwbgt.git", from: "1.0.0"),
    ],
    targets: [
        .executableTarget(
            name: "WeatherService",
            dependencies: [
                .product(name: "CLWBGT", package: "lwbgt"),
            ]
        ),
    ]
)

In Sources/WeatherService/main.swift:

import CLWBGT

var weather = lwbgt_input_v1(
    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: 1
)
var result = lwbgt_output_v1()
let status = lwbgt_calc_batch_v1(&weather, &result, 1)
precondition(status == Int32(LWBGT_BATCH_OK))
precondition(result.status == 0)
print(result.wbgt_c)
print(esat(273.15, 0))

CLWBGT exposes the C structs and functions directly. Check both the call's return code and the result's status. SwiftPM builds the canonical C sources; downstream consumption is tested on Linux and macOS in release mode.

Native C

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 install provides static and shared libraries, lwbgt.h, CMake package metadata, and pkg-config metadata. CMake consumers can select lwbgt::static or lwbgt::shared after find_package(lwbgt CONFIG REQUIRED). GCC, Clang/AppleClang, and MinGW GCC are supported. MSVC is available for experimental compatibility testing with -DLWBGT_EXPERIMENTAL_MSVC=ON.

Documentation

Topic Document
Inputs, units, layouts, status codes, and concurrency ABI contract
Numerical compatibility and measured performance Compatibility and performance
Scope and common integration questions FAQ
Package selection lwbgt vs pywbgt vs thermofeel
Source lineage Upstream provenance
Source changes Deviations from original Liljegren C
Release history Changelog
Release procedure Maintainer guide

Metadata

Release files for lwbgt 1.1.0

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

Source distribution (sdist)

Source distribution for lwbgt 1.1.0
File Size Uploaded
lwbgt-1.1.0.tar.gz 153.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for lwbgt 1.1.0
File
lwbgt-1.1.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
lwbgt-1.1.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details
lwbgt-1.1.0-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl Python 3 none Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details
lwbgt-1.1.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
lwbgt-1.1.0-py3-none-macosx_10_9_x86_64.whl Python 3 none macOS 10.9+ x86-64 Details

Total release size: 262.5 kB

Release files / lwbgt-1.1.0.tar.gz

Download URL lwbgt-1.1.0.tar.gz
Size 153.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1b1fcee9da9240d6aa72b9abea47aaf3f65064454dd715414677dcd880cbef52
BLAKE2b-256 checksum
How to use checksums
042cf958501427e13f895a73b4c41c26da22d693f4c1e71a0ceb1b1b5afedad4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / lwbgt-1.1.0-py3-none-win_amd64.whl

Download URL lwbgt-1.1.0-py3-none-win_amd64.whl
Size 27.2 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
e2a0c06e8a809c4aba74b1b86faa09eb26cb09c2ca99490530e24ed237b81750
BLAKE2b-256 checksum
How to use checksums
c3e4d586d296b4c82cb47c65ecb076036c00e56ab3ea38f155c995b20c13eb76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / lwbgt-1.1.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL lwbgt-1.1.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 21.3 kB
Tags Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
dbf99083ff348de3d1f5100eb3836451b6a02b695f77d33532e8560ed8f3d61c
BLAKE2b-256 checksum
How to use checksums
2eff4beec74af39c06f0381dd9ab2251b3c7a7099c7be4bf50ecccecbc6451a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / lwbgt-1.1.0-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL lwbgt-1.1.0-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 20.7 kB
Tags Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 Python 3
SHA-256 checksum
How to use checksums
0849be31b3d4a609f52d1f8e07358e5902cf51782ea632d42c20f322d4508416
BLAKE2b-256 checksum
How to use checksums
dde8f45fc0db01abd8b1f7f833243c982cf9e8a2a48b3308652319a96d48de2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / lwbgt-1.1.0-py3-none-macosx_11_0_arm64.whl

Download URL lwbgt-1.1.0-py3-none-macosx_11_0_arm64.whl
Size 20.3 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
061f6073926641d46320d6110ae3d9151cbe03ed11c5fde10d90849912d53f82
BLAKE2b-256 checksum
How to use checksums
787ae6e21db22560b617cee420818675484c31c3b60a804955b242a8ea713f1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / lwbgt-1.1.0-py3-none-macosx_10_9_x86_64.whl

Download URL lwbgt-1.1.0-py3-none-macosx_10_9_x86_64.whl
Size 19.5 kB
Tags Python 3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
699d227fe83feb5dc047834894155c45f60618ed16e660221255c10c6f1fa540
BLAKE2b-256 checksum
How to use checksums
6989230498f195aa216a91f7e2534186ffbdb5bcb21ce651538cdbc79cba148b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release history Release notifications | RSS feed

1.2.1

6 release files

1.2.0

6 release files

This release

1.1.0 This release

6 release files

1.0.1

6 release files

1.0.0

6 release files

0.4.3

6 release files

0.4.2

6 release files

0.4.1

6 release files

0.4.0

6 release files

0.3.0

6 release 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