You are currently browsing the category archive for the ‘computing’ category.

sunset accross Europe, 4PM

I don’t remember what sparked the idea, but for some time I have been thinking about having a desktop background that showed the changing view of Earth from space; a geostationary position showing the approaching sunrise/sunset. I have seen a ‘Desktop DreamScene‘? that was something akin to what I was after, but I wanted to do this myself and slightly differently. In the end I think I ended up using the same or very similar software to achieve my effect.

Google Earth was my first port of call to source these images, but this was limited by the limited ability to take clean screenshots and inability to position the view off-centre. After more stumbling around the web I came accross NASA’s World Wind Java application. This is fantastic, the Blue Marble Next Generation images look fantastic, it is open source and can be developed in a multitude of ways and it can be scripted. The drawback is that the applet is supplied as a demo, my Java skills are virtually non-existant and after some time playing around and looking at other peoples work I had made very little progress. Then whilst watching some of the BBC Wonders of the Solar System series I began wondering what software they used to create the models. The BBC site pointed me towards Celestia. Another free offering, it has its own scripting language and lets the user explore the solar system in its known entirety.

Celestia has its own scripting language and an active user base who have generated many higher resolution image maps and other objects. I downloaded a night view and higher res day views, then created my own cloud cover png.

I adapted the scattering effect after reading a discussion about adapting night time views, I don’t know about realism, but I prefer the look offered by the following:

Height 60
Lower [ 0.43 0.52 0.65 ]
Upper [ 0.26 0.47 0.84 ]
Sky [ 0.40 0.6 1.0 ]
Sunset [ 1.0 0.6 0.2 ]
CloudHeight 7
CloudSpeed 65
CloudMap "earth-clouds.*"
# Mie 0.001
# MieAsymmetry -0.25
# Rayleigh [ 0.001 0.0025 0.006 ]
# MieScaleHeight 12
# my old values
## Mie 0.0005
## MieAsymmetry -0.15
## Rayleigh [ 0.00025 0.0009 0.0015 ]
## Absorption [ 0.00018 0.00005 0.0 ]
## MieScaleHeight 18
Mie 0.0050
MieAsymmetry -0.35
Rayleigh [ 0.0008121 0.0020775 0.00375 ]
Absorption [ 0.00057 0.0004 0.0 ]
MieScaleHeight 15

There is more work to do on the night lights, I can improve on what I currently have, but I have not had any luck using the Radiance Calibrated Lights: 1996-1997 from This post and this one discuss creating texture maps, but I have not managed to do it. I will stick with what I have for now.

Version 1.6.1 of Celestia will allow the user to use a url directly in a script, but for now I set the view I would like to record then run a little script. The script increments the date and time and takes a series of screenshots. In this way I captured 288 images; images from midnight to midnight for the 15th Jan, 15th Feb etc. So I get a rougly accurate seasonal variation in sunlight. If I were really keen I would work out how to use the NASA Blue Marble monthly images so the snowline moves according to the season along with the sunlight, but then since all the snow seems to be melting anyway…

I use the images on my desktop background along with a little program wot I wrote to keep the images in sync with the local time. Below is the celx script i use in celestia.
To Use the Script: Read the rest of this entry »

Windows 7 comes with the option of a Desktop Slideshow, point out a folder of images and then tell the OS how often to cycle through them. Fantastic I thought, I can have a day time and a night time desktop, colourful and cheery by day, more subdued and less bright for night work. Hmm, doesn’t work like that, you can sertainly cycle though images every hour, but if you put your somputer to sleep or turn it off then the day/night images soon get out of sync.

Simple (I thought), name the images systematically then write a little VBScript that gets the system time then loads the appropriate image. This is well documented on the web, the following example is from the TechRepublic website:
dim wshShell
dim sUserName

Set wshShell = WScript.CreateObject("WScript.Shell")
sUserName = wshShell.ExpandEnvironmentStrings("%USERNAME%")
Set oShell = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")
sWinDir = oFSO.GetSpecialFolder(0)
sWallPaper = "c:\IMGP0816.bmp"

' update in registry
oShell.RegWrite "HKCU\Control Panel\Desktop\Wallpaper", sWallPaper
' let the system know about the change
oShell.Run "%windir%\System32\RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True

Unfortunately the user32.dll call does not work in Windows 7, the advice is to use the Win32 API instead.

So I wrote a little C++ app (my first) that uses the SystemParametersInfo API for Control Panel Settings, specifically SPI_SETDESKWALLPAPER. The source is below;

#include <windows.h>
#include <stdio.h>
#include <time.h>
#include <iostream>
#include <string>
#include <sstream>

int main()

std::string path = "C:\\wallpaper\\";
std::string filename;
std::stringstream sstm;
sstm << path << lt.wMonth << "_" << lt.wHour << ".jpg";
filename = sstm.str();

//Generate a null-terminated sequence of characters (c-string)
char * cstrfilename;
cstrfilename =
new char [filename.size()+1];
strcpy (cstrfilename, filename.c_str());

// cstr now contains a c-string copy of str
std::cout << "built string: " << sstm.str() << std::endl;

Compile this using MinGW and a command line like:
g++ wallpaper.cpp -o wallpaper.exe -mwindows
note -mwindows is depreacted, you should probably use “-Wl,–subsystem,windows“. This compiles the code so that no window pops up each time the litle program is run. Without this, the code is compiled as a console command and the command window will flash up each time the program is exectuted.

I have set this to run every 10 minutes, it works fine, the desktop slideshow has a smooth transition from one image to the next whereas this method simply swaps the images, but for the series of images I am using this works OK. I now have a time accurate view of the earth from space. Delighted with my fist C++ attempts, I would welcome any suggestions for tidying the code which I am sure is horrid. 2 examples from the series of desktop background images are below. I hope to write more on how I assembled these images.

The European continent around 9AM in April

sunset accross Europe, 4PM


  • Pass the image directory as a parameter
  • Format the time string returned eg currently 4_1 to 04_01 strftime (timestamp_buf, 10,"%m_%H", localtime(&now));

‘Twas a mystery to me until I read this post which describes how to mount the filesystem automatically at boot time. The VirtualBox guide says install Guest Additions, add a shared folder, boot the guest machine and enter:
sudo mount -t vboxsf -o uid=1000,gid=1000 share ~/host

To mount automatically, the VirtualBox guide continues…

“Using /etc/fstab has little effect, because that file is processed before the SF module is loaded and will fail to mount the share. Sometimes, the share does get mounted because the GA check for it when they are loaded upon boot, but it’s very flaky, meaning it doesn’t work most of the time. You’re better of with the first option.
When you put the mount command in /etc/rc.local, so it’s mounted at startup, you can’t use the short notation for your home folder. During startup, everything is done through the root user, so using ~ for home, means it’s the home folder of Root (/root). Change it to the full path.”

Here’s what I did

  • Go to the folder /etc
  • Use your favorite editor to open the file etc/modules
  • After the last line you write now vboxvfs and in the next line vboxadd. Then save save and close this file.
  • Now edit etc/fstab
  • after the last line write share ~/host vboxsf defaults 0 0

reboot the guest machine after adding the share – if you add a new share the guest will not see it until it is restarted. Having read all that I thought I’d just mount the share when it was needed, so I’ll just hang onto this post for reference.