Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
ad0992a
Separate input validation (#3)
Quba1 Feb 19, 2024
afbc568
update dependencies
Quba1 Feb 19, 2024
be37c8f
add vector macro
Quba1 Feb 19, 2024
d45b729
preliminary finish array macros
Quba1 Feb 19, 2024
48fe5da
start compute macros
Quba1 Feb 20, 2024
2e7cb3c
preliminary finish macros
Quba1 Feb 20, 2024
d365384
macro vapour pressure
Quba1 Feb 20, 2024
de8f099
macro vpd
Quba1 Feb 20, 2024
7abc80c
mixing ratio
Quba1 Feb 20, 2024
f8e2e59
macro relative humidity
Quba1 Feb 20, 2024
84756e5
macro potential temperature
Quba1 Feb 20, 2024
cc2f880
macro theta e
Quba1 Feb 20, 2024
e5307db
macro specific humidity
Quba1 Feb 20, 2024
322fc3b
macro wet bulb temperature
Quba1 Feb 20, 2024
37c2230
macro virtual temperature
Quba1 Feb 20, 2024
1603121
hmmm
Quba1 Feb 21, 2024
07c8019
WIP initial Formula implementation
Quba1 Feb 21, 2024
d241da9
WIP (slowly making API and tests work)
Quba1 Feb 22, 2024
cf12fb0
(WIP) comment out benchmarks
Quba1 Feb 22, 2024
d0826b6
rewrite vapour pressure
Quba1 Feb 22, 2024
1914f6f
rewrite mixing ration
Quba1 Feb 22, 2024
150ad65
rewrite wet bulb
Quba1 Feb 22, 2024
bb4b4c6
rewrite virtual temperature
Quba1 Feb 22, 2024
e12ca31
rewrite specific humdiity
Quba1 Feb 22, 2024
1249f7c
rewrite theta w
Quba1 Feb 22, 2024
04b75f7
rewrite potential temperature
Quba1 Feb 22, 2024
b3a4f55
add uniform test type for vapour pressure
Quba1 Feb 22, 2024
dc187ac
rewrite saturation vapour pressure
Quba1 Feb 22, 2024
8cd68ec
rewrite vpd
Quba1 Feb 22, 2024
2f7b477
rewrite saturation mixing ratio
Quba1 Feb 22, 2024
627a722
rewrtie relative humidity
Quba1 Feb 22, 2024
fe8616c
rewrite theta e
Quba1 Feb 22, 2024
f6d9941
WIP start array and parallel
Quba1 Feb 22, 2024
2da274e
implement arrays and parallel
Quba1 Feb 23, 2024
c66bc2a
begin yet another refactor
Quba1 Feb 23, 2024
c02972a
move floccus-proc to a common repo
Quba1 Feb 24, 2024
81a53a1
start proc macros refactor
Quba1 Feb 24, 2024
fde30ee
actually remove proc from repo because vscode dont work
Quba1 Feb 24, 2024
f08f304
refactor tests internals
Quba1 Feb 24, 2024
472ab35
WIP
Quba1 Feb 25, 2024
9e71a6f
add reasonable reference values
Quba1 Feb 26, 2024
08b7bff
(hopefully last time) finish vp
Quba1 Feb 26, 2024
98b17fe
vpd
Quba1 Feb 26, 2024
544faf6
virtual temperature
Quba1 Feb 26, 2024
be9f1e3
wet bulb temperature
Quba1 Feb 26, 2024
cb4d1e6
relative humidity
Quba1 Feb 26, 2024
58df217
wet bulb potential temperature
Quba1 Feb 26, 2024
47e7c01
specific humidity
Quba1 Feb 26, 2024
8ed802f
potential temperature
Quba1 Feb 26, 2024
efb8e8d
mixing ratio and saturation mixing ratio
Quba1 Feb 26, 2024
6fac716
saturation vapour pressure
Quba1 Feb 26, 2024
3199f16
start theta-e
Quba1 Feb 26, 2024
1f7334e
reorganise files
Quba1 Feb 27, 2024
c8a69e3
preliminary finish theta-e
Quba1 Feb 27, 2024
65a1642
refactor theta-e
Quba1 Feb 27, 2024
5413cda
fix tests
Quba1 Feb 27, 2024
61d6cde
add array functions for formula4
Quba1 Feb 27, 2024
d2d07c1
test array functions
Quba1 Feb 27, 2024
0b2f259
test arrays and imperial
Quba1 Feb 27, 2024
e66c07a
minor docs
Quba1 Feb 27, 2024
9d81109
switch to proc from repo
Quba1 Feb 28, 2024
1a7f5b0
Merge pull request #5 from ScaleWeather/arrays
Quba1 Feb 28, 2024
d990423
readme badges update
Quba1 Feb 28, 2024
2721873
test logs
Quba1 Feb 28, 2024
1e736d4
cleanup features
Quba1 Feb 28, 2024
54546a5
fmt
Quba1 Feb 28, 2024
dda09f6
intro to solving benches
Quba1 Feb 28, 2024
f82503d
saturation vapour pressure benchmarks
Quba1 Feb 28, 2024
e163ff0
relative humdiity benches
Quba1 Feb 28, 2024
10183bc
spec hum benches
Quba1 Feb 28, 2024
290bc10
virtual temp benches
Quba1 Feb 28, 2024
6058d03
all other benches
Quba1 Feb 28, 2024
561e5ed
add saturation mixing ratio benches
Quba1 Feb 28, 2024
a7b28a0
add all benches to group
Quba1 Feb 28, 2024
e95dae3
make same deps more flexible and allow publish
Quba1 Mar 6, 2024
a236ee4
improve benches naming
Quba1 Mar 6, 2024
558381b
fix bench warnings
Quba1 Mar 6, 2024
db1a865
correct benchmarks names
Quba1 Mar 6, 2024
afcb363
better organise benches
Quba1 Mar 28, 2024
63c66b7
add accessers for quantities + refactor
Quba1 Mar 28, 2024
a5ca57a
refactor traits for cleaner API
Quba1 Mar 28, 2024
0bf02a5
publish new alpha
Quba1 Mar 28, 2024
75b4f50
remove implicit dependencies
Quba1 Apr 5, 2024
cb0b800
simplify OutOfRange api
Quba1 Aug 16, 2024
4e8b93d
correct deps versions
Quba1 Aug 16, 2024
86eae17
relax APIs for computations with ndarray input
Quba1 Aug 17, 2024
8455130
debug log errors in all compute functions
Quba1 Aug 17, 2024
8b5a5be
make CI checks more exhaustive
Quba1 Aug 17, 2024
d6699bf
fix debug log compile condition
Quba1 Aug 17, 2024
3056ba6
add equivalent potential temperatures, clear up some constants
Quba1 Aug 19, 2024
cc94149
add theta_w with wider range
Quba1 Aug 19, 2024
91bbe81
generate inputs for vector/array tests as a percentage of reference v…
Quba1 Aug 19, 2024
a5ca7f8
add more extensive formula for wbt
Quba1 Aug 19, 2024
90eb2eb
corrected information about source of theta_e equation
Quba1 May 24, 2025
d48032e
updated dependecies and rust edition
Quba1 May 24, 2025
330cd32
IncorrectArgumentSet error argument does not have to be String
Quba1 May 24, 2025
27ada49
replace deprecated critertion::black_box
Quba1 May 24, 2025
b203843
remove floccus_proc dependecy
Quba1 May 24, 2025
41fd78a
use macros to remove repeated code in quantity implementations
Quba1 May 24, 2025
17d7cba
replace custom error logging logic with use of tracing crate
Quba1 May 24, 2025
0919680
validate inputs in parallel for ndarray
Quba1 May 24, 2025
a70b05d
auto clippy fixes
Quba1 May 24, 2025
37132ab
more clippy fixes
Quba1 May 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Basic Validation

on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '26 3 20 * *'

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-Dwarnings"

jobs:
build-and-test:

name: Build and Test

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Prepare environment
run: |
rustup update stable
cargo clean
- name: Test with cargo
run: |
cargo test
cargo test --no-default-features
cargo test --features "double_precision"
cargo test --features "argdebug"
cargo test --features "array"
cargo test --features "parallel"
cargo test --features "double_precision, argdebug"
cargo test --features "double_precision, array"
cargo test --features "double_precision, parallel"
cargo test --features "argdebug, array"
cargo test --features "argdebug, parallel"
cargo test --features "array, parallel"
cargo test --features "double_precision, argdebug, array"
cargo test --features "double_precision, argdebug, parallel"
cargo test --features "double_precision, array, parallel"
cargo test --features "argdebug, array, parallel"
cargo test --all-features
cargo clean
- name: Check release builds
run: |
cargo build --release
cargo build --release --no-default-features
cargo build --release --features "double_precision"
cargo build --release --features "argdebug"
cargo build --release --features "array"
cargo build --release --features "parallel"
cargo build --release --features "double_precision, argdebug"
cargo build --release --features "double_precision, array"
cargo build --release --features "double_precision, parallel"
cargo build --release --features "argdebug, array"
cargo build --release --features "argdebug, parallel"
cargo build --release --features "array, parallel"
cargo build --release --features "double_precision, argdebug, array"
cargo build --release --features "double_precision, argdebug, parallel"
cargo build --release --features "double_precision, array, parallel"
cargo build --release --features "argdebug, array, parallel"
cargo build --release --all-features
19 changes: 19 additions & 0 deletions .github/workflows/clippy-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on: pull_request

name: Cargo Clippy

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "-Dwarnings"

jobs:
clippy_check:
name: Check

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Clippy
run: |
rustup component add clippy
cargo clippy -- -D warnings
45 changes: 45 additions & 0 deletions .github/workflows/doc-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Cargo Doc

on:
pull_request

jobs:
pr-comment:
name: Check Coverage
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
- name: Fetch base
run: git fetch origin ${{ github.event.pull_request.base.sha }}
- name: Checkout base
run: git checkout ${{ github.event.pull_request.base.sha }}
- name: Calculate base doc coverage
uses: bewee/rustdoc-coverage-action@v1
- name: Fetch head
run: git fetch origin ${{ github.event.pull_request.head.sha }}
- name: Checkout head
run: git checkout ${{ github.event.pull_request.head.sha }}
- name: Calculate doc coverage
id: coverage
uses: bewee/rustdoc-coverage-action@v1
- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: "## Documentation Coverage:"
- name: Create or update comment
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## Documentation Coverage:
${{ steps.coverage.outputs.table }}
edit-mode: replace
46 changes: 0 additions & 46 deletions .github/workflows/rust.yml

This file was deleted.

66 changes: 45 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,67 +1,91 @@
[package]
name = "floccus"
version = "0.3.7"
version = "0.4.0-alpha.9"
authors = ["Jakub Lewandowski <scaleweather@gmail.com>"]
edition = "2021"
edition = "2024"
description = "Formulae for air thermodynamic calculations"
repository = "https://github.com/ScaleWeather/floccus"
readme = "README.md"
keywords = ["oceanography", "thermodynamics", "meteorology", "weather"]
categories = ["mathematics", "science"]
license = "Apache-2.0"
exclude = [
".github/*",
]
exclude = [".github/*"]

[dependencies]
thiserror = "^1.0.30"
float-cmp = "^0.9.0"
floccus-proc = {version = "0.2.5", optional = true}
log = "^0.4.14"
thiserror = "2.0"
float-cmp = "0.10"
tracing = { version = "0.1", optional = true, default-features = false, features = [
"attributes",
] }
ndarray = { version = "0.16", default-features = false, optional = true }
rayon = { version = "1.10", default-features = false, optional = true }
uom = { version = "0.37", default-features = false, features = [
"si",
"std",
"autoconvert",
"f32",
] }

[lib]
doctest = false

[dev-dependencies]
criterion = "0.4.0"
criterion = "0.6"
itertools = "0.14"
log = "0.4"
testing_logger = "0.1"
floccus = { path = ".", features = ["double_precision"] }

[features]
debug = ["floccus-proc"]
double_precision = []
default = []
argdebug = ["dep:tracing"]
double_precision = ["uom/f64"]
array = ["dep:ndarray"]
parallel = ["array", "ndarray/rayon", "dep:rayon"]

[[bench]]
name = "virtual_temperature"
name = "equivalent_potential_temperature"
harness = false

[[bench]]
name = "vapour_pressure"
name = "mixing_ratio"
harness = false

[[bench]]
name = "vapour_pressure_deficit"
harness = false
name = "potential_temperature"

[[bench]]
name = "mixing_ratio"
name = "relative_humidity"
harness = false

[[bench]]
name = "wet_bulb_temperature"
name = "saturation_mixing_ratio"
harness = false

[[bench]]
name = "relative_humidity"
name = "saturation_vapour_pressure"
harness = false

[[bench]]
name = "specific_humidity"
harness = false

[[bench]]
name = "potential_temperature"
name = "vapour_pressure_deficit"
harness = false

[[bench]]
name = "equivalent_potential_temperature"
name = "vapour_pressure"
harness = false

[[bench]]
name = "virtual_temperature"
harness = false

[[bench]]
name = "wet_bulb_potential_temperature"
harness = false

[[bench]]
name = "wet_bulb_temperature"
harness = false
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# floccus

[![License](https://img.shields.io/github/license/ScaleWeather/floccus)](https://choosealicense.com/licenses/apache-2.0/)
[![Crates.io](https://img.shields.io/crates/v/floccus)](https://crates.io/crates/floccus)
[![dependency status](https://deps.rs/repo/github/ScaleWeather/floccus/status.svg)](https://deps.rs/repo/github/ScaleWeather/floccus)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/ScaleWeather/floccus/rust.yml?branch=main&label=cargo%20build)](https://github.com/ScaleWeather/floccus/actions)
[![Github Repository](https://img.shields.io/badge/Github-Repository-blue?style=flat-square&logo=github&color=blue)](https://github.com/ScaleWeather/floccus)
[![Crates.io](https://img.shields.io/crates/v/floccus?style=flat-square)](https://crates.io/crates/floccus)
[![License](https://img.shields.io/github/license/ScaleWeather/floccus?style=flat-square)](https://choosealicense.com/licenses/apache-2.0/)
[![dependency status](https://deps.rs/repo/github/ScaleWeather/floccus/status.svg?style=flat-square)](https://deps.rs/repo/github/ScaleWeather/floccus)

Rust crate providing formulae for air thermodynamic calculations.

Expand Down Expand Up @@ -58,6 +58,9 @@ To prevent any unexpected behavior, all functions check whether provided inputs
Exact limits are specified in the documentation of each function.
If the input is out of range the function will return an `InputError::OutOfRange` with erroneous input specified.

Each function also has `_unchecked` and `_validate` versions. The `_validate` version only checks the inputs with bounds defined for its "parent" function.
The `_unchecked` version performs only the calculation without any input checking. All "parent" functions simply call `_validate` and then `_unchecked`.

## Debugging

If additional information is needed about which function returns the error and why, `debug` feature can be enabled.
Expand All @@ -66,6 +69,4 @@ information about the error. This feature potentially is not zero-cost so it is

## Benchmarks

Functions provided in this crate are intended for use in, i. a., numerical models. To provide the user information about performance overhead of each function all functions are benchmarked using [criterion.rs](https://bheisler.github.io/criterion.rs/book/index.html). Github Actions automatically runs all benchmarks.

To check the latest benchmark results the newest workflow on [Github Actions page of floccus](https://github.com/ScaleWeather/floccus/actions).
Functions provided in this crate are intended for use in, i. a., numerical models. To provide the user information about performance overhead of each function all functions are can be benchmarked using [criterion.rs](https://bheisler.github.io/criterion.rs/book/index.html).
62 changes: 55 additions & 7 deletions benches/equivalent_potential_temperature.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,59 @@
use criterion::{Criterion, black_box, criterion_group, criterion_main};
use floccus::equivalent_potential_temperature;
use criterion::{criterion_group, criterion_main, Criterion};
use floccus::{formulas::equivalent_potential_temperature, formulas::Formula4};

pub fn equivalent_potential_temperature_benchmark(c: &mut Criterion) {
c.bench_function("equivalent_potential_temperature::bryan1", |b| {
b.iter(|| equivalent_potential_temperature::bryan1(black_box(300.0), black_box(101325.0), black_box(3000.0)))
mod utils;
use utils::ReferenceValues;

pub fn benchmark(c: &mut Criterion) {
let ref_norm = ReferenceValues::normal();

let mut group = c.benchmark_group("equivalent_potential_temperature");

group.bench_function("Bolton1", |b| {
b.iter(|| {
equivalent_potential_temperature::Bolton1::compute(
ref_norm.pres,
ref_norm.temp,
ref_norm.dwpt,
ref_norm.vapr,
)
})
});

group.bench_function("Bolton2", |b| {
b.iter(|| {
equivalent_potential_temperature::Bolton2::compute(
ref_norm.temp,
ref_norm.dwpt,
ref_norm.mxrt,
ref_norm.thet,
)
})
});

group.bench_function("Bryan1", |b| {
b.iter(|| {
equivalent_potential_temperature::Bryan1::compute(
ref_norm.temp,
ref_norm.mxrt,
ref_norm.rehu,
ref_norm.thet,
)
})
});

group.bench_function("Paluch1", |b| {
b.iter(|| {
equivalent_potential_temperature::Kerry1::compute(
ref_norm.temp,
ref_norm.pres,
ref_norm.mxrt,
ref_norm.rehu,
)
})
});
group.finish();
}

criterion_group!(benches, equivalent_potential_temperature_benchmark);
criterion_main!(benches);
criterion_group!(benches, benchmark);
criterion_main!(benches);
Loading
Loading