Friday, 20 September 2013

SQL and PL/SQL

My new area of (limited for now, but rapidly growing) expertise

So, I started a new job at the beginning of the year, as a software developer for a company which specialises in providing medical aid and insurance solutions, based on the relational database model. We mostly use Oracle's implementation of SQL, which comes equipped with its own procedural language called PL/SQL (this stands for what you might think).

So why Software developer? I wrote loads of computer programs during my Msc and Phd, and so, even without much formal computer programming experience, I became quite good at it. In fact, I rather enjoyed it. Maybe it was the ability the control something as powerful as a  computer, making it do my bidding with a few simple (and many complex) set of instructions. It also turns out that my mind is rather logical, and I "get" how computers think. This means I can fairly efficiently form a program which follows a logical set of steps, and gives me what I want.

Fortunately, SQL and PL/SQL are not the hardest of languages to learn. SQL is way of asking a database what it knows about stuff, and does not have terribly many commands. The trick is knowing how to push your questions to the limits, and to optomise them so the database fetches exactly what you want, and no more, in the quickest amount of time possible. PL/SQL on the other hand, is a procedural language, which allows you to combine procedural statements with what the database knows. It has many similarities with my beloved Matlab, which I used almost exclusively during my time as a research student. 

I am happy to report that my migration into this new role went rather smoothly (despite the stricter working schedule - I think the coffee which our tea lady, who is a maestro, brews - helped a lot here). Also, I feel my training as a physicist has put me in good stead for this job. 

Physics research is the working out and understanding and explaining of how physical systems (which we have no control over) fit together a affect each other, producing certain observed phenomena. In some ways, this vast collection of tables which exist on our system, and link together, with a background set of routines controlling certain outcomes (which by the way I can pretty much fully control - within the confines of business requirements) has a remarkable similarity to this. And when I am able to figure out why data x combined with program sequence y produce a result z, the same "happy centres" in my brain are triggered as when I figured out that the plasmapause being close to Marion Island can trigger the reception of both chorus and hiss there, further confirming result that chorus generates hiss...  

Sometimes I miss the flexibility that being a postgraduate research student afforded me, and the many opportunities it gave me to present and talk about my work (I LOVE public speaking now - and do miss it). But there is something to be gained from working in a structured environment, where the projects last only months, and not 3 years. Also, every so often, pay day rolls around...

Anyway, there may be new posts about how PL/SQL works, as my curiosity about it, and expertise with it, grow.

Friday, 8 February 2013

2012 DA14

So, the title doesn't really say what this post is about, so I'll explain here. Last year, an asteroid was spotted in 2012 and calculation of its orbit showed that the comet would have a close encounter with Earth on the 15th February 2013. How close? 0.09 lunar distances (the distance to the moon), which is just shy of 35 000 km. Thats quite a distance, but in astronomical (and in asteroid near miss terms), its not all that far. The comet is around 59 meters in diameter, so about half a rugby field accross. Thats not huge, but it is pretty big.

Just to put it in perspective, the comet will come within geosynchronous orbit of the Earth, which is where many of the satellites which we use on a daily basis sit. DSTV, GPS and telecomunication satellites all sit in geosynchronous orbit.

Now, don't get alarmed. Asteroid orbits are VERY accurately predicted, and this one WILL NOT impact Earth. Not now, or in any other of its upcoming orbits. I just wanted to let you all know that this hunk of rock will be saying "howzit" next week.

This asteroid is the largest object that has come this close to Earth in recent history, so it is quite exciting for those who are able to photograph such things. 

But, what if this baby did impact Earth. We've (probably) all see a doomsday movie where an asteroid impacts Earth and everyone dies. Well, this would be far less disastrous. In fact, the Earth has had run ins with similar sized objects in the past. For instance, in 1927, a similar sized object exploded in Siberia, Russia. The resulting blast was at least 3 megatons (and estimates say it could have been around 15 megatons, which is 1000 times more powerful than the atomic bomb dropped on Hiroshima), and it leveled 2000 square kilometers of trees.

Another object of similar size formed the Barringer crater in the USA, which stretches about 3 km accross. Below is a picture of this crater:


So, on the day after valentines day, cast your eyes upward, and think about what is going on up there, and how close 2012 DA14 is to us.





Tuesday, 3 April 2012

High Dynamic Range (HDR)

Alright, so time for another photography post. I was recently introduced to a photography technique called HDR (High Dynamic Range). This is achieved using some software (although I guess there are other ways of doing it). This is most easily achieved using an SLR.

