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

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.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.2.0
File Size Uploaded
lwbgt-1.2.0.tar.gz 127.4 kB Details

Built distributions (wheels)

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

Total release size: 233.0 kB

Release files / lwbgt-1.2.0.tar.gz

Download URL lwbgt-1.2.0.tar.gz
Size 127.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f3a609c4bd2abc435915e9d2275eac52344111427ee0e9be1d997bc5475818fd
BLAKE2b-256 checksum
How to use checksums
87b8c97043592db2893b5805c90196b073d3beba13f5f685645148c48c4866ea
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 9, 2026.

Transparency log

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

Download URL lwbgt-1.2.0-py3-none-win_amd64.whl
Size 26.3 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
3e6f3160c196487ad4a4362b315540d3af2826e9cf99fec2736f834c3cc998f3
BLAKE2b-256 checksum
How to use checksums
1051e9b9b5175701f0edc6f190bc28fcbd52cfbf0480cc83b2a29793d499b8ad
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 9, 2026.

Transparency log

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

Download URL lwbgt-1.2.0-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
fba82660128773a1a7f472fcc5efde3c4cb23935bc31f282b16590aad75023f2
BLAKE2b-256 checksum
How to use checksums
50cdb149b18fe1aceeb82d851b60f17d5a1c52e1e6317eb7d4937d4d752f6e1a
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 9, 2026.

Transparency log

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

Download URL lwbgt-1.2.0-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
d5b1b9358f26b8637e4c0d296c67fea126aebe2ce51c1869503a8fbca327c784
BLAKE2b-256 checksum
How to use checksums
b741cec48647b4c92fd6e7099bd8b0c28b5114fb2062d8a9e92e0f2fd18bb893
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 9, 2026.

Transparency log

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

Download URL lwbgt-1.2.0-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
3e1b39e773da03cba61fffb710ab5370ab475ee320a6b4c3c6f19cbd023b6743
BLAKE2b-256 checksum
How to use checksums
1fe9149d74315f3a24a337a2901a5cf998aa920dbc6b4d8b8ae34d395bfdb12f
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 9, 2026.

Transparency log

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

Download URL lwbgt-1.2.0-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
d22871f905abdef49f709883acf52ebdf1c23d2446960ec6c56bba12a260af7b
BLAKE2b-256 checksum
How to use checksums
981222d33a105b08f0c7d8e6ce6427d3e544e95ef15b881abbd5f19640f14ac9
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 9, 2026.

Transparency log

Release history Release notifications | RSS feed

1.2.1

6 release files

This release

1.2.0 This release

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