Archive | Computing RSS for this section

Python: Julian date

An example of a nice mathematical use of functions in python.

Testing if a file exists in python

A really simple but important piece of testing that should always be incorporated.

Dual booting is fun!

Why not dual boot linux and windows? I’ve been doing this happily for years however my recent upgrade to Ubuntu 14.04┬á has meant a change to how the bootloader works, yes I was running a very old version of Ubuntu. I like stability. Anyway, I got annoyed that I had to build a simple pack from source as the repo didn’t exist so upgraded. I found that Grub2 was a bit different to edit and continuing the laziness I found an excellent tool to alter this. I want windows to boot my default as I’ll be using this more at school than home.

Anyway grub-customizer is the way to go:

sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer


Turning my raspberry pi into a NAS

I’ve never had a network storage system at home. Now with all of our wireless devices it really makes sense, both for backup and to access media. With a samba share and an external USB drive I’ve been easily able to turn my raspberry pi (running retropie) into a wireless media centre too. Its great, I just have to use a samba music player on my phone or tablet and boom there is my music ­čÖé I realised we weren’t listening to enough of our collection of music. So this will open a whole new world of our old music. Very much looking forward to this.

All I did for this was to edit the already configured raspberry pi settings for samba and added my own section to correctly load the samba share on my external drive. Edit: sudo nano /etc/samba/smb.conf

comment = music2
path = /media/usb0/Music
writeable = yes
guest ok = yes
create mask = 0644
directory mask = 0755
force user = pi
writeable= yes

You need to restart samba:  sudo /etc/init.d/samba restart

All worked nice and easily. Of course, this isn’t a proper NAS at the moment as it has no redundancy and I’ve not setup any rsync script to fetch/get data to backup. That’s the next task – once I’ve decided if I need to replace my old bulky external hard drive with a lower powered smaller one (I already have one but need a powered hub as the pi doesn’t give out enough to the USB ports).

If you want a more comprehensive guide that takes you all the way through to the drive mirroring look at

Raspberry Pi fun

— This post is mostly for me to show my Year 10 computer science students so might seem trivial or boring but hopefully not to any of them, if they ever read this bit —

So I got a raspberry pi at long last. After many years of being indecisive I decide that it would be ideal. I had originally intended to get it to play around with coding and to try out XBMC on it. If you’ve never tried XBMC its worth it. I decided in the end that my smart TV + TiVo box + Xbox was enough for my media needs.

In the end of decided what would be better to show off the power the raspberry pi than have it emulate tons of old consoles. Luckily some nice people have done all of the work there and even but a binary release together! Retropie is an excellent piece of software that I’ve very much loved using. That said installing version 1 from source was a mistake that I shouldn’t have been so nOOb to make. I guess, even the most hardened software developers sometimes copy the wrong repository link.

Retropie allows you, with the right ROMS, to emulate tons of ┬ádifferent consoles including my favourite childhood consoles (it uses emulationstation) – Atari 2600, SNES and Sega Master System. I was very pleased to find the first in there. Though I’m sure my wife wasn’t too pleased with me playing centipede quite loudly…

It is a very simply process to get this up and running and all the instructions can be found over on the retropie site. Alternatively you could look at using the instructions found on lifehacker. This is useful as it also gives direct instructions on how to setup a wired xbox controller.

Other useful things to setup include SSH. This can be enabled via the script. This is really useful. If you then type ifconfig you will get your IP address and via windows you can login using many tools. Good ones include PuTTY and WinSCP (a video guide to the later can be found here). This will then allow you to transfer over your ROMS and bobs your uncle you are good to play, this is what I started with:

Game playing on my raspberry pi :)

Have you Pynterferometer’d yet?

So you want to have a play with a radio telescope? Why not do it at home using a virtual array of telescopes. A while back I mentioned Pynterferometer and now we are pleased to be able to say that there is now a version for most operating systems. If you run Linux, Mac or Windows you can now use our tool. Pynterferometer is a graphical interface designed to demonstrated the techniques of radio interferometry used by telescopes like, ALMA, e-Merlin, the JVLA and SKA, in a manner accessible to the general public. For further information take a look at the tool’s webpage:


Oh and if you want to read all about the background to the tool and have an introduction to radio intereferometry take a look at our paper.

Making mosaics

For the [ALMA Summer Science Exhibition blog] I wanted to make a [big mosaic] of all the images taken – you’ll probably see this on the [post below] (unless its fallen off the bottom of the page!). To do this was really quite straight forward using python (well matplotlib mostly).
The below script takes in a list of png files and then setups a canvas – something I’d already figured out the dimensions for via the figure size of 12 by 12 inches and a 400dpi – that gives me 400 pixels for each inch and nicely each image is a 400×400 pixel square. I’d also already figured out the loop limits that were required to get all of my images in (if I get chance I might make these command line options and package this up as a little tool but I’m sure many better ones already exist – this is more a quick and dirty way of doing this).

import matplotlib.pyplot as plt
import Image
import numpy as np
import os
from scipy import ndimage

xtemp = os.popen("ls *png") #all files

xtemp2 = ('n'))

files = len(xtemp2)-1 #number of files.

stepsize = 400 #this is the image size in x,y

fig = plt.figure(num=None, figsize=(12, 12), facecolor='k', edgecolor='none')

k = 0

j = 0

i = 0

while k< 5000:

j = 0

while j < 5000:

im =[i])

im = np.array(im).astype(np.float) / 255

#im = ndimage.rotate(im, 90) #if we need to rotate

fig.figimage(im, k, j) #, zorder=i)

print k, j, i

i +=1

j +=stepsize

k +=stepsize

plt.subplots_adjust(left=0.00, right=1.0, top=0.9, bottom=0.0)

fig.savefig('outputprint.png',figsize=(12, 12),dpi=400, facecolor='k', edgecolor='k')