The Problem: You want to shoot some subject. In front of the subject is some foreground, behind it, some background. You point your camera at the subject, and it calculates the apeture size and exposure time for correct exposure. However, because you are shooting the background and foreground as well, these are often over/under exposed in the final image. Take this example, shot from my back yard:



Here the pool and grass are correctly exposed, but the foreground is under exposed, and the background (clouds) are over exposed.

The Solution: Obtain some form of HDR software (I used photomatic). Now shoot the same scene again, but shoot it once underexposed (by 2 stops or so, shorter exposure by 2 time stops), and one over exposed (by 2 stops or so, longer exposure by 2 time stops) all at constant aperture size (for constant depth of field - use the aperture priority mode on your camera). This can all be automatically done with a recent-ish SLR camera. Below are the under and over exposed photos.

Underexposed - the foreground is dark, but you can see the clouds better.

Overexposed - The clouds are not visible, but the foreground looks a bit better than the original.

You basically just push these into your HDR software, and there are some small amount of post processing options, and out comes the final product (below).


VoilĂ ! This technique is useful in particular when shooting architecture, or landscapes when there is a lot of depth. It could also work when shooting a subject with a bright background.

Sunday, 18 March 2012

Reverse Engineering "Black Snake"

Earlier this year I went on a tour of Birkinhead Breweries, a micro brewery near Hermanus in the Western Cape. One of their beers was called black snake, which was a delicate mixture of Klipdrift brandy, and milk stout beer, which came in at a jaw dropping 10% alcohol content. Needless to say, the student in me found this stuff quite pallet-able. Saturday being St. Paddy's day, I decided it would be a worthy Tribute to the Irish saint to try and make this stuff myself. I knew 2 things, the ingredients, and the final desired alcoholic content. The unknown was the exact ratio to mix the two constituents in. To the white board!



Using a complex set of equations, I discovered the ratio required to give me that magic 10%, namely 43ml brandy to 357ml Milk Stout (to give a 400ml total volume). These numbers were a little arbitrary, so I normalised up to the size of a single Castle Milk Stout quarts (750ml).



For this amount of beer, one requires 92 ml of brandy (I rounded up to 100 here - 4 shots of brandy per quarts, easy enough).

First step, pour the brandy into a 1L airtight (to prevent it going flat during the settling) container.

Next, pour the milk stout into the container. milk stout is especially foamy, so be careful here. A suggestion may be to add the beer first, giving you more volume for foam.

Close your vessel, and turn upside down once to mix.
After leaving it in the fridge for an hour to settle, and mix up nicely, pour into a beer glass and prepare yourself...
Enjoy!
What made it better was that I could enjoy this while watching the Sharks beat the Reds. This stuff was quite strong, and a bit of acquiring was required, but it started tasting better and better as I worked my way through it all. Some pretty potent stuff. Thanks St. Paddy. And Birkenhead. And Thanks to Monique for taking the photos.




Tuesday, 13 March 2012

The Moon

So after an extended break from blogging, and some pushing from my supervisor, I decided it was time for another post up in here. Earlier this year, Monique (whom I shall affectionately refer to as "the girlfriend") told me about a great deal one of her colleagues had for me. A whole SLR camera bundle, with 5 lenses, and a flash gun (external flash). The girlfriend, who is also an avid photographer (and who does a lot of it for the magazine she writes for) convinced me of the deal's worth, and that I would enjoy photography. Since then, I have learn't a thing or two about photography, and I decided it would make great subject matter for my blog. So today I bring you: The Moon.

A few nights before the last full moon, we got home late one night, and I saw this magnificent sight in the sky: A 3/4 full moon, in clear sky. I decided to try capture it, and this is the result.



It may be of interest to some exactly how I captured this level of detail. I was especially surprised to see the small craters near the day night line. To do this, all I did was hook my 300mm telephoto lens (which on my camera is equivalent to a 480mm), stuck the camera on to a tripod, and pointed it at the moon. I toyed with aperture and exposure settings until one worked. I settled on 1/15s and f/16. A smallish aperture exposed over some time gave me this. As a rule of thumb, a smaller aperture gives you a sharper image. Unfortunately, a bit of blur came in when I enlarged the image, due to a bit of camera shake which occurred when I pressed the button. Camera shake is emphasised at this level of zoom. I have some suggestions on how to make the next attempt better. However, the clouds rolled in a few second after I got this shot, and so I settled on this. I also cropped the photo, with the notable crater ~ midway along the day night line as a focus. Apparently, one's eye is drawn to one of 4 points on an image. I may try an experiment in future to see how true this is.

