Algorithms from Practical Astronomy, implemented in Python
Project description
practical-astronomy-python
Algorithms from "Practical Astronomy with your Calculator or Spreadsheet" by Peter Duffett-Smith, implemented in Python 3. API documentation is published here.
If you're interested in this topic, please buy the book! It provides far more detail and context.
CLI
Work is started on a command-line interface, but only the date/time functions are implemented, so far. Results are formatted as JSON.
Invoke as ./pa-cli.py -h
to see all of the options:
$ ./pa-cli.py -h
usage: pa-cli.py [-h] [--cd CD] [--ct CT] [--dh DH] [--gd GD] [--gl GL] [--gst GST] [--lst LST] [--jd JD] [--ut UT] [--year YEAR] [--dst] [--st] [--zc ZC] [--doe] [--cd_to_dn] [--gd_to_jd] [--jd_to_gd] [--ct_to_dh] [--dh_to_ct] [--lct_to_ut] [--ut_to_lct] [--ut_to_gst] [--gst_to_ut] [--gst_to_lst] [--lst_to_gst]
Practical Astronomy CLI.
optional arguments:
-h, --help show this help message and exit
Actions:
--doe Calculate date of Easter, for a given year.
--cd_to_dn Convert civil date to day number.
--gd_to_jd Convert Greenwich date to Julian date.
--jd_to_gd Convert Julian date to Greenwich date.
--ct_to_dh Convert civil time to decimal hours.
--dh_to_ct Convert decimal hours to civil time.
--lct_to_ut Convert local civil time to universal time.
--ut_to_lct Convert universal time to local civil time.
--ut_to_gst Convert universal time to Greenwich sidereal time.
--gst_to_ut Convert Greenwich sidereal time to universal time.
--gst_to_lst Convert Greenwich sidereal time to local sidereal time.
--lst_to_gst Convert local sidereal time to Greenwich sidereal time.
Inputs (used by Actions):
--cd CD Civil date. Input format: 'mm/dd/yyyy'
--ct CT Civil time. Input format: 'hh:mm:ss'
--dh DH Decimal hours. Input format: floating point number, e.g., 18.52416667
--gd GD Greenwich date. Input format: 'mm/dd/yyyy'. Fractional day is allowed, e.g., '6/19.75/2009'
--gl GL Geographical longitude. Input format: (+/-)##.##, e.g., -64.00
--gst GST Greenwich sidereal time. Input format: 'hh:mm:ss'
--lst LST Local sidereal time. Input format: 'hh:mm:ss'
--jd JD Julian date. Input format: floating point number, e.g., 2455002.25
--ut UT Universal time. Input format: 'hh:mm:ss'
--year YEAR Calendar year, e.g. 2019.
Inputs (time zone management):
--dst Observe daylight savings time.
--st Observe standard time (default)
--zc ZC Offset, in hours, for time zone correction.
Example
Convert universal time to Greenwich sidereal time:
$./pa-cli.py --ut_to_gst --ut "14:36:51.67" --gd "4/22/1980"
{"greenwichSiderealTimeHours": 4, "greenwichSiderealTimeMinutes": 40, "greenwichSiderealTimeSeconds": 5.23}
Unit Tests
Unit test run can be invoked via the Make utility:
make all
Library Functions
Date/Time
Type | Description |
---|---|
Calculate | Date of Easter |
Convert | Civil Date to Day Number |
Convert | Greenwich Date <-> Julian Date |
Convert | Julian Date to Day-of-Week |
Extract | Day, Month, and Year parts of Julian Date |
Convert | Civil Time <-> Decimal Hours |
Extract | Hour, Minutes, and Seconds parts of Decimal Hours |
Convert | Local Civil Time <-> Universal Time |
Convert | Universal Time <-> Greenwich Sidereal Time |
Convert | Greenwich Sidereal Time <-> Local Sidereal Time |
Coordinates
Type | Description |
---|---|
Convert | Angle <-> Decimal Degrees |
Convert | Right Ascension <-> Hour Angle |
Convert | Equatorial Coordinates <-> Horizon Coordinates |
Calculate | Obliquity of the Ecliptic |
Convert | Ecliptic Coordinates <-> Equatorial Coordinates |
Convert | Equatorial Coordinates <-> Galactic Coordinates |
Calculate | Angle between two objects |
Calculate | Rising and Setting times for an object |
Calculate | Precession (corrected coordinates between two epochs) |
Calculate | Nutation (in ecliptic longitude and obliquity) for a Greenwich date |
Calculate | Effects of aberration for ecliptic coordinates |
Calculate | RA and Declination values, corrected for atmospheric refraction and geocentric parallax |
Calculate | Heliographic coordinates |
Calculate | Carrington rotation number |
Calculate | Selenographic (lunar) coordinates (sub-Earth and sub-Solar) |
The Sun
Type | Description |
---|---|
Calculate | Approximate and precise positions of the Sun |
Calculate | Sun's distance and angular size |
Calculate | Local sunrise and sunset |
Calculate | Morning and evening twilight |
Calculate | Equation of time |
Calculate | Solar elongation |
Planets
Type | Description |
---|---|
Calculate | Approximate and precise position of planet |
Calculate | Visual aspects of planet (distance, angular diameter, phase, light time, position angle of bright limb, and apparent magnitude) |
Calculate | Position of comet (elliptical and parabolic) |
Calculate | Binary star orbit data |
The Moon
Type | Description |
---|---|
Calculate | Approximate and precise position of Moon |
Calculate | Moon phase and position angle of bright limb |
Calculate | Times of new Moon and full Moon |
Calculate | Moon's distance, angular diameter, and horizontal parallax |
Calculate | Local moonrise and moonset |
Eclipses
Type | Description |
---|---|
Calculate | Lunar eclipse occurrence and circumstances |
Calculate | Solar eclipse occurrence and circumstances |
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file practical_astronomy-0.0.2.tar.gz
.
File metadata
- Download URL: practical_astronomy-0.0.2.tar.gz
- Upload date:
- Size: 295.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad2993562b46e1beea819563540d0f20865f486ad998bb2b555b7c9640799b57 |
|
MD5 | 0c0a90b81b0ed05dc8891ffa2d93f344 |
|
BLAKE2b-256 | c5dbb582fa9e5697a20eb07476f53e1c5587e7cea9ebd89080f7dcc9e894f999 |
File details
Details for the file practical_astronomy-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: practical_astronomy-0.0.2-py3-none-any.whl
- Upload date:
- Size: 50.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dc197ec3e85ecb593c5c3625a7869c23f1ee866b40f7404fe9294bcd01b37a9 |
|
MD5 | d9866b82d48fdfdfa9f4d4c1393d9a1b |
|
BLAKE2b-256 | 8dd2b1b78136dc451ecf4707443b059bed4454c93f101815183458ce2168870d |