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 date in the Julian or Gregorian calendars to day of the year (Meeus 7.1).
- Parameters:
year (-) – (int) year
mon (-) – (int) month
day (-) – (int) day
- Keywords:
gregorian : (bool, default=True) If True, use Gregorian calendar, else use Julian calendar
- Returns:
1 = Jan 1…365 (or 366 for leap years) = Dec 31.
- Return type:
day number
- astronomia.calendar.cal_to_jd(year, mon=1, day=1, gregorian=True)¶
Convert a date in the Julian or Gregorian calendars to the Julian Day Number (Meeus 7.1).
- Parameters:
year (-) – (int) year
- Keywords:
mon : (int, default=1) month
day : (int, float, default=1) day, may be fractional day
gregorian : (bool, default=True) If True, use Gregorian calendar, else use Julian calendar
- Returns:
(int, float)
- astronomia.calendar.cal_to_jde(year, mon=1, day=1, hour=0, minute=0, sec=0.0, gregorian=True)¶
Convert a date in the Julian or Gregorian calendars to the Julian Day Ephemeris (Meeus 22.1).
- Parameters:
year (-) – year
- Keywords:
mon : (int, default=1) month
day : (int, default=1) day, may be fractional day
hour : (int, default=0) hour
minute : (int, default=0) minute
sec : (float, default=0.0) second
gregorian : (bool, default=True) If True, use Gregorian calendar, else use Julian calendar
- Returns:
(float)
- Return type:
julian day ephemeris
- astronomia.calendar.day_of_year_to_cal(year, N, gregorian=True)¶
Convert a day of year number to a month and day in the Julian or Gregorian calendars.
- Parameters:
year (-) – year
N (-) – day of year, 1..365 (or 366 for leap years)
- Keywords:
gregorian : If True, use Gregorian calendar, else use Julian calendar (default: True)
- Returns:
(tuple)
- Return type:
(month, day)
- astronomia.calendar.easter(year, gregorian=True)¶
Return the date of Western ecclesiastical Easter for a year in the Julian or Gregorian calendars.
- Parameters:
year (-) – (int) year
- Keywords:
gregorian : (bool, default=True) If True, use Gregorian calendar, else use Julian calendar
- Returns:
(tuple)
- Return type:
(month, day)
- astronomia.calendar.fday_to_hms(day)¶
Convert fractional day (0.0..1.0) to integral hours, minutes, seconds.
- Parameters:
day (-) – a fractional day in the range 0.0..1.0
- Returns:
(int, 0..23) - minute : (int, 0..59) - second : (int, 0..59)
- Return type:
hour
- astronomia.calendar.frac_yr_to_jd(year, gregorian=True)¶
Convert a date in the Julian or Gregorian fractional year to the Julian Day Number (Meeus 7.1).
- Parameters:
year (-) – (int, float) year
- Keywords:
gregorian : (bool, default=True) If True, use Gregorian calendar, else use Julian calendar
- Returns:
(float)
- astronomia.calendar.hms_to_fday(hr, mn, sec)¶
Convert hours-minutes-seconds into a fractional day 0.0..1.0.
- Parameters:
hr (-) – hours, 0..23
mn (-) – minutes, 0..59
sec (-) – seconds, 0..59
- Returns:
fractional day, 0.0..1.0
- astronomia.calendar.is_dst(julian_day)¶
Is this instant within the Daylight Savings Time period.
Uses the time zone database associated with Python and used in the ‘time’ module.
- Parameters:
julian_day (-) – (int) Julian Day number representing an instant in Universal Time
- Returns:
(bool) True if Daylight Savings Time is in effect, False otherwise.
- astronomia.calendar.is_leap_year(year, gregorian=True)¶
Return True if this is a leap year in the Julian or Gregorian calendars.
- Parameters:
year (-) – (int) year
- Keywords:
gregorian : (bool, default=True) If True, use Gregorian calendar, else use Julian calendar
- Returns:
(bool) True is this is a leap year, else False.
- astronomia.calendar.jd_to_cal(julian_day, gregorian=True)¶
Convert a Julian day number to a date in the Julian or Gregorian calendars.
- Parameters:
julian_day (-) – (int) Julian Day Number
- Keywords:
gregorian : (bool, default=True) If True, use Gregorian calendar, else use Julian calendar
- Returns:
(tuple) day may be fractional
- Return type:
(year, month, day)
- astronomia.calendar.jd_to_day_of_week(julian_day)¶
Return the day of week for a Julian Day Number.
The Julian Day Number must be for 0h UT.
- Parameters:
julian_day (-) – (int) Julian Day number
- Returns:
(int) 0 = Sunday…6 = Saturday.
- Return type:
day of week
- astronomia.calendar.jd_to_jcent(julian_day)¶
Return the number of Julian centuries since J2000.0.
- Parameters:
julian_day (-) – (int) Julian Day number
- Returns:
(int)
- Return type:
Julian centuries
- astronomia.calendar.lt_to_str(julian_day, zone='', level='second')¶
Convert local time in Julian Days to a formatted string.
The general format is:
YYYY-MMM-DD HH:MM:SS ZZZ
Truncate the time value to seconds, minutes, hours or days as indicated. If level = “day”, don’t print the time zone string.
Pass an empty string (“”, the default) for zone if you want to do your own zone formatting in the calling module.
- Parameters:
julian_day (-) – (int) Julian Day number
- Keywords:
zone : (str, default=””) Time zone string
level : (str, default=”second”) {“day”, “hour”, “minute”, “second”}
- Returns:
(str)
- Return type:
formatted date/time string
- astronomia.calendar.sidereal_time_greenwich(julian_day)¶
Return the mean sidereal time at Greenwich.
The Julian Day number must represent Universal Time.
- Parameters:
julian_day (-) – (int) Julian Day number
- Returns:
(float) 2pi radians = 24 hours
- Return type:
sidereal time in radians
- astronomia.calendar.ut_to_lt(julian_day)¶
Convert universal time in Julian Days to a local time.
Include Daylight Savings Time offset, if any.
- Parameters:
julian_day (-) – (int) Julian Day number, universal time
- Returns:
- (str) local time
zone string of the zone used for the conversion
- Return type:
Julian Day number
- astronomia.calendar.yr_frac_mon_to_jd(year, mon, gregorian=True)¶
Convert a year and fractional month in the Julian or Gregorian calendars to the Julian Day Number (Meeus 7.1).
- Parameters:
year (-) – (int) year
mon (-) – (int, float) month
- Keywords:
gregorian : (bool, default=True) If True, use Gregorian calendar, else use Julian calendar
- Returns:
(float)
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 equitorial coordinates.
[Meeus-1998: equations 13.3, 13.4]
- Parameters:
longitude (-) – ecliptic longitude in radians
latitude (-) – ecliptic latitude in radians
obliquity (-) – obliquity of the ecliptic in radians
- Returns:
Right accension in radians
Declination in radians
- astronomia.coordinates.ell_to_geo(latitude, longitude, height)¶
Convert elliptic to geocentric coordinates.
- Parameters:
latitude (-) – latitude
longitude (-) – longitude
height (-) – height
- Returns:
r
theta
phi
- astronomia.coordinates.equ_to_ecl(ra, dec, obliquity)¶
Convert equitorial to ecliptic coordinates.
[Meeus-1998: equations 13.1, 13.2]
- Parameters:
ra (-) – right accension in radians
dec (-) – declination in radians
obliquity (-) – obliquity of the ecliptic in radians
- Returns:
ecliptic longitude in radians
ecliptic latitude in radians
- astronomia.coordinates.equ_to_horiz(H, decl)¶
Convert equitorial to horizontal coordinates.
[Meeus-1998: equations 13.5, 13.6]
Note that azimuth is measured westward starting from the south.
This is not a good formula for using near the poles.
- Parameters:
H (-) – hour angle in radians
decl (-) – declination in radians
- Returns:
azimuth in radians
altitude in radians
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
- astronomia.dynamical.dt_to_ut(jd)¶
Convert Julian Day from dynamical to universal time.
- Parameters:
jd (-) – (int) Julian Day number (dynamical time)
- Returns:
(int) (universal time)
- Return type:
Julian Day number
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 (-) – Julian Day in dynamical time
- Returns:
argument of latitude in radians
- dimension(jd, dim)¶
Return one of geocentric ecliptic longitude, latitude and radius.
- Parameters:
jd (-) – Julian Day in dynamical time
dim (-) – “L” (longitude”) or “B” (latitude) or “R” (radius)
- Returns:
longitude in radians or latitude in radians or radius in km, Earth’s center to Moon’s center, depending on value of dim.
- dimension3(jd)¶
Return geocentric ecliptic longitude, latitude and radius.
When we need all three dimensions it is more efficient to combine the calculations in one routine.
- Parameters:
jd (-) – Julian Day in dynamical time
- Returns:
longitude in radians
latitude in radians
radius in km, Earth’s center to Moon’s center
- mean_anomaly(jd)¶
Return geocentric mean anomaly.
- Parameters:
jd (-) – Julian Day in dynamical time
- Returns:
mean anomaly in radians
- mean_elongation(jd)¶
Return geocentric mean elongation.
- Parameters:
jd (-) – Julian Day in dynamical time
- Returns:
mean elongation in radians
- mean_longitude(jd)¶
Return geocentric mean longitude.
- Parameters:
jd (-) – Julian Day in dynamical time
- Returns:
mean longitude in radians
- mean_longitude_ascending_node(jd)¶
Return mean longitude of ascending node.
Current implemention 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 (-) – julian Day
- Returns:
mean longitude of ascending node
- mean_longitude_perigee(jd)¶
Return mean longitude of lunar perigee.
- Parameters:
jd (-) – julian Day
- Returns:
mean longitude of perigee
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 (-) – Julian of an approximate time of the event in dynamical time
season (-) – one of (“spring”, “summer”, “autumn”, “winter”)
delta (-) – the required precision in days. Times accurate to a second are reasonable when using the VSOP model.
- Returns:
(int) dynamical time
- Return type:
Julian Day
- 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) {“spring”, “summer”, “autumn”, “winter”}
- Returns:
(int) in dynamical time
- Return type:
Julian Day
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 (-) – Julian Day in dynamical time
- Returns:
nutation in longitude, in radians
- astronomia.nutation.nutation_in_obliquity(jd)¶
Return the nutation in obliquity.
High precision. [Meeus-1998: pg 144]
- Parameters:
jd (-) – Julian Day in dynamical time
- Returns:
nutation in obliquity, in radians
- 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 (-) – Julian Day in dynamical time
- Returns:
obliquity, in radians
- 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 (-) – Julian Day in dynamical time
- Returns:
obliquity, in radians
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 (-) – Distance between the centers of the Earth and Moon, in km.
- Returns:
Standard altitude in radians.
- 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 (-) – (float, float, float) a sequence of three right accension values, in radians, for (jd-1, jd, jd+1)
decList (-) – (float, float, float) a sequence of three right 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
- astronomia.riseset.settime(jd, raList, decList, h0, delta)¶
Return the Julian Day of the set time of an object.
- Parameters:
jd (-) – Julian Day number of the day in question, at 0 hr UT
raList (-) – a sequence of three right accension values, in radians, for (jd-1, jd, jd+1)
decList (-) – a sequence of three right declination values, in radians, for (jd-1, jd, jd+1)
h0 (-) – the standard altitude in radians
delta (-) – 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
- astronomia.riseset.transit(jd, raList, delta)¶
Return the Julian Day of the transit time of an object.
- Parameters:
jd (-) – Julian Day number of the day in question, at 0 hr UT
raList (-) – a sequence of three right accension values, in radians, for (jd-1, jd, jd+1)
delta (-) – desired accuracy in days.
- Returns:
Julian Day of the transit time
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 and radius.
- Parameters:
jd (-) – Julian Day in dynamical time
dim (-) – one of “L” (longitude) or “B” (latitude) or “R” (radius).
- Returns:
Either longitude in radians, or latitude in radians, or radius in au, depending on value of dim.
- dimension3(jd)¶
Return geocentric ecliptic longitude, latitude and radius.
- Parameters:
jd (-) – Julian Day in dynamical time
- Returns:
longitude in radians
latitude in radians
radius in au
- mean_longitude(jd)¶
Return mean longitude.
- Parameters:
jd (-) – Julian Day in dynamical time
- Returns:
Longitude in radians
- mean_longitude_perigee(jd)¶
Return mean longitude of solar perigee.
- Parameters:
jd (-) – Julian Day in dynamical time
- Returns:
Longitude of solar perigee in radians
- astronomia.sun.aberration_low(R)¶
Correct for aberration; low precision, but good enough for most uses.
[Meeus-1998: pg 164]
- Parameters:
R (-) – radius in au
- Returns:
correction in radians
- astronomia.sun.apparent_longitude_low(jd, L)¶
Correct the geometric longitude for nutation and aberration.
Low precision. [Meeus-1998: pg 164]
- Parameters:
jd (-) – Julian Day in dynamical time
L (-) – longitude in radians
- Returns:
corrected longitude in radians
- 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 (-) – Julian Day in dynamical time
- Returns:
longitude in radians
radius in au
- astronomia.sun.rise(year, month, day, longitude=0.0, latitude=0.0, gregorian=True)¶
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.
Return a tuple (degrees, minutes, seconds). Degrees and minutes will be integers, seconds may be floating.
If the argument is negative:
The return value of degrees will be negative. If degrees is 0, minutes will be negative. If minutes is 0, seconds will be negative.
- Parameters:
x (-) – degrees
- Returns:
(int) - minutes : (int) - seconds : (int, float)
- Return type:
degrees
- astronomia.util.d_to_r(d)¶
Convert degrees to radians.
- Parameters:
d (-) – (int, float), degrees
- Returns:
(float)
- Return type:
radians
- astronomia.util.diff_angle(a, b)¶
Return angle b - a, accounting for circular values.
Parameters a and b should be in the range 0..pi*2. The result will be in the range -pi..pi.
This allows us to directly compare angles which cross through 0:
359 degress… 0 degrees… 1 degree… etc
- Parameters:
a (-) – (int, float) first angle, in radians
b (-) – (int, float) second angle, in radians
- Returns:
(int, float)
- Return type:
b - a, in radians
- astronomia.util.dms_to_d(deg, minute, sec)¶
Convert an angle in degree components to decimal degrees.
If any of the components are negative the result will also be negative.
- Parameters:
deg (-) – (int, float) degrees
minute (-) – (int, float) minutes
sec (-) – (int, float) seconds
- Returns:
(float)
- Return type:
decimal degrees
- astronomia.util.interpolate3(n, y)¶
Interpolate from three equally spaced tabular values.
[Meeus-1998; equation 3.3]
- Parameters:
n (-) – the interpolating factor, must be between -1 and 1
y (-) – a sequence of three values
- Results:
the interpolated value of y
- astronomia.util.interpolate_angle3(n, y)¶
Interpolate from three equally spaced tabular angular values.
[Meeus-1998; equation 3.3]
This version is suitable for interpolating from a table of angular values which may cross the origin of the circle, for example: 359 degrees…0 degrees…1 degree.
- Parameters:
n (-) – the interpolating factor, must be between -1 and 1
y (-) – a sequence of three values
- Results:
the interpolated value of y
- astronomia.util.load_params()¶
Read a parameter file and assign global values.
- Parameters:
none
- Returns:
nothing
- astronomia.util.mod360(x)¶
Reduce an angle in degrees to the range 0..360.
- Parameters:
x (-) – angle in degrees
- Returns:
angle in degress in the range 0..360
- astronomia.util.modpi2(x)¶
Reduce an angle in radians to the range 0..2pi.
- Parameters:
x (-) – angle in radians
- Returns:
angle in radians in the range 0..2pi
- astronomia.util.polynomial(terms, x)¶
Evaluate a simple polynomial.
Where: terms[0] is constant, terms[1] is for x, terms[2] is for x^2, etc.
- Parameters:
terms (-) – sequence of coefficients
x (-) – variable value
- Results:
value of the polynomial
Examples
>>> t = 4.1 >>> polynomial((1.1, -3.2, 3.3, 4.5), t) 353.59749999999997
returns the value of:
1.1 + 2.2 * t + 3.3 * t^2 + 4.4 * t^3
- astronomia.util.r_to_d(r)¶
Convert radians to degrees.
- Parameters:
r (-) – radians
- Returns:
degrees
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 (-) – Julian Day in dynamical time
planet (-) – must be one of (“Mercury”, “Venus”, “Earth”, “Mars”, “Jupiter”, “Saturn”, “Uranus”, “Neptune”)
dim (-) – must be one of “L” (longitude) or “B” (latitude) or “R” (radius)
- Returns:
longitude in radians, or latitude in radians, or radius in au, depending on the value of dim.
- dimension3(jd, planet)¶
Return heliocentric ecliptic longitude, latitude and radius.
- Parameters:
jd (-) – Julian Day in dynamical time
planet (-) – must be one of (“Mercury”, “Venus”, “Earth”, “Mars”, “Jupiter”, “Saturn”, “Uranus”, “Neptune”)
- Returns:
longitude in radians
latitude in radians
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 (-) – Julian Day in dynamical time
planet (-) – must be one of (“Mercury”, “Venus”, “Earth”, “Mars”, “Jupiter”, “Saturn”, “Uranus”, “Neptune”)
deltaPsi (-) – nutation in longitude, in radians
epsilon (-) – True obliquity (corrected for nutation), in radians
delta (-) – desired accuracy, in days
- Returns:
right accension, in radians
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 (-) – Julian Day in dynamical time
L (-) – longitude in radians
B (-) – latitude in radians
- Returns:
corrected longitude in radians
corrected latitude in radians