Sunday 21 July 2013

GSoC-Week5

Time flies! As this post marks the fifth(!) week of GSoC, I can't help feeling how true this (albeit hackneyed) saying is! So here goes the progress for this week:

This week resulted in one more PR with the NED web service. There are finishing touches to be added and docs to be done but apart from that the PR can now be seen here.

Since Astroquery is basically about querying web services, it involves writing methods to fetch various astronomical data such as spectra, images, astronomical references, etc. Most of these queries require similar arguments such as the object we are interested in querying, in addition to some query specific arguments that are relevant only to a particular kind of query. So what I had been doing is write a separate method for each of these queries. This led to quite some repetition also blowing up the code base. My mentor suggested that a better way to achieve the same thing would be to write a common method for all these queries, with optional keyword args that were relevant to specific query types. So for instance initially while I had
def get_positions(*args, **kwargs):
    # code

def get_diameters(*args, **kwargs):
    #code

...
after the refactor the effect was now similar to
def get_table(object_name, table='positions', **kwargs):
    #code


So now all the common arguments are abstracted out, and the optional specific to each query type just go into **kwargs. Amazingly this cut down the code by 455 sloc at the cost of adding 129 sloc. Awesome!. The specific commit pertaining to this is here

The next module coming up is IRSA. Of course most of this is tidying up converting functions to class methods, etc... Also we'll be adding an interface to the ATLAS service which is available under IRSA. This should add functionality to access several image services, apart from the NED images...

PS I am now using Syntax Highlighter for code snippets since gists may be troublesome for RSS readers.

No comments:

Post a Comment