| Crates.io | solunatus |
| lib.rs | solunatus |
| version | 0.3.2 |
| created_at | 2025-10-25 11:44:29.906786+00 |
| updated_at | 2025-12-04 15:38:01.88107+00 |
| description | High-precision astronomical calculation library and CLI for sun/moon positions, rise/set times, and lunar phases |
| homepage | https://github.com/FunKite/solunatus |
| repository | https://github.com/FunKite/solunatus |
| max_upload_size | |
| id | 1900120 |
| size | 1,109,792 |
A high-precision astronomical calculation library and CLI tool that provides comprehensive sun and moon information for any location and date.
Solunatus computes astronomical events and positions using industry-standard algorithms (NOAA for solar calculations, Meeus for lunar). Whether you're planning photography sessions, scheduling outdoor activities, or building astronomy-related applications, Solunatus delivers accurate, offline-first calculations for sunrise/sunset, moon phases, twilight periods, and celestial positions.
Dual Purpose:
Key Highlights:
⚠️ Notice: Though efforts have been made to ensure reliability, the software may contain defects or inaccuracies. It is intended for educational and entertainment use only.
Get up and running in under a minute:
# Install from crates.io
cargo install solunatus
# Run with a city name
solunatus --city "New York"
# Or use coordinates
solunatus --lat 40.7128 --lon -74.0060 --tz America/New_York
The interactive TUI will display live astronomical data. Press q to quit, s for settings, or r for reports/calendar generation.
For detailed installation instructions, see the Installation Guide or the Quick Start Guide.
Solunatus in watch mode showing live astronomical data for Los Angeles:

