calculate azimuth and elevation using the PSA algorithm

Go To StackoverFlow.com

1

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?

2012-04-05 17:37
by Dill
What is the value you expect to have - rbelli 2012-04-05 18:28
The result is the sun position is almost at east and is 4 degree in elevation. (90 - 86). It looks like correct. And did you take care to use the UTC time in the equation? I think it is the time expected - rbelli 2012-04-05 18:30
Have you tried [suncalc.net/#/48.1448,11.558,9/2008.08.06/06:00] - j4x 2012-04-05 19:00


2

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?

2012-04-05 18:47
by rbelli
Ads