The Venus Transit

So it’s already over, we will never see the transit of Venus across the Sun again in our lifetime. As the Wikipedia puts it, this rare event occurs  in a pattern that repeats every 243 years, with pairs of transits eight years apart separated by long gaps of 121.5 years and 105.5 years. The last pair of transits took place on 8 June 2004 and last night (5-6 June 2012), and the next pair of events will take place on December 2117 and 2125.

But don’t worry, thousands of eyes around the world recorded the experience in multiple ways and wavelengths so that no one would miss a detail. I wanted to be one of those eyes but since I live inside the wrong time zone there was no way to do it. So I decided to try a little experiment after learning that the SDO team had set up a high resolution feed updated every 15 minutes.

I wrote a very simple script  that  downloads an image every minute and checks if it’s different from the last one. As you may recall, the transit was scheduled to happen between 10pm and 5am (UTC) so the script is set up to work only between 9 PM and 8 AM, in order to get enough images to record a full transit. After that, each image is resized using ImageMagick and the time-lapse video is generated with ffmpeg.



if [ ! -e "$next.jpg" ]; then
    wget --cache=off $url -O "$next.jpg"

while true; do
    time=$(date +%k%M)
    time=`echo $time|sed 's/^0*//'`

    if [[ $time -ge 2100 ]] || [[ $time -le 800 ]]; then
        wget --cache=off $url -O aux.jpg

        if [ $? -eq 0 ] && ! diff aux.jpg "$next.jpg" > /dev/null ; then
            next=$((next + 1))
            mv aux.jpg "$next.jpg"
            rm aux.jpg

    sleep 60

mogrify -resize 1024x1024 *.jpg
ffmpeg -r 5 -qscale 1 -i %d.jpg VenusTransit.mp4

The result was quite nice, although not as impressive as the official videos from the SDO team.


Overall, it looks like Bash and Astronomy are a good combination!

Posted In:

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s