Blog

Article Tags

planet-rs Improvements

By William Jeffrey Rankin, Sat Jul 26 2025

I've made a few improvements to my shell-script interface for aa (Stephen L. Moshier's astronomical almanac program):

XML Output

XML is now included among the output formats (csv, html, xml, ps, raw, and table). It's specified just like any of the others:

jrankin@Callisto: ~/planet-rs $ ./planet-rs.sh Mars.txt xml -4 EDT
<?xml version="1.0" encoding="UTF-8"?>
<rs>
    <input_file>Mars.txt</input_file>
    <day>
        <date>07/01/2025</date>
        <rise>11:02 EDT</rise>
        <set>00:11 EDT</set>
    </day>
    <day>
        <date>07/02/2025</date>
        <rise>11:01 EDT</rise>
        <set>00:08 EDT</set>
    </day>
    <day>
        <date>07/03/2025</date>
        <rise>11:00 EDT</rise>
        <set>00:06 EDT</set>
    </day>
    ...

An XSLT is included (fmt-html.xsl) to transform the XML to HTML.

Year Output

The shell script year.sh outputs all formats (and all objects) for the designated year (if year is not specified, current year is output). Example usage and output:

jrankin@Callisto: ~/planet-rs $ ./year.sh 
Generating JAN files...
    ...for 0 (csv)
    ...for 0 (raw)
    ...for 0 (html)
    ...for 0 (table)
    ...for 0 (ps)
    ...for 0 (ps to pdf)
    ...for 0 (xml)
    ...for 2 (csv)
    ...for 2 (raw)
    ...for 2 (html)
    ...for 2 (table)
    ...for 2 (ps)
    ...for 2 (ps to pdf)
    ...for 2 (xml)
    ...

Files are output to directory by format and named according to (YYYY)-(MMM)-(object).(format).

Download

planet-rs.tar.gz, 5.9K

