Skip to main content

lwbgt

PyPI CRAN R-universe Julia General

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

Compatibility and performance

Version: v1.3.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 measured 1.45–1.67× the original throughput across two CPU cores with GCC 13.3.0. 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.

JavaScript and TypeScript

The first npm release is planned for v1.3.0. Once published, install with npm install lwbgt.

import { createLWBGT, type Input } from 'lwbgt';

const model = await createLWBGT();
const 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, pressure_hpa: 1008.4,
  air_temperature_c: 32.1, relative_humidity_percent: 68,
  wind_speed_m_s: 2.8, wind_height_m: 10,
  vertical_temperature_difference_c: -0.4,
};
const { status, wbgt_c } = model.calculate(weather);

See the JS API and module worker example and validation report.

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.

Psychrometric wet-bulb is calculated by default. When only WBGT and its components are needed, use calculate(weather, psychrometric=False) or calculate_batch(records, psychrometric=False) to skip the independent solve. That result field is -9999; the remaining fields and status are unchanged. The C equivalent is lwbgt_calc_batch_ex_v1 with LWBGT_SKIP_PSYCHROMETRIC_WET_BULB; see the ABI contract above.

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

Use LWBGT.jl with Julia 1.10 or later. Install from General:

using Pkg
Pkg.add("LWBGT")
using LWBGT

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
println(result.wbgt_c)

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

Input and Result are immutable typed records following the ABI contract.

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

See the documentation index for API contracts, input assumptions, numerical evidence, and release history. For development and publishing, use Contributing and Releasing.

Metadata

Release files for lwbgt 1.3.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.3.0
File Size Uploaded Provenance Actions
lwbgt-1.3.0.tar.gz 166.8 kB With provenance Details for lwbgt-1.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for lwbgt 1.3.0
File Actions
lwbgt-1.3.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for lwbgt-1.3.0-py3-none-win_amd64.whl
lwbgt-1.3.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 for lwbgt-1.3.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
lwbgt-1.3.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 for lwbgt-1.3.0-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
lwbgt-1.3.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for lwbgt-1.3.0-py3-none-macosx_11_0_arm64.whl
lwbgt-1.3.0-py3-none-macosx_10_9_x86_64.whl Python 3 none macOS 10.9+ x86-64 Details for lwbgt-1.3.0-py3-none-macosx_10_9_x86_64.whl

Total release size: 274.0 kB

Release files / lwbgt-1.3.0.tar.gz

Download URL lwbgt-1.3.0.tar.gz
Size 166.8 kB
Tags Source
SHA-256 checksum
How to use checksums
517d00f696ea24019868b4294fe41d31a841cad3f702c8d2c9dfd0de8a98950d
BLAKE2b-256 checksum
How to use checksums
cff35c74a3d4cb94a769f985bd52328808350ef1ac9c6506d5d015f6ea81b699
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

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

Download URL lwbgt-1.3.0-py3-none-win_amd64.whl
Size 26.6 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
50a08eeec307e795206f6b6658b9b25fce555de4de66e83d82cfdfffae09b3ac
BLAKE2b-256 checksum
How to use checksums
3db2132f2b28af46ccd810939967513ccf6298f39cee7b118830051295f0aaa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

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

Download URL lwbgt-1.3.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 21.2 kB
Tags Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
36cd680ea2156a1e1f5fff11cd77d15955ef953940486dfb9e6d0269ae4691f5
BLAKE2b-256 checksum
How to use checksums
e722d155d88da2d2b1d729b761c4533e1835388bea6ee29b0e548cf7d1b47bcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

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

Download URL lwbgt-1.3.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
c749d7486c453fca76beb0ca8c634385a1a3c4ce1dae3fdedc583fc1d337fd9c
BLAKE2b-256 checksum
How to use checksums
b01ac369b6fb0f06531b847764b1cf77b16acfce8b85ff779d7f770f55bf1c69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

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

Download URL lwbgt-1.3.0-py3-none-macosx_11_0_arm64.whl
Size 19.6 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
28d6e1566d5f9f8b62ef718a650f5c985a430877679a4256c511420f857a0a27
BLAKE2b-256 checksum
How to use checksums
76edbdefc1f9fab40424f392d402b8f02dd7c314e479f6b39d84df80e443dff5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

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

Download URL lwbgt-1.3.0-py3-none-macosx_10_9_x86_64.whl
Size 19.0 kB
Tags Python 3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
5b09596a1a963235622254b3f40ee5274ca9c496239798199c3fb895476b96e5
BLAKE2b-256 checksum
How to use checksums
aa35ceb8396d59e64123eb93433f1f697fc1f8f00986eefe605e6e9b9a3e1122
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Security for lwbgt 1.3.0

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.

Full provenance

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for lwbgt-1.3.0.tar.gz

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 Dec 1, 2026.

Transparency log

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.

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