Monday, June 21, 2010

New STSCI Python package (2.10)

Those who updated Ubuntu from version 9.10 (Karmic Koala) to 10.04 (Lucid Lynx) might have noticed that Python 2.5 is not available in the new default repository. This is a big issue for the users such as the users of the Space Telescope Science Institute Python packages (PyRAF, MultiDrizzle, etc...) or some older google engine apps.

Fortunately a new version of the stsci_python is out today! With full support to Python 2.6 (3.0 will take longer).

http://www.stsci.edu/resources/software_hardware/pyraf/stsci_python/current/download

Update (21/06)

Some may have the following error when importing the iraf modules using
from pyraf import iraf
File "", line 38
iraf.set(as = 'host$as/')
^
SyntaxError: invalid syntax
/usr/local/lib/python2.6/dist-packages/pyraf/irafimport.py:54: RuntimeWarning: Parent module 'pyraf' not found while handling absolute import
return _originalImport(name, globals, locals, fromlist, level)


To fix it the trailing slash on the /iraf/iraf/unix/hlib/zzsetenv file on line 38 should be removed. Everything runs smoothly.

Saturday, June 19, 2010

Practical spell checker: aspell

aspell is a practical spell checker available for Linux and Mac OS X. It is installed by default on most linux distros. You can get it in mac using MacPorts/Fink. aspell goes through your document, asking to replace words that it suspects are wrong.

I used it a few days ago to spell check a paper of mine before submitting. It has different modes, for instance a TeX mode. Here is how you call it to spell check a latex document written in english:
aspell check -l en --mode tex paper.tex

How to spell check a document in brazilian portuguese:
aspell check -l pt_br test.txt

Try it, it is very easy to use.

Friday, June 18, 2010

Google CL is amazing

This post was done using only the *NIX command line using the googlecl (http://code.google.com/p/googlecl/) tool. Try it

Wednesday, June 2, 2010

Vim tricks for Python programmers

Hi there, as many of my friends know I am a Vi enthusiast. The truth is that I am just faster using Vi than using the mouse in any graphical editor. I know many of *NIX users would agree with me when it comes to command line vs. clicking.

This post is for Vi users that may find frustrating programming Python without a mouse cursor to help on indentation and block selection. The tricks are to set these environmental variables on Vi:

autocmd BufRead *.py \
set expandtab \
set tabstop=4 \
set shiftwidth=4 \
set smarttab \
set softtabstop=4 \
set autoindent \
set textwidth=110
autocmd BufRead *.py set smartindent \
inwords=if,elif,else,for,while,try,except,finally,def,class

So if you put this on your ~/.vimrc you should get a Vi that is Python friendly every time you edit a *.py file.

Essentially these options will make tabs become 4 spaces and add auto-indentation after keywords of python (if, while, do, try, etc...). For more info on each command type on Vi ':help '

Have fun!
 
Locations of visitors to this page