Tuesday, July 1, 2014

Weeks 5+6

You know that feeling when you think a task is going to be super hard but once you get to it, it turns out to be easier than you expected? And once you've finished it, you feel like you're the best programmer ever? I've been on that high for the past few days so I think I'll make a blog post while the feeling lasts.

Over the past two weeks or so I've been working on three tasks. The first thing I worked on was to implement different coordinate systems into WCSAxes. Previously, WCSAxes only allowed users to convert coordinates to the systems FK5 and Galactic but since there are a lot more coordinate systems out there, WCSAxes should be able to handle them. Like I said, this turned out to be pretty easy. The hardest part was probably refactoring the code to make it clean and efficient, but other than that I just had to use the Astropy method 'lookup_name' method to look up the correct coordinate class. Although, since this method is only available for Astropy 0.4, someone using WCSAxes with older versions of Astropy is limited to the old coordinate systems.

The second thing I worked on was a bug with the way axis labels were positioned on images. Previously, WCSAxes always tried to place axis labels as close as possible to the axis without intersecting with the tick labels.

but if the tick labels are in the way, it pushes the axis label further away
This could get annoying in certain situations and people preferred that axis labels always be positioned below the tick labels, whether or not they intersect. I had to read up on matplotlib's code to figure out how they position labels and tried to implement a similar way. It was a bit tricky since Matplotlib and WCSAxes handle ticks, labels and axes very different but luckily I was able to figure it out! And the results are

See? The axis label is now below the tick label by default! Users now also have the ability to adjust the padding of the axis label so they can move it as close or far away from the axis as they wish :)

The third thing that I've been working on is writing a wrapper for the package APLpy that uses WCSAxes. There are several packages out there that are used to plot astronomical images and one of them is APLpy, a package that my mentor helped write. The way APLpy does the actual plotting of images isn't all that great so we're trying to write a wrapper for it that uses WCSAxes to do the actual plotting, which will allow people to still use the package. So far work on the wrapper has been going good and I haven't hit any major roadblocks. Hopefully it'll continue to be this straightforward - or maybe not, things get interesting when they don't go the way you expected them to.

Now what I'm really excited about is the first release of WCSAxes! The package is almost ready for release except for one tiny feature I have to add. The sooner I finish this post, get to actual work and finish my task, the sooner we can do our first release! 

No comments:

Post a Comment