Friday, October 28, 2011

Querying with a Python script

I have written a Python script/module to query the spectral line catalog compilation. It does not rely on any SPLAT-VO protocol at all. It queries the database through the normal web interface, which makes it possible to query with the same parameters as through the web interface. Yay! The instructions below is for Ubuntu Linux, but is probably easily adapted to other platforms.

EDIT2: I have rewritten the module and the updated version is now part of astropy.astroquery ( However, the CLI interface is stripped out of this version. Furthermore, according to, the php interface will be replace by a java onlye sometime this year (, see Milestone no 4.) which would mean that I have to update it.  
The code is hosted on my trunk (bazaar versioning):

EDIT: I have moved my code to github (!)

the file splatsearch (.py, in the "bin" folder on github) is all that is needed from Launchpad. The prerequisite modules are UrlLib2 and ClientForm, for the form submission/HTML parsing.

In Ubuntu the ClientForm ( module is installed by running

sudo apt-get install python-clientform

in a terminal. UrlLib should come packed with Python. There is a plan to move the splatsearch script over to use some newer module, like the Mechanize module (

EDIT: Mechanize now actually takes care the clientform and urllib (linked) part. I haven't had time to move the script over to it yet. (Branch and fix perhaps?)

It is runnable from the command line (set it to be runnable "chmod +x"). After this, running --help

without any input, from the terminal should give you the usage rundown. Although, first you have to add the path to to your environment variables. Alternatively run it from the same catalog as the file with:

./ [parameters]

It can also be used inside your favorite Python script/interactive session with:

Python : from splatsearch import splatsearch

Yes, I guess it is bad programming to name them the same (module and function). After this initial import it is easy to get the idea of how to search and get it to return what/how you want (print on screen, list or dictionary) with:

Python : help splatsearch

My page also hosts other astronomical data analysis and visualization scripts to do different things on interferometric spectral cubes (small FOV, <60 arcsec). The ADAVIS module has e.g. a function for plotting spectrum and at the same time fit Gaussians, take the fitted frequencies and query for line identification. It is far from done though, and I have a huge to-do list of things to fix, but most things work well enough.

 Happy line identification!

Thursday, October 6, 2011

Interoperating GILDAS and MIRIAD, attempt 1

EDIT: There is a guide for interoperating GILDAS and MIRIAD here : 

I am now trying to work with data from the Submillimeter Array (SMA), calibrated in IDL with the MIR package, continuum subtracted in MIRIAD, exported to UVFITS and read in to GILDAS for imaging. Yes, it is a mess.

It kind of works. Except the RMS noise somehow is 10-15% higher for the imaged data in GILDAS than for the same uv-data and same RMS channels in MIRIAD. Why? I do not know, but I have now resorted to work only in MIRIAD with the MIR calibrated data. I will conduct my normal analysis there, and output a FITS file of the cleaned data to work with my own scripts for creating various maps and spectra.

The best would be if I could write/use some Python modules for fitting Gaussians in the uv-plane as well, so I could finally break free of the dependence of MIRIAD/GILDAS/CASA/whatever package that is used at telescope X.