/SkyAlmanac-Py3

Creates the daily pages of a Nautical Almanac using Skyfield and PyEphem (Python 3)

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

SkyAlmanac-Py3

SkyAlmanac-Py3 is a Python 3 script that creates the daily pages of the Nautical Almanac. These are tables that are needed for celestial navigation with a sextant. Although you are strongly advised to purchase the official Nautical Almanac, this program will reproduce the tables with no warranty or guarantee of accuracy.

SkyAlmanac-Py3 was developed with the intention of having identical output format as SFalmanac-Py3. It is a hybrid version based on two astronomical libraries:

It uses the star database in Skyfield, which is based on data from the Hipparcos Catalogue. PyEphem is used for calculating twilight (actual, civil and nautical sunrise/sunset) and moonrise/moonset. As a consequence, it is four times faster than SFalmanac (which uses Skyfield for almost everything).

NOTE: two scripts are included (both can be run): 'skyalmanac.py' and 'increments.py'
NOTE: a Python 2.7 script with identical functionality can be found at: https://github.com/aendie/SkyAlmanac-Py2
NOTE: a 100% PyEphem version of SkyAlmanac is available here: https://github.com/aendie/Pyalmanac-Py3

An aim of this development was to maintain:

  • identical PDF output formatting with a similar control program
    It is then possible to display both generated tables (from PyEphem, Skyfield and SkyAlmanac) and compare what has changed by flipping between the two tabs in Adobe Acrobat Reader DC. Anything that has changed flashes, thereby drawing your attention to it. This crude and simple method is quite effective in highlihgting data that might need further attention.

The results have been crosschecked with USNO data to some extent.
(However, constructive feedback is always appreciated.)

UPDATE: Nov 2019

Declination formatting has been changed to the standard used in Nautical Almanacs. In each 6-hour block of declinations, the degrees value is only printed on the first line if it doesn't change. It is printed whenever the degrees value changes. The fourth line has two dots indicating "ditto". This applies to all planet declinations and for the sun's declination, but not to the moon's declination as this is continuously changing.

This also includes some very minor changes and an improved title page for the full almanac with two star charts that indicate the equatorial navigational stars.

UPDATE: Jan 2020

The Nautical Almanac tables now indicate if the sun never sets or never rises; similarly if the moon never sets or never rises. For better performance, the SunNeverSets or SunNeverRises state is determined only by the month of year and hemisphere. (This is reliable for the set of latitudes printed in the Nautical Almanac tables.) The code also has cosmetic improvements.
P.S. The Overfull \hbox in paragraph... messages can be ignored - the PDF is correctly generated.

UPDATE: Feb 2020

The main focus was on cleaning up the TeX code and eliminating the Overfull/Underfull hbox/vbox messages. Other minor improvements were included.

UPDATE: Mar 2020

A new parameter in config.py enables one to choose between A4 and Letter-sized pages. A new approach to string formatting has been implemented: the old style Python string formatting syntax has been replaced by the new style string formatting syntax.

UPDATE: Jun 2020

The Equation Of Time is shaded whenever EoT is negative indicating that apparent solar time is slow compared to mean solar time (mean solar time > apparent solar time). It is possible to extend the maximum year beyond 2050 by choosing a different ephemeris in config.py. Bugfix applied to correct the Meridian Passage times.

UPDATE: Jul 2020

A new option has been added into config.py: moonimg = True will display a graphic image of the moon phase (making the resulting PDF slightly larger). Use moonimg = False to revert to the previous format without the graphic moon image.

Requirements

    Computation is done by the free PyEphem and Skyfield libraries.
    Typesetting is done by MiKTeX or TeX Live so you first need to install:

  • Python v3.4 or higher (the latest version is recommended)
  • Skyfield 1.20 (latest tested version - older versions work too)
  • Pandas (to load the Hipparcos catalog; tested: 1.0.3)
  • PyEphem 3.7.6 or 3.7.7
  • TeX/LaTeX  or  MiKTeX  or  TeX Live

Files required in the execution folder:

  • *.py
  • Ra.jpg
  • croppedmoon.png
  • A4chart0-180_P.pdf
  • A4chart180-360_P.pdf

INSTALLATION GUIDELINES on Windows 10:

    Install Python 3.8 (add python.exe to path)
    Install MiKTeX 2.9 from https://miktex.org/
    When MiKTeX first runs it will require installation of additional packages.
    Run Command Prompt as Administrator, go to your Python folder and execute, e.g.:

    cd C:\Python38-32
    pip install --upgrade pip
    ... for a first install:
    pip install pyephem
    ... if already installed, check for upgrade explicitly:
    pip install --upgrade pyephem
    pip install skyfield
    pip install pandas

    Put the SkyAlmanac files in a new folder, run Command Prompt and start with:
    py -3 skyalmanac.py

INSTALLATION GUIDELINES on Ubuntu 19.10 or 20.04:

    Ubuntu 18.04 and higher come with Python 3 preinstalled,
    however pip may need to be installed:
    sudo apt install python3-pip

    Install the following TeX Live package:
    sudo apt install texlive-latex-extra

    Install the required astronomical libraries etc.:
    pip3 install pyephem
    pip3 install skyfield
    pip3 install pandas

    Put the SkyAlmanac files in a folder and start with:
    python3 skyalmanac.py

INSTALLATION GUIDELINES on MAC:

    Every Mac comes with python preinstalled.
    (Please choose this version of SkyAlmanac if Python 3.* is installed.)
    You need to install the Skyfield (and PyEphem) library to use SFalmanac.
    Type the following commands at the commandline (terminal app):

    sudo easy_install pip
    pip install pyephem
    pip install skyfield
    pip install pandas

    If this command fails, your Mac asks you if you would like to install the header files.
    Do so - you do not need to install the full IDE - and try again.

    Install TeX/LaTeX from http://www.tug.org/mactex/

    Now you are almost ready. Put the SkyAlmanac files in any directory and start with:
    python skyalmanac
    or
    ./skyalmanac