문제

I have recently downloaded and installed the PySolar module and would like to use it to calculate sun position (azimuth and altitude).

The problem I am having is that the results calculated do not match the results calculated by the NOAA Solar calculator http://www.esrl.noaa.gov/gmd/grad/solcalc/azel.html

For example. Using the PySol

>>> import datetime, solar
>>> d = datetime.datetime(2007,12,21,9,0,0,0)
>>> lat = 41.5
>>> long = -111.5
>>> solar.GetAltitude(lat, long, d)
-63.0267096801
>>solar.GetAzimuth(lat, long, d)
-235.44406245

Using the NOAA model The Altitude is calculated at 0.7 and Azimuth is calculated at 237.64.

Therefore there is a discrepancy between the two values. To summarise:

  • Pysolar is calculating Altitude at -63.03 and NOAA is calculating it at 0.7
  • Pysolar is calculating Azimuth at -235.44 and NOAA is calculating it at 237.64

If you have any suggestions what I am doing wrong or how I can calculate the correct altitude and azimuth for a given location, it would be much appreciated.

도움이 되었습니까?

해결책

Your datetime.datetime has no tzinfo value so will give you the GMT time which is about 7 hours off from the local time. The other factor could well be that NOAA used DMS rather than decimal lat/long so you need to remember to input 41,30,0 and -111,30,0 for the values.

N.B. You might find it instructive to try PyEphrem for this sort of calculation as I find that the documentation is clearer.

다른 팁

Change -111 to +111 and your results might be better. Going west is positive.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top