Get excited and make things with science

Last weekend, 19th & 20th June 2010, saw the first Science Hack Day at the Guardian offices in London. Jeremy Keith organised a venue, food and drink and sponsorship for around 100 people to spend two days building small science projects. Saturday morning saw a series of short talks to introduce the event,  give people some ideas of what they might make, and what tools were available to help them make it. 24 hours of hacking and building followed, with presentations and prizes for the best hacks on Sunday afternoon. Ed Gomez has a great write-up of the hack day itself, and the winning hacks. My personal favourites were the Aurorascope, which shows auroral activity by lighting up LEDs inside a ball representing the Earth, and Random Orbit, a RESTful service to track satellites in real time.

I was asked by Jeremy to give one of the talks at the beginning of the hack day, so I chatted a bit about the work we’ve done with astrometry.net to tag Flickr photos with their celestial locations — astrotagging.

Introducing astrotags

At the Royal Observatory, Greenwich, we’ve set up a Flickr group for our photography competition, Astronomy Photographer of the Year. Photos in the group are being scanned by the astrometry.net bot, which identifies stars in a photo then solves for celestial coordinates by comparison with a reference catalogue. Astrometry.net leaves a comment on each photo, listing the coordinates of the image and the names of objects within the field of view. The comments are relatively easy to parse, and I’ve written a small utility to extract information from commented photos. However, this is the sort of problem that’s ideally suited to machine tags so we asked astrometry.net to add tags to photos in our group using the astro: prefix. The tags are:

astro:RA
Right Ascension of the centre of the photo.
astro:dec
Declination of the centre of the photo.
astro:orientation
Orientation of the photo from North, in degrees.
astro:fieldsize
Angular extent of the photo, East-West × North-South.
astro:name
Named objects in the field. One tag per name.

Some good examples of tagged photos are:

The simplest way to get at these machine tags and use them in your own applications is with YQL, which allows you to query the flickr search and photo info APIs using a simple, SQL-like syntax. To make life easier, I’ve written a YQL open table, flickr.photos.astro, which can be queried to return a feed of astronomical coordinates and info for a set of Flickr photos.

select * from flickr.photos.astro where astro_name = 'Horsehead Nebula'

That query, for example, returns a feed of photos tagged astro:name=’Horsehead Nebula’. For some other examples, have a look at my post on searching astro:name with YQL.

My hack

Astrometry.net have solved almost 7,000 photos on Flickr, but only around 600 of those have been tagged with astro: machine tags. For my hack, I decided to try making a YQL table based on screen-scraping Flickr for information left by the astrometry.net robot. I took the code from my astrotagging web form and put together flickr.photos.astrometry, a YQL open table that can parse astrometry information from Flickr comments. The input parameter is a Flickr photo page URL, so a query looks like

select * from flickr.photos.astrometry where url = 'http://www.flickr.com/photos/dangerous_astro/4722913544/'

This returns a feed of the coordinates and names found on that page.

To demo this, I hacked together a little javascript astronomy photo search engine. You pass in a search query in the URL:

http://eatyourgreens.org.uk/yql/scihackday.html?text=milky+way

That text is then used to run a Flickr search and grab up to 30 photos, shown as thumbnails. The search is limited to photos which have been solved by astrometry.net, and we also request the photographer’s name so that we can credit them:

select * from flickr.photos.search(30) where text = 'milky way' and extras='owner_name' and machine_tags = 'Astrometrydotnet:status=solved'

If you don’t pass in a search query, we instead return the 30 most recent photos solved by astrometry.net.

select * from flickr.photos.search(30) where extras='owner_name' and machine_tags = 'Astrometrydotnet:status=solved'

When you select a thumbnail, by clicking on it, another YQL query is run against flickr.photos.astrometry to return the coordinates and names for that photo. The coordinates are used to plot the photo on a map of the sky, while the names are listed as links so that you can go on to search for pictures of specific objects in the field of view.

It’s quite a simple little bit of code, but hopefully it shows how useful YQL can be for accessing structured data on the web, even when that data is in HTML or plain text. If anyone does use it to build anything, Astronomy Photographer of the Year has a showcase page for mashups built using the Flickr astrometry data.