[Matplotlib-users] Fwd:

2013-01-05 Thread David Craig
http://smallshop.lt/gbwpmas.php

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122912
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] histogran2d and polar axis

2012-11-21 Thread David Craig

  
  

  

  
Hi,
  This one has been driving me crazy all day. I have three
  vectors, azimuth, frequency and power, which I would like
  to histogram and plot on a polar axis. I can plot a
  scatter plot this way no problem but the histogram gets
  messed up somehow. An example is below, anybody know how
  to do this properly??
  
  import random
  import numpy as np
  import matplotlib.pyplot as plt
  
  baz = np.zeros((20))
  freq = np.zeros((20))
  pwr = np.zeros((20))
  for x in range(20): 
   baz[x] = random.randint(20,25)*10
   freq[x] = random.randint(1,10)*10
   pwr[x] = random.randint(-10,-1)*10
  
  baz = baz*np.pi/180. 
  
  abins = np.linspace(0,2*np.pi,360) 
  sbins = np.linspace(1, 100) 
  
  H, xedges, yedges = np.histogram2d(baz, freq,
  bins=(abins,sbins), weights=pwr)
  
  plt.figure(figsize=(14,14))
  plt.subplot(111, polar=True)
  #plt.scatter(baz, freq, c=pwr)
  plt.pcolormesh(H)
  plt.show()
  


 
   

  

  

--
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] ginput with undefined number of points

2012-06-07 Thread David Craig

Hi,
I trying to define an area in a pcolor plot (several plots) using the 
ginput(). However since it is an irregular shape and will be different 
in each plot so I cant define how many points there will be before hand, 
I've tried the following but it requires a double click at each point, 
which I would like to avoid as it duplicates points


|x = randn(10,10)
imshow(x)

button = False
points = []
while button == False:
points.append(ginput(1))
button = waitforbuttonpress()
|

Anyone know a better way to go about this??
thanks
Dave

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] basemap and fill_between()

2012-05-13 Thread David Craig
Hi, I'm having a problem usinf fill_between() with basemap. I plot two
great circles and want to shade the region between them. My code is below,
it doesnt give any error just creates the plot without filling the area.
Does anyone know if it's possible to do this or should I try a different
method?
Thanks,
David

from mpl_toolkits.basemap import Basemap
from pylab import *

### PARAMETERS FOR MATPLOTLIB :
import matplotlib as mpl
rcParams['font.size'] = 10.
rcParams['font.family'] = 'Comic Sans MS'
rcParams['axes.labelsize'] = 8.
rcParams['xtick.labelsize'] = 6.
rcParams['ytick.labelsize'] = 6.

def shoot(lon, lat, azimuth, maxdist=None):
Shooter Function
Original javascript on http://williams.best.vwh.net/gccalc.htm
Translated to python by Thomas Lecocq

glat1 = lat * pi / 180.
glon1 = lon * pi / 180.
s = maxdist / 1.852
faz = azimuth * pi / 180.

EPS= 0.005
if ((abs(cos(glat1))EPS) and not (abs(sin(faz))EPS)):
alert(Only N-S courses are meaningful, starting at a pole!)

a=6378.13/1.852
f=1/298.257223563
r = 1 - f
tu = r * tan(glat1)
sf = sin(faz)
cf = cos(faz)
if (cf==0):
b=0.
else:
b=2. * arctan2 (tu, cf)

cu = 1. / sqrt(1 + tu * tu)
su = tu * cu
sa = cu * sf
c2a = 1 - sa * sa
x = 1. + sqrt(1. + c2a * (1. / (r * r) - 1.))
x = (x - 2.) / x
c = 1. - x
c = (x * x / 4. + 1.) / c
d = (0.375 * x * x - 1.) * x
tu = s / (r * a * c)
y = tu
c = y + 1
while (abs (y - c)  EPS):

sy = sin(y)
cy = cos(y)
cz = cos(b + y)
e = 2. * cz * cz - 1.
c = y
x = e * cy
y = e + e - 1.
y = (((sy * sy * 4. - 3.) * y * cz * d / 6. + x) *
  d / 4. - cz) * sy * d + tu

