Cartasol is an algorithm written in QBasic by this guy:
http://editorial.cda.ulpgc.es/ambiente/2_clima/2_soleamiento/9_anexo/index.htm
I just translated it to a better language C#:
using System;
namespace Cartasol {
public class Cartasol {
private double latitude;
private double dayOfTheYear;
private double rad;
private double decl;
private double c1;
private double c2;
private double[] asol;
private double[] zsol;
public static void Main(string[] args) {
new Cartasol();
}
public Cartasol() {
asol = new double[49];
zsol = new double[49];
Console.WriteLine("Cartasol!");
Console.Write("Latitude: "); latitude = double.Parse(Console.ReadLine());
Console.Write("Day of the year: "); dayOfTheYear = double.Parse(Console.ReadLine());
rad = Math.Atan(1) / 45;
decl = (23.45 * rad) * Math.Sin(360 * rad * ((dayOfTheYear - 81) / 365));
c1 = Math.Sin(latitude * rad) * Math.Sin(decl);
c1 = Math.Cos(latitude * rad) * Math.Cos(decl);
for(int i = 0; i <= 48; i++) {
double w = (i / (48 * 360 * 180));
double senasol = c1 + c2 * Math.Cos(w);
double cosasol = Math.Sqrt(1 - Math.Pow(senasol, 2));
asol[i] = Math.Atan(senasol / cosasol) / rad;
double coszsol = (Math.Sin(latitude * rad) * senasol - Math.Sin(decl)) / (Math.Cos(latitude * rad) * cosasol);
if(coszsol >= 1 || coszsol <= -1)
coszsol = 1;
double senzsol = Math.Sqrt(1 - Math.Pow(cosasol, 2));
zsol[i] = 90; // prevent an error
if(coszsol != 0)
zsol[i] = Math.Atan(senzsol / coszsol) / rad;
if(zsol[i] < 0)
zsol[i] = 180 + zsol[i];
if(w < 0)
zsol[i] = -zsol[i];
}
for(int i = 0; i <= 48; i += 2)
Console.WriteLine((i / 2).ToString() + ", " + asol[i].ToString() + ", " + zsol[i].ToString());
}
}
}
I have no idea of what this thing do... you can ask my friend about it: luisram06@gmail.com



