solposx.solarposition.michalsky

Contents

solposx.solarposition.michalsky#

solposx.solarposition.michalsky(times, latitude, longitude, spencer_correction=True, julian_date='original')#

Calculate solar position using the Michalsky algorithm.

Michalsky’s algorithm [1] has a stated accuracy of 0.01 degrees from 1950 to 2050.

Parameters:
  • times (pandas.DatetimeIndex) – Timestamps - must be localized. Prior to 1970 and far in the future UTC and UT1 may deviate significantly. For such use cases, UT1 times should be provided.

  • latitude (float) – Latitude in decimal degrees. Positive north of equator, negative to south. [degrees]

  • longitude (float) – Longitude in decimal degrees. Positive east of prime meridian, negative to west. [degrees]

  • spencer_correction (bool, default True) – Applies the correction suggested by Spencer [2] so the algorithm works for all latitudes.

  • julian_date (string, default 'original') –

    Julian date calculation. Can be one of the following:

    • 'original': calculation based on Michalsky’s paper [1].

    • 'pandas': calculation using a pandas built-in function

Returns:

DataFrame with the following columns (all values in degrees):

  • elevation : actual sun elevation (not accounting for refraction).

  • apparent_elevation : sun elevation, accounting for atmospheric refraction.

  • zenith : actual sun zenith (not accounting for refraction).

  • apparent_zenith : sun zenith, accounting for atmospheric refraction.

  • azimuth : sun azimuth, east of north.

Return type:

pandas.DataFrame

Raises:

ValueError – An error is raised if the julian_date calculation is not original or pandas.

Notes

The Michalsky algorithm is based equations in the Astronomical Almanac.

As pointed out by Spencer (1989) [2], the original Michalsky algorithm [1] did not work for the southern hemisphere. This implementation includes by default the correction provided by Spencer such that it works for all latitudes.

Minor clarifications to the original paper have been published as errata in [3] and [4].

The Julian date calculation in the original Michalsky paper [1] ensures the stated accuracy (0.01 degrees) only for the period 1950 - 2050. Outside this period, the Julian date does not handle leap years correctly. Thus, there is the option to use the pandas.DatetimeIndex.to_julian_date() method.

References