b = cu * cy * cf - su * sy
c = r * sqrt(sa * sa + b * b)
d = su * cy + cu * sy * cf
glat2 = (arctan2(d, c) + pi) % (2*pi) - pi
c = cu * cy - su * sy * cf
x = arctan2(sy * sf, c)
c = ((-3. * c2a + 4.) * f + 4.) * c2a * f / 16.
d = ((e * cy * c + cz) * sy * c + y) * sa
glon2 = ((glon1 + x - (1. - c) * d * f + pi) % (2*pi)) - pi

baz = (arctan2(sa, b) + pi) % (2 * pi)

glon2 *= 180./pi
glat2 *= 180./pi
baz *= 180./pi

return (glon2, glat2, baz)

#Create a basemap around N. Atlantic
m = Basemap(llcrnrlon=-45.0,llcrnrlat=30.0,urcrnrlon=15.0,urcrnrlat=75.0,
resolution='i',projection='merc',lon_0=-17.5,lat_0=60.0)


m.drawcountries(linewidth=0.5)
m.drawcoastlines(linewidth=0.5)
m.bluemarble()
m.drawparallels(arange(40.,75.,10.),labels=[1,0,0,0],color='black',dashes=[1,0],labelstyle='+/-',linewidth=0.2)
# draw parallels
m.drawmeridians(arange(-45.,15.,10.),labels=[0,0,0,1],color='black',dashes=[1,0],labelstyle='+/-',linewidth=0.2)
# draw meridians

# Shade region defined by great circles.
x1, y1 = -9.1676613, 51.602
az1 = 270.
az2 = 290.
maxdist = 2000
x2, y2, baz = shoot(x1, y1, az1, maxdist)
x3, y3, baz = shoot(x1, y1, az2, maxdist)

m.drawgreatcircle(x1, y1, x2, y2, del_s=10, color='gray', lw=1.)
m.drawgreatcircle(x1, y1, x3, y3, del_s=10, color='gray', lw=1.)
a=linspace(x3,x1)
b=linspace(y2,y1)
c=linspace(y3,y1)
fill_between(a, b, c, where=None, alpha=0.2)
show()
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] installing basemap

2012-04-03 Thread David Craig
Hi again,
So I removed everything and started again ( with version 1-0-2 :) )
but am still having trouble, GEOS_DIR seems to be set correctly but I
get the following error when trying to make the GEOS library with,

sudo make; make install

