Eat your greens!

Actually, I am a rocket scientist
Home » 2009

Searching astro:name with YQL

Posted in astronomy, geekage, yql

Searching astro:name with YQL, originally uploaded by Eat your greens!.

The YQL team announced personal URLs for queries this week. I’ve used the new feature to set up a shortcut for looking up photos of astronomical objects by name. The URL is:

http://queries.yahooapis.com/v1/public/yql/eatyourgreens/astrolookup?name=M+42

You can set the name parameter in the URL to change the name of the object you are looking for. I’ve also set up a demo page to render results from this query. The URL is:

http://eatyourgreens.org.uk/testapps/yql/astronamesearch.html?name=Horsehead+nebula

Again, change the name parameter in the URL to lookup different objects. Note that it looks for an exact match with the astro:name machine tag, so looking up stars is cumbersome:

http://eatyourgreens.org.uk/testapps/yql/astronamesearch.html?name=the+star+deneb+(αcyg)

Update: it seems Flickr’s machine tag search can match just the first part of a tag, so you can search for stars by supplying the first part of the tag’s value.

http://eatyourgreens.org.uk/testapps/yql/astronamesearch.html?name=the+star+deneb

I’ve also made some changes to flickr.photos.astro in order to enable faster searching by name. Use astro_name in a query to find objects by matching on astro:name:

select * from flickr.photos.astro where astro_name = 'M 31'

or use text to run a Flickr text search across photo descriptions and titles:

select * from flickr.photos.astro where text = 'orion'

If you want to see what values have been used for astro:name on Flickr, I recommend Paul Mison’s excellent machine tag browser.

London web standards: Introducing astrotags

Posted in astronomy, geekage, yql

Here are the slides from my talk at the December LWS meetup – Introducing astrotags: astrometry, machine tags and YQL (20MB pdf). The examples and demos should all be in the YQL category on this blog.

If you’re interested in the nuts and bolts of the automated astrometry robot, I recommend having a look at astrometry.net and reading Making the sky searchable: Fast geometric hashing for automated astrometry.

Is it about elephants?

Posted in geekage

I found my copy of Ghastly Beyond Belief, Neil Gaiman and Kim Newman’s wonderful collection of quotations from science fiction and fantasy. Page 164 has this excellent exchange between Michael Moorcock and Thomas Disch.

Tom Disch: I’m writing a book about what everyone wants most.

Moorcock: Really? Is it about elephants?

Disch: Elephants? No, it’s about becoming more intelligent.

Moorcock: Oh, what I’ve always wanted most is to be an elephant.

Azerbaijani bloggers imprisoned after unfair trial

Posted in amnesty

From Amnesty International on 18 November 2009:

Azerbaijani youth activists and bloggers Emin Abdullayev (aged 30) and Adnan Hajizade (aged 26) have been sentenced to two and a half years and two years respectively in an unfair trial. Amnesty International believes the charges against them were fabricated and they have been imprisoned solely for exercising their right to freedom of expression.

On 28 June, a satirical video made by Adnan Hajizade criticizing the Azerbaijani government was posted on the video-sharing website YouTube. On 8 July, Adnan Hajizade and Emin Abdullayev (who blogs under the name Emin Milli) were approached by two men as they were dining with friends in a restaurant in the capital Baku. The men demanded to know what they were talking about. When Emin Abdullayev replied that it did not concern the two men, one of the men head-butted him and he fell to the floor. The same man then struck Adnan Hajizade, knocking him to the ground, and continued to kick and beat Adnan Hajizade and Emin Abdullayev until restaurant staff intervened.

Adnan Hajizade and Emin Abdullayev immediately went to a local police station to report the incident. However, police officers interrogated them as suspects for five hours, denying them access to a lawyer of their choosing and arrested them on charges of ‘hooliganism’. The activists were remanded in custody pending their trial. They were later also charged with inflicting minor bodily harm.

During their investigation the police and prosecutors failed to interview witnesses and to obtain video evidence from a security camera which may have recorded the incident in the restaurant. They also submitted documents to the court which wrongly stated that Adnan Hajizade was unemployed and that he had a criminal record. According to the activist’s lawyers, at the trial the court refused to consider photographs showing the injuries they sustained in the attack, as well as video evidence from mobile phones and the security camera, but provided no explanation as to why. The two men were convicted and sentenced to two and a half and two years respectively in prison. Emin Abdullayev and Adnan Hajizade intend to appeal against the decision.

There is a letter calling for the release of Emin and Adnan, which you can send to President Aliyev, the Minister of Justice, the Ombudsperson and the Azerbaijani Ambassador in London.

£3736.56

Posted in amnesty, book sale


Amnesty book sale 2009, originally uploaded by Eat your greens!.

