« September 2010 | Main | December 2010 »

November 2010 Archives

November 9, 2010

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;
srandom(rdtsc());
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);;
}

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

Faceoff!

Flames vs Oilers

For more pics see [here].

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)

November 10, 2010

Calgary Hitmen

Another one of my recent ice hockey experiences was watching the Calgary Hitmen against Kamloops Blazers on 23rd Oct (2010). I think I've very much started to get the hockey bug... This one was actually my first hockey game at the Saddledome. This was with my Dad while he visited. The Hitmen though being 2-0 up had an awful final period losing 3-2 in the end.

IMG_4096

IMG_4120

IMG_4121

Here is a video of the game:

If it doesn't work try [here]

November 11, 2010

Calgary Stampeders

I recently went and watched my first Canadian Football League (CFL) game. I have to say that "football", well the Canadian kind (not the NFL), is really quite growing on me - not as much as hockey has (go flames go!) but its a game I appreciate a lot more. I'm glad I went to see the Stamps play against the BC Lions. The game took place at McMahon Stadium (up by the Uni, the place that the 1988 Olympic Games ceremonies took place) on 22/10/2010 and the BC Lions won 36 - 31.

IMG_3902

IMG_3857

IMG_3825

... gotta love the horse riding around the ground whenever the Stamps score...

I also made a short [video of the action]

and more pics can be found [here].

Monsters

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.



November 14, 2010

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

November 21, 2010

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].

IMG_4332

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:

IMG_4372

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.

IMG_4359

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):

IMG_4401

IMG_4373

November 22, 2010

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):
     sortedvalues = sorted(inputvalues) #sort values
     total_len = len(sortedvalues)
     if (total_len % 2) == 1:
         return sortedvalues[((total_len+1)/2)-1]
     else:
         upperval = sortedvalues[(total_len)/2]
         lowerval = sortedvalues[(total_len/2)-1]
         return (float(lowerval + upperval)) / 2


#test function
def validatemedian(correct, takemedianvalue):
     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]))

November 24, 2010

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:

1,1.89167,16.50972,0.1249,514.3,3.342

and you want to convert this into a nice tab spaced data set and cut off the header...

awk -F',' '{printf("%10.8f\t%10.8f\t%10.8f\t%10.8f\t%10.8f\t%10.8f\n", $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.

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:

IMG_4862

17th Ave bandstand:

IMG_4857

Downtown Scene from 12th Ave SW:

IMG_4851

this bike is going nowhere fast:

IMG_4846

lost ya hat....

IMG_4842

Downtown by Snow Central

IMG_4826

View from my office, no mountains today

IMG_4883

A very cold morning view of downtown, with windchill -40C... yikes

IMG_4872

-40C construction....

IMG_4869

About November 2010

This page contains all entries posted to Krioma.net Blog in November 2010. They are listed from oldest to newest.

September 2010 is the previous archive.

December 2010 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Get Firefox! Valid XHTML 1.0! Valid CSS! RSS Feed BlogUniverse - listed Powered by Apache Creative Commons License ringsofsaturnrock's Most Interesting Photos on Flickriver

Powered by
Movable Type 3.38