Search code examples
calgorithmastronomy

calculate azimuth and elevation using the PSA algorithm


there is an implementation of the PSA algorithm here:

http://www.psa.es/sdg/sunpos.htm

i added this test code to sunpos.cpp to calculate the suns position for Munich, August 6, 2008, 6:00. But i get useless results, output is:

dZenithAngle: 71.034037 dAzimuth:86.052150

#include <stdio.h>
main(){

    cTime t = {2008, 8, 6, 6.0, 0.0, 0.0};
    cLocation l = {11.6, 48.1};
    cSunCoordinates s;

    sunpos(t, l, &s);

    printf("%f %f\n", s.dZenithAngle, s.dAzimuth);
}

anybody some experience with this algorithm?


Solution

  • As I comment, I think the result of the function is ok:

    The result is the sun position is almost at east and is 4 degree in elevation. (90 - 86). It looks like correct.

    Are you sure you enter the time in UTC? I see in a site that German has the local time UTC+2 in the summer. Then 6:00 is trully 8:00 in German. Does it explains the result you have?