I am trying to contour some data plots, and am running into an exception (it's a divide by zero problem, but I don't see how it's coming about). I read in a 3D grid then plot 2D slices of it. The program works for about 5 slices, then throws the exception. My relevant code is:
figure()
im = imshow(gridslice, interpolation='bicubic', origin='lower',\
cmap=cm.hot, extent=dims, vmin = min_val, vmax = max_val, alpha=1)
levels, colls = contour(gridslice, \
arange(min_val,max_val, (max_val-min_val)/5),\
origin='lower', linewidths=3, alpha = 1, extent=dims)
clabel(colls, levels, inline=1, fmt='%1.2f', fontsize=12)
Traceback (most recent call last):
File "./dx_slice_contours.py", line 64, in ?
MakeContours('1_my_var.dx')
File "./dx_slice_contours.py", line 56, in MakeContours
clabel(colls, levels, inline=1, fmt='%1.2f', fontsize=12)
File "/sw/lib/python2.4/site-packages/matplotlib/pylab.py", line 1737, in clabel
ret = gca().clabel(*args, **kwargs)
File "/sw/lib/python2.4/site-packages/matplotlib/axes.py", line 1245, in clabel
return self._contourLabeler.clabel(*args, **kwargs)
File "/sw/lib/python2.4/site-packages/matplotlib/contour.py", line 186, in clabel
self.inline_labels(levels, contours, colors, fslist, fmt)
File "/sw/lib/python2.4/site-packages/matplotlib/contour.py", line 399, in inline_labels
x,y, rotation, ind = self.locate_label(slc, lw)
File "/sw/lib/python2.4/site-packages/matplotlib/contour.py", line 370, in locate_label
dist = add.reduce(([(abs(s)[i]/L[i]) for i in range(xsize)]),-1)
OverflowError: math range error
I know that abs(s)[i] = is an array of zeros, L[i] = 0, and xsize = 1 at this point.