Wednesday, October 24, 2007

Beamer on MikTeX

Need xcolor and pgf for the new beamer to run. MikTeX kept failing on pgf install. Led to discovery of problem with MikTeX 2.6 and LZMA compressed package archive files. Had to update just the miktex-bin, then update the rest to get the latest package manager. Remember, don't have package manager and updater running at the same time - they access some same files and can lock each other out on windows.

MikTeX on vista

MikTeX works fine on vista, except on occasion if I don't run package manager as root I get a com surrogate error. I just start package manager as root (run as administrator) to get around this problem.

Monday, October 22, 2007


t = mlab.Title()
t.text = 'Blah'
t.text_actor.height = .1

#see all traits using

Saturday, October 20, 2007

Odd error with mlab and lighting - TVTK

Is there a time delay to the lighting manager being instantiated when a figure is set up?

In ipython the following lines work fine

fig = mlab.figure(browser=False)

But this doesn't

fig = mlab.figure(browser=False);fig.renwin.light_manager.lights[0].move_to(0,-45)

In the noninteractive mode (i.e. running a script as opposed to typing in commands in the shell) even the first version does not work. I tried inserting a delay (time.sleep()) but that does not help

l = light_manager.CameraLight(fig.renwin)

Figure properties - TVTK

fig.renwin.off_screen_rendering = True #allows you to minimize the window and keep drawing/saving to file

.light_mode = 'vtk' or 'raymond'

light[0] seems to be the important one. azimuth , elevation, with 0 elevation being right over head

The rendering properties (size etc.) are controlled from

.aa_frames =

.size = array([width, height]) OR
.set_size(width, height)

fig.renwin.show_axes = True #turns on the little axis orientation indicator

Some important properties - TVTK

(For how to access object properties see this post)

fig = mlab.figure(browser = False)
s = mlab.Surf(x,y,z)


.representation =
  • 'w' wireframe
  • 's' surface
.opacity = 0...1
.interpolation =
  • 'flat'
  • 'gouraud'
  • 'phong'
.ambient = 0...1 #uniform (direction independent) lighting on surface
.color = [r,g,b]
.specular = 0...1
.specular_color = [r,g,b]
.specular_power =0...1

Save figure to bitmap - TVTK'tada.png', size = (200,200)) 
#save the figure to png with stated size

view manipulation - TVTK

You have to manipulate the camera which is a
enthought.​pyface.​tvtk.​decorated_scene.​DecoratedScene object

if fig is a figure window handle returned from mlab.figure() rotate scene by .. degrees rotate scene by .. degrees zoom in/out

remember to call fig.renwin.render() to see the changes

Setting surface rendering properties - TVTK

From a hint here

import scipy

x = scipy.arange(-7., 7.05, 0.1)
y = scipy.arange(-5., 5.05, 0.1)

[X,Y] = scipy.meshgrid(x,y)
Z = 3.0*scipy.sin(X*Y+1e-4)/(X*Y+1e-4)

from import mlab
fig = mlab.figure(browser = False)
s = mlab.Surf(X, Y, Z)

act = fig.objects[1].actors[0] #object[1] is the surface, it has one actor, which turns out to be a surface = 'w' #make it a wireframe = 's' #turn it back to a surface!

Friday, October 19, 2007

Plotting irregularly spaced data - MATLAB griddata

From this site:

xmin = min(a(:,1));
ymin = min(a(:,2));
xmax = max(a(:,1));
ymax = max(a(:,2));
xi = xmin : 0.02*(xmax-xmin):xmax;
yi = ymin : 0.02*(ymax-ymin):ymax;
zi = griddata(a(:,1), a(:,2), a(:,3), xi', yi);
surf(xi, yi, zi)

You can do this in matplotlib too, but its not built in. See this post

Thursday, October 18, 2007

Getting mlab/ivtk/mayavi to work

  1. Download and run Enthought Enstaller.
    It pulls of various things from Enthought's website and installs them in the site-pacages etc. Crucially it will put enstaller.exe under \python25\Scripts
  2. Run enstaller.exe
  3. In the GUI tab to repositories and check Mavavi, VTK, enthought.traits, enthought.tvtk, wxPython
  4. click install packages
  5. change ipython to run with wthread commandline option (ipython -wthread)
  6. follow any number of examples from the cookbook for mlab

from import mlab
fig = mlab.figure(browser = False)
mlab.test_surf(fig) #a built in test function for a nice looking surface

t = mlab.Title()#add a title object
t.text = 'Ha'

fig.pop() #remove the last added object (in this case the title) ='tada.png') #save the figure to png

Useful links:

Tuesday, October 16, 2007

Memory leaks in matplotlib

On windows, with Python 2.5 matplotlib has a memory problem using the default tk backend. Say I have to generate 100 figures in succession, dumping each to a file because I want to create and animation from them. Using tk the memory consumption just keeps increasing. The trick is to use the agg backend for such tasks (see this post). The agg backend does not have this memory leak.

Sunday, October 14, 2007

Lucid dreams

I should try out reporting from dreams by training myself to dream lucidly. Hopefully my reports will be a little more interesting than this (xkcd).

Saturday, October 13, 2007

Archery at UMD

At the range today I ran into two fellas from the University of Maryland who are taking the initiative to start a Archery club at the university. About time !

Information about the group can be found at

A note on the bow stringer

The bow stringer I have came with instructions to step on the string with both feet about shoulder width apart. I didn't understand why, especially since some instructions elsewhere (and here) say to stand on the string with one foot. Today I think I figured out why, at least with my bowstringer.

The cup, which covers the upper tip, into which you are trying to slide the bowstring, has a tendency to cover the tip more and more closely, eventually pinching off the notch in the tip into which you need to slide the bowstring.

By standing with your feet apart, you cause the tension in the string to act more perpendicularly to the limb, and so the cup is less likely to slide inwards and cover the notch.

If you stand with only one foot on the stringer, or with feet close together, the string makes a shallow angle with the limb. This pulls the cup more tightly onto the tip, sliding it over the notch.

An additional benefit is that you are causing less tension in the bowstringer.

(Note that the bowstringers in the links do not have a cup that goes on the upper tip - they have a saddle, that you place over the limb. This difference in design probably accounts for the difference in optimum technique.)

Thursday, October 4, 2007

Ditching blender for Alibre free edition

Ok, either I am doing something wrong or Blender really has a problem with stl export. When I export my models to stl I can load the models just fine in Myriad 3D viewer , but when I load them in Zcorp's Zprint the normals are wrong and they show up as wire frames and not solid models. Hyunyoung from the fab-lab suggested I try out Alibre Design Xpress, which is a free version of their CAD software. I got it to work with minimum hassle. The only thing I could not figure out how to do was sketch elipses!

I needed the latest JVM