The Amnesty November book sale is over and we raised an amazing £3736.56, which brings our total for 2009 to a phenomenal £16,500. Many thanks to everyone who volunteered time to help set up the Church of the Ascension and also sell books on the day. Thanks also to the Ascension for allowing us to take over their church for the three days it takes to set up the November sale. Finally, thanks also to everyone who offered books to the group. We’re sorry that we haven’t been able to accept donations for the November sale. There were simply so many books leftover from June that we were kept busy trying to sell those. I will try to contact everyone who offered books and suggest some alternative places which may be collecting. We will start collecting books again in May 2010.

Amnesty book sale, 14th November 2009

Posted in amnesty, book sale

8th annual Blackheath & Greenwich Amnesty clearance book sale
Saturday 14th November 2008
10am until 4pm
Church of the Ascension
Dartmouth Row
Blackheath SE10 8BF

20,000 new and used books at bargain prices. In June we raised a record-breaking £12,500 for Amnesty International UK but we still have thousands of books left to sell. We hope to raise a further £3,000 by selling the unsold books in November.

If you would like to help with preparing for the sale, or are interested in collecting unsold books at the end of the day, please leave a comment using the form below.

You can also find us on Upcoming and facebook. Flyers can be downloaded from flickr.

Look out honey cos I’m using technology

Posted in geekage, yql

My last post gave some examples of YQL queries that could be used to access the data for the Science Museum’s Cosmic Collections competition. Looking at XML feeds is pretty dry, though, so I thought it would be fun to put together a demo which uses a YQL query to visualise the data. I’ve also been looking at Raphaël recently, a small library for working with SVG in web pages. Inspired by the Royal Observatory’s Flickr touchscreen, and knowing next to nothing about either jQuery or SVG, I wrote some quick code with jQuery and Raphaël to display photos of the Science Museum objects as a pile of polaroid photos.

Here’s the code, with some explanation in the comments that hopefully shows how to extract the Science Museum data from the query results and do something useful with it. The event handling code seems a little dodgy to me ( I really know very little about SVG or jQuery) but seems to work in Opera, Firefox and Safari. You can try it on the demo page. Click to pick up a photo and move it. Click again to drop it.

A small update: Here’s a second demo using drag-and-drop instead of mouse clicks. I’ve also added the focusable attribute to the SVG rectangles, to make them accessible from the keyboard. This only seems to work in Opera.

// URL of the environment file, which points to the URL
// of the nmsi.cosmosculture YQL table definition.
var env = 'http://eatyourgreens.org.uk/yql/nmsi.env';
// YQL query to select everything from the Cosmic Collections dataset.
// Change this query to change the objects displayed in the page.
var yql = "select * from nmsi.cosmosculture";
// Example alternate query - fetch everything linked to the Moon
// var yql = "select * from nmsi.cosmosculture where LinkedCelestialBodies.CelestialBody.CommonName = 'Moon'";

// Encode the query and env file URL in a call to the YQL web service.
// Specify JSON as the return format.
var url = 'http://query.yahooapis.com/v1/public/yql?q='+ encodeURIComponent(yql) + '&env='+encodeURIComponent(env)+'&diagnostics=false&format=json&callback=?';

// Set a canvas for Raphael to draw on.
var height = 600;
var width = 800;
var paper = Raphael('canvas', width, height);

// Set some global variables to use when we are dragging elements around the canvas.
var startx = 0;
var starty = 0;
var dragging = false;
var draggedSet = null;

// Call the YQL web service and pass the json result to a callback function
$.getJSON(url, function(json){
//  Get the array of museum objects from the query result.
	var items = json.query.results.MuseumObject;
// Loop through the items array
	$.each(items, function(i, item) {
// Ignore items which don't have a photo
		if(item.Image.Source){
			var src = item.Image.Source;
// The smallest available image size is 'Inline'.
			src = src.replace("Medium","Inline");
			src = 'http://www.sciencemuseum.org.uk'+src;
// Generate a random x,y position for the photo
 			var x = 10 + (width-110) * Math.random();
 			var y = 10 + (height-110) * Math.random();
// Generate a random angle between 350 and 10 degrees.
 			var rot = 10*Math.random();
 			if(Math.random() < 0.5) rot = 360-rot;
// Each photo is built from a set consisting of a white rectangle and the photo
 				var s = paper.set();
 				s.push(paper.rect(x,y,110,140).attr('fill','white'),paper.image(src, x+5, y+5, 100, 100));
// Rotate the set by our random angle
 				s.rotate(rot);
// When the set is clicked, if already dragging, drop the photo.
// Otherwise, bring to the front and store the mouse
// coordinates for future use.
 				s.click(function(e) {
 					if (dragging) {
 						dragging=false;
 					}else {
 						dragging = true;
 						startx = e.clientX;
 						starty = e.clientY;
 						s.toFront();
 						draggedSet = s;
 					}
 				});
// Listen for mouse movement on the document.
// If dragging, move the dragged set to the
// x,y coordinates of the mouse.
// Store the current coordinates for the start
// of the next move.
 				document.onmousemove = function(e){
 					if(dragging) {
 						dx = e.clientX - startx;
 						dy = e.clientY - starty;

 						for (var j=0; j < 2; j++) {
 							var node = draggedSet[j];
 							node.attr({x: node.attr('x')+dx, y: node.attr('y')+dy});
 						}

 						startx = e.clientX;
 						starty = e.clientY;
 					}
 				};
 			}
 		});
})

