SunCalcNet 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package SunCalcNet --version 1.0.1
NuGet\Install-Package SunCalcNet -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SunCalcNet" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SunCalcNet --version 1.0.1
#r "nuget: SunCalcNet, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SunCalcNet as a Cake Addin
#addin nuget:?package=SunCalcNet&version=1.0.1

// Install SunCalcNet as a Cake Tool
#tool nuget:?package=SunCalcNet&version=1.0.1

SunCalcNet

A .NET port of the SunCalc JS lib for calculating sun/moon positions and phases.

Usage example

Get position of the sun (azimuth and altitude)

var date = new DateTime(2013, 3, 5, 0, 0, 0, DateTimeKind.Utc);
var lat = 50.5;
var lng = 30.5;

var sunPosition = SunCalc.GetSunPosition(date, lat, lng);

Assert.Equal(-2.5003175907168385, sunPosition.Azimuth, 15);
Assert.Equal(-0.7000406838781611, sunPosition.Altitude, 15);

Get position of the moon (azimuth, altitude, distance and parallactic angle)

var date = new DateTime(2013, 3, 5, 0, 0, 0, DateTimeKind.Utc);
var lat = 50.5;
var lng = 30.5;

var sunPosition = SunCalc.GetMoonPosition(date, lat, lng);

Assert.Equal(-0.9783999522438226, sunPosition.Azimuth, 15);
Assert.Equal(0.0145514822438922, sunPosition.Altitude, 15);
Assert.Equal(364121.37256256194, sunPosition.Distance, 15);
Assert.Equal(-0.59832117604234014, sunPosition.ParallacticAngle, 15);

Get Sun phases

var date = new DateTime(2013, 3, 5, 0, 0, 0, DateTimeKind.Utc);
var lat = 50.5;
var lng = 30.5;

var sunPhases = SunCalc.GetSunPhases(date, lat, lng).ToList();

foreach (var sunPhase in sunPhases)
{
    ...
}

Get Moon Illumination

var date = new DateTime(2013, 3, 5, 0, 0, 0, DateTimeKind.Utc);

var moonIllum = SunCalc.GetMoonIllumination(date);

Assert.Equal(0.4848068202456373, moonIllum.Fraction, 15);
Assert.Equal(0.7548368838538762, moonIllum.Phase, 15);
Assert.Equal(1.6732942678578346, moonIllum.Angle, 15);

About Suncalc.js

SunCalc is a tiny BSD-licensed JavaScript library for calculating sun position, sunlight phases (times for sunrise, sunset, dusk, etc.), moon position and lunar phase for the given location and time, created by Vladimir Agafonkin (@mourner) as a part of the SunCalc.net project.

Most calculations are based on the formulas given in the excellent Astronomy Answers articles about position of the sun and the planets. You can read about different twilight phases calculated by SunCalc in the Twilight article on Wikipedia.

Sun phases

Currently supported sun phases are:

Phase Description
Sunrise sunrise (top edge of the sun appears on the horizon)
SunriseEnd sunrise ends (bottom edge of the sun touches the horizon)
GoldenHourEnd morning golden hour (soft light, best time for photography) ends
SolarNoon solar noon (sun is in the highest position)
GoldenHour evening golden hour starts
SunsetStart sunset starts (bottom edge of the sun touches the horizon)
Sunset sunset (sun disappears below the horizon, evening civil twilight starts)
Dusk dusk (evening nautical twilight starts)
NauticalDusk nautical dusk (evening astronomical twilight starts)
Night night starts (dark enough for astronomical observations)
Nadir nadir (darkest moment of the night, sun is in the lowest position)
NightEnd night ends (morning astronomical twilight starts)
NauticalDawn nautical dawn (morning nautical twilight starts)
Dawn dawn (morning nautical twilight ends, morning civil twilight starts)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 is compatible.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 2.0

    • No dependencies.
  • .NETFramework 4.6.1

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SunCalcNet:

Package Downloads
VL.SunCalc

Provides Sun and Moon related calculations in VL

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on SunCalcNet:

Repository Stars
t1m0thyj/WinDynamicDesktop
Port of macOS Mojave Dynamic Desktop feature to Windows
compujuckel/AssettoServer
Custom Assetto Corsa server with focus on freeroam
Version Downloads Last updated
1.2.2 9,400 11/24/2022
1.2.1 1,531 9/2/2022
1.2.0 7,885 4/2/2021
1.1.4 8,064 7/21/2020
1.1.3 1,504 5/13/2020
1.1.2 1,360 5/13/2020
1.1.1 2,160 12/27/2019
1.1.0 4,056 6/21/2019
1.0.3 1,127 3/12/2019
1.0.2 1,521 3/9/2018
1.0.1 1,340 2/19/2018