Monday, August 24, 2009

compiling sherpa for standalone python

Download tarball from hea-www Sherpa Home and compile.

Here is sample setup.


#! /bin/sh
CIAO=/usr/astro/ciao-4.1
CIAO_OTS=/usr/astro/ciao-4.1/ots
CIAO_LIB=$CIAO/lib
CIAO_INC=$CIAO/include
CIAO_OTS_LIB=$CIAO_OTS/lib
CIAO_OTS_INC=$CIAO_OTS/include

python setup.py \
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 libregion.so 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)
ax.set_aspect(1.)

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

# 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=axins.get_axes_locator()
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)

plt.draw()
plt.show()

Friday, August 14, 2009

A few new things in MPL svn

[BboxImage]

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

example 1 : demo_bboximage.py



example 2 : demo_ribbon_box.py - making the image on the fly



[AnnotationBbox]

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 : demo_annotation_box.py


[TextPatch]

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

example : demo_text_path.py


[agg_filter]

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

example : demo_agg_filter.py

Followers