Tags: hf, radio, propagation, perl

Posted: December 18, 2011

Visualising The Solar Terminator

Following on from the previous post, I wanted to play with using the same system to visualise changes in the shape of the terminator over the course of a year. The code for this is much simpler than the previous version, so it offers a good starting point for experimenting with your own variations.

Code

#!/usr/bin/perl -w

use strict;
use File::Spec;
use File::Temp;

my $tmp_dir_base = '/tmp';

unless ( -e $tmp_dir_base and -d $tmp_dir_base ) {
    die "Temporary directory $tmp_dir_base does not exist.";
}

my @days = qw( 31 28 31 30 31 30 31 31 30 31 30 31 );
my $tmp_dir = File::Temp->newdir ( DIR => $tmp_dir_base );

open( my $fh, '>', File::Spec->join( $tmp_dir, "config" ) ) or die $!;
print $fh "[earth]\n";
print $fh "marker_file=" . File::Spec->join( $tmp_dir, "markers" ) . "\n";
close( $fh );

my $i = 0;
for my $month ( 01..12 ) {
    for my $day ( 01..$days[$month - 1] ) {
        my $monthday = sprintf( "%02d%02d", $month, $day );
        my $datetime = "2011$monthday.000000";
        my $jpg      = sprintf("%03d", $i++);

        open( my $fh, '>', File::Spec->join( $tmp_dir, "markers" ) ) or die $!;
        print $fh qq{-10 900 "$monthday" image=none position=pixel } . 
                  qq{color=black outlined=false\n};
        close( $fh );

        system( "xplanet -projection mercator -geometry 1000x500 -config " .
            File::Spec->join( $tmp_dir, "config" ) .  " -output " .
            File::Spec->join( $tmp_dir, "$jpg.jpg" ) .
            " -num_times 1 -date $datetime -quality 100" );
    }
}

system( "ffmpeg -r 8 -y -i " .
    File::Spec->join( $tmp_dir, '%03d.jpg' ) . " -vcodec libx264 output.mp4" );

Result

For me, the video makes the dramatic change in shape of the terminator over the course of a year much clearer; as well as showing how the speed of change varies (especially around the solstices and equinoxes.)

In terms of applicability to HF propagation, the video obviously demonstrates that the greyline will take you to some very different places over the course of a year, so picking the right season could make it much easier to snag that rare DX you’ve been chasing for a while. An interesting extension to this code would be to plot sunrise and sunset centred on a particular location for the year in order to create a personalised greyline map.