Tags: radio, hf, propagation, greyline, python

Posted: December 21, 2011

Personalised greyline videos.

I finished the previous post on the subject of solar terminator visualisation by considering extending the code presented to generate a personalised greyline ‘map’ for a specific location. Today, I’ve been playing with some code to make that happen.

Although the previous visualisation posts have used Perl for the automation script, I’ve switched to Python for this post. Partially this is for a bit of variety, to compare similar tasks in different programming languages, but mainly it’s because Python has the incredibly useful pyephem module, which will take care of the required astronomical calculations for us.

To begin with, we need to install a few Python modules that we’ll be using. To avoid cluttering up your system, we’ll use vitualenv, which allows us to install the required Python modules and their dependencies in a temporary working directory without requiring administrator privileges.

Pre-requisites

In addition to a Python interpreter, you will need:

Setup

  1. Make a working directory (I’ll call mine ‘greyline-video’) and change into it.

    $ mkdir greyline-video
    $ cd greyline-video
  2. Head on over to the virtualenv homepage and download virtualenv.py into your working directory.

  3. Use virtualenv to create a local Python environment:

    $ python virtualenv.py local
    New python executable in local/bin/python
    Installing setuptools............................done.
    Installing pip.....................done.
  4. Now we have a Python environment in place we can install pyephem, which we’ll need to calculate sunrise and set times. (Note: you will need a compiler installed for this next step.)

    $ ./local/bin/pip install pyephem
    ...
    ...
    Successfully installed pyephem
    Cleaning up...
  5. Finally, download the Python code for this post and save it in your working directory.

  6. To start building videos, run the greyline-video script passing it your location and callsign

    $ ./local/bin/python greyline-video <lat> <long> <call>

Assuming you have everything installed correctly, this will fill your working directory with a whole load of jpeg images (two for each day of the year) and two mp4 files named ss.mp4 and sr.mp4.

Results

I started off running the script with

$ ./local/bin/greyline-video 53.744 -0.3325 M0PRL

to produce these two videos for my home QTH.

Producing videos for Halley threw up a wide variety of problems due to assuming that the sun rises in the morning and sets in the evening! At polar latitudes you can go for months with the sun either not rising or not setting. To handle this, I added some logic that would draw the map for solar noon or solar midnight as appropriate on days when the sun was either always up or always down. This looks slightly strange in the video, but makes sense given the application because noon or midnight are the closest you’ll get to twilight on such days. More troublesome are days when the sun rises late one evening and sets early the following morning. Fortunately, these are quite rare.