Click here to Skip to main content
12,444,360 members (52,630 online)
Click here to Skip to main content

Stats

73.3K views
3.3K downloads
77 bookmarked
Posted

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

, 10 Jan 2011 CPOL
A C# assembly for calculating Sunrise, Sunset, and Maximum Solar Radiation
// 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)

Share

About the Author

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

Patrick enjoys writing his blog. It discusses agile software development. Patrick can be reached at patrick@simpletechture.nl.

Published Windows 8 apps:

Published Windows Phone apps:

Awards:

Best Mobile article of March 2012
Best Mobile article of June 2012

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160811.3 | Last Updated 10 Jan 2011
Article Copyright 2010 by Patrick Kalkman
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid