Tests Test Coverage Latest release BSD-3 clause license PyPI - Python Version

astronomia Package

calendar Module

Copyright 2000, 2001 Astrolabe by William McClain.

Forked in 2013 to Astronomia

Copyright 2013 Astronomia by Tim Cera

This file is part of Astronomia.

Astronomia is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Astronomia is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Astronomia; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

A collection of date and time functions.

The functions which use Julian Day Numbers are valid only for positive values, i.e., for dates after -4712 (4713BC).

Unless otherwise specified, Julian Day Numbers may be fractional values.

Numeric years use the astronomical convention of a year 0: 0 = 1BC, -1 = 2BC, etc.

Numeric months are 1-based: Jan = 1…Dec = 12.

Numeric days are the same as the calendar value.

Reference: Jean Meeus, Astronomical Algorithms, second edition, 1998, Willmann-Bell, Inc.

exception astronomia.calendar.Error

Bases: Exception

local exception class.

astronomia.calendar.cal_to_day_of_year(year, mon, day, gregorian=True)

Convert a calendar date to day of the year.

Parameters:
  • year (int) – Year

  • mon (int) – Month

  • day (int) – Day

  • gregorian (bool, optional) – If True, use Gregorian calendar, else use Julian calendar (default=True)

Returns:

Day number (1 = Jan 1, 365/366 = Dec 31)

Return type:

cal_to_day_of_year

Notes

Implementation based on Meeus 7.1

astronomia.calendar.cal_to_jd(year, mon=1, day=1, gregorian=True)

Convert a calendar date to Julian Day Number.

Parameters:
  • year (int) – Year

  • mon (int, optional) – Month (default=1)

  • day (int or float, optional) – Day, may be fractional (default=1)

  • gregorian (bool, optional) – If True, use Gregorian calendar, else use Julian calendar (default=True)

Returns:

Julian Day Number

Return type:

cal_to_jd

Notes

Implementation based on Meeus 7.1

astronomia.calendar.cal_to_jde(year, mon=1, day=1, hour=0, minute=0, sec=0.0, gregorian=True)

Convert a calendar date to Julian Day Ephemeris.

Parameters:
  • year (int) – Year

  • mon (int, optional) – Month (default=1)

  • day (int, optional) – Day (default=1)

  • hour (int, optional) – Hour (default=0)

  • minute (int, optional) – Minute (default=0)

  • sec (float, optional) – Second (default=0.0)

  • gregorian (bool, optional) – If True, use Gregorian calendar, else use Julian calendar (default=True)

Returns:

Julian Day Ephemeris

Return type:

cal_to_jde

Notes

Implementation based on Meeus 22.1

astronomia.calendar.day_of_year_to_cal(year, N, gregorian=True)

Convert a day of year number to month and day.

Parameters:
  • year (int) – Year

  • N (int) – Day of year (1..365 or 366 for leap years)

  • gregorian (bool, optional) – If True, use Gregorian calendar, else use Julian calendar (default=True)

Returns:

  • month – Calendar month

  • day – Calendar day

astronomia.calendar.easter(year, gregorian=True)

Calculate the date of Western ecclesiastical Easter.

Parameters:
  • year (int) – Year

  • gregorian (bool, optional) – If True, use Gregorian calendar, else use Julian calendar (default=True)

Returns:

  • month – Month of Easter

  • day – Day of Easter

astronomia.calendar.fday_to_hms(day)

Convert fractional day to hours, minutes, seconds.

Parameters:

day (float) – Fractional day in range 0.0..1.0

Returns:

  • hour (int) – Hours of the fractional day (0..23)

  • minute (int) – Minutes of the fractional day (0..59)

  • second (int) – Seconds of the fractional day (0..59)

astronomia.calendar.frac_yr_to_jd(year, gregorian=True)

Convert Julian or Gregorian fractional year date to Julian Day Number.

Parameters:
  • year (int or float) – Year to convert

  • gregorian (bool, optional) – If True, use Gregorian calendar, else use Julian calendar (default=True)

Returns:

Julian Day Number

Return type:

frac_yr_to_jd

Notes

Implementation based on Meeus 7.1

astronomia.calendar.hms_to_fday(hr, mn, sec)

Convert hours-minutes-seconds to fractional day.

Parameters:
  • hr (int) – Hours (0..23)

  • mn (int) – Minutes (0..59)

  • sec (int) – Seconds (0..59)

Returns:

Fractional day (0.0..1.0)

Return type:

hms_to_fday

astronomia.calendar.is_dst(julian_day)

Check if instant is within Daylight Savings Time period.

Parameters:

julian_day (int) – Julian Day number representing Universal Time

Returns:

is_dst – True if Daylight Savings Time is in effect, False otherwise

Return type:

bool

Notes

Uses the time zone database associated with Python’s time module

astronomia.calendar.is_leap_year(year, gregorian=True)

Check if year is a leap year.

Parameters:
  • year (int) – Year to check

  • gregorian (bool, optional) – If True, use Gregorian calendar, else use Julian calendar (default=True)

Returns:

is_leap_year – True if leap year, False otherwise

Return type:

bool

astronomia.calendar.jd_to_cal(julian_day, gregorian=True)

Convert a Julian Day Number to calendar date.

Parameters:
  • julian_day (int) – Julian Day Number

  • gregorian (bool, optional) – If True, use Gregorian calendar, else use Julian calendar (default=True)

Returns:

  • year – Calendar year

  • month – Calendar month

  • day – Calendar day (may be fractional)

astronomia.calendar.jd_to_day_of_week(julian_day)

Calculate day of week from Julian Day Number.

Parameters:

julian_day (int) – Julian Day number (must be for 0h UT)

Returns:

Day of week (0=Sunday…6=Saturday)

Return type:

jd_to_day_of_week

astronomia.calendar.jd_to_jcent(julian_day)

Calculate number of Julian centuries since J2000.0.

Parameters:

julian_day (int) – Julian Day number

Returns:

Number of Julian centuries

Return type:

jd_to_jcent

astronomia.calendar.lt_to_str(julian_day, zone='', level='second')

Convert local time in Julian Days to formatted string.

Parameters:
  • julian_day (int) – Julian Day number

  • zone (str, optional) – Time zone string (default=””) Pass empty string for zone to handle zone formatting in calling module

  • level ({'day', 'hour', 'minute', 'second'}, optional) – Time precision level (default=’second’) Truncate the time value to seconds, minutes, hours or days as indicated. If level = “day”, don’t print the time zone string.

Returns:

Formatted date/time string in format: YYYY-MMM-DD HH:MM:SS ZZZ

Return type:

lt_to_str

astronomia.calendar.sidereal_time_greenwich(julian_day)

Calculate mean sidereal time at Greenwich.

Parameters:

julian_day (int) – Julian Day number (must represent Universal Time)

Returns:

Sidereal time in radians (2pi radians = 24 hours)

Return type:

sidereal_time_greenwich

astronomia.calendar.ut_to_lt(julian_day)

Convert Universal Time to local time.

Parameters:

julian_day (int) – Julian Day number (Universal Time)

Returns:

  • julian_day (float) – (local time)

  • zone_string (str) – (timezone used for conversion)

Notes

Includes Daylight Savings Time offset if applicable

astronomia.calendar.yr_frac_mon_to_jd(year, mon, gregorian=True)

Convert a year and fractional month to Julian Day Number.

Parameters:
  • year (int) – Year

  • mon (int or float) – Month

  • gregorian (bool, optional) – If True, use Gregorian calendar, else use Julian calendar (default=True)

Returns:

Julian Day Number

Return type:

float

Notes

Implementation based on Meeus 7.1

coordinates Module

Copyright 2000, 2001 Astrolabe by William McClain.

Forked in 2013 to Astronomia

Copyright 2013 Astronomia by Tim Cera

This file is part of Astronomia.

Astronomia is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Astronomia is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Astronomia; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Collection of miscellaneous functions

exception astronomia.coordinates.Error

Bases: Exception

Local exception class.

astronomia.coordinates.ecl_to_equ(longitude, latitude, obliquity)

Convert ecliptic to equatorial coordinates.

[Meeus-1998: equations 13.3, 13.4]

Parameters:
  • longitude (float | ndarray | list) – Ecliptic longitude in radians.

  • latitude (float | ndarray | list) – Ecliptic latitude in radians.

  • obliquity (float | ndarray | list) – Obliquity of the ecliptic in radians.

Return type:

Tuple[float | ndarray | list, float | ndarray | list]

Returns:

  • right_ascension – Right ascension in radians

  • declination – Declination in radians

astronomia.coordinates.ell_to_geo(latitude, longitude, height)

Convert elliptic to geocentric coordinates.

Parameters:
  • latitude (float | ndarray | list) – Latitude in radians.

  • longitude (float | ndarray | list) – Longitude in radians.

  • height (float | ndarray | list) – Height above the ellipsoid in kilometers.

Return type:

Tuple[float | ndarray | list, float | ndarray | list, float | ndarray | list]

Returns:

  • r – Distance from the center of the Earth in kilometers.

  • theta – Angle from the x-axis in radians.

  • phi – Angle from the z-axis in radians.

astronomia.coordinates.equ_to_ecl(ra, dec, obliquity)

Convert equatorial to ecliptic coordinates.

[Meeus-1998: equations 13.1, 13.2]

Parameters:
  • ra (float | ndarray | list) – Right ascension in radians.

  • dec (float | ndarray | list) – Declination in radians.

  • obliquity (float | ndarray | list) – Obliquity of the ecliptic in radians.

Return type:

Tuple[float | ndarray | list, float | ndarray | list]

Returns:

  • ecliptic_longitude – Ecliptic longitude in radians

  • ecliptic_latitude – Ecliptic latitude in radians.

astronomia.coordinates.equ_to_horiz(H, decl)

Convert equatorial to horizontal coordinates.

[Meeus-1998: equations 13.5, 13.6]

Parameters:
  • H (float | ndarray | list) – Hour angle in radians.

  • decl (float | ndarray | list) – Declination in radians.

Return type:

Tuple[float | ndarray | list, float | ndarray | list]

Returns:

  • azimuth – azimuth in radians

  • altitude – altitude in radians

Notes

Azimuth is measured westward starting from the south. This formula is not accurate near the poles.

dynamical Module

Copyright 2000, 2001 Astrolabe by William McClain.

Forked in 2013 to Astronomia

Copyright 2013 Astronomia by Tim Cera

This file is part of Astronomia.

Astronomia is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Astronomia is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Astronomia; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Functions which calculate the deltaT correction to convert between dynamical and universal time.

Reference: Jean Meeus, Astronomical Algorithms, second edition, 1998, Willmann-Bell, Inc.

astronomia.dynamical.deltaT_seconds(jd)

Return deltaT as seconds of time.

For a historical range from 1620 to a recent year, we interpolate from a table of observed values. Outside that range we use formulae.

Parameters:

jd (int) – Julian Day number

Returns:

deltaT in seconds

Return type:

deltaT_seconds

astronomia.dynamical.dt_to_ut(jd)

Convert Julian Day from dynamical to universal time.

Parameters:

jd (int) – Julian Day number (dynamical time)

Returns:

Julian Day number (universal time)

Return type:

dt_to_ut

lunar Module

Copyright 2000, 2001 Astrolabe by William McClain.

Forked in 2013 to Astronomia

Copyright 2013 Astronomia by Tim Cera

This file is part of Astronomia.

Astronomia is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Astronomia is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Astronomia; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Lunar position model ELP2000-82 of Chapront.

The result values are for the equinox of date and have been adjusted for light-time.

This is the simplified version of Jean Meeus, Astronomical Algorithms, second edition, 1998, Willmann-Bell, Inc.

exception astronomia.lunar.Error

Bases: Exception

Local exception class.

class astronomia.lunar.Lunar

Bases: object

ELP2000 lunar position calculations.

argument_of_latitude(jd)

Return geocentric mean longitude.

Parameters:

jd (float) – Julian Day in dynamical time.

Returns:

argument_of_latitude – Argument of latitude in radians.

Return type:

float

dimension(jd, dim)

Return one of geocentric ecliptic longitude, latitude and radius.

Parameters:
  • jd (float) – Julian Day in dynamical time.

  • dim (str) – “L” (longitude), “B” (latitude), or “R” (radius).

Returns:

dimension – Longitude in radians or latitude in radians or radius in km, Earth’s center to Moon’s center, depending on value of dim.

Return type:

float

dimension3(jd)

Return geocentric ecliptic longitude, latitude, and radius.

When all three dimensions are needed, it is more efficient to combine the calculations in one routine.

Parameters:

jd (float) – Julian Day in dynamical time.

Returns:

  • longitude (float) – Geocentric ecliptic longitude in radians.

  • latitude (float) – Geocentric ecliptic latitude in radians.

  • radius (float) – Radius in kilometers (Earth’s center to Moon’s center).

mean_anomaly(jd)

Return geocentric mean anomaly.

Parameters:

jd (float) – Julian Day in dynamical time.

Returns:

mean_anomaly – Mean anomaly in radians.

Return type:

float

mean_elongation(jd)

Return geocentric mean elongation.

Parameters:

jd (float) – Julian Day in dynamical time.

Returns:

mean_elongation – Mean elongation in radians.

Return type:

float

mean_longitude(jd)

Return geocentric mean longitude.

Parameters:

jd (float) – Julian Day in dynamical time.

Returns:

mean_longitude – Mean longitude in radians.

Return type:

float

mean_longitude_ascending_node(jd)

Return mean longitude of ascending node.

Current implementation in astronomia is from:

PJ Naughter (Web: www.naughter.com, Email: pjna@naughter.com)

Previous implementation.

Another equation from:

This routine is part of the International Astronomical Union’s SOFA (Standards of Fundamental Astronomy) software collection. Fundamental (Delaunay) arguments from Simon et al. (1994)

  • Arcseconds to radians DOUBLE PRECISION DAS2R PARAMETER ( DAS2R = 4.848136811095359935899141D-6 )

  • Milliarcseconds to radians DOUBLE PRECISION DMAS2R PARAMETER ( DMAS2R = DAS2R / 1D3 )

  • Arc seconds in a full circle DOUBLE PRECISION TURNAS PARAMETER ( TURNAS = 1296000D0 )

  • Mean longitude of the ascending node of the Moon. OM = MOD ( 450160.398036D0 -6962890.5431D0*T, TURNAS ) * DAS2R

Parameters:

jd (float) – Julian Day in dynamical time.

Returns:

mean_longitude_ascending_node – Mean longitude of ascending node in radians.

Return type:

float

mean_longitude_perigee(jd)

Return mean longitude of lunar perigee.

Parameters:

jd (float) – Julian Day in dynamical time.

Returns:

mean_longitude_perigee – Mean longitude of perigee in radians.

Return type:

float

equinox Module

Copyright 2000, 2001 Astrolabe by William McClain.

Forked in 2013 to Astronomia

Copyright 2013 Astronomia by Tim Cera

This file is part of Astronomia.

Astronomia is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Astronomia is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Astronomia; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Calculate the times of solstice and equinox events for Earth

exception astronomia.equinox.Error

Bases: Exception

local exception class.

astronomia.equinox.equinox(jd, season, delta)

Return the precise moment of an equinox or solstice event on Earth.

Parameters:
  • jd (float) – Julian of an approximate time of the event in dynamical time

  • season (str) – one of (“spring”, “summer”, “autumn”, “winter”)

  • delta (float) – the required precision in days. Times accurate to a second are reasonable when using the VSOP model.

Returns:

Julian Day in dynamical time

Return type:

equinox

astronomia.equinox.equinox_approx(yr, season)

Returns the approximate time of a solstice or equinox event.

The year must be in the range -1000…3000. Within that range the the error from the precise instant is at most 2.16 minutes.

Parameters:
  • yr (int) – year

  • season (str) – one of {“spring”, “summer”, “autumn”, “winter”}

Returns:

Julian Day in dynamical time

Return type:

equinox_approx

nutation Module

Copyright 2000, 2001 Astrolabe by William McClain.

Forked in 2013 to Astronomia

Copyright 2013 Astronomia by Tim Cera

This file is part of Astronomia.

Astronomia is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Astronomia is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Astronomia; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Functions to calculate nutation and obliquity values.

The IAU “1980 Theory of Nutation” is used, but terms with coefficients smaller than 0.0003” have been dropped.

Reference: Jean Meeus, Astronomical Algorithms, second edition, 1998, Willmann-Bell, Inc.

The first edition of the Meeus book had some errors in the table. These may be corrected in the second edition. I recall correcting my values from those published in Explanatory Supplement to the Astronomical Almanac, revised edition edited by P. Kenneth Seidelman, 1992

astronomia.nutation.nutation_in_longitude(jd)

Return the nutation in longitude.

High precision. [Meeus-1998: pg 144]

Parameters:

jd (float) – Julian Day in dynamical time.

Returns:

Nutation in longitude, in radians.

Return type:

float

astronomia.nutation.nutation_in_obliquity(jd)

Return the nutation in obliquity.

High precision. [Meeus-1998: pg 144]

Parameters:

jd (float) – Julian Day in dynamical time.

Returns:

nutation_in_obliquity – Nutation in obliquity, in radians.

Return type:

float

astronomia.nutation.obliquity(jd)

Return the mean obliquity of the ecliptic.

Low precision, but good enough for most uses. [Meeus-1998: equation 22.2]. Accuracy is 1” over 2000 years and 10” over 4000 years.

Parameters:

jd (float) – Julian Day in dynamical time.

Returns:

obliquity – Obliquity, in radians.

Return type:

float

astronomia.nutation.obliquity_hi(jd)

Return the mean obliquity of the ecliptic.

High precision [Meeus-1998: equation 22.3].

Accuracy is 0.01” between 1000 and 3000, and “a few arc-seconds after 10,000 years”.

Parameters:

jd (float) – Julian Day in dynamical time.

Returns:

Obliquity, in radians.

Return type:

obliquity_hi

riseset Module

Copyright 2000, 2001 Astrolabe by William McClain.

Forked in 2013 to Astronomia

Copyright 2013 Astronomia by Tim Cera

This file is part of Astronomia.

Astronomia is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Astronomia is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Astronomia; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Compute Rise, Set, and Transit times.

Each of the routines requires three equatorial coordinates for the object: yesterday, today and tomorrow, all at 0hr UT.

This approach is inadequate for the Moon, which moves too fast to be accurately interpolated from three daily positions.

Bug: each of the routines drops some events which occur near 0hr UT.

exception astronomia.riseset.Error

Bases: Exception

local exception class.

astronomia.riseset.moon_rst_altitude(r)

Return the standard altitude of the Moon.

Parameters:

r (float) – Distance between the centers of the Earth and Moon, in kilometers.

Returns:

Standard altitude in radians.

Return type:

moon_rst_altitude

astronomia.riseset.rise(jd, raList, decList, h0, delta)

Return the Julian Day of the rise time of an object.

Parameters:
  • jd (int) – Julian Day number of the day in question, at 0 hr UT.

  • raList (tuple of float) – A sequence of three right ascension values, in radians, for (jd-1, jd, jd+1).

  • decList (tuple of float) – A sequence of three declination values, in radians, for (jd-1, jd, jd+1).

  • h0 (float) – The standard altitude in radians.

  • delta (float) – Desired accuracy in days. Times less than one minute are infeasible for rise times because of atmospheric refraction.

Returns:

Julian Day of the rise time.

Return type:

rise

astronomia.riseset.settime(jd, raList, decList, h0, delta)

Return the Julian Day of the set time of an object.

Parameters:
  • jd (int) – Julian Day number of the day in question, at 0 hr UT.

  • raList (tuple of float) – A sequence of three right ascension values, in radians, for (jd-1, jd, jd+1).

  • decList (tuple of float) – A sequence of three declination values, in radians, for (jd-1, jd, jd+1).

  • h0 (float) – The standard altitude in radians.

  • delta (float) – Desired accuracy in days. Times less than one minute are infeasible for set times because of atmospheric refraction.

Returns:

Julian Day of the set time.

Return type:

settime

astronomia.riseset.transit(jd, raList, delta)

Return the Julian Day of the transit time of an object.

Parameters:
  • jd (int) – Julian Day number of the day in question, at 0 hr UT.

  • raList (tuple of float) – A sequence of three right ascension values, in radians, for (jd-1, jd, jd+1).

  • delta (float) – Desired accuracy in days.

Returns:

Julian Day of the transit time.

Return type:

transit

sun Module

Copyright 2000, 2001 Astrolabe by William McClain.

Forked in 2013 to Astronomia

Copyright 2013 Astronomia by Tim Cera

This file is part of Astronomia.

Astronomia is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Astronomia is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Astronomia; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Geocentric solar position and radius, both low and high precision.

exception astronomia.sun.Error

Bases: Exception

Local exception class.

class astronomia.sun.Sun

Bases: object

High precision position calculations.

This is a very light wrapper around the VSOP87d class. The geocentric longitude of the Sun is simply the heliocentric longitude of the Earth + 180 degrees. The geocentric latitude of the Sun is the negative of the heliocentric latitude of the Earth. The radius is of course the same in both coordinate systems.

dimension(jd, dim)

Return one of geocentric ecliptic longitude, latitude, or radius.

Parameters:
  • jd (float or ndarray) – Julian Day in dynamical time.

  • dim (str) – One of “L” (longitude), “B” (latitude), or “R” (radius).

Returns:

dimension – Longitude in radians, latitude in radians, or radius in AU, depending on the value of dim.

Return type:

float or ndarray

dimension3(jd)

Return geocentric ecliptic longitude, latitude, and radius.

Parameters:

jd (float or ndarray) – Julian Day in dynamical time.

Returns:

  • longitude (float) – Longitude in radians.

  • latitude (float) – Latitude in radians.

  • radius (float) – Radius in AU.

mean_longitude(jd)

Return the mean longitude of the Sun.

Parameters:

jd (float or ndarray) – Julian Day in dynamical time.

Returns:

mean_longitude – Longitude in radians.

Return type:

float

mean_longitude_perigee(jd)

Return the mean longitude of the solar perigee.

Parameters:

jd (float or ndarray) – Julian Day in dynamical time.

Returns:

mean_longitude_perigee – Longitude of the solar perigee in radians.

Return type:

float

astronomia.sun.aberration_low(R)

Correct for aberration; low precision, but good enough for most uses.

[Meeus-1998: pg 164]

Parameters:

R (float) – Radius in AU.

Returns:

aberration_low – Correction in radians.

Return type:

float

astronomia.sun.apparent_longitude_low(jd, L)

Correct the geometric longitude for nutation and aberration.

Low precision. [Meeus-1998: pg 164]

Parameters:
  • jd (float or ndarray) – Julian Day in dynamical time.

  • L (float) – Longitude in radians.

Returns:

apparant_longitude_low – Corrected longitude in radians.

Return type:

float

astronomia.sun.longitude_radius_low(jd)

Return geometric longitude and radius vector.

Low precision. The longitude is accurate to 0.01 degree. The latitude should be presumed to be 0.0. [Meeus-1998: equations 25.2 through 25.5]

Parameters:

jd (float or ndarray) – Julian Day in dynamical time.

Returns:

  • longitude (float) – Longitude in radians.

  • radius (float) – Radius in AU.

astronomia.sun.rise(year, month, day, longitude=0.0, latitude=0.0, gregorian=True)

Calculate the rise time of the Sun for a given date and location.

Parameters:
  • year (int) – Year of the date.

  • month (int) – Month of the date.

  • day (int) – Day of the date.

  • longitude (float, optional) – Longitude of the observer in radians. Default is globls.longitude.

  • latitude (float, optional) – Latitude of the observer in radians. Default is globls.latitude.

  • gregorian (bool, optional) – Whether the date is in the Gregorian calendar. Default is True.

Returns:

Updates the Sun object’s right ascension, declination, and standard altitude.

Return type:

rise

util Module

Copyright 2000, 2001 Astrolabe by William McClain.

Forked in 2013 to Astronomia

Copyright 2013 Astronomia by Tim Cera

This file is part of Astronomia.

Astronomia is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Astronomia is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Astronomia; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Collection of miscellaneous functions

exception astronomia.util.Error

Bases: Exception

Local exception class.

astronomia.util.d_to_dms(x)

Convert an angle in decimal degrees to degree components.

Parameters:

x (float) – Angle in decimal degrees.

Returns:

  • degrees (int) – Degrees component.

  • minutes (int) – Minutes component.

  • seconds (float) – Seconds component.

astronomia.util.d_to_r(d)

Convert degrees to radians.

Parameters:

d (float) – Angle in degrees.

Returns:

Angle in radians.

Return type:

d_to_r

astronomia.util.diff_angle(a, b)

Return the difference between two angles, accounting for circular values.

Parameters:
  • a (float) – First angle in radians.

  • b (float) – Second angle in radians.

Returns:

Difference between the two angles in radians, in the range -pi to pi.

Return type:

diff_angle

astronomia.util.dms_to_d(deg, minute, sec)

Convert an angle in degree components to decimal degrees.

Parameters:
  • deg (float) – Degrees component.

  • minute (float) – Minutes component.

  • sec (float) – Seconds component.

Returns:

Angle in decimal degrees.

Return type:

dms_to_d

astronomia.util.interpolate3(n, y)

Interpolate from three equally spaced tabular values.

[Meeus-1998; equation 3.3]

Parameters:
  • n (float) – Interpolating factor, must be between -1 and 1.

  • y (sequence of float) – Sequence of three values.

Returns:

Interpolated value.

Return type:

interpolate3

astronomia.util.interpolate_angle3(n, y)

Interpolate from three equally spaced tabular angular values.

[Meeus-1998; equation 3.3]

Parameters:
  • n (float) – Interpolating factor, must be between -1 and 1.

  • y (sequence of float) – Sequence of three angular values.

Returns:

Interpolated angular value.

Return type:

interpolate_angle3

astronomia.util.load_params()

Read a parameter file and assign global values.

Parameters:

None

Return type:

None

astronomia.util.mod360(x)

Reduce an angle in degrees to the range 0..360.

Parameters:

x (float) – Angle in degrees.

Returns:

Angle in degrees in the range 0..360.

Return type:

mod360

astronomia.util.modpi2(x)

Reduce an angle in radians to the range 0..2pi.

Parameters:

x (float) – Angle in radians.

Returns:

Angle in radians in the range 0..2pi.

Return type:

modpi2

astronomia.util.polynomial(terms, x)

Evaluate a simple polynomial.

Parameters:
  • terms (sequence of float) – Coefficients of the polynomial. terms[0] is the constant term, terms[1] is the coefficient for x, terms[2] is for x^2, etc.

  • x (float) – Variable value.

Returns:

Value of the polynomial.

Return type:

polynomial

Examples

>>> t = 4.1
>>> polynomial((1.1, -3.2, 3.3, 4.5), t)
353.59749999999997
astronomia.util.r_to_d(r)

Convert radians to degrees.

Parameters:

r (float) – Angle in radians.

Returns:

Angle in degrees.

Return type:

r_to_d

planets Module

Copyright 2000, 2001 Astrolabe by William McClain.

Forked in 2013 to Astronomia

Copyright 2013 Astronomia by Tim Cera

This file is part of Astronomia.

Astronomia is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Astronomia is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Astronomia; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

The VSOP87d planetary position model

exception astronomia.planets.Error

Bases: Exception

Local exception class.

class astronomia.planets.VSOP87d

Bases: object

The VSOP87d planetary model.

All instances of this class share a common dictionary of planetary terms.

dimension(jd, planet, dim)

Return one of heliocentric ecliptic longitude, latitude and radius.

[Meeus-1998: pg 218]

Parameters:
  • jd (float or ndarray) – Julian Day in dynamical time.

  • planet (str) – Must be one of (“Mercury”, “Venus”, “Earth”, “Mars”, “Jupiter”, “Saturn”, “Uranus”, “Neptune”).

  • dim (str) – Must be one of “L” (longitude), “B” (latitude), or “R” (radius).

Returns:

longitude in radians, or latitude in radians, or radius in au, depending on the value of dim.

Return type:

dimension

dimension3(jd, planet)

Return heliocentric ecliptic longitude, latitude and radius.

Parameters:
  • jd (float or ndarray) – Julian Day in dynamical time.

  • planet (str) – Must be one of (“Mercury”, “Venus”, “Earth”, “Mars”, “Jupiter”, “Saturn”, “Uranus”, “Neptune”).

Returns:

  • longitude – heliocentric ecliptic longitude in radians

  • latitude – heliocentric ecliptic latitude in radians

  • radius – radius in au

astronomia.planets.geocentric_planet(jd, planet, deltaPsi, epsilon, delta)

Calculate the equatorial coordinates of a planet.

The results will be geocentric, corrected for light-time and aberration.

Parameters:
  • jd (float or ndarray) – Julian Day in dynamical time.

  • planet (str) – Must be one of (“Mercury”, “Venus”, “Earth”, “Mars”, “Jupiter”, “Saturn”, “Uranus”, “Neptune”).

  • deltaPsi (float) – Nutation in longitude, in radians.

  • epsilon (float) – True obliquity (corrected for nutation), in radians.

  • delta (float) – Desired accuracy, in days.

Returns:

  • right_ascension (float) – Right ascension in radians.

  • declination (float) – Declination in radians.

astronomia.planets.vsop_to_fk5(jd, L, B)

Convert VSOP to FK5 coordinates.

This is required only when using the full precision of the VSOP model. [Meeus-1998: pg 219]

Parameters:
  • jd (float or ndarray) – Julian Day in dynamical time.

  • L (float) – Longitude in radians.

  • B (float) – Latitude in radians.

Returns:

  • corrected_longitude (float) – Corrected longitude in radians.

  • corrected_latitude (float) – Corrected latitude in radians.