Monday, August 24, 2009

compiling sherpa for standalone python

Download tarball from hea-www Sherpa Home and compile.

Here is sample setup.

#! /bin/sh

python \
xspec_library_dir=/usr/astro/heasoft/i686-pc-linux-gnu/lib \
reg_include_dir=$CIAO_INC \
reg_library_dir=$CIAO_LIB \
wcs_include_dir=$CIAO_OTS_INC \
wcs_library_dir=$CIAO_OTS_LIB \
cfitsio_library_dir=$CIAO_OTS_LIB \
install --prefix=$HOME/local

But the import will give a few warnings, which is not very critical though.

  • You need to copy from $CIAO_LIB to somewhere in you library path.
  • A tricky part is group module, and ore about it later.

Saturday, August 22, 2009

Creating a color bar using inset axes

An example to create an inset axes outside the axes area, and use it as a colorbar axes.

import matplotlib.pyplot as plt

from mpl_toolkits.axes_grid.inset_locator import inset_axes

fig = plt.figure(1, [5.5, 3])

# first subplot
ax = fig.add_subplot(111)

axins = inset_axes(ax,
width="5%", # width = 10% of parent_bbox width
height="50%", # height : 50%

# Unfortunately, inset_axes currently ignores bbox_to_anchor and
# borderpad parameters, which is a bug.
# As a workaround, set these values after axes creation.

locator.set_bbox_to_anchor((1.05, 0, 1, 1), ax.transAxes)
locator.borderpad = 0.
# Controlling the placement of the inset axes is basically same as that
# of the legend. you may want to play with the borderpad value and
# the bbox_to_anchor coordinate.

im=ax.imshow([[1,2],[2, 3]])
plt.colorbar(im, cax=axins)


Friday, August 14, 2009

A few new things in MPL svn


Similar to AxesImage, but image occupies the area specified by the bbox parameter.

example 1 :

example 2 : - making the image on the fly


similar to annotation, but works with OffsetBox instead of text. Can be used to place a BboxImage(e.g., clip art image) or a TextPatch object (see below)

example :


A patch class with outline of the text. I'm still experimenting with the api and It is currently included as an example.

example :


a simple framework for image filtering effects (only for agg backend).

example :