Skip to main content

lwbgt

PyPI CRAN R-universe

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.2.1. 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.

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.2.1

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.2.1
File Size Uploaded
lwbgt-1.2.1.tar.gz 131.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for lwbgt 1.2.1
File
lwbgt-1.2.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
lwbgt-1.2.1-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.2.1-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.2.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
lwbgt-1.2.1-py3-none-macosx_10_9_x86_64.whl Python 3 none macOS 10.9+ x86-64 Details

Total release size: 237.0 kB

Release files / lwbgt-1.2.1.tar.gz

Download URL lwbgt-1.2.1.tar.gz
Size 131.4 kB
Tags Source
SHA-256 checksum
How to use checksums
56993b1216eed96465bad2515120ca7ef9f098dffb1e7ff0a7301765d0fe74a4
BLAKE2b-256 checksum
How to use checksums
4b7347612cf38132e553acfe55dc19a9654d63f8dab30743b44abad843e8a7e2
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 11, 2026.

Transparency log

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

Download URL lwbgt-1.2.1-py3-none-win_amd64.whl
Size 26.3 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
22fe0afa28b7e7bc348ce80c7b0351d81abdb53a1e3996a292c9be3959980c62
BLAKE2b-256 checksum
How to use checksums
e02c32d71f17728c3b54c259f3e4c3875ccb3d9a7eb3adc2ef791da1bfb29d99
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 11, 2026.

Transparency log

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

Download URL lwbgt-1.2.1-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 20.9 kB
Tags Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
3f6037c71a1b49959d515c3076eb6f523bf0ec8602e650d83a8ef23377ee8837
BLAKE2b-256 checksum
How to use checksums
aa376cff3e98f51d27e4cfc49699e76a085c654283ce8f7a092fba4272776fd1
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 11, 2026.

Transparency log

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

Download URL lwbgt-1.2.1-py3-none-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 20.4 kB
Tags Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 Python 3
SHA-256 checksum
How to use checksums
6e1f5bec6ab010eed09e122c2a17ff4902c61cc2ec4d58774df5e58ded6ff6c5
BLAKE2b-256 checksum
How to use checksums
eeec23d7f6419191ea277e8ce28ceb60f125dfd94c380e850ce432713a95ef1b
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 11, 2026.

Transparency log

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

Download URL lwbgt-1.2.1-py3-none-macosx_11_0_arm64.whl
Size 19.3 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3f1b9d6ee1dc556d9c03239180da6a392f33fb64ff016a216e4c8ea0a45bb0f1
BLAKE2b-256 checksum
How to use checksums
4053cdb0332b5a0fa4527d09e73923088e6adbcd884e9d07397410b7d8e75b37
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 11, 2026.

Transparency log

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

Download URL lwbgt-1.2.1-py3-none-macosx_10_9_x86_64.whl
Size 18.7 kB
Tags Python 3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
66cfb83a5cc090fa99c0f22ee91cc468fa1f27ad2be2db1c1f150be0308671d6
BLAKE2b-256 checksum
How to use checksums
279ae1cd4f4181dad1449139bcdcb913acf8f7d28b4789e89c86fe374214de8e
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 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.1 This release

6 release files

1.2.0

6 release files

1.1.0

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