My idea for this blog is to post more photos in future, with maybe a small write up about how I took them. Photography is my new hobby and I am quite excited about it, and so I have been researching how to make mine better. So some of the details may be a bit technical, but I will also try to capture some kind of story in the posts too. I have a large backlog of cool images to put up here, and I will slowly work through them. Let me know in the comments if this sounds like a cool idea.

Monday, 3 October 2011

Black Hole Search Volume

Spent a few minutes toying with google trends. This nifty feature gives you a relative idea of how often a particular word or phrase is googled over time.

I used it to do some random research on how the Internet contributes to mass hysteria. Found three interesting results in a few minutes. First, do you remember when the Large Hadron Colider was commissioned in 2008 (10/9/2008 to be exact - http://en.wikipedia.org/wiki/Large_Hadron_Collider). There was all this talk about how it could create black holes and destroy the Earth. well, I did a google trends search for "black hole", and see what is showed.

black hole

Interesting, a huge spike just before the end of the 3rd quarter of 2008. Next, remember the movie 2012. Around the time that it came out (13 November 2009 - http://en.wikipedia.org/wiki/2012_(film)), there was a lot of hype about the world's end being tied to the end of the mayan calendar. People actually belived that the movie was an accurate prediction of things to come. Look at the google trend for "mayan calendar".

mayan calendar

I can guess what people were thinking. "Wow, the mayan calendar actually does end in 2012. Everything in that movie must be based on fact." Well, as a space physicist, I can say that is not true. The main plot (SPOILER ALERT!!!!!!!!!!!!!!)

involves neutrinos heating the core of the Earth. Now this is impossible (or if you have read my previous post: http://nerdyguy-fatman.blogspot.com/2011/09/schrodingers-cat.html, it is at best EXTREMELY unlikely). Hollywood Physics - gotta love it.

End of spoilers. Finally, remember earlier this year, we were all told that the world was going to end on May 21st. Well have a look at google trends for "end of the world"

end of the world

I see another big spike around the 21st March. I can see how that rumor spread. Mass hysteria set in. People blew all their savings, and racked up enormous bills not expecting to have to pay them on Monday morning. There was a lot of misinformation going about then. People don't seem to know what the Rapture actually is. But lets not get side tracked. 

In conclusion let me just say the obvious : Don't believe everything you read on the internet. It is an excellent tool for spreading misinformation, and creating mass hysteria.




Thursday, 29 September 2011

Schrodinger's Cat

Our faculty is having a funwalk tomorrow, and as a school (School of Physics) we go as a group, and have T-shirts designed. I was asked to find some design for the tshirt. Well, I have kind of had this idea in my mind for the past few months that Schrodinger's Cat would make for a great physics themed t-shirt. I spent a bit of time trawling the internet for some ideas, and some really nice pictures popped up. Anyway, it got me to thinking, how many people actually know the story behind  the unfortunate feline companion of Erwin Schrodinger.

Erwin Schrodinger was a big player in the early development of quantum mechanics, and is responsible for providing the world with Schrodinger's Equation, which allows one to determine the time evolution of quantum states. I'll say no more about that. One of the underlying concepts in quatum mechanics is the one of probability, namely that nothing is certain. Our everyday understanding of how the world works, does not apply in the realm of quantum mechanics. For instance, if I drop a glass full of red wine onto the floor (shame on me), then we all expect that that glass would hit the floor, and spill. But, quantum mechanics predicts that there is a small chance of the glass passing right through the floor, and landing in the basement (either result is bad for me though).

Okay, so back to Schrodinger's Cat. Schrodinger proposed a thought experiment (meaning that he only conducted the experiment in his mind).  For this experiment, one would place a cat in a box, with a sealed vial of poison, and seal the box. The vial of poison is set to release its contents at an undetermined time. So, without opening the box, one has no way of knowing whether the cat is alive or dead. And so we can think of the cat as both alive and dead. Weird, but this is the kind of stuff that quantum mechanics deals with. It is a very complex field.

Anyway, this brings me to my tshirt design idea. I have attached the picture, which I think is from an episode of Big Bang Theory. Also, I should point out that the powers that be opted for a different design, but oh well. Now that you know where it comes from, you can see that it is a rather clever design.