apexpy.helpers
This module contains helper functions used by Apex
.
Functions
|
Set array data type to float. |
|
Makes sure the latitude is inside [-90, 90], clipping close values |
|
Computes sinIm from modified apex latitude. |
|
Computes cosIm from modified apex latitude. |
|
Converts |
|
Converts geocentric latitude to geodetic latitude using WGS84. |
|
Finds subsolar geocentric latitude and longitude. |
Module Contents
- apexpy.helpers.set_array_float(in_val)[source]
Set array data type to float.
- Parameters:
in_val (any) – Input value, only modified if it is a np.ndarray
- Returns:
out_val (any) – Output value, if in_val was an array, out_val will be an array of type np.float64.
- 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
ordatetime.datetime
to decimal year.- Parameters:
date (
datetime.date
ordatetime.datetime
) – Input date or datetime object- 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
ornumpy.ndarray[datetime64]
) – Date and time in UTC (naive objects are treated as UTC)- 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.