Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Solar Calculator - Calculate Sunrise, Sunset, and Maximum Solar Radiation

, 10 Jan 2011
A C# assembly for calculating Sunrise, Sunset, and Maximum Solar Radiation
SolarCalculator.zip
Astronomy
Properties
AstronomyTest
Properties
ConsoleCalculator
Properties
Include
nunit.framework.dll
Rhino.Mocks.dll
// SunCalculator.cs - Calculator for calculating SunRise, SunSet and
// maximum solar radiation of a specific date and time.
//
// Patrick Kalkman  pkalkie@gmail.com
//
// (C) Patrick Kalkman http://www.semanticarchitecture.net
//
using System;
using Astronomy;

namespace ConsoleCalculator
{
   class Program
   {
      static void Main(string[] args)
      {
         const Double LongituteUtrechtNetherlands = 5.127869;
         const Double LatitudeUtrechtNetherlands = 52.108192;

         SunCalculator sunCalculator = new SunCalculator(LongituteUtrechtNetherlands, LatitudeUtrechtNetherlands, 15, false);
         
         //Calculate the sunrise for the city Utrecht in the Netherlands 
         DateTime startDateTime = new DateTime(2010, 1, 1);
         DateTime endDateTime = new DateTime(2010, 3, 31);
         DateTime dateTime = startDateTime;
         while (dateTime < endDateTime)
         {
            DateTime sunRise = sunCalculator.CalculateSunRise(dateTime);
            Console.WriteLine("On {0:MM/dd/yyyy} the sun rises at {1:t}", dateTime, sunRise);
            dateTime = dateTime.AddDays(1);
         }
         Console.ReadLine();
      }
   }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Patrick Kalkman
Architect http://www.hinttech.nl
Netherlands Netherlands
Patrick Kalkman is a senior Software Architect with more than 20 years professional development experience. He works for Hinttech where he develops state of the art web applications.

Patrick enjoys writing his blog. It discusses software architectures using semantic web technologies. Patrick can be reached at pkalkie@gmail.com.
 
Published Windows 8 apps:
 
Published Windows Phone apps:
 
Awards:

Best Mobile article of March 2012
Best Mobile article of June 2012
Follow on   Twitter

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 10 Jan 2011
Article Copyright 2010 by Patrick Kalkman
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid