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§
- Solar
Pos - The solar position
Enums§
- SpaError
- The error conditions
- StdFloat
Ops - FloatOps for the std environment, mapping directly onto f64 operations
- Sunrise
AndSet - The sun-rise and sun-set as UTC, otherwise permanent polar-night or polar-day
Traits§
- Float
Ops - platform specific floating operations
Functions§
- solar_
position - Returning solar position (azimuth and zenith-angle) at time
t
and geo-poslat
andlon
- sunrise_
and_ set - Returning Sunrise and Sunset (or PolarNight/PolarDay) at geo-pos
lat/lon
at timet
(UTC)