Science Museum Cosmic Collections competition

Posted in geekage, yql

The Science Museum have launched their Cosmic Collections website competition. They are offering two £1,000 prizes for web mashups built using their data describing the objects in the Cosmos & Culture gallery. The deadline for entries is 28th November 2009. Full details are available on the competition web page. There’s also a Yahoo! Developer Network interview with Mia Ridge about the competition.

The data has been released using a fairly simple API, so I’ve drafted a YQL open table definition for it. You can use it to retrieve the full dataset:

use "http://eatyourgreens.org.uk/yql/nmsi.cosmosculture.xml";
select * from nmsi.cosmosculture

Try it

or retrieve an individual item, given the accession number:

use "http://eatyourgreens.org.uk/yql/nmsi.cosmosculture.xml";
select * from nmsi.cosmosculture where AccessionNumber = '1923-668';

Try it

You can also use YQL’s own filtering operators to restrict the result set. For example, get items for a particular place:

use "http://eatyourgreens.org.uk/yql/nmsi.cosmosculture.xml";
select * from nmsi.cosmosculture
where LinkedPlaces.Place.PlaceName like '%Italy%'

Try it

The competition wiki has a page describing the catalogue fields returned by the API.

YQL updates for nmm.collections

Posted in geekage, yql

I’ve made a couple of updates to the National Maritime Museum YQL tables, to hopefully make it a little easier to search the NMM collections with YQL.

Firstly, I’ve added a new input parameter, sortby, to nmm.collections.search, which specifies the field used to sort search results. Possible values are objectid, title, maker, year, updated. You can also specify sortby = 'rank' to order results by relevance for free text searches. So, for example, you can get the most recently updated records from the art collection with the following query:

select * from nmm.collections.search
where category = 'art' and searchterm = '' and sortby='updated'
Try it

Secondly, I’ve set up an XML feed to look up entries in the authority tables, and a corresponding YQL table nmm.collections.authorities. So, rather than having to know that the Aquitania is entry 21209 in the vessels authority, you can look up its entry with:

select * from nmm.collections.authorities
where authority = 'vessels' and title = 'Aquitania'
Try it

This is most useful when doing search for objects linked to a particular authority record, as you can join the two nmm.collections tables. For example, to search for art by the painter Charles Pears, you could try the query:

select * from nmm.collections.search
where searchterm='' and (authority,category) in
(select authority,id from nmm.collections.authorities
where authority = 'people' and title = 'pears')
Try it

The new YQL table definitions are available on github, and will hopefully be available to use in the YQL console soon. I’ve set up a javascript demo page where developers can test YQL queries against the NMM collections. There’s also a page of documentation about the NMM’s collections feeds, with some sample YQL queries for developers.

Belarus: Stop the execution of Vasily Yusepchuk

Posted in amnesty

Vasily Yusepchuk was sentenced to death by Brest Regional Court on 29 June 2009. He was convicted of murdering six elderly women. On 2 October his appeal against the death sentence was turned down by the Supreme Court. In Belarus, people who have been sentenced to death have 10 days in which to apply for clemency after their appeals are rejected. Only one request for clemency has been granted since President Lukashenka came to power in 1994.

Vasily Yusepchuk, belongs to a marginalized group; he is a Roma who does not have an internal passport which is a requirement of all citizens in Belarus. He may have an intellectual disability and his lawyer has stated that he is illiterate and unable to tell the months of the year. Vasily Yusepchuk has alleged that he was beaten while in pre-trial detention on two separate occasions in January and in March.

In Belarus, condemned prisoners are given no warning that they are about to be executed, and they are usually executed within minutes of being told that their appeal for clemency has been rejected. They are first taken to a room where, in the presence of the Director of the detention facility, the Prosecutor and one other Ministry of Interior employee, they are told that their appeal for clemency has been turned down and that the sentence will be carried out. They are then taken to a neighbouring room where they are forced to their knees and shot in the back of the head. Their families will only be informed days or sometimes weeks after the execution that their relative has been executed.

You can send an e-mail to President Lukashenka calling for clemency for Vasily Yusepchuk.