make[3]: Entering directory `/home/davcra/basemap-1.0.2/geos-3.3.1/src'
test -z /home/davcra/lib || /bin/mkdir -p /home/davcra/lib
 /bin/sh ../libtool   --mode=install /usr/bin/install -c   libgeos.la
'/home/davcra/lib'
libtool: install: /usr/bin/install -c .libs/libgeos-3.3.1.so
/home/davcra/lib/libgeos-3.3.1.so
libtool: install: (cd /home/davcra/lib  { ln -s -f libgeos-3.3.1.so
libgeos.so || { rm -f libgeos.so  ln -s libgeos-3.3.1.so libgeos.so;
}; })
libtool: install: /usr/bin/install -c .libs/libgeos.lai
/home/davcra/lib/libgeos.la
libtool: install: /usr/bin/install -c .libs/libgeos.a /home/davcra/lib/libgeos.a
libtool: install: chmod 644 /home/davcra/lib/libgeos.a
libtool: install: ranlib /home/davcra/lib/libgeos.a
libtool: finish:
PATH=/usr/ncl_files/bin:/usr/ncl_files/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/davcra/.local/bin:/home/davcra/bin:/sbin
ldconfig -n /home/davcra/lib
--
Libraries have been installed in:
   /home/davcra/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
 during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
 during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
--
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/home/davcra/basemap-1.0.2/geos-3.3.1/src'
make[2]: Leaving directory `/home/davcra/basemap-1.0.2/geos-3.3.1/src'
make[1]: Leaving directory `/home/davcra/basemap-1.0.2/geos-3.3.1/src'
Making install in capi
make[1]: Entering directory `/home/davcra/basemap-1.0.2/geos-3.3.1/capi'
make[2]: Entering directory `/home/davcra/basemap-1.0.2/geos-3.3.1/capi'
test -z /home/davcra/lib || /bin/mkdir -p /home/davcra/lib
 /bin/sh ../libtool   --mode=install /usr/bin/install -c
libgeos_c.la '/home/davcra/lib'
libtool: install: warning: relinking `libgeos_c.la'
libtool: install: (cd /home/davcra/basemap-1.0.2/geos-3.3.1/capi;
/bin/sh /home/davcra/basemap-1.0.2/geos-3.3.1/libtool  --tag CXX
--mode=relink g++ -DGEOS_INLINE -pedantic -Wall -ansi -Wno-long-long
-ffloat-store -g -O2 -version-info 8:1:7 -no-undefined -o libgeos_c.la
-rpath /home/davcra/lib libgeos_c_la-geos_c.lo
libgeos_c_la-geos_ts_c.lo ../src/libgeos.la )
mv: cannot move `libgeos_c.so.1.7.1' to `libgeos_c.so.1.7.1U': Permission denied
libtool: install: error: relink `libgeos_c.la' with the above command
before installing it
make[2]: *** [install-libLTLIBRARIES] Error 1
make[2]: Leaving directory `/home/davcra/basemap-1.0.2/geos-3.3.1/capi'
make[1]: *** [install-am] Error 2
make[1]: Leaving directory `/home/davcra/basemap-1.0.2/geos-3.3.1/capi'
make: *** [install-recursive] Error 1

any ideas??
thanks
D

On 3/31/12 5:48 AM, David Craig wrote:
 Hi, I previously installed basemap by using the yum command. This
 installed version 0.99.4. I want to install the latest version so I
 can use shaded relief etc. This may be more of a linux problem but as
 I am more familiar with python than linux I thought someone here may
 be able to help.
 Following the website instructions
 (http://matplotlib.github.com/basemap/users/installing.html) I
 downloaded the latest version and untarred it. Then in the basemap
 directory (which contains geos-3.2.0) I try to set the environment
 variable GEOS_DIR to point to the location of libgeos_c and geos_c.h.
 I use the find command to locate the files,
 /find / -name geos_c.h/ returns the location of that file as
 //usr/lib/basemap-1.0.1/geos-3.2.0/capi/geos_c.h/
 and
 /find / -name libgeos*/
 returns
 //libgeos_c_la-geos_c.Plo
 /usr/lib/libgeos-3.3.1.so http://libgeos-3.3.1.so
 /usr/lib/libgeos_c.so.1.7.1
 /usr/lib/libgeos_c.so.1/
 so I set GEOS_DIR to /usr/lib(not sure if this is correct).
 I then cd to the basemap directory and run,
 python setup.py install
 [davcra@... basemap-1.0.1]$ sudo python setup.py install
 [sudo] password for davcra:
 checking for GEOS lib in /root 
 checking for GEOS lib in /usr 
 checking for GEOS lib in /usr/local 
 checking for GEOS lib in /sw 
 checking for GEOS lib in /opt 
 checking for GEOS lib in /opt/local 

 Can't find geos library . Please set the
 environment variable GEOS_DIR to point to the location

[Matplotlib-users] trouble with pcolor

2012-04-01 Thread David Craig
Hi, I am trying to use pcolor to visualise three variables. For example if
I have a value for z at x and a value for z at y something like [x1, x2,
x3] = [z1, z2, z3] and [y1, y2, y3] = [z2, z1, z3]. Then I use meshgrid to
create the grid for x and y,
X, Y = meshgrid(x, y)
the result is two array's of shape (3,3).
I then need to reshape Z to use pcolor, which is what I am having trouble
with. I know I want a result like,

y3  0   0  z3

y2  z1 0   0

y1  0  z2  0

 x1 x2 x3

but have no idea how to create it. Anyone able to help??
thanks
D
--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] installing basemap

2012-03-31 Thread David Craig
Hi, I previously installed basemap by using the yum command. This installed
version 0.99.4. I want to install the latest version so I can use shaded
relief etc. This may be more of a linux problem but as I am more familiar
with python than linux I thought someone here may be able to help.
Following the website instructions (
http://matplotlib.github.com/basemap/users/installing.html) I downloaded
the latest version and untarred it. Then in the basemap directory (which
contains geos-3.2.0) I try to set the environment variable GEOS_DIR to
point to the location of libgeos_c and geos_c.h.
I use the find command to locate the files,
*find / -name geos_c.h* returns the location of that file as *
/usr/lib/basemap-1.0.1/geos-3.2.0/capi/geos_c.h*
and
*find / -name libgeos**
returns
*/libgeos_c_la-geos_c.Plo
/usr/lib/libgeos-3.3.1.so
/usr/lib/libgeos_c.so.1.7.1
/usr/lib/libgeos_c.so.1*
so I set GEOS_DIR to /usr/lib(not sure if this is correct).
I then cd to the basemap directory and run,
python setup.py install

[davcra@David basemap-1.0.1]$ sudo python setup.py install
[sudo] password for davcra:
checking for GEOS lib in /root 
checking for GEOS lib in /usr 
checking for GEOS lib in /usr/local 
checking for GEOS lib in /sw 
checking for GEOS lib in /opt 
checking for GEOS lib in /opt/local 

Can't find geos library . Please set the
environment variable GEOS_DIR to point to the location
where geos is installed (for example, if geos_c.h
is in /usr/local/include, and libgeos_c is in /usr/local/lib,
set GEOS_DIR to /usr/local), or edit the setup.py script
manually and set the variable GEOS_dir (right after the line
that says set GEOS_dir manually here.

The problem seems to be with GEOS_DIR but I am not sure what I should set
it to.
Thanks
D
--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Problem using plot_surface.

2012-03-23 Thread David Craig
Hi, I have three variables I would like to plot using plot_surface but I 
keep getting the error given at the bottom. Anyone know what I am doing 
wrong?? My code is as follows,

fig3 = plt.figure()
ax = Axes3D(fig3)
X = np.zeros((78,1))
Y = np.zeros((78,1))
Z = np.zeros((78,1))
for p in range(len(data)):
 X[p,0] = data[p][1] #distance
 Y[p,0] = data[p][3] #azimuth
 Z[p,0] = data[p][4] #snr
X, Y = np.meshgrid(X, Y)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)


ValueErrorTraceback (most recent call last)

/home/davcra/python_scripts/plot_snr_az.py in module()
  48 Z[p,0] = data[p][4] #snr
  49 X, Y = np.meshgrid(X, Y)
--- 50 surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
  51 #fig.colorbar(surf, shrink=0.5, aspect=5)

  52 #plt.show()


/usr/lib64/python2.6/site-packages/mpl_toolkits/mplot3d/axes3d.pyc in 
plot_surface(self, X, Y, Z, *args, **kwargs)
 616 normals.append(np.cross(v1, v2))
 617
-- 618 polyc = art3d.Poly3DCollection(polys, *args, **kwargs)
 619 if cmap is not None:
 620 polyc.set_array(np.array(avgz))

/usr/lib64/python2.6/site-packages/mpl_toolkits/mplot3d/art3d.pyc in 
__init__(self, verts, *args, **kwargs)
 282 '''
 283
-- 284 PolyCollection.__init__(self, verts, *args, **kwargs)
 285 self._zsort = 1
 286 self._sort_zpos = None

/usr/lib64/python2.6/site-packages/matplotlib/collections.pyc in 
__init__(self, verts, sizes, closed, **kwargs)
 666 Collection.__init__(self,**kwargs)
 667 self._sizes = sizes
-- 668 self.set_verts(verts, closed)
 669 __init__.__doc__ = cbook.dedent(__init__.__doc__) % 
artist.kwdocd
 670

/usr/lib64/python2.6/site-packages/mpl_toolkits/mplot3d/art3d.pyc in 
set_verts(self, verts, closed)
 304 def set_verts(self, verts, closed=True):
 305 '''Set 3D vertices.'''
-- 306 self.get_vector(verts)
 307 # 2D verts will be updated at draw time

 308 PolyCollection.set_verts(self, [], closed)

/usr/lib64/python2.6/site-packages/mpl_toolkits/mplot3d/art3d.pyc in 
get_vector(self, segments3d)
 297 segis.append((si, ei))
 298 si = ei
-- 299 xs, ys, zs = zip(*points)
 300 ones = np.ones(len(xs))
 301 self._vec = np.array([xs, ys, zs, ones])

ValueError: need more than 0 values to unpack
WARNING: Failure executing file: plot_snr_az.py

thanks,
David

--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] 3d plotting

2012-03-18 Thread David Craig
Hi,
I'm using surface_plot to view the results of solving the 2d wave equation.
It works fine (code is below) except I would like to add a color bar and
fix the limits on the vertical axis. When I add the color bar a new one is
added in every iteration instead of overwriting the previous one, anyone
know how I can prevent this?
Also is it possible to specify a view point when plotting?
Thanks
D



import matplotlib.pyplot as plt
import numpy as np
import pylab as py
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm

pi = np.pi

#Set up grid.

fig = py.figure()
ax = Axes3D(fig)

nx = 50
nz = 50

X = np.arange(0, nx, 1)
Y = np.arange(0, nz, 1)
X, Y = np.meshgrid(X, Y)

nsteps = 100

# Constants for equation.
c = 4000
dt = 1e-4
h = 1


# Set up source.
xs = 0
zs = 0

#fig2 = py.figure()
ts = np.arange(dt,nsteps*dt,dt)
s = 0.5*np.sin(2*pi*100*ts)
#py.plot(ts,s)
#py.show()


# Homogeneous pressure field.
p = np.zeros([nx, nz, nsteps])

# Solve equation.
for t in range(0,nsteps-1):


for z in range(0,nz-1):

for x in range(0,nx-1):

p[xs,zs,t] = s[t]

k = (c*dt/h)**2

p[x,z,t] = 2*p[x,z,t-1] - p[x,z,t-2] +
k*(p[x+1,z,t-1]-4*p[x,z,t-1]+p[x-1,z,t-1]+p[x,z+1,t-1]+p[x,z-1,t-1])

snap = p[:,:,t]
surf = ax.plot_surface(X,Y,snap, rstride=1, cstride=1, cmap=cm.jet,
linewidth=0)
#fig.colorbar(surf, shrink=0.5, aspect=5)
#py.draw()
py.savefig('/home/davcra/Desktop/plots/2Dwave/'+str(t))
--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] draw lines in basemap

2012-02-29 Thread David Craig
Hi,
I'm trying to produce a map with 12 locations marked on it and straight 
lines plotted between each point and all other points on the map. I have 
the map with the locations ok but am having trouble getting the lines. 
My code is below anyone know how to do this??
Thanks
D

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import matplotlib.lines as lines
import numpy as np

m = Basemap(llcrnrlon=-11.5,llcrnrlat=51.0,urcrnrlon=-4.5,urcrnrlat=56.0,
 resolution='i',projection='cass',lon_0=-4.36,lat_0=54.7)

lats = [53.5519317,53.8758499, 54.2894659, 55.2333142, 
54.9846137,54.7064869, 51.5296651, 51.5536226, 51.7653115, 52.1625237, 
52.5809163, 52.9393892]

lons = [-9.9413447, -9.9621948, -8.9583439, -7.6770179, -8.3771698, 
-8.7406732, -8.9529546, -9.7907148, -10.1531573, -10.4099873, 
-9.8456417, -9.4344939]

x, y = m(lons, lats)
for i in range(len(lons)):
 for j in range(len(lons)):
 if i == j: continue
 m.plot([x[i],y[i]],[x[j],y[j]],'k')

m.plot(x, y, 'bD', markersize=10)
m.drawcoastlines()
#m.drawmapboundary()
#plt.savefig('/media/A677-86E0/dot_size'+str(i)+'.png')
plt.show()


--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] basemap problem

2012-02-26 Thread David Craig
Hi, I recently installed basemap and python imaging library on my laptop. I
have an i686 machine with fedora 16 on it. I just tried some test plots and
basemap seems to work fine but according to the documentation to use the
bluemarble(), etopo(), shadedrelief() and warpimage() instance methods I
need PIL. SO I installed it via yum,

$ sudo yum install python-imaging.i686

however only the bluemarble method works. If I try any of the others I get
the following error.

AttributeErrorTraceback (most recent call last)
/usr/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in
execfile(fname, *where)
173 else:
174 filename = fname
-- 175 __builtin__.execfile(filename, *where)

/home/davcra/Desktop/python_scripts/blue_marble.py in module()
 10
 11
--- 12 m.shadedrelief()
 13 plt.show()

AttributeError: 'Basemap' object has no attribute 'shadedrelief'

Anyone know what I did wrong
Thanks
David
--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] surface plot

2012-02-23 Thread David Craig
Hi,
I have an array defined by 3 variables p(x,z,t). I would like to produce 
a surface plot with colors defined by p and animate it. That is plot the 
value of p at all x and z, over time (t).  My code to get p is below but 
I really have no idea how to plot this. Anyone know the best way to go 
about this?
thanks,
D


# 2D Finite Distance Wave Equation.
from pylab import *
from numpy import math

ion()

# Set up variables.
nx = 100
nz = 100
nsteps = 300
c = 3500
dt = 10**-4
h = 1
t = arange(0,nsteps,dt)

# Define source as a spike.
s = zeros(nsteps)
s[1] = 1
s[2] = 2
s[3] = 1

# Position source.
xs = 50
zs = 50
##plot(t,s)
##show()


# Set up pressure field.
p=empty([nx,nz,nsteps])

for t in range(0,nsteps-1):

 for z in range(0,nz-1):

 for x in range(0,nx-1):

 p[x,z,t] = 0



# Solve wave equation.
for t in range(2,nsteps-1):


 for z in range(1,nz-1):

 for x in range(2,nx-1):

 p[xs,zs,t] = s[t]

 k = (c*dt/h)**2

 p[x,z,t] = 2*p[x,z,t-1] - p[x,z,t-2] + 
k*(p[x+1,z,t-1]-4*p[x,z,t-1]+p[x-1,z,t-1]+p[x,z+1,t-1]+p[x,z-1,t-1])


 #Plot somehow
 draw()
#close()



--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] x-axis ticks and labels

2012-02-09 Thread David Craig
Hi,
I am trying to relabel the x-axis on a plot. I want it to have 10 evenly 
spaced labels ranging from 274 at zero to 283 at one increment short of 
the axis. My code is as follows:

 im.axes.xaxis.set_major_locator(py.MaxNLocator(10))
 im.axes.xaxis.set_ticklabels(range(274,284))

My understanding is that MaxNLocator defines the number of spaces 
between labels. I've tried a few variations on the above but can only 
seem to get the last label to be 282 or 284. Anyone know what I am doing 
wrong.
Thanks
D

--
Virtualization  Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] add a single x tick label

2012-02-08 Thread David Craig
Hi, I have a plot of a time series and I would like to add a single 
extra tick mark and label to the plot in a different color to the 
already existing tick marks. Is this possible??
Thanks,
D

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Change xaxis labels

2012-02-06 Thread David Craig
Hi, I have a plot and the xaxis shows number of seconds after a start 
point. I would like to convert them to days anyone know how to do this. 
I have looked at the documentation but cant find what I need.

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] specgram memory problem

2012-02-06 Thread David Craig
I'm using a lenovo laptop with fedora 16. It has 2.9 GiB memory and 4  
intel core CPUs @ 2.3GHz each. Available disk space is 147.9GiB.
numpy 1.6.0
matplotlib 1.0.1


On 6 Feb 2012, at 10:29, Fabrice Silva wrote:

 On Sat, Feb 4, 2012 at 9:44 AM, Fabrice Silva si...@lma.cnrs- 
 mrs.fr wrote:
 Le vendredi 03 février 2012 à 17:39 +, David Craig a  
 écrit :
 sure how to get it to plot the outputs from specgram. I use
 specgram as follows,
 Pxx, freqs, bins, im = plt.specgram(..)
 what am I trying imshow??


 plt.specgram computes the spectrogram and when calls  
 imshow to display
 the resulting array into an image

 Please tell the shape of Pxx, and try the following

 import numpy as np
 import matplotlib.pyplot as plt
 a = np.empty((12000, 14400), dtype=float)
 plt.imshow(a)
 plt.show()

 Le samedi 04 février 2012 à 10:30 +, David Craig a écrit :
 Pxx has shape (6001, 1430) and when I tried the lines of code it  
 returned the following memory error,

 Traceback (most recent call last):
   File /usr/lib/python2.7/site-packages/matplotlib/backends/ 
 backend_gtk.py, line 394, in expose_event
 self._render_figure(self._pixmap, w, h)
   File /usr/lib/python2.7/site-packages/matplotlib/backends/ 
 backend_gtkagg.py, line 75, in _render_figure
 FigureCanvasAgg.draw(self)
   File /usr/lib/python2.7/site-packages/matplotlib/backends/ 
 backend_agg.py, line 394, in draw
 self.figure.draw(self.renderer)
   File /usr/lib/python2.7/site-packages/matplotlib/artist.py,  
 line 55, in draw_wrapper
 draw(artist, renderer, *args, **kwargs)
   File /usr/lib/python2.7/site-packages/matplotlib/figure.py,  
 line 798, in draw
 func(*args)
   File /usr/lib/python2.7/site-packages/matplotlib/artist.py,  
 line 55, in draw_wrapper
 draw(artist, renderer, *args, **kwargs)
   File /usr/lib/python2.7/site-packages/matplotlib/axes.py, line  
 1946, in draw
 a.draw(renderer)
   File /usr/lib/python2.7/site-packages/matplotlib/artist.py,  
 line 55, in draw_wrapper
 draw(artist, renderer, *args, **kwargs)
   File /usr/lib/python2.7/site-packages/matplotlib/image.py,  
 line 354, in draw
 im = self.make_image(renderer.get_image_magnification())
   File /usr/lib/python2.7/site-packages/matplotlib/image.py,  
 line 569, in make_image
 transformed_viewLim)
   File /usr/lib/python2.7/site-packages/matplotlib/image.py,  
 line 201, in _get_unsampled_image
 x = self.to_rgba(self._A, self._alpha)
   File /usr/lib/python2.7/site-packages/matplotlib/cm.py, line  
 193, in to_rgba
 x = self.norm(x)
   File /usr/lib/python2.7/site-packages/matplotlib/colors.py,  
 line 802, in __call__
 val = ma.asarray(value).astype(np.float)
   File /usr/lib/python2.7/site-packages/numpy/ma/core.py, line  
 2908, in astype
 output = self._data.astype(newtype).view(type(self))
 MemoryError

 Please, answer on the mailing list,
 It confirms that the troubles lie in the rendering of images. Could  
 you
 tell the versions of numpy and matplotlib you are using, and the
 characteristics of the computer you are working on ?


 -- 
 
 Try before you buy = See our experts in action!
 The most comprehensive online learning library for Microsoft  
 developers
 is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3,  
 MVC3,
 Metro Style Apps, more. Free future releases when you subscribe now!
 http://p.sf.net/sfu/learndevnow-dev2
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] specgram memory problem

2012-02-06 Thread David Craig
uname -a gives,
Linux David 3.2.2-1.fc16.i686 #1 SMP Thu Jan 26 03:38:31 UTC 2012 i686 i686
i386 GNU/Linux

On Mon, Feb 6, 2012 at 6:07 PM, Benjamin Root ben.r...@ou.edu wrote:



 On Mon, Feb 6, 2012 at 11:59 AM, David Craig dcdavem...@gmail.com wrote:

 I'm using a lenovo laptop with fedora 16. It has 2.9 GiB memory and 4
 intel core CPUs @ 2.3GHz each. Available disk space is 147.9GiB.
 numpy 1.6.0
 matplotlib 1.0.1


 32-bit or 64-bit OS?  Please use 'uname -a' to tell us, because you can
 install a 32-bit OS on a 64-bit machine.

 Ben Root


--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] specgram memory problem

2012-02-03 Thread David Craig
Hi, I am using matplotlib to produce some spectrograms for seismic data. I
am looking at a 10 day period with a sample rate of 20sps. I would like to
have my spectrogram to be composed of 10 minute windows with an overlap of
90%. However when I try and run my script I run out of memory. I can
produce the spectrogram for a maximum of 3 days before an error occurs.
I have also tried to produce a spectrogram for each day and stick them
together using subplot, but I then get the error given below. Anyone know a
way around this??
Thanks,
David

Traceback (most recent call last):
  File
/usr/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py, line
394, in expose_event
self._render_figure(self._pixmap, w, h)
  File
/usr/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py,
line 75, in _render_figure
FigureCanvasAgg.draw(self)
  File
/usr/lib/python2.7/site-packages/matplotlib/backends/backend_agg.py, line
394, in draw
self.figure.draw(self.renderer)
  File /usr/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
  File /usr/lib/python2.7/site-packages/matplotlib/figure.py, line 798,
in draw
func(*args)
  File /usr/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
  File /usr/lib/python2.7/site-packages/matplotlib/axes.py, line 1946, in
draw
a.draw(renderer)
  File /usr/lib/python2.7/site-packages/matplotlib/artist.py, line 55, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
  File /usr/lib/python2.7/site-packages/matplotlib/image.py, line 354, in
draw
im = self.make_image(renderer.get_image_magnification())
  File /usr/lib/python2.7/site-packages/matplotlib/image.py, line 569, in
make_image
transformed_viewLim)
  File /usr/lib/python2.7/site-packages/matplotlib/image.py, line 201, in
_get_unsampled_image
x = self.to_rgba(self._A, self._alpha)
  File /usr/lib/python2.7/site-packages/matplotlib/cm.py, line 194, in
to_rgba
x = self.cmap(x, alpha=alpha, bytes=bytes)
  File /usr/lib/python2.7/site-packages/matplotlib/colors.py, line 551,
in __call__
rgba = np.empty(shape=xa.shape+(4,), dtype=lut.dtype)
MemoryError
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] specgram

2012-02-01 Thread David Craig
Hi, I am trying to produce a spectrogram for my data set and am having 
an issue with the color map. My data is filtered between 0.02 and 1.0Hz, 
but specgram() produces an image in the range 0 to 10Hz. Also the color 
map is not set properly. I would like to have it so the colormap ranges 
from the min and max powers obtained by specgram. Anyone know how to do 
this? My code is below.

Pxx, freqs, bins, im = plt.specgram(data, NFFT=nfft, Fs=sps, 
detrend=py.detrend_none, window=py.window_hanning, noverlap=nfft/2, 
cmap=None, xextent=None, pad_to=None, sides='default', scale_by_freq=None)
plt.ylim(0,1)
plt.colorbar()
plt.show()

thanks,
D

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] seconds to julian time

2012-02-01 Thread David Craig
Hi,
I have a plot that covers a 10 day period on its x-axis in seconds. I 
would like to change it to julian days, is this possible with matplotlib 
and if so how do I do it??
D

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] psd

2012-01-30 Thread David Craig
Hi I have some data for a 24hr period with a sample rate of 100
samples/second. I want to create a power spectrum using matplotlibs
function psd. I want it to have 10 minute windows with a 50% overlap, but
cant seem to get the syntax right. My code is as follows:

NFFT = len(data)
Fs = 100
window=np.hanning(Fs*60*10)
noverlap = window*0.5
plt.psd(data, NFFT, Fs, window, noverlap )

anyone kow how to do this properly???

Thanks,
D
--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] psd

2012-01-30 Thread David Craig
Hi, thanks for that. I've made the following changes:

NFFT = 100*60*10# Linked to window size
Fs = stream[0].stats.sampling_rate
win = np.hanning(NFFT)
overlap = NFFT/2
power, freq = plt.psd(data, NFFT, Fs, win, overlap)

but it returns the following error:

Traceback (most recent call last):
  File /home/davcra/Desktop/python_scripts/welchPSD.py, line 20, in
module
power, freq = plt.psd(data, NFFT, Fs, win, overlap)
  File /usr/lib/python2.7/site-packages/matplotlib/pyplot.py, line 2322,
in psd
ret = ax.psd(x, NFFT, Fs, Fc, detrend, window, noverlap, pad_to, sides,
scale_by_freq, **kwargs)
  File /usr/lib/python2.7/site-packages/matplotlib/axes.py, line 7876, in
psd
sides, scale_by_freq)
  File /usr/lib/python2.7/site-packages/matplotlib/mlab.py, line 389, in
psd
scale_by_freq)
  File /usr/lib/python2.7/site-packages/matplotlib/mlab.py, line 419, in
csd
noverlap, pad_to, sides, scale_by_freq)
  File /usr/lib/python2.7/site-packages/matplotlib/mlab.py, line 268, in
_spectral_helper
thisX = windowVals * detrend(thisX)
TypeError: 'int' object is not callable


On Mon, Jan 30, 2012 at 12:13 PM, Fabrice Silva si...@lma.cnrs-mrs.frwrote:

 Le lundi 30 janvier 2012 à 11:45 +, David Craig a écrit :
  Hi I have some data for a 24hr period with a sample rate of 100
  samples/second. I want to create a power spectrum using matplotlibs
  function psd. I want it to have 10 minute windows with a 50% overlap,
  but cant seem to get the syntax right. My code is as follows:
 
  NFFT = len(data)
  Fs = 100
  window=np.hanning(Fs*60*10)
  noverlap = window*0.5
  plt.psd(data, NFFT, Fs, window, noverlap )
 
  anyone kow how to do this properly???

 Be careful to use a suitable value for NFFT. It must be linked to your
 windows size, not the total data length, and you would rather use a
 power of 2 for efficience. Do not use it to increase the frequency
 resolution (use pad_to instead).

 Fs = 100
 NFFT = Fs*60*10
 Pxx, f = plt.psd(data, NFFT, Fs, window=np.hanning(NFFT), NFFT/2)

 --
 Fabrice Silva



 --
 Try before you buy = See our experts in action!
 The most comprehensive online learning library for Microsoft developers
 is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
 Metro Style Apps, more. Free future releases when you subscribe now!
 http://p.sf.net/sfu/learndevnow-dev2
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users