Surveying the Universe
Archive for June, 2012
Authors list script
11 Jun 2012
One of my most important roles within HerMES has been to generate the LaTeX for the lists of authors and affiliations in the astronomy journal papers (previous posts here and here). HerMES is a big consortium, so some of the papers have something like 100 authors (with each author contributing, say, 10 or 20 words, and the first author having the job of putting them in the right order). When the list of authors is determined by complicated rules of the consortium, and when each author has to be associated with one or more institutes, with the correct superscript numbers after their names, and everything in the correct order, then having a script to do that for you can save a lot of time.
As part of my new GitHub spree, I've made my HerMES authorship script more presentable, and it's now freely available for all the world in the authors_list repository. Just download the files, use the "authors_data" template to fill in the names and institutes of the members of your consortium, then follow the instructions in the usage message for the "authors_list" script. It's written in Python, but runs as a command-line script. So far, it can produce output for MNRAS, A&A and ApJ, but it wouldn't take a Python wiz to adapt it for other journals.
Feedback and improvements to the script are welcome!
pIDLy on GitHub
7 Jun 2012

I thought I'd better figure out what Git and GitHub are. Git is a revision control system, enabling you to keep track of changes to computer software (for example). GitHub is a web-based hosting service for Git repositories. (The GitHub logo is the "octocat", by the way.)
It's all very simple to use too. My python/IDL interface, pIDLy, is now on GitHub, and it wasn't hard to set things up.
One of the points of GitHub is to make sharing and collaborating easier. So I'm kind of hoping that someone out there will want to do some work improving pIDLy, seeing as I'm spending most of my time on Java these days. I do get occasional emails from pIDLy users, so it is being used. But it's still quite easy to break it... The latest version on GitHub should be very slightly better than version 0.2.4, which I made four years ago and haven't touched since.
Aspect-oriented programming
1 Jun 2012
That's right, not object-oriented, but aspect-oriented. What's that all about then?
Computers store data, and computer programs do stuff to the data. You can write computer programs in that way: basically as a list of things to do to some data. But those programs end up very messy (as I know from experience!). So we need a better way of representing what is going on.
Enter object-oriented programming (OOP). We represent what is going on under the surface in terms of objects. An object is the basic unit of a program. It hides (encapsulates) some data, and if you ask it nicely, it will do something and tell you what you need to know. A computer program is now a collection of objects that interact with each other to perform some complex task. This is much better, as the software developer can focus on crafting elegant objects (or, more accurately, kinds of objects, or classes). If these are well designed, the program will be robust, and you can change little bits of it without worrying that the whole thing will break.
But wait: what if we can't represent all that a program needs to do in terms of individual objects? What if there are some concerns that are relevant for every element of the program? For example, a typical program might be littered with statements dealing with logging, security, or handling errors. These are concerns that cut across the basic functionality of a program.
Enter aspect-oriented programming (AOP). This provides a way of separating out those cross-cutting concerns into separate aspects, which provide additional commands to be executed at particular points (or particular kinds of points) in the program execution.
I'm going to give it a try with the Java development I'm working on. I'll let you know how it goes. It should be useful for testing, allowing me to keep track of how many times a particular method is executed, what the values of the parameters are, how much time is spent on different steps, and what is making it go wrong, for example.
Fortunately, it's dead easy to get started. For Java, the most widely-used AOP extension is AspectJ. If you have a Java project in Eclipse, simply install the AspectJ Development Tools plugin, convert the project to an AspectJ project, and that's it. Here's "Hello world" using an aspect:
public class HelloWorld { private void sayHello() { System.out.println("Hello"); } public static void main(String[] args) { new HelloWorld().sayHello(); } } public aspect World { pointcut greeting(): execution(* HelloWorld.sayHello(..)); after() returning: greeting() { System.out.println("World!"); } } |
The sayHello method executes, and then the aspect interrupts the execution and prints "World!".
Part of the attraction of AOP to me is that it has resonances with the philosophy of Herman Dooyeweerd, who worked on a model of reality called the Theory of Aspects, in which the whole of reality can be described in terms of (around) 15 (cross-cutting) aspects. In fact, I first heard of AOP via Andrew Basden's page on the topic.
I live in York and I