Follow the reluctant adventures in the life of a Welsh astrophysicist sent around the world for some reason, wherein I photograph potatoes and destroy galaxies in the name of science. And don't forget about my website, www.rhysy.net



Saturday, 30 November 2013

Blog update !

Regular readers may notice some changes to the blog. Irregular readers should eat more fibre, or see a doctor. A medical doctor. But anyway, in an effort to keep things organised, I've re-arranged the blog slightly. Since most of my posts revolve around pretty pictures, and often have revolving pretty pictures, I changed the layout so that large images will no longer intersect the side banner.


Well he seems happy enough, whoever he is. The side banner now has a subscribe button (at last !) and a link to follow me on Google+ (a.k.a. everyone's favourite anti-social network, where no-one gives a damn about what anyone did in the pub last night and instead posts epic science). There's also a list of labels, so if you don't care about my thoughts on creating the perfect piece of toast, it's easier to filter those out.
Mmm, toast.
Just to make things extra-specially organised, there are now separate pages with links to the more popular / interesting posts. Track my adventures in time and space in the travel section. View selected art highlights in the art section, only don't because instead you should buy some from StockTrek images. Or, if you'd rather actually learn something, try the popular science section. But don't do that either, because it's lame. Instead visit the unpopular science section, where science is explained with the help of an imaginary monkey, a princess, a magical moose and a potato.

Tuesday, 26 November 2013

The Princess, Some Goblins, And A Magical Moose

Astronomy may be many things, but dull and predictable it is not. One day you're sorting through endless lines of code trying to find a wrongly-placed minus sign, the next you're detecting hydrogen with the help of an imaginary monkey. Even so, I never expected that I would end up writing a story about a princess and a magical moose in order to explain data visualisation, but that's what happened.

FRELLED, my custom 3D data viewer, cannot be said to be intuitive to learn. It can't be really, because Blender is designed to make art, not love science. So there are plenty of idiosyncrasies and unexpected pitfalls for anyone trying to just load in data who's never used Blender before. And though I try and work around as many of these as possible, avoiding some of them would involve learning C++ and recoding Blender. Which is not what I signed up for.

Neither can I expect everyone else to spend ten years learning Blender, so I put some effort into writing a fairly detailed manual. Alas, the latest AGES thrall complained that the manual was unreadable. She said it needed, "a joke on every page" and "a story about a princess". And that the princess' name should be - by a remarkable coincidence - Olivia. Well, I managed a joke every other page (but you'll have to actually read the manual for that) and decided that a story would be a good format for a quick-start guide. So here it is, complete with princess, goblins, and a magical moose (moose being the name of said student's computer).



The Story Of Princess Olivia And The Magical Moose Whose Name No-One Could Quite Remember 

Once upon a time, the fair Princess Olivia was bored and decided to look in her magic mirror. “Mirror, mirror, on the wall,” said the Princess, “who has the best HI data of them all ?”
“You, O Princess”, said the mirror, “but it would be even better if you looked at it with FRELLED.”
The Princess decided that this was a good idea and would go to the library to learn all about it. It was a long way to walk, but luckily a magical moose appeared from nowhere. That’s what magical mooses do.

“Climb aboard !” said the moose, “I’ll take you to the library in no time at all.” The moose ran to the library at an amazing speed. “Thanks, moose !” said the Princess, “I don’t suppose you know where I could find out about FRELLED ?”
“Why yes,” said the moose, “for I am a magical moose.” The moose and the Princess sat down in front of one of the library’s many computers. “First,” said the moose, “you should look at your data in ds9 or kvis”.*
 * The moose had the magical ability to pronounce italics.

“Why ?” asked Princess Olivia.
“You need to know how bright your sources are,” explained the moose, “then you will be able to tell FRELLED which parts of the data should be dark, and which should be bright.”
The Princess looked at the data and discovered that the lowest value was about 0 Jy and the highest was about 1 Jy. “How very convenient” she declared in a regal manner. “What’s next, moose ?”
“Now you open the ExportFITS script,” said the moose, “and enter those values in the data range boxes.”
“Anything else ?” asked the Princess.
“Yes,” said the moose, “You must choose which projections to export. Let’s try just the XY projection for now, it will be faster. And press the 3D button and the map 1 button. Then press go.”
The Princess did as she was bid and in no time at all, the FITS cube had been rendered into lots of .png images.

“Amazing !” said the Princess.
“Well done,” said the magical moose, “now you can import the images into FRELLED. Load and run the ImportFITS script.”
“Alright,” said the Princess, “but will this take long ? I have to go and fight off an invading horde of goblins this afternoon.”**
 “Oh no, it’s very fast,” the moose reassured her, “Just press the ‘Axes’ button... that’s the one. Now press ‘XY’ and then ‘Import images’ ”.
** Princess Olivia was a warrior princess.

The Princess marvelled to see a wonderful three-dimensional image appear on the screen. “Wow !” she exclaimed, “This is better than Avatar ! But.... oh, if I rotate it too much, it all disappears !”
“Ah, yes,” said the moose, who magically blushed and shuffled his feet in an embarrassed manner, “I’m afraid you must press the ‘Enable script links’ button when looking the data.”
Princess Olivia was not amused. “Why ?” she asked, scornfully, “That’s not intuitive at all !”
“Sorry !” said the luckless moose, “It’s a software limitation.”
“Oh well,” said the Princess, “I suppose this will have to do. But what about all these other buttons ?”
 “There isn’t any time to explain. This is only a quick start guide,” said the moose, magically breaking the fourth wall. But he tipped his head and something white and fluttery fell from his antlers. “Try reading this manual. That should answer all your questions.”

Princess Olivia thought about this and adjusted her tiara in a haughty fashion. She wasn’t sure that Princesses were allowed to read manuals. Perhaps she could find a servant to read it for her. “Oh, alright,” she said. “Goodbye moose !”
The moose magically disappeared. Later on, Princess Olivia decided that fighting the goblins was too much effort. Instead she decided to teach them all about FRELLED. And they all analysed HI data ever after.

THE END. 

Monday, 25 November 2013

Damn That's A Nice Piece Of Gas

I mean, seriously, why would you choose a career in astronomy if you didn't want to look at pretty pictures all day ? Fortune and glory ? The only way to get rich in astronomy is to sell your students into slavery. The only glory you'll ever get is - if you're very lucky - a five minute slot on the local news where the reporters insist you're a fully qualified, eminent astrologer. The rest of the time you'll struggle to be heard against the background noise of everyone else's ludicrously high publication rate... except by your competitors, who will claim everything you do is wrong and also hate you.

Tycho Brahe learned this lesson the hard way,
losing in nose in a duel about an equation.
Far safer, then, to shun the bright lights of celebrity status and get on with the important business of looking at pretty pictures. Lately I've been obsessing with one particular set of particularly pretty pictures : the neutral hydrogen gas* in our own galaxy. In fact, I've always had something of an fascination with visualising fluffy (a.k.a. volumetric) clouds and explosions. Intricate structures without a well-defined edge are just about some of the most beautiful things in existence, in my opinion.
* Colours in all of the following images are false, because to see neutral hydrogen we'd need enormous eyes made of metal. The structures the colours represent are absolutely real.


Two-dimensional images taken at roughly the same wavelengths of light that we can see are one thing, but visualising 3D data is another challenge altogether. I've previously managed this reasonably well, I think, for certain cases. The basic method is incredibly simple : chop up the data into lots of slices, and make an image of each slice. Then you just line up all the image slices and you get a very convincing illusion that you're looking at a whole volume of data (each slice has to be slightly transparent, of course).


This actually works pretty well for most hydrogen observations of distant galaxies. For these, the observations generally only span a small part of the sky, so the data forms something which is roughly cube-shaped. The only major complication is that while we can map the hydrogen on the sky, the third axis is not distance, but velocity. On very large scales, this turns out to be a good approximation to distance. But not on the scale of a single galaxy. Here the velocity information tells you about the rotation of a galaxy and nothing about how distant individual parts of it are.

That doesn't really matter too much, though, because it's still useful to view the data in 3D. And prettier too, otherwise there'd be no point in bothering.

Ironically, things get more difficult with our own, much closer galaxy. We can see things in much greater detail and with quadrillions of times more sensitivity, over the entire sky. The sensitivity brings me to the first problem - the "dynamic range" of the data. All this means is that there's a massive difference between the faintest and brightest emission we can detect. The contrast between the faint and bright parts of the image also varies with velocity. So, for instance, in some parts of the data volume you might have a single small bright structure, whereas in others you'll have huge complicated things but all at about the same brightness.


The above shows the view moving through part of the the hydrogen detected in the Milky Way by the GALFA-HI survey. Someone - I believe it was Josh Peek - came up with the genius idea of generating colour by using different slices. So one slice will be coloured red, the next green and the next blue.


If you use parts of the cube that are too far apart, you get a meaningless mess, because the structures in different parts of the volume are very different. But if you use adjacent (or nearly so) slices, the structures are similar but not identical - and the effect is to create a really quite wonderful lightshow. That's fine for 2D images and animations. In 3D, however, all of those glorious colours wash each other out and you get a sort of big browny-coloured fuzzy blob.

Leiden / Argentine / Bonn all-sky data.
With other galaxies, a large part of the data is actually just noise. This is easy to remove, leaving only the relatively small important data. Not so with our own galaxy. Here, all of the data is important. And some parts, as I've said, are very bright, which can overwhelm the faint structures. So how do you see the full 3D complexity of the data ? And how do you preserve the glorious technicolour of the 2D images ?

One nice trick is to allow the colour of each slice of the data to vary according to the range of data values in each slice. What this means is that the contrast between bright and faint structures will always be the same, even if the faintest emission in one slice of the data is brighter than the strongest emission in other slices.

The second important trick is to have colour and transparency vary differently. You need to be able to see which parts of the data are really bright, but you don't want them to block the view of the fainter features. If you want to get really fancy, you can have the colours vary logarithmically. That means that something has to actually be, say, 10 times brighter before it will appear to be twice as bright. The upshot is that both faint and bright features become visible.

Enough talk. Here's what the above GALFA data set looks like in 3D, with the correct settings :


But that's only part of the problem. Most extragalactic data only covers a small part of the sky. GALFA data covers 13,000 square degrees, but over a relatively narrow portion of the sky. Pretending the data is actually a cuboid doesn't really make much difference - like peeling a narrow strip of the skin from an orange, you won't cause much distortion by flattening it.

But other HI surveys cover the entire sky. If you try and pretend the whole, spherical sky is actually cube-shaped, you get something that looks kinda cool, but also pretty weird and difficult to interpret :

The entire sky from the Leiden / Argentine / Bonn survey.


One thing you could do instead is to sum up all the values along each pixel in the cube, and map those values onto a sphere. Which you can then flatten into a 2D map. You've seen such things before for the Earth, I'm sure.


Unfortunately, this is really boring. A much better approach is to keep the sphere and render a rotating GIF of it, because the internet freakin' loves GIFs :



But then of course, you can't see how the structures vary in velocity. The simplest method is to animate the texture on the sphere so that you see different slices of the data - just like before, with the flat images, but this time wrapped to a sphere. This works, and it looks lovely. I think this may be my favourite gif :


This doesn't help at all with the problem of viewing the data in 3D, of course. The solution to that is to make hundreds of nested spheres, each one with a map of the hydrogen at a different velocity channel. And then you get something which looks... well, a bit weird, really.


The center of this bizarre-looking thing looks even more spectacular :


And here's the resulting obligatory movie :



OK, what are we looking at here ? The problem is that velocity bares little obvious relation to distance, and interpreting it is... well, it's not fun. Yet it is possible, with enough mathematical jiggery-pokery, to convert the velocity and position on the sky into something approaching true 3D position. And that looks like this :


So why did the galaxy turn into an iridescent butterfly ? The moire patterning is due to the limited resolution of the survey - there are, in a sense, only so many angles the telescope can point at. Transforming this into distance creates long blank streaks where (effectively) the telescope didn't look.

More serious problems occur because looking directly towards or away from the galactic center, we can't measure the velocity of the gas at all. That's because we can only measure how fast the gas is moving toward or away from us, and at these particular angles, it isn't. It's only moving across the sky, which we can't measure. Another weird effect is that for any point closer to the center of the galaxy than the Sun, the equations produce two (yes, TWO !) possible distances for the gas, and there's no easy way to find out which is the right one. That's what causes the weird bubble-like structure in the center.

Ironically then, it really is easier to see the structure of external galaxies than the one we live in. But all is not lost. Further away from the center than the Sun, and avoiding looking directly toward or away from the center, the measurments are pretty good. When the parts where measurements become meaningless are removed (well mostly), things look quite a bit better. It's even just about possible to see that the galaxy has spiral arms.


Hardcore enthusiasts - who have somehow read this entire thing - should go and get a cup of tea, and then take a look at  Kevin Jardine's extraordinarily awesome Galaxy Map - especially the mapping hydrogen and velocity pages. All I really wanted to do was make pretty pictures, but the (arguably) more important business of mapping the galaxy has to use other techniques to fill in the gaps. But don't worry - this post is almost over, so I'll skip ahead to the end result.

Credit : GalaxyMap.org
What's that ? You'd like this post in video form, with narration by an angry Scotsman ? No problem !



And that's it. Excuse me while I attend to the needs of my iridescent butterfly.

Monday, 11 November 2013

Prague Castle 2 : The Sequel

As I've previously reported, people flock in droves to the Charles Bridge to the point where it becomes invisible. This is undoubtedly the peak of the population density in Prague, but on the surrounding streets the flow of tourists is still torrential. Yet, walk for merely a minute - or less - orthogonal to this living human filament and the streets are practically empty.

It isn't that the towers and spires of the city are mere fronts, disguising some kind of foul city-wide cesspit. In fact the rest of central Prague is no less beautiful than the army-ant tourist route, though it is, perhaps, less iconic. Even this isn't true of Vysehrad, Prague's second castle. It's accessible by a short, very easy (i.e. flat) walk from a metro station, is about a thousand years old and has sweeping panoramic views of the city. And yet on a sunny Saturday afternoon there were no more than a handful of visitors in the whole, extensive site.


What's wrong with people ? The site is only two metro stops from the city center - so it's basically still in the city center. A city with a population of 1.3 million, yet it almost feels like somewhere rural. This is wonderful. In fact, I'm wary of promoting it, in case it too is swallowed whole by the voracious human wyrm.

It's also cheaper than Prague Castle (which itself it not very expensive). Entering the cathedral is about £1 (St Vitus is free to simply enter but costs about £5 to walk around - still, admittedly, a bargain) while the spacious grounds are entirely free. As is the cemetery, where the great and good of Czech society are buried. As I understand it, the nearest British equivalent would be Westminster Abbey.



It's a fascinating place to explore, though the only name I recognized was Dvorak. Even so, I would have spent longer had I not already been around the site for about 3 or 4 hours. I kept getting distracted by just how lovely the place is.



If you want landscapes, go to Switzerland. For skyscrapers go to America, and for castles go to Wales. But for churches, go to Prague. So far I'm convinced that the city could no more allow an ugly church than a Greenpeace activist would eat a  whale burger with a side order of dolphin fins. Vysehrad is not as magnificent as St Vitus or as ornate as Our Lady Before Tyn. But it is cheaper than St Vitus and far less crowded. It's not free, unlike Tyn, but they do let you take photos (unlike Tyn). The interior is certainly remarkable, and well worth seeing, being entirely covered in paintings.




One could be forgiven for walking through Prague Castle and not realising it's a castle. Not so at Vysehrad, whose massive ramparts are... err, well, they're very large. I think I've run out of metaphors for the day. Still, they provide a very nice walk through the extensive park grounds. I had lunch in what was an unremarkable café until I realised that the walls were four feet thick. Well, I suppose it was important to protect the tourists back in medieval times*.
* Another, much less likely possibility is that it wasn't originally built as a café.


Also, the bar was literally ship-shape and had a demon head hanging at the front.
Vysehrad, though almost deserted, does not lack for places to eat. I can only assume the place is busier in the summer. It also has one or two exhibitions, though I did not pay them a visit. Having spent several hours wandering around, and with the need for laundry becoming ever more pressing, it was time to return. For, as the poet Homer would say :

"But despite my grief, let me do laundry, since there is nothing more shameful than the wretched washing machine that demands a man’s attention however deep his distress, or heavy his heart, and my heart is heavy now, yet my laundry goes on insisting I wash it at 40 degrees with a 1200rpm spin cycle, making me forget what I suffered, demanding the washing machine its fill. "

Why An Imaginary Monkey Is Helping Me Measure Hydrogen

I once photographed a potato for NASA. This is going to be difficult to top, but I'll give it a damn good try.

Galaxies, by and large, are fairly simple shapes. Generally speaking they're either pretty spiral discs or tremendously boring yellow blobs (a.k.a. ellipticals). You can make analysing them as complicated and tedious as you like, but measuring how bright they are is pretty simple. Put a circle around them and have a program add up all the flux (energy) within the circle. Easy-peasy.

Images from the SDSS.
Of course, things get more complicated most of the time. Usually spiral galaxies are tilted away from us, so they're not neat circles. Sometimes there are stars in our own galaxy lined up directly in front of the distant galaxy, in which case there's little option but to break down and cry. Or find another galaxy to measure.

There are also galaxies whose shapes are just downright freakin' weird. Like this one, discovered by a Puerto Rican student this very summer. I can't resist re-posting this, because... NESSIE !


There are even galaxies which aren't so much exotic as they are... erotic. Well, erotic corporate logos at any rate, which is even weirder. I kid you not.


With galaxies shaped like Nessie or...ahem... rabbits, you could still slap a circle around them and get a reasonable answer. But in these cases you might suspect that the galaxy is made of several separate parts, so possibly you would choose to fit more complicated shapes.

With neutral hydrogen the observations give you 3D data cubes, and the gas can be all kinds of wonderfully complicated shapes. And pretty too. Did I mention it was pretty ? Because it is.

Gas clouds of the Milky Way, from the GALFA-HI survey.
NGC 628 from the THINGS survey.
The above GIFs were produced with FRELLED, my own script that imports FITS files into 3D art software Blender. That lets you freely rotate the view around the 3D images in realtime, which is nice because it makes the animations a lot easier to produce. And do all kinds of science, etc. etc. Anyway, it's pretty obvious in these cases that just drawing a circle wouldn't help much, unless it was accompanied by some arcane symbols and ritual chanting. This - unless you're a dyslexic astrologer who chose the wrong career path - is generally frowned upon as a method of data analysis.

So I was asked to give FRELLED the ability to measure the gas content within spherical or spheroidal regions (it only did cubes*, which are trivial). Well, spheres are easy, because you can very easily find all the pixels in the file which are inside the sphere and add them all up. Deformed spheres (ellipsoids) aren't much harder.
* Most of our observations have much worse resolution than the above examples, so cubes work just fine.

But the heck with that. I can see where this is going - today a sphere, tomorrow an ellipsoid, the day after... well, let's just go for broke and let it do arbitrary shapes. Like, say, a monkey. That's about as arbitrary as you can get.


This is Suzanne, beloved icon of Blender. Over the years she's been subjected to all kinds of deranged shenanigans, though not, I suspect, ever quite as pointlessly technical as this. What I needed was a way to check if any particular point was inside or outside of Suzanne (more generally any closed surface). And I found one on the internet, making life twenty times easier or more.

It's very simple to define the smallest possible cube which contains all of Suzanne. All I have to do is check all the points within this cube to see if they're inside Suzanne or not (I could check the entire data set, of course, but this is huge and would take a lot longer).

At that point I could make a leap of faith and have the program just spit the measurement of how much hydrogen is present. This is a terrible and boring idea. I'd rather have it first show me what the data it thinks is inside Suzanne looks like. That way I get to check if it's working correctly or not.* More importantly, I can now present you with a monkey head made out of hydrogen gas from the Milky Way. You saw it here first.
* Actually this was really important, because several early tests were giving ghastly results - and there isn't some "monkey parameter" to check if this is working. The only way is to look at the data and see if it looks like a monkey**.
**This is not a phrase used much in astronomy.


OK, this is pretty specialist stuff. It boils down to a short algorithm to let you measure hydrogen within an arbitrary volume. This is quite useful, but it isn't going to revolutionize astronomy. Not unless that depends on measuring the gas content of a monkey-shaped galaxy, at any rate.

Friday, 1 November 2013

Happy Birthday Arecibo !

Few would deny that Arecibo Observatory is home to the world's most iconic radio telescope, star of Goldeneye and Contact (Pierce Brosnan... ? Jodie Foster ? Who ?). Even fewer would deny that Arecibo is 50 years old, because this is a fact. This magnificent facility suffers, however, from a surfeit of names, being variously described as "Arecibo Observatory"*, "El radar"**, and, just to annoy the heck out of everyone, the "National Astronomy and Ionosphere Center"***.

* What nearly everyone calls it.
** The local name. Would a letter sent (from within Puerto Rico) to the address "El radar" get there ? "Yes" was the unhesitating and unflinching response from a senior staff member.
*** The name the lawyers use, and the website too.



These days the telescope itself is known as the William E. Gordon telescope, after its designer. Who, incidentally, made an almighty factor-of-ten slip in his calculations, and that's why a small island in the Caribbean ended up with a 300m telescope and not just another forgettable 30m antenna.

I'm not even going to attempt to do justice to either William Gordon or the telescope. About the telescope I will only saw that its list of accomplishments is by anyone's standards impressive. It measured the rotation rate of Mercury, discovered the first binary pulsar, the first exoplanets, has sent messages to aliens, measured the distance to numerous potentially hazardous Earth-crossing asteroids, and done a bunch of atmospheric work I don't understand but I assume is important.

About William E Gordon, I will only point out that (I'm told) he was more usually known as Bill, so really we should be calling it Bill's Big Dish. My suggestion that honour the Observatory's instigator by painting some suitable tribute in big letters on the dish somehow never got taken up. Can't imagine why.

It would be a talking point if nothing else.
Anyway, Arecibo is, as I mentioned, 50 years old - the same age as Dr Who (coincidence ?). I was asked to create a short animation to be shown in the background for the resulting, "hooray, we're still here !" celebration. Fortunately, I already have my computer model (which was used to produce a laser-etched glass cube you can buy in the visitor center for $80). What I really wanted to do was include something like this...

Thanks, NRAO !

... which is a wonderful image of the NRAO Green Bank facility with the sky shown as if the viewer could somehow see at 4.85 GHz. So I wanted to do something similar for Arecibo, but using (obviously) Arecibo data.

For this I was graciously allowed to use data from the GALFACTS survey, which covers a huge chunk of the sky (the image I have spans about 85 x 17 degrees). Arecibo can't see all of the sky, because it's pretty hard to move a 300m dish. So it can only see a (still pretty respectable) swathe, but Bill's bloody big dish makes up for it by being ridiculously sensitive. Here's what it would look like if we could see GALFACTS data (after the experts corrected me for having it the wrong way round) :


The forest is looking decidedly deciduous for a tropical island.
But having a computer model means I can do a lot more than make a static image (though having moved from Arecibo to Prague recently does rather slow things down somewhat). I opted to ape the award-winning opening credits from one of the best shows on TV at the moment...

Game of Scopes
A Song of High Humidity Levels and the Occasional Hurricane
The fact that the inspiration for this image missed out Arecibo is a source of continuing disgust to me.

Anyway, here's the resulting final animation. Somewhat crude - no vegetation at all because it took too long to render - but quite serviceable, I think.