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.



Monday, 19 September 2011

NerdyGuy: Traffic Circles

NerdyGuy: Traffic Circles: I had an interesting, but not entirely unfamiliar experience this weekend. It surprises me that in Umhlanga, where traffic circles are so an...

Traffic Circles

I had an interesting, but not entirely unfamiliar experience this weekend. It surprises me that in Umhlanga, where traffic circles are so annoyingly prevelent, that so many of the local drivers don't understand how to use them. I was going around a traffic circle (I was going straight), much in the way that I have always accepted as correct, and some driver came around my outside, trying to go right. He slammed on breaks, missing the collision, but what made it worse, is that he had the nerve to hoot and use some unrated hand signals. Traffic circles are easy in principle, but there seems to me an inconsistent understanding on what do do if there are two lanes in the circle. My rule of thumb: If you are going let or straight, use the outside lane. If you are going straight or right, use the inside lane. If you are going all the way around (back the way you came) then use the lane you are most comfortable with, but you make very sure you don't obstruct any one when you exit, because no one expects this. Also, appropriate use of indicators is just polite.

But, as my girlfriend has revealed to me, there is an online source from a professional traffic adviser, which explains, with the aid of  a picture-video, exactly how to use them. Unfortunately this does not include any advice for the 360, which in my opinion, raises the most chance for a fender bender.

You can check it out at http://www.arrivealive.co.za/pages.aspx?i=2163. This is something which everyone needs to know how to do, even if you are from Gauteng where (based on what I have seen of their traffic circle etiquette) there are probably very few traffic circles.

Anyway, lets open this up for discussion. Post a comment of how you usually handle the 2-lane daemon (it should be automatic after all).

Monday, 12 September 2011

Cloning a disk using Linux's dd

As a scientist, it is pretty convenient to use linux for my work. It is a flexible, lightweight and not to mention free OS. Over the past 4.5 years of using this system, I have learn't a few handy things, but this OS never runs out of things to teach me. Today, I learn't about using dd to create a cloned hard disk. Now, you will of course need to know something about how linux manages disks and partitions, but hopefully the elegance of this will be evident even if you do not.

dd creates a byte by byte replica of a source to some destination (hard drive to hard drive, or hard drive/cdrom to an image file). The advantages of this are that it only sees 1's and 0's, not files. It will replicate partitions, and file distribution. There are some downsides, like it will preserve "fragmentation" of the drive, and empty space, will still take up space on the image, ie: creating an image from a 40GB drive will produce a 40GB image file, even if the original hard drive was half empty. But, when you want to be sure that your data is preserved, then these are a small price to pay.  

To use dd (which might need to be installed on your particular distro), you would use something like the following (from a terminal of course):

dd if=/dev/sda of=/dev/sdb

where if is the source, and of is the destination. The source can be anything like

/dev/sda; /dev/sda1; /dev/cdrom; /home/user/

and the destination can be anything like

/dev/sdb; /dev/sdb1; /home/user/image.img (hard drive image), or /home/user/image.iso (cd/dvd image).

You might already see how this could be used to create a hard drive image, or optical disk image, which can serve as a backup, or for replication onto several other devices.

Some tips on how to optomise this process are:

1: Change the blocksize to 1MB using "bs=1M"
2: Compress the image file using gzip (or pigz - a parallel version of gzip)

Go Linux!


Tuesday, 12 July 2011

Another Sunny Video

The Sun demonstrated another spectacular display recently. Here you can see a small limb extending from the sun, and just below it, you can see some "closed magnetic loops". See how the plasma races along these field lines. This is the net I spoke of in my previous post. If enough plasma gets trapped in there, it can burst as a CME.



Credit to www.spaceweather.com for the image.

Wednesday, 15 June 2011

Coronal Mass Ejection (CME)

I was doing my usual browsing around the internet, looking for interesting news, and I came across this. This is a time lapse taken by the SOHO satellite, which sits at a very unique point in space where Earth and the Sun's gravity "cancel out" (This is called a Lagrangian point, and there are in fact 5 of them). This results in the satellite always lying between the Earth and the sun, which makes it an ideal spot to watch the sun from. In these images, they block out the sun (as it would saturate the image), so that we can see the active corona (hence the image is called a coronagraph).

Here we can see something called a coronal mass ejection (CME). The Sun's surface is a rather turbulent place, since it is not solid like the Earth's. This results in magnetic fields getting twisted together to form "closed loops", kind of like a net, which traps plasma. Eventually when the plasma pressure exceeds the magnetic pressure, the net bursts, spewing out billions of tons of very energetic radiation (+-800km/s). This particular one, luckily, was not pointed towards the Earth.

Things are like this are going to become more and more frequent as we head into the period known as solar max (the sun is most active during this) which will peak next year.

Oh, and in case you were wondering, that horizontal bright line to the left of the sun, is mercury. It appears so bright to the camera that light bleeds into adjacent pixels.

Monday, 13 June 2011

Lunar eclipse this week

This week Wednesday (15 June) there will be a total lunar eclipse occurring, and us in South Africa are in a favourable position to view it. A lunar eclipse occurs when the Earth passes between the sun and the moon, casting Earth's shadow on the moon. This will peak at around 22:12 on Wednesday night, causing the moon to appear a dull red colour. Anyone with nothing to do that night should definately keep an eye on the moon, as this is a fairly rare event. Maybe even a romantic evening picnic is in order...

Tuesday, 31 May 2011

Hummus, mmm...

Two weeks ago I had the privilege of visiting Budapest, Hungary for some R&R (Research and Relaxation). The city is an amazing place, and if you ever find yourself in East Europe with a schengen visa and some time to kill. I would definitely suggest visiting this amazing place. One of the things which me and another student from SA working with me discovered, was a take away place called Hummus Bar. The concept was simple. Pick a filling, order some beer (hence the bar in the name we figured) and prepare your taste buds for something special. You receive some empty pitas, your filling, and so much hummus its unhealthy (and hummus is a pretty healthy food stuff). All this for the price of a Big Mac McMeal.

