astrocalc ∞
perform common astronomy-related calculations, conversions and measurements within python scripts or from the command-line.
Documentation for astrocalc is hosted by Read the Docs ( development version and master version). The code lives on github. Please report any issues you find here.
Features ∞
How to cite astrocalc ∞
If you use astrocalc
in your work, please cite using the following BibTeX entry:
@software{Young_astrocalc,
author = {Young, David R.},
doi = {10.5281/zenodo.8014736},
license = {GPL-3.0-only},
title = ,
url = {https://github.com/thespacedoctor/astrocalc}
}
Installation ∞
The easiest way to install astrocalc is to use pip
(here we show the install inside of a conda environment):
conda create -n astrocalc python=3.7 pip
conda activate astrocalc
pip install astrocalc
Or you can clone the github repo and install from a local version of the code:
git clone git@github.com:thespacedoctor/astrocalc.git
cd astrocalc
python setup.py install
To upgrade to the latest version of astrocalc use the command:
pip install astrocalc --upgrade
To check installation was successful run astrocalc -v
. This should return the version number of the install.
Development ∞
If you want to tinker with the code, then install in development mode. This means you can modify the code from your cloned repo:
git clone git@github.com:thespacedoctor/astrocalc.git
cd astrocalc
python setup.py develop
Pull requests are welcomed!
Initialisation ∞
Before using astrocalc you need to use the init
command to generate a user settings file. Running the following creates a yaml settings file in your home folder under ~/.config/astrocalc/astrocalc.yaml
:
astrocalc init
The file is initially populated with astrocalc’s default settings which can be adjusted to your preference.
If at any point the user settings file becomes corrupted or you just want to start afresh, simply trash the astrocalc.yaml
file and rerun astrocalc init
.
Modifying the Settings ∞
Once created, open the settings file in any text editor and make any modifications needed.
Basic Python Setup ∞
If you plan to use astrocalc
in your own scripts you will first need to parse your settings file and set up logging etc. One quick way to do this is to use the fundamentals
package to give you a logger, a settings dictionary and a database connection (if connection details given in settings file):
## SOME BASIC SETUP FOR LOGGING, SETTINGS ETC
from fundamentals import tools
from os.path import expanduser
home = expanduser("~")
settingsFile = home + "/.config/astrocalc/astrocalc.yaml"
su = tools(
arguments={"settingsFile": settingsFile},
docString=__doc__,
)
arguments, settings, log, dbConn = su.setup()
Todo List ∞
Todo
add usage info create a sublime snippet for usage
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/coordinates_to_array.py:docstring of astrocalc.coords.coordinates_to_array.coordinates_to_array, line 19.)
Todo
replace get_angular_separation throughout all code using dryxPython
replace getAngularSeparationthroughout all code using dryxPython
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/separations.py:docstring of astrocalc.coords.separations.separations, line 16.)
Todo
replace shift_coordinates class in all other code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/translate.py:docstring of astrocalc.coords.translate.translate, line 14.)
Todo
add usage info
create a sublime snippet for usage
add ra_sexegesimal_to_decimal
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/unit_conversion.py:docstring of astrocalc.coords.unit_conversion.unit_conversion, line 12.)
Todo
replace dryxPython declination_sexegesimal_to_decimal with this version in all my code
replace coords_sex_to_dec in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/unit_conversion.py:docstring of astrocalc.coords.unit_conversion.unit_conversion.dec_sexegesimal_to_decimal, line 26.)
Todo
replace ra_to_sex from dryxPython in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/unit_conversion.py:docstring of astrocalc.coords.unit_conversion.unit_conversion.ra_decimal_to_sexegesimal, line 19.)
Todo
replace dec_to_sex in dryxPython in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/unit_conversion.py:docstring of astrocalc.coords.unit_conversion.unit_conversion.dec_decimal_to_sexegesimal, line 19.)
Todo
replace calculate_cartesians in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/unit_conversion.py:docstring of astrocalc.coords.unit_conversion.unit_conversion.ra_dec_to_cartesian, line 15.)
Todo
replace convert_mpc_to_redshift in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/distances/converter.py:docstring of astrocalc.distances.converter.converter.distance_to_redshift, line 16.)
Todo
replace convert_redshift_to_distance in all other code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/distances/converter.py:docstring of astrocalc.distances.converter.converter.redshift_to_distance, line 22.)
Todo
update key arguments values and definitions with defaults
update return values and definitions
update usage examples and text
update docstring text
check sublime snippet exists
clip any useful text to docs mindmap
regenerate the docs and check redendering of this docstring
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/docstring_test.py:docstring of astrocalc.docstring_test.docsting_test, line 38.)
Todo
nice!
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/docstring_test.py:docstring of astrocalc.docstring_test.docsting_test, line 52.)
Todo
add usage info
create a sublime snippet for usage
add mjd_to_date
add decimal_day_to_day_hour_min_sec
add date_to_mjd
convert all functions in __init__ to modules
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/times/conversions.py:docstring of astrocalc.times.conversions.conversions, line 12.)
Todo
replace getMJDFromSqlDate in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/times/conversions.py:docstring of astrocalc.times.conversions.conversions.ut_datetime_to_mjd, line 18.)
Todo
replace getDateFromMJD in all code
replace getSQLDateFromMJD in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/times/conversions.py:docstring of astrocalc.times.conversions.conversions.mjd_to_ut_datetime, line 13.)
Todo
replace decimal_day_to_day_hour_min_sec in all other code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/times/conversions.py:docstring of astrocalc.times.conversions.conversions.decimal_day_to_day_hour_min_sec, line 21.)
Todo
add clutil
remove getCurrentMJD from all other code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/times/now.py:docstring of astrocalc.times.now.now.get_mjd, line 11.)
Todo
add usage info create a sublime snippet for usage
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/coordinates_to_array.py:docstring of astrocalc.coords.coordinates_to_array.coordinates_to_array, line 19.)
Todo
replace get_angular_separation throughout all code using dryxPython
replace getAngularSeparationthroughout all code using dryxPython
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/separations.py:docstring of astrocalc.coords.separations.separations, line 16.)
Todo
replace shift_coordinates class in all other code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/translate.py:docstring of astrocalc.coords.translate.translate, line 14.)
Todo
add usage info
create a sublime snippet for usage
add ra_sexegesimal_to_decimal
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/unit_conversion.py:docstring of astrocalc.coords.unit_conversion.unit_conversion, line 12.)
Todo
replace dec_to_sex in dryxPython in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/unit_conversion.py:docstring of astrocalc.coords.unit_conversion.unit_conversion.dec_decimal_to_sexegesimal, line 19.)
Todo
replace dryxPython declination_sexegesimal_to_decimal with this version in all my code
replace coords_sex_to_dec in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/unit_conversion.py:docstring of astrocalc.coords.unit_conversion.unit_conversion.dec_sexegesimal_to_decimal, line 26.)
Todo
replace calculate_cartesians in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/unit_conversion.py:docstring of astrocalc.coords.unit_conversion.unit_conversion.ra_dec_to_cartesian, line 15.)
Todo
replace ra_to_sex from dryxPython in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/coords/unit_conversion.py:docstring of astrocalc.coords.unit_conversion.unit_conversion.ra_decimal_to_sexegesimal, line 19.)
Todo
replace convert_mpc_to_redshift in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/distances/converter.py:docstring of astrocalc.distances.converter.converter.distance_to_redshift, line 16.)
Todo
replace convert_redshift_to_distance in all other code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/distances/converter.py:docstring of astrocalc.distances.converter.converter.redshift_to_distance, line 22.)
Todo
add usage info
create a sublime snippet for usage
add mjd_to_date
add decimal_day_to_day_hour_min_sec
add date_to_mjd
convert all functions in __init__ to modules
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/times/conversions.py:docstring of astrocalc.times.conversions.conversions, line 12.)
Todo
replace decimal_day_to_day_hour_min_sec in all other code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/times/conversions.py:docstring of astrocalc.times.conversions.conversions.decimal_day_to_day_hour_min_sec, line 21.)
Todo
replace getDateFromMJD in all code
replace getSQLDateFromMJD in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/times/conversions.py:docstring of astrocalc.times.conversions.conversions.mjd_to_ut_datetime, line 13.)
Todo
replace getMJDFromSqlDate in all code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/times/conversions.py:docstring of astrocalc.times.conversions.conversions.ut_datetime_to_mjd, line 18.)
Todo
add clutil
remove getCurrentMJD from all other code
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/envs/master/lib/python3.7/site-packages/astrocalc-0.4.2-py3.7.egg/astrocalc/times/now.py:docstring of astrocalc.times.now.now.get_mjd, line 11.)
Todo
nice!
(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/astrocalc/checkouts/master/docs/source/_template_.md, line 1.)
API Reference ∞
Modules ∞
common tools used throughout package |
|
Calculations and conversions based on sky-coordinates |
|
Tools to work with and manipulate astronomical distances |
|
Calculations and conversions based on astronomical times |
|
Get common file and folder paths for the host package |
Classes ∞
The worker class for the separations module |
|
Translate a set of coordinates north and east by distances given in arcsecs |
|
The worker class for the unit_conversion module |
|
A converter to switch distance between various units of measurement |
|
The worker class for the conversions module |
|
Report the current time into various formats |
Functions ∞
Get the root path for this python package |
|
Convert a single value RA, DEC or list of RA and DEC to numpy arrays |
|
Convert luminosity to a flux |
A-Z Index ∞
Modules
common tools used throughout package |
|
Calculations and conversions based on sky-coordinates |
|
Tools to work with and manipulate astronomical distances |
|
Calculations and conversions based on astronomical times |
|
Get common file and folder paths for the host package |
Classes
The worker class for the separations module |
|
Translate a set of coordinates north and east by distances given in arcsecs |
|
The worker class for the unit_conversion module |
|
A converter to switch distance between various units of measurement |
|
The worker class for the conversions module |
|
Report the current time into various formats |
Functions
Get the root path for this python package |
|
Convert a single value RA, DEC or list of RA and DEC to numpy arrays |
|
Convert luminosity to a flux |