Non-printable characters and ASCII with IDL

Sometimes it is necessary to use non-printable characters in a string or special characters such as the ‘ and ” that normally denote a string in IDL. It is easy to do so by referring to the correct byte presentation using the string() function.

For example to put in a tab: string(9B)

The apostrophe ‘: string(39B)

The quotation mark “: string(34B)

The other ASCII characters can be found here: http://en.wikipedia.org/wiki/ASCII – use the Dec. column

Tcl/tk error in python

In python, if the tcl package is not compiled with the threads option, if it runs a tcl/tk application, it will crash with the following error at the end:
TclError: out of stack space (infinite loop?)

To reproduce this, just run the pydoc.gui() program:

import pydoc
pydoc.gui()

This problem will affect pyraf and prevent it from loading. To fix this, compile the tcl package with --enable-threads or in macports, install the thread variant: port install tcl +threads.

Removing the frame from legends in matplotlib

One of the features of the legends from matplotlib that can be distracting is the black borders around every legend. To remove them, or to change other properties of the frame, you can use the get_frame() function and adjust the properties of the legend. For example:


leg = legend()
leg.get_frame().set_alpha(0) # this will make the box totally transparent
leg.get_frame().set_edgecolor('white') # this will make the edges of the border white to match the background instead

More info about changes to legends can be found here: http://matplotlib.sourceforge.net/users/recipes.html

Downgrading SVN directory to work with older client

If an SVN command is used on any file, it will automatically upgrade the directory to the most recent version of SVN. This will result in the error: This client is too old to work with working copy

The way to fix this is either to upgrade the client, or to downgrade the directory to a previous version. This can be accomplished using the script change-svn-wc-format.py from http://subversion.apache.org/faq.html#working-copy-format-change

To use this script: change-svn-wc-format directory version, where version is the SVN version (1.4 or 1.5). For more help, type: change-svn-wc-format --help

Using ipython mode in emacs

Using ipython in emacs is very useful because of the advantages in debugging and having everything in one environment. To do so, just download http://ipython.scipy.org/dist/ipython.el

To use, add the following lines in your .emacs file:

(add-to-list 'interpreter-mode-alist '("python" . python-mode))
(require 'ipython)
(setq load-path (cons "~/directory with ipython.el/" load-path))
(setq ipython-command "path to/ipython")

To start the ipython shell, use C-c ! from a .py file or from the menu bar. Shortcut to run the .py file C-c C-c or C-c RET.

By default, to scroll up and down the history for ipython is ctrl+up or ctrl+down, but can be changed to just up and down using:


(require 'comint)
(define-key comint-mode-map [(up)]
'comint-previous-matching-input-from-input)
(define-key comint-mode-map [(down)]
'comint-next-matching-input-from-input)

More instructions can be found here and here.