apexpy.helpers

This module contains helper functions used by Apex.

apexpy.helpers.checklat(lat, name='lat')[source]

Makes sure the latitude is inside [-90, 90], clipping close values (tolerance 1e-4).

Parameters:
  • lat (array_like) – latitude
  • name (str, optional) – parameter name to use in the exception message
Returns:

lat (ndarray or float) – Same as input where values just outside the range have been clipped to [-90, 90]

Raises:

ValueError – if any values are too far outside the range [-90, 90]

apexpy.helpers.getsinIm(alat)[source]

Computes sinIm from modified apex latitude.

Parameters:alat (array_like) – Modified apex latitude
Returns:sinIm (ndarray or float)
apexpy.helpers.getcosIm(alat)[source]

Computes cosIm from modified apex latitude.

Parameters:alat (array_like) – Modified apex latitude
Returns:cosIm (ndarray or float)
apexpy.helpers.toYearFraction(date)[source]

Converts datetime.date or datetime.datetime to decimal year.

Parameters:date (datetime.date or datetime.datetime)
Returns:year (float) – Decimal year

Notes

The algorithm is taken from http://stackoverflow.com/a/6451892/2978652

apexpy.helpers.gc2gdlat(gclat)[source]

Converts geocentric latitude to geodetic latitude using WGS84.

Parameters:gclat (array_like) – Geocentric latitude
Returns:gdlat (ndarray or float) – Geodetic latitude
apexpy.helpers.subsol(datetime)[source]

Finds subsolar geocentric latitude and longitude.

Parameters:datetime (datetime.datetime)
Returns:
  • sbsllat (float) – Latitude of subsolar point
  • sbsllon (float) – Longitude of subsolar point

Notes

Based on formulas in Astronomical Almanac for the year 1996, p. C24. (U.S. Government Printing Office, 1994). Usable for years 1601-2100, inclusive. According to the Almanac, results are good to at least 0.01 degree latitude and 0.025 degrees longitude between years 1950 and 2050. Accuracy for other years has not been tested. Every day is assumed to have exactly 86400 seconds; thus leap seconds that sometimes occur on December 31 are ignored (their effect is below the accuracy threshold of the algorithm).

After Fortran code by A. D. Richmond, NCAR. Translated from IDL by K. Laundal.