AstroConst

A Python package that provides astronomical constants.
The code is being developed by Marc van der Sluys of the department of
Astrophysics at the Radboud University Nijmegen, the Institute of Nuclear and High-Energy Physics (Nikhef),
and the Institute for Gravitational and Subatomic Physics (GRASP) at Utrecht University, all in The
Netherlands. The AstroConst package can be used under the conditions of the
EUPL 1.2 licence.
Note that the package is currently is its alpha stage, and things may still change as I start using this.
Installation
This package can be installed using pip install astroconst
. This should automatically install the
dependency package numpy
, if it has't been installed already. If you are installing by hand, ensure that
this package is installed as well.
Example use
SI units should be used everywhere - no ergs, dyn or cm (sorry!). Values include mathematical constants (like
π), angle-conversion factors (from/to radians, degrees, hours, arcseconds, ...), calendar stuff (names of
weekdays and months, JDs, lengths of days, months and years), solar-system objects (Sun, Moon, planet
names diameters, orbital separations, etc. - note that Moon = planet #0), and some basic physical constants
((Stefan-)Bolzmann, Planck, speed of light, etc.).
The submodule aa
contains constants published by the Astronomical Almanac, converted to Python.
"""Example Python script using the AstroConst package."""
import astroconst as ac
print(ac.c)
print(ac.aa.c)
print(ac.jd2000)
print(ac.m_sun)
print(ac.sol_const)
print(ac.year_jul)
print(ac.year_jul/ac.day)
print(ac.month_syn/ac.day)
print('The diameter of '+ac.plname_en[5]+' is '+str(ac.pl_d[5]/ac.km)+' km')
print('a_'+ac.plname_en[0]+' = '+str(ac.pl_a[0]/ac.km)+' km')
print(ac.dow_en_abr[0])
print(ac.months_en[3])
AstroConst pages
Author and licence
References
Copyright (c) 2022-2025 Marc van der Sluys