Archive | May 2010

Degrees to steradians

I quite often find myself wanting to convert from square degrees to [steradians] (SI unit
for solid angle), its simple but I waste too much time doing it (just recalling if its pi/180 or the otherway etc), so I’ve wrote a PHP function to do it – [deg2sr.php]. Oh, I’ve also wrote a python implementation of this:

#!/usr/bin/python
#usage: deg2sr.py -v 0  #convert square degrees to steradians.
import string, sys, math, scipy, numpy, pylab, os
from numpy import *
values_pass = sys.argv[2:]  #return value passed to script
deg = (double(values_pass[0]))
sr = ((pi/180)**2)*deg
print deg, sr

Simply copy this and save it and run as deg2sr.py -v 10 (where 10 is the number of square degrees).

Advertisements

What’s up with the UoB clocktower…

I was playing around on Google maps the other day, well I was showing off glorious Birmingham while ranting on about the general election to some North Americans, and I came across this rather odd looking “halo” on top of old Joe! It’s obviously just some image processing artefact but still looks rather odd… (so I did a screenshot!):
uob_clock

Installing fonts in Ubuntu

Something I always forget how-to-do is installing fonts, so I thought I’d put this short entry together… its actually pretty simple if you want them just for one user. You can either do this graphically or as I prefer at the command line:
Simply make a directory called “.fonts” in your home directory:
mkdir .fonts
and then drag and drop to install fonts graphically or simply
cp font.ttf $HOME/.fonts/
Then open the program you want to use them in, job done.

FAS Newsletter – article about Arecibo

After my trip to the Arecibo observatory I thought it might be a cool thing to do a write up for the Federation of Astronomical Societies (FAS) newsletter – given I’m at heart still an amateur astronomer… anyway it was included:
FAS Newsletter 93 April 2010
Here is the text in case you fancy reading it and don’t want to stare at my ugly mug on the page!
Soaking up the Sun (i.e. observing) at Arecibo
Dr Samuel George; University of Calgary
It’s not every day you go to work and get told that you are going to Puerto Rico next week. Well for radio astronomers this probably happens a little more often than the norm since the wonderful Arecibo observatory is there. Before I left I’d not quite realised how un-American Puerto Rico would be. I’m glad I had that GCSE in Spanish – as if that really helped. At least I was able to order water without any hassle. Of course once at the observatory I was surrounded by Brits! Oh well. I have to say it was welcome break from the frozen tundra of Calgary (it was -35C when I left).
You may know the telescope from the sci-fi film Contact and they did indeed record it there. I stayed in the “wooden hut” next to the one they filmed Jodie Foster in. I was disappointed that I didn’t end up in the right one. The Arecibo Observatory is operated by Cornell University under cooperative agreement with the National Science Foundation. The observatory’s 305 m radio telescope is the largest single-aperture telescope ever built. Its just breathtaking when you see it. I also got to go up onto the receiver and though scared at first you’d be surprised quite how solid it is. After 20 minutes up there you forget quite how high up you really are!
So why was I there? Well I work for the University of Calgary and we are conducting a large survey of the galactic plane with the telescope called GALFACTS. GALFACTS is a project by the GALFA Continuum Consortium to use the new Arecibo L-band Feed Array (ALFA) to carry out a spectro-polarimetric survey of the sky visible from the Arecibo Observatory. It should provide the most detailed polarimetric view of the sky to date and is going to take around 1000 hours of observing time.
Controlling Arecibo telescope is actually remarkably simple. This is probably the easiest observing experience I have. Now that could be due to the fantastic support staff or just the brilliant software.. either that or I got the wrong end of the stick and the data I took will come out pants (maybe I shouldn’t have been watching Top Gear in the control room..)!
I would urge you, if you ever get chance to go to the Carribean go take a stop in Puerto Rico – Arecibo is around an 1.5hours away from San Juan (the capital) and everyone is nice and friendly.

Tickmarks in matplotlib

Over time I’ve become more and more a lover of Python. I still don’t use half of the fancy stuff and very much use it as a scripting language, but as you can see from some previous posts I really do think that it is well suited for astronomical purposes. Anyway, I digress, one thing that was bugging me was producing publication quality plots. I’ve still got things to tweak with my plots but I think I’m finally happy with my script and thought I’d share one vital thing – tickmark lenghts. It took me ages to figure out what paramter this was called and lets be honest if no body else gets any use from this I’m bound to the next time I forget / can’t find any code with this implmeneted in. So here we go, how change tickmark lengths in matplotlib:

import string, sys, math, scipy, numpy, pylab
from pylab import *
#DATA
x = [0,1,2,3,4]; y = [2,3,4,5,6]
#Plotting
fig = plt.figure(figsize=(9, 8))
fig.subplots_adjust(left=None, bottom=0.2, right=None, top=0.97,wspace=None, hsp
ace=None)
ax1 = fig.add_subplot(111)
ax1.semilogx(x,y)
setp(gca().get_ymajorticklabels(), fontsize=’large’)
setp(gca().get_xmajorticklabels(), fontsize=’large’)
labels = setp(gca(), ylabel=’y axis’, xlabel=’x axis’)
setp(labels, fontsize=’large’)
for l in ax1.get_xticklines() + ax1.get_yticklines():
l.set_markersize(6)
l.set_markeredgewidth(1.2)
for l in ax1.yaxis.get_minorticklines()+ax1.xaxis.get_minorticklines():
l.set_markersize(3)
l.set_markeredgewidth(1.2)
save = “test.eps”
pylab.savefig(save)