Tuesday, October 19, 2010

Is my object in your footprint? The XSLT solution

How can you tell whether a particular astronomical position is within the bounds of a particular survey? Obviously you use the JHU footprint service which supports queries both from your browser via a form and programmatically via web services.

Now the nice thing about the latter option is that there is an HTTP GET binding which means that you can just call a particular URL and get back an answer, albeit in XML form. Of course, you've still got to parse the XML and extract the information you want and this can often be messy.

One (particularly elegant IMHO) solution is to use an XSLT stylesheet to manage the whole process. It's a little realized feature but XSLTs can make external HTTP GET calls via the document() function:

<xsl:variable name="response">
   <xsl:copy-of select="document(someURL)" />
</xsl:variable>

This can then be processed by the XSLT to produce whatever output you desire.

To illustrate this, I've written a little XSLT that takes the RA and Dec you're interested in and then outputs the surveys returned together with a 'Yes' or 'No' response as appropriate.

If you want to use xsltproc to run it then you'll need the XSLT 1.0 version:

> xsltproc -stringparam ra 23 -stringparam dec 45 -stringparam survey all footprint_1.0.xsl footprint_1.0.xsl


The name of the XSLT needs to be repeated to foolxsltproc into thinking that it's processing a file.

If you're happier with saxon then use the XSLT 2.0 version:

> java -jar saxon9.jar -it main footprint_2.0.xsl ra=163 dec=2.3 survey=all


Either way the output is the same:

SDSS DR4 PhotoPrimary: Yes
GALEX GR2 MIS Primaries w/ R=36': Yes
2dF survey bounds from S Maddox 27 May 1997: No
GALEX GR2 AIS Primaries w/ R=36': Yes
SDSS DR5 PhotoPrimary: Yes
UKIDSS LAS: Yes
HST ACS WFC, Sept. 2006: Yes
PS1 3PI (2007-04-04): No
GALEX GR3 AIS Primary w/ R=36': No
SDSS DR6 PhotoPrimary: No
SDSS DR6 SkyBox: No
VLA FIRST Survey: No
sdss dr6 + galex mis: Yes
PS1 3PI Arch Fix: No
GALEX GR5 MIS Primary w/ R=36': No
GALEX GR5 MIS Primary w/ R=30': No
SDSS DR7 Legacy PhotoPrimary: No
SDSS DR6 + FIRST : No
My SDSS DR7: No
SDSS + PS1 MDS: No

Obviously this technique can be used to call any web service which supports a HTTP GET binding.

Friday, October 15, 2010

Installing Diaspora on a Mac

Eli Bressert (@astrobiased) tweeted today that he had managed to get Diaspora, the pre-alpha open-source social networking app, running on a Mac following these instructions. I decided to give this a go this evening and found that I had to make some amendments to get it to install and run OK on my MacBook Pro running 10.6.4. So here's my version:

1. Get the source:
git clone http://github.com/diaspora/diaspora.git

2. Install Homebrew:
curl http://gist.github.com/raw/323731/install_homebrew.rb > install_homebrew.rb
ruby -e install_homebrew.rb

3. Install MongoDB:
brew install mongo
(Note: I use MacPorts and Homebrew will warn that using this and Fink could cause problems at runtime)

4. Install ImageMagick:
brew install imagemagick
(This did not work on my Mac but I already had a version of ImageMagick installed)

5. Make sure GEMS is up to date:
sudo gem update --system

6. Get the bundler:
sudo gem install bundler

7. Switch to the directory where github dumped the diaspora tree:
cd diaspora
bundle install

8. Start Mongo:
mongod run --config /usr/local/Cellar/mongodb/1.6.3--x86_64/mongod.conf
(This is a slightly newer version that Eli's instructions were written against - 1.6.2-i386)

9. Start the app server:
bundle thin exec start
(The diaspora installation instructions at github start the server instead with: ./script/server)

10. Seed the db with some info:
rake db:seed:dev
(Eli's notes say to use 'rake db:seed:tom' but the github instructions say that this is for instances managed by capistrano)

11. Point your browser at http://localhost:3000 and login as tom/evankorth