In watch mode (the default), this display updates in real-time every second, giving you a live view of the sky. Press s to open the settings menu, r for reports, or q to quit.
Requirements:
cargo install solunatus
# Clone the repository
git clone https://github.com/FunKite/solunatus.git
cd solunatus
# Build release version
cargo build --release
# Install to system
cargo install --path .
Solunatus supports optional features that can be disabled for lighter builds or to avoid OpenSSL compilation issues:
# Minimal build (no USNO validation, no AI insights, no reqwest dependency)
cargo install solunatus --no-default-features
# Build with only USNO validation (requires reqwest)
cargo install solunatus --no-default-features --features usno-validation
# Build with only AI insights (requires reqwest)
cargo install solunatus --no-default-features --features ai-insights
Available Features:
usno-validation (default: enabled) - USNO API validation reports (--validate flag, r key)ai-insights (default: enabled) - Ollama AI integration (--ai-insights flag, a key)Both features require reqwest (which uses rustls-tls for pure-Rust TLS). Disabling them completely removes the reqwest dependency, solving cross-compilation issues.
Solunatus can be used as a library in your Rust projects for high-precision astronomical calculations.
Add to your Cargo.toml:
[dependencies]
solunatus = "0.3.1"
chrono = "0.4"
chrono-tz = "0.10"
Quick example:
use solunatus::prelude::*;
use chrono::Local;
use chrono_tz::America::New_York;
fn main() {
// Create a location (latitude, longitude)
let location = Location::new(40.7128, -74.0060).unwrap();
let now = Local::now().with_timezone(&New_York);
// Calculate sunrise and sunset
if let Some(sunrise) = calculate_sunrise(&location, &now) {
println!("Sunrise: {}", sunrise.format("%H:%M:%S"));
}
if let Some(sunset) = calculate_sunset(&location, &now) {
println!("Sunset: {}", sunset.format("%H:%M:%S"));
}
// Get current sun position
let (altitude, azimuth) = calculate_sun_position(&location, &now);
println!("Sun: {:.2}° altitude, {:.2}° azimuth", altitude, azimuth);
// Get current moon phase
let (phase_name, phase_emoji) = get_current_moon_phase(&location, &now);
println!("Moon phase: {} {}", phase_emoji, phase_name);
}
Feature Flags for Library Usage:
When using Solunatus as a library, you can disable optional features to reduce binary size and compilation dependencies:
# Minimal library (no HTTP, no parallelization - smallest binary)
solunatus = { version = "0.3.1", default-features = false }
# Core + parallelization (faster calendar generation, no HTTP)
solunatus = { version = "0.3.1", default-features = false, features = ["cpu-portable", "parallel"] }
# Full features (default - includes USNO validation and AI insights)
solunatus = "0.3.1"
Available Feature Flags:
cpu-portable (default: enabled) - Baseline CPU features for cross-platform compatibilityusno-validation (default: enabled) - USNO API validation functions (requires reqwest)ai-insights (default: enabled) - AI integration functions (requires reqwest)parallel (default: disabled) - Parallel calendar generation using Rayon (~500KB smaller when disabled)Disabling usno-validation and ai-insights removes the reqwest dependency entirely, which:
All core astronomical calculations work identically regardless of feature flags.
More Examples:
The examples directory contains comprehensive usage patterns:
Run any example with:
cargo run --example basic_usage
API Documentation:
Full API documentation is available at docs.rs/solunatus
# Use a city from the database
solunatus --city "New York"
# Specify location with coordinates
solunatus --lat 40.7128 --lon=-74.0060 --tz=America/New_York
# Show help
solunatus --help
The default mode is a live-updating display:
| Key | Action |
|---|---|
q |
Quit the application |
s |
Open Settings menu |
r |
Open Reports menu (calendar, USNO validation, benchmark) |
f |
Manually refresh AI insights (if enabled) |
Settings Menu (s key):
Reports Menu (r key):
Watch mode continuously updates the clock and refreshes sun/moon positions every 5 seconds, detailed moon data every 10 minutes, and rebuilds the lunar phase list at local midnight to balance accuracy with CPU efficiency.
solunatus --city "Tokyo" --json
Produce full-range astronomical calendars with daily sunrise, sunset, twilight, moonrise, moonset, and phase data.
# Generate an HTML calendar for January 2026
solunatus --city "Lisbon" \
--calendar \
--calendar-start 2026-01-01 \
--calendar-end 2026-01-31 \
--calendar-format html \
--calendar-output lisbon-jan-2026.html
# JSON calendar spanning the Apollo 11 mission window
solunatus --lat 28.5721 --lon -80.6480 \
--calendar \
--calendar-start 1969-07-15 \
--calendar-end 1969-07-27 \
--calendar-format json
Calendars can cover any range between astronomical years -0999 (1000 BCE) and 3000. BCE dates use the proleptic Gregorian format with a leading minus (e.g. -0032-11-01).
In watch mode, press r to open the Reports menu, then select the calendar generator to interactively adjust the range, toggle HTML/JSON, and export directly from the TUI.
Solunatus can connect to a local Ollama instance to provide narrative, AI-generated insights based on the current astronomical data. This feature can summarize the sky view, highlight interesting events, and offer context beyond the raw numbers.
To use this feature:
ollama pull llama3:8b).--ai-insights flag.# Enable AI insights with a default model
solunatus --ai-insights
# Specify a custom model and server
solunatus --ai-insights --ai-model "llama3:8b" --ai-server "http://192.168.1.100:11434"
In watch mode, press s to open the Settings menu where you can configure AI insights, including enabling/disabling them, selecting models, and setting the refresh interval.
All astronomical calculations follow U.S. Naval Observatory (USNO) conventions for standardized, reproducible results that align with celestial navigation standards used in maritime and aviation almanacs.
| Flag | Description |
|---|---|
--lat <LAT> |
Latitude in decimal degrees |
--lon <LON> |
Longitude in decimal degrees |
--tz <TZ> |
Timezone (IANA format, e.g., America/New_York) |
--city <CITY> |
Select city from database |
--date <DATE> |
Date in YYYY-MM-DD format (default: today) |
--json |
Output in JSON format |
--calendar |
Generate a calendar instead of standard output |
--calendar-format <html|json> |
Calendar output format (html or json, default: html) |
--calendar-start <DATE> |
Calendar start date (requires --calendar) |
--calendar-end <DATE> |
Calendar end date (requires --calendar) |
--calendar-output <PATH> |
Optional file path for the calendar |
--ai-insights |
Enable AI-powered insights (requires Ollama) |
--ai-server <URL> |
Ollama server address (e.g., http://localhost:11434) |
--ai-model <MODEL> |
Ollama model to use for insights (e.g., llama3:8b) |
--ai-refresh-minutes <MIN> |
Refresh interval for AI insights in minutes (1-60) |
--no-prompt |
Disable interactive prompts |
--no-save |
Don't save configuration |
Solunatus uses industry-standard astronomical algorithms for maximum accuracy:
All calculations follow U.S. Naval Observatory (USNO) conventions and have been validated against USNO data. Typical accuracy:
See Astronomical Accuracy Documentation for detailed validation methodology and test results.
Configuration is saved to ~/.solunatus.json:
{
"lat": 40.7128,
"lon": -74.0060,
"tz": "America/New_York",
"city": "New York"
}
The project is organized into focused modules:
astro/ - Core astronomical calculations
sun.rs - Solar position and event calculations (NOAA algorithms)moon.rs - Lunar position, phases, and events (Meeus algorithms)coordinates.rs - Coordinate transformations and compass bearingstime_utils.rs - Time formatting and duration calculationstui/ - Terminal user interface
app.rs - Application state managementui.rs - Rendering and display logicevents.rs - Keyboard input handlingcli.rs - Command-line argument parsingcity.rs - City database and search functionalityconfig.rs - Configuration persistenceoutput.rs - JSON output formattingmain.rs - Application entry point and orchestrationAll dependencies are well-maintained Rust crates:
Core dependencies:
clap - Command-line argument parsingratatui + crossterm - Terminal UIchrono + chrono-tz - Date/time handlingserde + serde_json - Serializationfuzzy-matcher - City searchanyhow - Error handlingOptional dependencies (configurable via feature flags):
reqwest - HTTP client with rustls-tls (optional: for USNO validation and AI insights)rayon - Parallel processing (optional: for faster calendar generation)Solunatus is optimized for speed and efficiency:
parallel feature)Tested and optimized for all Rust Tier 1 platforms:
# Native CPU optimization (recommended for local use)
RUSTFLAGS="-C target-cpu=native" cargo install solunatus
# Apple Silicon optimized build
cargo build --profile release-m1-max
# x86_64 with AVX2 support
cargo build --profile release-x86-64-v3
See Performance Documentation for detailed benchmarks and optimization guides.
Comprehensive documentation is available in the docs/ directory:
Solunatus welcomes feedback and bug reports! While external pull requests are not currently being accepted, your input is valuable:
See our Contributing Guide for more details.
MIT
🌅 Astronomical calculations for any location and date