Related Articles

    Article Tags

    Data File Generator for aa (astronomical almanac)

    By William Jeffrey Rankin, Sat Aug 31 2024

    I've added a bash script (gen-planets.sh) to the planet-rs package that generates data files for aa (Stephen L. Moshier's astronomical almanac). It currently outputs files for the Sun, Venus, Mars, Jupiter, and Saturn, but the planets variable can be modified to include any object from the catalog.

    planet-rs.tar.gz, 5.9K

    Related Articles

        Article Tags

        Old Farmer's Almanac Sun/Planetary Rise and Set Times

        By William Jeffrey Rankin, Sat Nov 12 2022

        A set of scripts written in the Rexx programming language that produce localized sun/planetary rise/set times based upon data in The Old Farmer's Almanac. These have been replaced by the Astronomical Almanac scripts, but are still occasionally useful.

        Included are supporting libraries (CORTIME.rex and TIMEADJS.rex) and sample data files. The DAY.txt file contains time adjustments for locality and should be replaced with appropriate values for your location (refer to the Time Corrections section in the almanac).

        The scripts have been tested on Cygwin, Linux, Windows 10, and FreeDOS.

        Example Usage

        srss.rex: Takes a file containing uncorrected sunrise and set values from the Old Farmer's Almanac and a file containing time corrections for locality. Pass 'today' as third argument to show results for current day only. Outputs corrected values.

        jeffr@Ganymede: ~/rise-set-times $ regina srss.rex srss-data.txt DAY.txt | tail -n 5
        11/26/2022, 7:32 AM, 5:16 PM
        11/27/2022, 7:33 AM, 5:15 PM
        11/28/2022, 7:34 AM, 5:15 PM
        11/29/2022, 7:36 AM, 5:14 PM
        11/30/2022, 7:37 AM, 5:14 PM
        

        planets.rex: Takes a file containing uncorrected planet rise and set values and a file containing time corrections for locality. Outputs corrected values.

        jeffr@Ganymede: ~/rise-set-times $ regina planets.rex planet-data-2022.txt DAY.txt | tail -n 5
        10/11/2022, Saturn, Set, 2:48 AM
        10/21/2022, Venus, Set, 6:52 PM
        10/21/2022, Mars, Rise, 9:45 PM
        10/21/2022, Jupiter, Set, 5:41 AM
        10/21/2022, Saturn, Set, 2:08 AM
        

        rscli.rex: A simple command line interface to the CORTIME library. Takes an uncorrected time, AM/PM, a file containing time corrections for locality, and correction column. Outputs corrected time.

        jeffr@Ganymede: ~/rise-set-times $ regina rscli.rex 6:32 AM DAY.txt e
        7:16 AM
        

        lod.rex: Takes the output of srss.rex and calculates day lengths.

        jeffr@Ganymede: ~/rise-set-times $ regina srss.rex srss-data.txt DAY.txt \ | tail -n 5 | regina lod.rex
        12/27/2022, 9:06
        12/28/2022, 9:06
        12/29/2022, 9:07
        12/30/2022, 9:08
        12/31/2022, 9:08
        

        Download

        rise-set-times.tar.gz, 7K

        Related Articles

            Article Tags

            Planetary Rise and Set Times Using aa

            By William Jeffrey Rankin, Thu June 23 2022

            A set of scripts (bash and awk) used to produce localized planet rise and set times based upon output from aa (Stephen L. Moshier's astronomical almanac program). Output formats include the raw output from aa, CSV, HTML, tabular, and postscript.

            Usage

            planet-rs.sh takes a standard aa input file (refer to my post on aa for an example) and, optionally, format (raw, csv, html, or ps), time zone and a time zone label. In the example outputs below, rise and set times are displayed for Jupiter in July, 2022, EDT (-4 hours from UT).

            Raw Output

            jeffr@Europa: ~/planet-rs $ ./planet-rs.sh Jupiter-07-2022.txt raw -4 EDT | head
            Input file: Jupiter-07-2022.txt
            rises 2022 July 1 Friday 1h 20m 19.873s EDT
            sets 2022 July 1 Friday 13h 36m 25.567s EDT
            rises 2022 July 2 Saturday 1h 16m 37.113s EDT
            sets 2022 July 2 Saturday 13h 32m 54.005s EDT
            rises 2022 July 3 Sunday 1h 12m 53.963s EDT
            sets 2022 July 3 Sunday 13h 29m 21.585s EDT
            rises 2022 July 4 Monday 1h 09m 10.417s EDT
            sets 2022 July 4 Monday 13h 25m 48.300s EDT
            rises 2022 July 5 Tuesday 1h 05m 26.473s EDT

            CSV Output

            jeffr@Europa: ~/planet-rs $ ./planet-rs.sh Jupiter-07-2022.txt csv -4 EDT | head
            Input file: Jupiter-07-2022.txt
            07/01/2022, 01:20 EDT, 13:36 EDT
            07/02/2022, 01:16 EDT, 13:32 EDT
            07/03/2022, 01:12 EDT, 13:29 EDT
            07/04/2022, 01:09 EDT, 13:25 EDT
            07/05/2022, 01:05 EDT, 13:22 EDT
            07/06/2022, 01:01 EDT, 13:18 EDT
            07/07/2022, 00:57 EDT, 13:15 EDT
            07/08/2022, 00:54 EDT, 13:11 EDT
            07/09/2022, 00:50 EDT, 13:07 EDT

            Tabular Output

            jeffr@Europa: ~/planet-rs $ ./planet-rs.sh Jupiter-07-2022.txt table -4 EDT | head
            Input file: Jupiter-07-2022.txt
            +-----------+------------+------------+
            |   Date    |    Rise    |    Set     |
            +-----------+------------+------------+
            |07/01/2022 |  01:20 EDT |  13:36 EDT |
            +-----------+------------+------------+
            |07/02/2022 |  01:16 EDT |  13:32 EDT |
            +-----------+------------+------------+
            |07/03/2022 |  01:12 EDT |  13:29 EDT |
            +-----------+------------+------------+

            HTML and Postscript

            Here's an example of the HTML output. The example postscript output was converted to PDF using ps2pdf.

            Day Length Calculations

            The lod.awk script takes CSV output and calculates day lengths.

            jeffr@Europa: ~/planet-rs $ ./planet-rs.sh Sun-12-2022.txt csv -5 EST | head | awk -f lod.awk
            Date, Length of Day
            12/01/2022, 9:33
            12/02/2022, 9:31
            12/03/2022, 9:30
            12/04/2022, 9:29
            12/05/2022, 9:28
            12/06/2022, 9:28
            12/07/2022, 9:27
            12/08/2022, 9:26
            12/09/2022, 9:25

            Current Day Information

            The today.sh script shows sunrise, sunset, and length of day for the current day.

            jeffr@Europa: ~/planet-rs $ ./today.sh 
            
            Date, Sunrise, Sunset
            11/14/2024, 07:21 EST, 17:20 EST
            Date, Length of Day
            11/14/2024, 9:59

            Download

            The package below includes a sample aa.ini (edit to reflect desired latitude, longitude, etc.) as well as input files for various planets. The scripts have been tested on Ubuntu Linux and Cygwin.

            planet-rs.tar.gz, 5.9K

            Known Issues

            If you get an error message similar to the following when attempting to use the ps output format:

            troff: fatal error: can't find macro file s

            It may be due to a missing Groff macro. I solved this issue on Ubuntu Linux by installing the complete Groff package (in addition to the base package, which is installed be default).

            Related Articles

                Article Tags

                aa - Astronomical Almanac - Compiled for Cygwin

                By William Jeffrey Rankin, Thu June 16 2022

                Stephen L. Moshier's venerable aa program (an astronomical almanac used to calculate planet and star positions), compiled for Cygwin (gcc version 11.3.0). It can be used interactively, or input can be directed from a text file.

                aa - Astronomical Almanac, version 5.6 (aa-5.6.tar.gz, 161K)

                Example Usage

                Used interactively, simply ./aa. Or with input directed from a file, ./aa < Mars-2022-06.txt. Sample input file Mars-2022-06.txt to display data for Mars in June, 2022. The second set of numbers, ending with -1, tells aa to quit.

                Configuration

                Longitude, latitude, altitude, and other local parameters are specified in the aa.ini file. Note: this file must reside in the same directory as the aa executable.

                -84.17 ;Terrestrial east longitude of observer, degrees
                39.95  ;Geodetic latitude, degrees
                252.0  ;Height above sea level, meters
                10.0   ;Atmospheric temperature, deg C
                1000.0 ;Atmospheric pressure, millibars
                1      ; 0 - TDT=UT, 1 - input=TDT, 2 - input=UT
                0.0    ;Use this deltaT (sec) if nonzero, else compute it.

                Further Reading

                Refer to the read.me file included with the distribution.

                Related Articles