Crate spa

Source
Expand description

Solar Position Algorithm module for Rust

Collection of algorithms calculating sunrise/sunset and azimuth/zenith-angle.

The SPA library supports std and no_std build targets. The following example uses the built-in implementation StdFloatOps for std build targets.

use chrono::{TimeZone, Utc};
use spa::{solar_position, sunrise_and_set, SolarPos, StdFloatOps, SunriseAndSet};

// main
fn main() {
    let dt = Utc.with_ymd_and_hms(2005, 9, 30, 12, 0, 0)
        .single().unwrap();

    // geo-pos near Frankfurt/Germany
    let lat = 50.0;
    let lon = 10.0;

    let _solpos: SolarPos = solar_position::<StdFloatOps>(dt, lat, lon).unwrap();
    // ...
    let _sunrise_set: SunriseAndSet =  sunrise_and_set::<StdFloatOps>(dt, lat, lon).unwrap();
    // ...
}

Structs§

SolarPos
The solar position

Enums§

SpaError
The error conditions
StdFloatOps
FloatOps for the std environment, mapping directly onto f64 operations
SunriseAndSet
The sun-rise and sun-set as UTC, otherwise permanent polar-night or polar-day

Traits§

FloatOps
platform specific floating operations

Functions§

solar_position
Returning solar position (azimuth and zenith-angle) at time t and geo-pos lat and lon
sunrise_and_set
Returning Sunrise and Sunset (or PolarNight/PolarDay) at geo-pos lat/lon at time t (UTC)