BaseCalendar

Class

class badidatetime.base_calendar.BaseCalendar(*args, **kwargs)[source]

Bases: AstronomicalTerms, JulianPeriod

Basic functionality used with all calendars.

U.T. = Mean solar time at Greenwich, England (0◦ meridian), reckoned from

midnight; sometimes GMT, Greenwich Mean Time

Transformations between Time Systems: | https://gssc.esa.int/navipedia/index.php/Transformations_between_Time_Systems

_AMOD(x, y)
_ANGLE(d, m, s)
_AUTUMN = 180
_EVENING = False
_HR(x)
_JULIAN_CAL_EPOCH = 1721423.5
_MEAN_TROPICAL_YEAR = 365.2421897
_MINS(x)
_MN(x)
_MOD3(x, a, b)
_MOON_OFFSET = 0.125
_MORNING = True
_PARTIAL_DAY_TO_HOURS(x)
_PARTIAL_HOUR_TO_MINUTE(x)
_PARTIAL_MINUTE_TO_SECOND(x)
_PARTIAL_SECOND_TO_MICROSECOND(x)
_POSIX_EPOCH = 2440585.5
_QUOTIENT(m, n)
_ROUNDING_PLACES = 12
_SEC(x)
_SECONDS_PER_DAY = 86400
_SECS(x)
_SPRING = 0
_STARS_PLANET_OFFSET = 0.5667
_SUMMER = 90
_SUN_OFFSET = 0.8333
_US(x)
_WINTER = 270
_aberration(tm: float, fixed: bool = True) float[source]

Find the aberration of a date with respect to a fixed reference frame or to the mean equinox.

Parameters:
  • tc (float) – The moment in time referenced to J2000 millennia.

  • fixed (bool) – If True (default) the results is to a fixed reference frame, if False the result is referenced to the mean equinox.

Returns:

The aberration of the date in degrees.

Return type:

float

Note

AA p.167 Eq. 25.11, p. 168

_altitude(delta: float, lat: float, h: float) float[source]

Altitude in degrees, positive above the horizon, negative below.

Parameters:
  • delta (float) – Declination in sidereal time.

  • lat (float) – Geographic latitude.

  • h (float) – Local hour angle.

Returns:

Altitude in degrees.

Return type:

float

Note

Meeus–AA p. 93 Eq. 13.6

_apparent_sidereal_time_greenwich(tc: float) float[source]

The apparent sidereal time, or the Greenwich. (GAST) If the hour angle is measured with respect to the true equinox, apparent sidereal time is being measured.

Parameters:

tc (float) – Julian century.

Returns:

The apparent sidereal time at Greenwich.

Return type:

float

Note

Meeus–AA ch. 12 p. 88

_apparent_solar_latitude(jde: float, degrees: bool = True) float[source]

Find the apparent solar latitude.

Parameters:
  • jde (float) – The Julian Period day.

  • degrees (bool) – The results if False are radians, else True are degrees. Default is False.

Returns:

The apparent solar latitude.

Return type:

float

Note

Meeus–AA ch. 25 p. 166

_apparent_solar_longitude(jde: float, degrees: bool = True) float[source]

Find the apparent solar longitude.

Parameters:
  • jde (float) – The Julian Period day.

  • degrees (bool) – The results if False are radians, else True are degrees. Default is False.

Returns:

The apparent solar longitude.

Return type:

float

Note

Meeus–AA ch. 25 p. 166

_approx_julian_day_for_equinoxes_or_solstices(g_year: int, lam: int = 0) float[source]

Find the approximate Julian day for the equinoxes or solstices.

Parameters:
  • g_year (int) – The Gregorian year.

  • lam (int) – The lambda, either _SPRING (default), _SUMMER, _AUTUMN, or _WINTER.

Returns:

The approximate Julian day for the equinoxes or solstices.

Return type:

float

Note

See: Meeus AA ch. 27 p. 177

_approx_local_hour_angle(tc: float, lat: float, offset: float = 0.8333) float[source]

Approximate local hour angle, measured westwards from the south in degrees.

Hour angle, in astronomy, the angle between an observer’s meridian (a great circle passing over his head and through the celestial poles) and the hour circle (any other great circle passing through the poles) on which some celestial body lies. This angle, when expressed in hours and minutes, is the time elapsed since the celestial body’s last transit of the observer’s meridian.

Parameters:
  • tc (float) – Julian century.

  • lat (float) – Latitude in decimal

  • offset (float) – A constant “standard” altitude, i.e., the geometric altitude of the center of the body at the time of apparent rising or setting, namely, h0 = -0°34’ = -0°5667 for stars and planets; h0 = -0°50’ = -0°8333 for the Sun. Default is _SUN_OFFSET, _STARS_PLANET_OFFSET can also be used.

Returns:

The approximate local hour angle in degrees.

Return type:

float

Note

  1. Meeus–AA p. 101, 102

  2. If the result of the equation is negative then add 360° (6.283185307179586 radians). If result is greater than 360° then subtract 360° (6.283185307179586 radians). https://www.quora.com/How-do-I-calculate-the-hour-angle

_cos_deg(theta: float) float[source]

Convert a value to the cosine in degrees.

Parameters:

theta (float) – The value to convert to degrees.

Returns:

The degrees representing the value provided.

Return type:

float

LISP code from Reingold & Dershowitz CC TUE p. 513

(defun cos-degrees (theta)
  ;; TYPE angle -> amplitude
  ;; Cosine of theta (given in degrees).
  (cos (radians-from-degrees theta)))
_coterminal_angle(value: float) float[source]

Find the Coterminal Angle from a value that is either more than 360 or less than 0.

Parameters:

value (float) – The value that is more than 360 or less than 0.

Returns:

The adjusted angle to be between 0 and 360.

Return type:

float

_days_in_years(y: int, *, alt: bool = False) int[source]

Find the number of days up to the provided year.

Parameters:
  • y (int) – The year to count to.

  • alt (bool) – If True use the 4|128 rule else if False (default) use the 4|100|400 rule

Returns:

The count of days including year one to the given year.

Return type:

int

Note

This method starts the count from year 1 of the Proleptic Gregorian Calendar, however, it uses one of the two leap rules described above instead of the usual Julian Calendar leap year rule of every 4 year.

_decimal_day_from_hms(h: int, m: int, s: float, us: int = 0) float[source]

Convert hours, minutes, and seconds to a decimal day.

Parameters:
  • h (ine) – The hour.

  • m (int) – The minute.

  • s (float) – The second.

  • us (int) – The microseconds.

Returns:

A decimal value representing the day with a partial that indicates the hours, minutes, and seconds.

Return type:

float

_decimal_from_dms(degrees: int, minutes: int, seconds: float, direction: str = 'N') float[source]

Coordinates in degrees, minutes, and seconds.

The Shrine of Baha’u’llah: 32°56’36.86″N, 35° 5’30.38″E
The Shrine of The Bab: 32°48’52.49″N, 34°59’13.91″E
The Guardian’s Resting Place (not 3D): 51°37’21.85″N, 0°08’35.57″W

Process

Convert degrees, minutes, and seconds to a decimal.

Degrees, minutes, and seconds to a decimal coordinate:

  1. Add the degrees to the minutes divided by 60

  2. Add the seconds divided by (60 x 60), which is 3600

Example

To convert 35° 20′ 35”, the answer is 35 + (20/60) + (35/3600) = 35.34306 degrees.

Parameters:
  • degrees (int) – The degree part of the coordinates.

  • minutes (int) – The minute part of the coordinate.

  • seconds (float) – The second part of the coordinate.

  • direction (str) – The direction part of the coordinate which can be any of the following N, S, E, W in upper or lower case.

Returns:

latitude and longitude

Return type:

tuple

_degrees_from_hms(h: int, m: int, s: float) float[source]

Find the degrees from the hours, minutes, and seconds of 360 degrees. Where as time zones are 15 degrees apart so 24 time zones times 15 degrees is 360 degrees.

The angle may be expressed as negative east of the meridian plane and positive west of the meridian plane, or as positive westward from 0° to 360°. The angle may be measured in degrees or in time, with 24h = 360° exactly. So one hour is equal to (360/24)° = 15°.

Parameters:
  • h (int) – The hour.

  • m (int) – The minute.

  • s (float) – The second.

Returns:

The degrees from the hours, minutes, and seconds of 360 degrees.

Return type:

float

_delta_t(jd: float, *, seconds: bool = False) float[source]

Calculate the value of ΔT = TD − UT, for TD = ΔT + UT, and for UT = ΔT - TD. Only the year and month are considered, days, hours, minutes, and seconds are ignored.

Parameters:
  • jd (float) – Julian day.

  • seconds (bool) – If True leave as seconds in a minute else convert to seconds of a day (default).

Returns:

The delta t.

Return type:

float

_dhms_from_seconds(seconds: float, zone: float = 0, us: bool = False) tuple[source]

Convert seconds into days, hours, minutes, and seconds. Depending on the timezone there could be an additional day added.

Parameters:
  • seconds (float) – The number of seconds with possible fraction.

  • zone (float) – The timezone in degrees, defaults to 0 or GMT.

  • us (bool) – If False (default) no separate field for microseconds is returned else return microseconds.

Returns:

The days, hours, minutes, and seconds.

Return type:

tuple

Note

See: https://www.timeanddate.com/time/map/

Time-zones can be from -12 to +14 based on the political times-zones as of 2024-08-09.

_dms_from_decimal(coord: float, direction: str) tuple[source]

Convert a decimal degree into degrees, minutes, and seconds.

Parameters:
  • coord (float) – The decimal coordinate.

  • direction (str) – The direction part of the coordinate which can be any of the following N, S, E, W in upper or lower case.

Returns:

The degree, minute, second, and direction for of the coordinate.

Return type:

tuple

_eccentricity_earth_orbit(tc: float) float[source]

The eccentricity of the earth’s orbit.

Parameters:

tc (float) – Time in Julian centuries.

Returns:

The eccentricity of the earth’s orbit.

Return type:

float

Note

Meeus–AA ch. 25 p. 163 Eq. 25.4

_exact_from_meeus(jd: float) float[source]

The returned difference value to convert a Meeus algorithm jd to an exact algorithm jd. This is subtracted from the meeus jd.

Parameters:

jd (float) – Meeus Julian Period day.

Returns:

The difference subtracted from an historically correct jd.

Return type:

float

Note

  1. The JDs below are the historically correct (Meeus) JDs.

  2. This library uses a continuous proleptic solar day count for the Badí’ Calendar.

  3. The exact JD numbering is uninterrupted across 1582-10-05 … 1582-10-14.

  4. Invalid days checked with https://aa.usno.navy.mil/data/JulianDate

The table below indicates that dates less than the ones shown are legal dates. The dates shown except the last two rows indicate invalid days in the historic (Meeus) algorithm. The second to the last indicates the end of the Gregorian reform and the last dates indicates that from then to forever the proleptic algorithm is 2 days below the historic algorithm.

Historic JD

Proleptic JD

Offset

Gregorian DT

< 1757641.5

< 1757641.5

0

0100-02-29

< 1794166.5

< 1794165.5

1

0200-02-29

< 1830691.5

< 1830689.5

2

0300-02-29

< 1903741.5

< 1903738.5

3

0500-02-29

< 1940266.5

< 1940262.5

4

0600-02-29

< 1976791.5

< 1976786.5

5

0700-02-29

< 2049841.5

< 2049835.5

6

0900-02-29

< 2086366.5

< 2086359.5

7

1000-02-29

< 2122891.5

< 2122883.5

8

1100-02-29

< 2195941.5

< 2195932.5

9

1300-02-29

< 2232466.5

< 2232456.5

10

1400-02-29

< 2268991.5

< 2268980.5

11

1500-02-29

< 2299160.5

< 2299148.5

12

1582-10-15

>= 2299160.5

>= 2299158.5

2

1582-10-15

_find_moment_of_equinoxes_or_solstices(jd: float, lam: int = 0, zone: float = 0) float[source]

With the jd and season of the year find the equinox or solstice at Greenwich. If a time zone is provided modify the returned value.

Parameters:
  • jd (float) – Meeus algorithm Julian day.

  • lam (int) – The lambda, either _SPRING (0° default), _SUMMER (90°), _AUTUMN (180°), or _WINTER (270°).

  • zone (float) – The time zone.

Returns:

The Julian day of the equinox or solstice.

Return type:

float

Note

Meeus–AA ch. 27 p. 177

_heliocentric_ecliptical_latitude(tm: float, degrees: bool = False) float[source]

Find the heliocentric elliptical latitude.

Parameters:
  • tm (float) – The moment in time referenced to J2000 millennia.

  • degrees (bool) – The results if False are radians, else True are degrees. Default is False.

Returns:

Latitude in degrees or radians.

Return type:

float

Note

Meeus–AA ch. 25 p. 166
Referenced by B
_heliocentric_ecliptical_longitude(tm: float, degrees: bool = False) float[source]

Find the heliocentric elliptical longitude.

Parameters:
  • tm (float) – The moment in time referenced to J2000 millennia.

  • degrees (bool) – The results if False are radians, else True are degrees. Default is False.

Returns:

Longitude in degrees or radians.

Return type:

float

Note

Meeus–AA ch. 25 p. 166
Referenced by L
_hms_from_decimal_day(dec: float, *, us: bool = False) tuple[source]

Convert a decimal day to hours, minutes, and seconds. If this method is used for a Julian Period day, 0.5 must be added to the value before being passed in.

Parameters:
  • dec (float) – A decimal number.

  • us (bool) – If False (default) no separate field for microseconds is returned else return microseconds.

Returns:

A tuple representing the hour, minute, and seconds.

Return type:

tuple

Note

If a number as in 10.5 is passed in, the value to the left of the decimal will be stripped off before calculations are done.

_hms_from_degrees(deg: float) tuple[source]

Find the hours, minutes, and seconds from 0 - 360 degrees. Where as time zones are 15 degrees apart so 24 time zones times 15 degrees is 360 degrees.

The angle may be expressed as negative east of the meridian plane and positive west of the meridian plane, or as positive westward from 0° to 360°. The angle may be measured in degrees or in time, with 24h = 360° exactly. So one hour is equal to (360/24)° = 15°.

Parameters:

deg (float) – The degrees of the 360 degree circumference of the earth.

Returns:

The hours, minutes, and seconds.

Return type:

tuple

_interpolation_from_three(y1: float, y2: float, y3: float, n: float, normalize: bool = False) float[source]

Interpolate from three terms with a factor.

Parameters:
  • y1 (float) – 1st of the three parameters.

  • y2 (float) – 2nd of the three parameters.

  • y3 (float) – 3rd of the three parameters.

  • n (float) – The factor.

  • normalize (bool) – If False’ (default) no normalization is done else if `True normalize.

Returns:

The three factor interpolation.

Return type:

float

_local_hour_angle(srt: float, lon: float, alpha: float) float[source]

The LHA is the angle between the meridian of the observer and the meridian of the geographical position of the celestial body.

Parameters:
  • srt (float) – Sidereal time.

  • lon (float) – The Geographic longitude of the observer in degrees.

  • alpha (float) – The apparent right ascensions.

Returns:

The local hour angle.

Return type:

float

_local_zone_correction(jd_ut: float, zone: float = None, lon: float = None, *, inverse: bool = False, mod_jd: bool = False) float[source]

Convert the UT time to local time.

Note

  1. If the full JD is passed as jd_ut then the result will be the correct value.

  2. If jd_ut is the fractional part of the JD the result of this method replaces the fractional part of the JD. DO NOT add it to the fractional part.

  3. If the zone is None the zone will be calculated from the longitude, a value other than None will be regarded as a political time zone.

Parameters:
  • jd_ut (float) – UT time as a fractional part of a JD.

  • zone (float) – The time zone in hours.

  • lon (float) – The longitude.

  • inverse (bool) – Subtract the zone instead of adding it.

  • mod_jd (bool) – If False (default) a correction value is returned else if True the jd_ut is updated to local time.

Returns:

The local time corrected from the UT time as a fraction.

Return type:

float

_mean_moon_elongation(tc: float) float[source]
Parameters:

tc (float) – Time in Julian centuries.

Returns:

Mean moon elongation.

Return type:

float

Note

Meeus–AA ch. 22 p. 144
Referenced by dd (D).
_mean_sidereal_time_greenwich(tc: float) float[source]

Mean sidereal time at Greenwich. (GMST) If the hour angle is measured with respect to the mean equinox, mean sidereal time is being measured.

Parameters:

tc (float) – Julian century.

Returns:

The mean sidereal time at Greenwich .

Return type:

float

Note

Meeus–AA ch. 12 p. 88 Eq. 12.3

_meeus_from_exact(jd: float) float[source]

Returns the Meeus algorithm jd converted from the exact algorithm jd.

Parameters:

jd (float) – Exact Julian Period day.

Returns:

The difference added to an astronomically correct jd.

Return type:

float

Note

The JDs below are the proleptic (astronomically correct) JDs.

_moon_ascending_node_longitude(tc: float) float[source]

Longitude of the ascending node of the Moon’s mean orbit on the ecliptic, measured from the mean equinox of the date:

Parameters:

tc (float) – Time in Julian centuries.

Returns:

Moon ascending node longitude.

Return type:

float

Note

Meeus–AA ch. 22 p. 144
Referenced by om (omega).
_moon_latitude(tc: float) float[source]

The angle between the Moon’s ecliptic longitude and its mean longitude.

Parameters:

tc (float) – Time in Julian centuries.

Returns:

Moon latitude.

Return type:

float

Note

Meeus–AA ch. 22 p. 144
Referenced by ff (F).
_moon_mean_anomaly(tc: float) float[source]

The position of the moon in its orbit around the Earth.

Parameters:

tc (float) – Time in Julian centuries.

Returns:

Moon mean anomaly.

Return type:

float

Note

Meeus–AA ch. 22 p. 144
Referenced by lm (M’).
_nutation_longitude(tc: float, *, degrees: bool = False) float[source]

Nutation longitude of the Earth’s axis around it’s ‘mean’ position.

Parameters:
  • tc (float) – The Julian Period century.

  • degrees (bool) – If False (default) return radians else if True return degrees.

Returns:

Either the radians or degrees depending on the degrees argument.

Return type:

float

_nutation_obliquity(tc: float, *, degrees: bool = False) float[source]

Nutation obliquity of the Earth’s equator around it’s ‘mean’ position.

Parameters:
  • tc (float) – The Julian Period century.

  • degrees (bool) – If False (default) return radians else if True return degrees.

Returns:

The nutation of obliquity.

Return type:

float

_nutation_obliquity_longitude(tc: float, degrees: bool = False) float[source]

Nutation of the Earth’s axis around it’s ‘mean’ position.

Parameters:
  • tc (float) – Time in Julian centuries.

  • degrees (float) – If True units of degrees is returned, if False units of radians is returned.

Returns:

Moon latitude.

Return type:

float

_poly(x: float, a: list) float[source]

This is the Horner method of polynomial used to eliminate the use of powers.

Note

Instead of:
y = A + B * x + C * x^2 + D * x^3 + E * x^4
do this
y = A + x * (B + x * (C + x * (D + x * E)))
Parameters:
  • x (float) – Power of number.

  • a (list) – The list of numbers in polynomial.

Returns:

The polynomial result.

Return type:

float

LISP code from Reingold & Dershowitz CC TUE p. 473

(defun poly (x a)
  ;; TYPE (real list-of-reals) -> real
  ;; Sum powers of x with coefficients (from order 0 up) in list a.
  (if (equal a nil)
      0
    (+ (first a) (* x (poly x (rest a))))))
_radius_vector(tm: float, degrees: bool = False) float[source]

Find the distance of earth to the sun.

Parameters:
  • tm (float) – The moment in time referenced to J2000 millennia.

  • degrees (bool) – The results if False are radians, else True are degrees. Default is False.

Returns:

Radius vector in degrees or radians.

Return type:

float

Note

Meeus–AA ch. 25 p. 166
Referenced by R
_rise_set_correction(tc: float, ast: float, dt: float, lat: float, lon: float, m: float, offset: float) float[source]

Find the correction to the sunrise and sunset.

Parameters:
  • tc (float) – The Julian Period century.

  • ast (float) – The apparent sidereal time at Greenwich.

  • dt (float) – The delta T of the JD.

  • lat (float) – The latitude.

  • lon (float) – The longitude.

  • m (float) – Times on day, expressed as fractions.

  • offset (float) – Either _SUN_OFFSET or _STARS_PLANET_OFFSET.

Returns:

The correction to the sunrise or sunset.

Return type:

float

_rising_setting(jd: float, lat: float, lon: float, *, offset: float = 0.8333, sr_ss: str = 'RISE') float[source]

Find the jd difference for sunrise or sunset of the given jd.

Parameters:
  • jd (float) – Julian day in UT.

  • lat (float) – Geographic latitude positive north negative south.

  • lon (float) – Geographic longitude positive east negative west.

  • offset (float) – A constant “standard” altitude, i.e., the geometric altitude of the center of the body at the time of apparent rising or setting, namely, h0 = -0°34’ = -0°5667 for stars and planets; h0 = -0°50’ = -0°8333 for the Sun. Default is _SUN_OFFSET, _STARS_PLANET_OFFSET can also be used.

  • sr_ss (str) – If ‘RISE’ return the sunrise else return sunset.

Returns:

The offset that would be added to the currant date.

Return type:

float

Note

Meeus-AA ch. 15 p. 102, 103 Eq. 15.1, 15.2

_sec_microsec_from_seconds(second: float) tuple[source]

Split the second and microseconds.

Parameters:

second (float) – The second with a partial indicating the microseconds.

Returns:

The second split between the second and microseconds.

Return type:

tuple

_seconds_from_dhms(days: int, hours: int, minutes: int, seconds: float, microseconds: int = 0, zone: float = 0) float[source]

Convert days, hours, minutes, and seconds to seconds depending on the timezone.

Parameters:
  • days (int) – Number of days.

  • hours (int) – Number of hours.

  • minutes (int) – The number of minutes.

  • seconds (float) – The number of seconds with possible fraction.

  • microseconds (int) – The number of microseconds if they exist.

  • zone (float) – The timezone in degrees, defaults to 0 or GMT.

Returns:

The number of seconds.

Return type:

float

_sigma(lists: tuple, func: object) float[source]

This gives a summation of a list based on the criteria in the provided function.

Parameters:
  • lists (tuple) – The list of values to sum.

  • func (object) – The function that determines the summation parameters.

Returns:

The summation.

Return type:

float

LISP code from Reingold & Dershowitz CC TUE p. 473

(defmacro sigma (list body)
  ;; TYPE (list-of-pairs (list-of-reals->real))
  ;; TYPE -> real
  ;; list is of the form ((i1 l1)...(in ln)).
  ;; Sum of body for indices i1...in
  ;; running simultaneously thru lists l1...ln.
  `(apply `+ (mapcar (function (lambda
                                 ,(mapcar `car list)
                                 ,body))
                     ,@(mapcar `cadr list))))
_sin_deg(theta: float) float[source]

Convert a value to sine in degrees.

Parameters:

theta (float) – The value to convert to degrees.

Returns:

The degrees representing the value provided.

Return type:

float

LISP code from Reingold & Dershowitz CC TUE p. 513

(defun sin-degrees (theta)
  ;; TYPE angle -> amplitude
  ;; Sine of theta (given in degrees).
  (sin (radians-from-degrees theta)))
_sun_apparent_declination(tc: float) float[source]

Declination is measured (from 0° to +90°) from the equator, positive to the north, negative to the south.

Parameters:
  • tc (float) – Julian century.

  • app (bool) – If True the apparent declination is returned, if

Returns:

The apparent declination of the sun in radians.

Return type:

float

Note

Meeus–AA ch. 25 p. 165 Eq. 25.7

_sun_apparent_longitude(tc: float) float[source]

The Sun’s apparent longitude is the angle measured from the vernal equinox to the Sun’s position on the ecliptic plane as seen from Earth.

Parameters:

tc (float) – Time in Julian centuries.

Returns:

The Sun’s apparent longitude.

Return type:

float

Note

Meeus–AA p. 164

This has a less accurate result. apparent_solar_longitude() should be more accurate.

_sun_apparent_right_ascension(tc: float) float[source]

Right ascension is measured (from 0 to 24 hours, sometimes from 0° to 360°) from the vernal equinox, positive to the east, along the celestial equator.

Parameters:

tc (float) – Julian century.

Returns:

The apparent declination of the sun in radians.

Return type:

float

Note

Meeus–AA ch. 25 p. 165 Eq. 25.6

_sun_earth_mean_anomaly(tc: float) float[source]

The position of the Earth in its orbit around the Sun.

Parameters:

tc (float) – Time in Julian centuries.

Returns:

Sun and earth mean anomaly.

Return type:

float

Note

Meeus–AA ch. 22 p. 144
Referenced by ls (M).
_sun_equation_of_center(tc: float) float[source]

Describes the difference between the true anomaly (the actual angular position of the Earth in its orbit around the Sun) and the mean anomaly (the position the Earth would have if its orbit were perfectly circular and uniform). This difference is caused by the elliptical shape of Earth’s orbit and the resulting non-uniform motion of the Earth around the Sun.

Parameters:

tc (float) – Time in Julian centuries.

Returns:

The Sun’s equation of it’s center.

Return type:

float

Note

Meeus–AA ch. 25 p. 164

_sun_mean_longitude(tc: float) float[source]

The geometric mean longitude of the Sun, referred to the mean equinox of the date.

Parameters:

tc (float) – Time in Julian centuries.

Returns:

Mean longitude of the sun in degrees.

Return type:

float

Note

Meeus–AA ch. 25 p. 163 Eq. 25.2
References by L0
_sun_rising(jd: float, lat: float, lon: float, *, offset: float = 0.8333) float[source]

Find the jd for sunrise of the given jd.

Parameters:
  • jd (float) – Julian day in UT.

  • lat (float) – Geographic latitude positive north negative south.

  • lon (float) – Geographic longitude positive east negative west.

  • offset (bool) – A constant “standard” altitude, i.e., the geometric altitude of the center of the body at the time of apparent rising or setting, namely, h0 = -0°34’ = -0°5667 for stars and planets; h0 = -0°50’ = -0°8333 for the Sun. Default is _SUN_OFFSET, _STARS_PLANET_OFFSET can also be used.

Returns:

The jd moment of the sunrise.

Return type:

float

Note

Meeus-AA ch. 15 p. 102, 103 Eq. 15.1, 15.2

_sun_setting(jd: float, lat: float, lon: float, *, offset: float = 0.8333) float[source]

Find the jd for sunset of the given jd.

Parameters:
  • jd (float) – Julian day in UT.

  • lat (float) – Geographic latitude positive north negative south.

  • lon (float) – Geographic longitude positive east negative west.

  • offset (bool) – A constant “standard” altitude, i.e., the geometric altitude of the center of the body at the time of apparent rising or setting, namely, h0 = -0°34’ = -0°5667 for stars and planets; h0 = -0°50’ = -0°8333 for the Sun. Default is _SUN_OFFSET, _STARS_PLANET_OFFSET can also be used.

Returns:

The jd moment of the sunset.

Return type:

float

Note

Meeus-AA ch. 15 p. 102, 103 Eq. 15.1, 15.2

_sun_transit(jd: float, lon: float) float[source]

The transit is when the body crosses the local meridian at upper culmination.

Parameters:
  • jd (float) – Julian day in UT.

  • lon (float) – Geographic longitude positive east negative west.

Returns:

The center point between sunrise and sunset.

Return type:

float

Note

Meeus-AA ch. 15 p. 102, 103 Eq. 15.1, 15.2

_sun_true_longitude(tc: float) float[source]

The true geometric longitude referred to the mean equinox of the date. This longitude is the quantity required for instance in the calculation of geocentric planetary positions.

Parameters:

tc (float) – Time in Julian centuries.

Returns:

The true geometric longitude.

Return type:

float

Note

Meeus–AA p. 164

_transit_correction(tc: float, ast: float, dt: float, lon: float, m: float) float[source]

Find the correction to the transit.

Parameters:
  • tc (float) – The Julian Period century.

  • ast (float) – The apparent sidereal time at Greenwich.

  • dt (float) – The delta T of the JD.

  • lon (float) – The longitude.

  • m (float) – Times on day, expressed as fractions.

Returns:

The correction to the transit.

Return type:

float

_true_obliquity_of_ecliptic(tc: float) float[source]

The obliquity of the ecliptic, or inclination of the Earth’s axis of rotation, is the angle between the equator and the ecliptic.

Parameters:

jde (float) – Julian century.

Returns:

The obliquity of the ecliptic in degrees as a decimal.

Return type:

float

Note

Meeus–AA ch. 22 p. 147 Eq. 22.3
Convert lots of things:
_truncate_decimal(n: int, places: int) int[source]

Truncate a decimal to a number of places.

Note

This is somewhat like rounding, but is used in places where rounding gives an invalid results.

Parameters:
  • n (int) – Number to truncate.

  • places (int) – The number of places to truncate to.

Returns:

The truncated number.

Return type:

int

_tz_decimal_from_dhms(days: int, hours: int, minutes: int, seconds: int) int[source]

Convert days, hours, minutes, and seconds to a decimal number representing percentage of one revolution around the Earth. Where the number 1 indicates one revolution.

Parameters:
  • days (int) – Number of days.

  • hours (int) – Number of hours.

  • minutes (int) – The number of minutes.

  • seconds (float) – The number of seconds with possible fraction.

Returns:

A decimal number.

Return type:

int

Note

This method is used in determining time zones.

_tz_dhms_from_decimal(dec: float) tuple[source]

Convert a decimal number into days, hours, minutes, and seconds of a time zone. The decimal number represents the percentage of one revolution around the Earth. Where the number 1 indicates one revolution.

Parameters:

dec (float) – A decimal number.

Returns:

The days, hours, minutes, and seconds of a time zone.

Return type:

tuple

Note

This method is used in determining time zones.

_xor_boolean(booleans: tuple) bool[source]

Test that any number of booleans can all be False or only one True.

Parameters:

booleans (tuple) – A tuple of booleans that cannot be used together.

Returns:

True if only one of the booleans are True or if None are True else False.

Return type:

bool