nrel-spa-dart/.github/wiki/Home.md
Aric Camarata 86db6c6bae
feat: gap-fill API surface parity with nrel-spa JS (v1.0.1) (#1)
* feat: gap-fill API surface parity with nrel-spa JS (v1.0.1)

Add formatTime, calcSpa, SpaFormattedResult, SpaFormattedAnglesResult,
functionCode parameter for getSpa (spaZa/spaZaInc/spaZaRts/spaAll),
incidence field on SpaResult, and export all function code constants.

All 48 tests pass including numerical cross-validation against the NREL
SPA reference date (Golden CO, 2003-10-17) and surface incidence angle.

* docs: add CHANGELOG.md for v1.0.1 release

* chore: polish pubspec, fix unused import, add wiki docs
2026-05-29 06:49:12 -04:00

998 B

nrel_spa

NREL Solar Position Algorithm for Dart and Flutter. Calculates solar zenith, azimuth, sunrise, sunset, and solar noon for any location and time. Pure Dart, zero dependencies, accurate to ±0.0003 degrees.

Based on Reda & Andreas (2004), NREL/TP-560-34302.

Install

dependencies:
  nrel_spa: ^1.0.1
import 'package:nrel_spa/nrel_spa.dart';

final result = getSpa(
  DateTime.utc(2024, 3, 15, 17, 0, 0),
  40.7128,   // latitude
  -74.0060,  // longitude
  -5.0,      // UTC offset (EST)
);

print('Zenith:  ${result.zenith.toStringAsFixed(4)}°');
print('Sunrise: ${result.sunrise.toStringAsFixed(4)} h');

Contents