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.

No comments:

Post a Comment