The beer was a local Czech brew called kozöl, which is slightly better than pilsner urquell (another fine beer) and complimented the meal very well. In fact, of all the numerous bars we visited, this place was the only one which had stock of kozöl.

We were so happy with the meal, that this was the one place we went to twice for supper during our 10 night stay in Budapest, and believe me, food is something the Hungarians are very good at. I have heard that hummus is quite easy to make, so I googled a recipe for this amazing Mediterranean treat, and found this:

You will need:

500 gr canned chickpeas
45-75 ml lemon juice (squeezed or bottled), to taste
2 cloves of crushed garlic (or equivalent amount of already crushed garlic)
1/2 teaspoon of salt
30 ml olive oil

Preparation:

Drain the liquid from the chickpeas, and keep it aside. combine all the ingredients together in a mixing bowl or food processor. Add 1/4 cup of the liquid from the canned chickpeas to this. Then blend it for 3-5 minutes until it is smooth and creamy.

Place in a bowl and serve as a dip for pita or whatever really. You can zing this up with some diced chilli, or some peri-peri sauce (or paprika for a Hungarian flavour). Chickpeas are a great source or protein, zinc and dietry fiber. They are also low in fat (and the fat which is there is poly-unsaturated). Also great for people with diabetes as there are some good carbs in there. Healthy and really good!

Enjoy!

Tuesday, 29 March 2011

A bit about space physics

Next post, I want to tell you a bit about space physics, what it involves, and why it's important. Firstly, you need understand a bit about the Earth, and the sun, and how they interact. The sun provides us with the light which we need to survive. It makes it warm so we can enjoy ourselves at the beach, and there is nothing better than the suns warming rays after you have been really cold. The sun gets its energy by fusing hydrogen atoms in its core. That is what happens in a hydrogen bomb. A whole lot of radioactive particles are created in this process (stuff that are really bad for us). The sun hurls these radioactive particles out in all directions, at 400km per second (up to 800 km per second when the sun gets angry). This is called the solar wind, and the Earth is constantly bombarded by it.

The earth would be cooked, if we wernen't protected by the Earth's magnetic field. The Earth's core produces a magnetic field, similar to that created by a bar magnet. It's what makes a compass point towards (magnetic) north. The picture below shows what this magnetic field looks like.



Well, thats what the field produced by the Earth would like, if it wasn't hit by the solar wind. In reality, it looks more like this:



Notice how the field on the side of the Sun is all squashed up, and that away from the Sun it is all stretched out? This is a pretty drastic change to the magnetic field. Also, as the solar wind speed changes, such as after a solar flare where particles are shot out in much higher quantities at a much higher speed, it causes a drastic compression or expansion of the magnetic field. Faradays Law says that a changing magnetic field will induce a current in a conductor. So one consequence is that electrical currents are created in our power lines. If the current in these power lines become too great, they can cause the lines to melt. One thing which space physicists do is to monitor the Sun, trying to predict such solar flares, to warn power suppliers. One thing to look out for is the occurrence of sun spots. More sun spots means there is a higher chance of a solar flare. The power suppliers will then reduce the current in power lines, to minimise the risk of them burning out.

In 1859, the largest solar flare ever recorded hit the Earth (http://en.wikipedia.org/wiki/Solar_storm_of_1859). This caused ALL the telegraph wires in the US to melt. If this kind of thing had to hit us today, global power supply would likely be destroyed.

Not all of the solar wind is diverted by the magnetic field. Some of it penetrates past the barrier, and becomes trapped in the field. These particles then travel along the magnetic field and interact with our ionosphere and atmosphere. This is what causes Aurora (the northern and southern lights). Another effect of this is modifying radio propagation conditions (radio signals reflect off the ionosphere). Ham radio operators often keep track of solar conditions for this reason. These particles have all kinds of other effects as well (there is evidence that they even trigger lightning strokes).

As you can see, our magnetic field is incredibly important. Scientists believe that Mars was once a planet like ours, with water, and a breathable atmosphere, but when its magnetic field died, the solar wind began to erode away its atmosphere. This may sound familiar if you have seen the movie, "The Core".

This post was just a heads up, hopefully alerting you to the hazards of our closest star!

Tuesday, 22 March 2011

My first blog (and its first post)

Well, I have had very limited experience in blogging, having blogged twice only because I had to, and even then it was on some obscure server which 20 people have access to (and only a fraction of them even try to access it). So, having seen some peoples blogs, I decided that for me who has alot of stuff on my mind, this would be a great place to get it out.

Seeing as how its my first blog, lets do an introduction. I am a Phd student, studying space physics in Durban, South Africa. Since most of my (work) day is consumed by space physics, a lot of my blog will be flavoured with space, and general physics. Also, because I consider myself a nerd anyway (or geek, depending on your interpretation) , there will be a generous helping of nerdiness in this too.

I am a 20-something year old male (for the next five years anyway :P), and I enjoy reading, watching cricket and rugby, computer games (Starcraft 2!!!), geo-caching (I'll explain what that is later) technology, music (and playing it) and of course, science!

Something I get asked a lot is, "Are you going to be a rocket scientist one day?". This question can be rather annoying, because space physics (believe it or not) doesn't actually involve much of space. Astronomy is the study of stars, galaxies, black holes, the big bang and stellar evolution. Space physics, is quite plainly, the study of the Sun, and how it affects the Earth, and the space nearest us.

That will do for now. Looking forward to getting more stuff out there soon, and for now, I think a more in depth look at space physics will be required... later.