Archive | November 2010

Calgary’s winter landscape

As temperatures with windchill hit -40C today (raw temperatures of -30C and -20C for the past week) Calgary is in the mist of a rather snowy landscape so I took a few photos (well I tried to before my fingers froze):
The lunch area at UofC:
17th Ave bandstand:
Downtown Scene from 12th Ave SW:
this bike is going nowhere fast:
lost ya hat….
Downtown by Snow Central
View from my office, no mountains today
A very cold morning view of downtown, with windchill -40C… yikes
-40C construction….

Awk csv and cut the header…

Something I keep having to look up how todo so I’m putting it here for future reference:
Suppose you have a comma separated file, say the list of Abell clusters: e.g. first line:
and you want to convert this into a nice tab spaced data set and cut off the header…
awk -F’,’ ‘{printf(“%10.8ft%10.8ft%10.8ft%10.8ft%10.8ft%10.8fn”, $1,$2,$3,$4,$5,$16)}’ abell_all.csv > temp_abellcut
len=$(wc -l temp_abellcut | awk ‘{print $1 -1}’)
tail -n $len temp_abellcut > abell_all.dat
rm -rf temp_abellcut
echo “id ra dec z D search_radius” > abell_all.header
… and bob’s ya uncle.

Simple median in python

Yesterday I was doing some python scripting for work on [GALFACTS] and I wanted to take the median of an array. I know I could simply use the [numpy] function but I specifically wanted to alter the behaviour to skip NaNs (in the end I ended up doing this a different way using the isnan functionality) and so I wrote a short script to calculate the median, thought I’d post it as a short example of some simple python programming / you never know if it will come in handy again (for me or anyone else). The full script can be retrieve from my [research script dump], oh and below:
#Function to determine the median of an passed array/list of number
def takemedian(inputvalues):
&nbsp&nbsp&nbsp&nbsp sortedvalues = sorted(inputvalues) #sort values
&nbsp&nbsp&nbsp&nbsp total_len = len(sortedvalues)
&nbsp&nbsp&nbsp&nbsp if (total_len % 2) == 1:
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp return sortedvalues[((total_len+1)/2)-1]
&nbsp&nbsp&nbsp&nbsp else:
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp upperval = sortedvalues[(total_len)/2]
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp lowerval = sortedvalues[(total_len/2)-1]
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp return (float(lowerval + upperval)) / 2
#test function
def validatemedian(correct, takemedianvalue):
&nbsp&nbsp&nbsp&nbsp print “Test Median is: %.2f, takemedian function value is: %.2f, Is Correct? %s” % (correct, takemedianvalue, correct==takemedianvalue)
#test what the ouput is
validatemedian(5.0, takemedian([0,1,2,3,4,5,6,7,8,9,10]))

Lougheed House

Another place that I hadn’t managed to take a look at in Calgary yet, despite only living 3 blocks away, was [Lougheed House].
I’ve walked passed it a few times but never made that trip inside, well it was quite cold when my Dad was here so we decided that doing something indoors would be a good idea. It wasn’t too expensive, especially since they kindly gave us a buy-one-get-one-free voucher discount even though we didn’t have one. We had a 30 minute or so tour around the building and gave me an interesting take of Calgary 100 years ago. Strange to think all the land around this building would have just been prairie, now its smack bang in the middle of the downtown. As can be seen from this:
The building was built in 1891, so one of the oldest structures still remaining around Calgary. It has been through many different uses, but thankfully it has now been nicely restored. A good day out, thoroughly would recommend it.
Oh and I really loved some of the stained glass windows (there is even one, I can’t recall which one, that was placed the wrong way round with the paint on the outside):

Walking through downtown Calgary

Just a couple of pictures that I took whilst waiting for a few folks on my way to see the [Prime Time Big Band] and [Ian McDougall] at Ironwood (I really enjoyed the gig, especially since I’m not normally one for jazz).
Nexen Building
Nexen Building
Nexen Building
Oh I did take a few pictures at the gig too, here is one featuring the band and their guest:
Prime Time Big Band @ Ironwood


Last night I got to go watch a preview of the new film [“Monsters”] courtesy of a friend giving me a ticket she won via [FFWD] (thanks all round!). Simply, wow. I was very impressed, my expectations were quite low, the concept sounded interesting though: “Six years after Earth has suffered an alien invasion a cynical journalist agrees to escort a shaken American tourist through an infected zone in Mexico to the safety of the US border”.
I was very afraid a good idea would have been spoiled by bad execution. This was not a problem. The film was put together really well, especially given the tiny budget of $15,000. They didn’t use cheesy special effects just nice little things, such as playing low resolution TV reports instead of going into the action (and also had some cool effects too). This actually meant you get to “feel” the characters better. Some sci-fi fans might be disappointed (especially if you are expecting a gun tooting film) and I heard one or two in the audience say quite loudly “I can’t believe I just watched a romance”. I’d say that it was what sci-fi was supposed to be (well what I like anyway biggrin.gif). There was something more to it and I loved the parallels with the US/Mexico border issues now.. but add some real aliens in there, not just the illegal kind.
There was thing I noticed as strange the space-craft they showed was taking off not breaking up… oh well, mistakes happen.
In short I came out thinking this was a bit of Cloverfield meets District 9, but that would be wrong – some links could easily be made to both. The monsters have the Cloverfield sort of feel about them. Comparisons with District 9 are more obvious, especially the social issues being explored through alien interaction.
Overall this is probably the best sci-fi movie over seen in quite a while.

Flames vs Oilers video…

and here is the video…

(video might be slightly truncated to the right / in case link does work: take a look at the actual youtube page)

Flames vs Oilers

I meant to post this before but well I was busy and I’ve been a bit crap at updating my blog as of late. Anyway, while my Dad was visiting me in Calgary a couple of weeks ago I had the privilege of going to my first NHL game. T he Calgary Flames against the Edmonton Oilers (on 26/10/2010) – a proper local derby. WOW it was good fun. We actually bought cheap tickets and ended up right in the back row:
Flames vs Oilers
… but courtesy of the Flames president and a wonderful customer service person we got moved to:
Flames vs Oilers - zamboni!
I have a video of myself going on about our tickets, not that I wasn’t happy to be there anyway, and then moments later we were moved (will have to post that soon: UPDATE: see [here]). The game was great, with a 4-4 final score and a shootout to decide the winner. Flames win! GO FLAMES GO!
We even managed to get on the jumbotron:
Flames vs Oilers - on the jumbotron
Flames vs Oilers
For more pics see [here].

Random number in c++

This is really more of a reminder for myself… how to draw random numbers fast in c/c++. (download [random.cpp]) and compile like so: g++ -O2 -o random random.cpp

#include ‹iostream›
#include ‹cmath›
#include ‹fstream›
#include ‹cstdlib›
using namespace std;
#define PI M_PI
#define RAD PI/180.0
#define SIG5 5.0*sig
#define SIG10 10.0*sig
#define SIG20 20.0*sig
unsigned long long int rdtsc();
int main (int argc, char* argv[]) //take in commandline arguements
int ii = 0;
while (ii ‹ 100)
cout ‹‹ rand(); //RAND_MAX;
cout ‹‹ “t”;
cout ‹‹RAND_MAX;
cout ‹‹ “n”;
ii +=1;
return 0;
unsigned long long int rdtsc(void) //Call a Random number.
unsigned long long int x;
unsigned a, d;
__asm__ volatile(“rdtsc” : “=a” (a), “=d” (d));
return ((unsigned long long)a) | (((unsigned long long)d) ‹‹ 32);;