Sunday, November 25, 2012

Code release: GFFT

This week I released a new Python package to the world. It's called GFFT (General Fast Fourier Transformation) and what it does is it makes applying (relatively) fast Fourier transformations to a wider class of data much simpler.

Fast Fourier transformation in Python is pretty simple in many circumstances already. Just use the Numpy FFT and you're all set, right? Well, that's true if you have data that is regularly sampled, e.g. you've repeatedly made some measurement exactly once every second. But what if your measurements are taken at irregular intervals? Or what if you need to do a lot of phase shifts because your data doesn't start at the origin of whatever coordinate system on which it is defined?

Well, these are both situations that I and others in my group face quite often, and we found that we were using similar pieces of code again and again in a variety of projects. So Henrik Junklewitz and I developed GFFT to make life a bit simpler. The features of GFFT include:

  • Fast Fourier transformations of data defined on, and being transformed to, arbitrarily defined coordinate spaces including:
    • regular to regular
    • irregular to regular
    • regular to irregular
    • irregular to irregular
  • Fast transformations, even when working on irregular spaces, thanks to the included gridding algorithm.
  • The gridding code is implemented in C (via Cython), so it's fast.
  • When working with irregular to regular space transforms, you can store irregularly sampled Hermitian symmetric data in an efficient way... just store half of the data and the symmetric parts will be generated internally.
  • Automatically handles arbitrary phase shifts of the input and output data if they are not defined on axes that start at the origin.
Interested? Check out the project on GitHub: http://mrbell.github.com/gfft/

Please note that as of now the package is in beta, and a major revision is already underway (see the rewrite branch in the git repository). The revision will clean up the code base significantly (it's almost embarrassingly sloppy right now, but you know how it goes when you develop code for scientific applications...) and will make the interface more intuitive. So if you start using GFFT immediately, just be aware that we are planning to fundamentally change the interface soon and future updates may break your code (we'll put in a deprecation warning first...). Things will stabilize soon. Until then, try it out and let us know what you think!

Friday, November 23, 2012

New submission: Improving CLEAN for rotation measure synthesis

This week we submitted a new paper to A&A where we suggest a method for improving CLEAN images in the context of RM synthesis. The method allows one to make lower resolution images while obtaining better results than when using CLEAN alone and moreover it makes the results much less dependent on the choice of pixelization.

What we and many others have found is that RMCLEAN doesn't do such a great job at reconstructing the locations or fluxes of sources, especially when there are several of them close together. When writing the 3D CLEAN algorithm for Faraday synthesis we noticed that RMCLEAN doesn't even do that great with a single source unless it is located directly in the middle of an image pixel. The dynamic range in a CLEANed image is well-known to be limited due to the fact that you can't exactly model the location of a source in a pixelized image. You can partially overcome the issue by making the image have very high resolution, but especially for 3D imaging this becomes expensive both computationally and in terms of storage.

So we looked into this in a bit more detail, and devised a method for improving the CLEAN generated model using maximum likelihood (ML) estimation. The method is similar to others that have been suggested for aperture synthesis imaging. but it seems to have even more impact in the case of RM synthesis. In our testing, we found that the ML method dramatically reduces the error in measurements of both source location and flux. Somewhat surprisingly, we also found that increasing resolution doesn't reduce the errors in normal CLEAN images in the case where two sources are nearby to one another. However, he ML algorithm was able to get accurate results in such a case even in a low resolution image.

Ultimately we don't think that CLEAN (or any method that assumes the signal to be diagonal in pixel space) is the right approach in all cases, and we're actively working on new methods that take advantage of correlated structures in the data to help constrain reconstructions. Nevertheless, CLEAN is undoubtedly a useful algorithm in some circumstances, and together with this new algorithm it can give rather good results while being easy to implement and (relatively) computationally inexpensive.

The pre-print is available now on the arXiv. Give it a read if you want to learn more. And if you're interested in implementing the method for your own analysis, then be sure to stay tuned because I plan to release the code for this relatively soon.