Revision: 8970
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8970&view=rev
Author:   jswhit
Date:     2011-02-11 19:30:12 +0000 (Fri, 11 Feb 2011)

Log Message:
-----------
add new Line Integral Convolution (LIC) example (requires vectorplot scikit)

Modified Paths:
--------------
    trunk/toolkits/basemap/MANIFEST.in
    trunk/toolkits/basemap/examples/README
    trunk/toolkits/basemap/examples/run_all.py

Added Paths:
-----------
    trunk/toolkits/basemap/examples/hurrearl.nc
    trunk/toolkits/basemap/examples/lic_demo.py

Modified: trunk/toolkits/basemap/MANIFEST.in
===================================================================
--- trunk/toolkits/basemap/MANIFEST.in  2011-02-10 07:37:05 UTC (rev 8969)
+++ trunk/toolkits/basemap/MANIFEST.in  2011-02-11 19:30:12 UTC (rev 8970)
@@ -75,9 +75,11 @@
 include examples/cities.shx
 include examples/show_colormaps.py
 include examples/plotprecip.py
+include examples/lic_demo.py
 include examples/nws_precip_conus_20061222.nc
 include examples/C02562.orog.nc
 include examples/ccsm_popgrid.nc
+include examples/hurrearl.nc
 include examples/NetCDFFile_tst.py
 include examples/maskoceans.py
 include examples/README

Modified: trunk/toolkits/basemap/examples/README
===================================================================
--- trunk/toolkits/basemap/examples/README      2011-02-10 07:37:05 UTC (rev 
8969)
+++ trunk/toolkits/basemap/examples/README      2011-02-11 19:30:12 UTC (rev 
8970)
@@ -141,3 +141,6 @@
 daynight.py shows how to shade the regions of a map where the sun has set.
 
 ploticos.py demonstrates plotting on unstructured grids.
+
+lic_demo.py shows how to use vectorplot scikit to visualize vector fields with
+Line Integral Convolutions (LIC).

Added: trunk/toolkits/basemap/examples/hurrearl.nc
===================================================================
(Binary files differ)


Property changes on: trunk/toolkits/basemap/examples/hurrearl.nc
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/toolkits/basemap/examples/lic_demo.py
===================================================================
--- trunk/toolkits/basemap/examples/lic_demo.py                         (rev 0)
+++ trunk/toolkits/basemap/examples/lic_demo.py 2011-02-11 19:30:12 UTC (rev 
8970)
@@ -0,0 +1,42 @@
+# example showing how to use Line Integral Convolution to visualize a vector
+# flow field (from Hurricane Earl).  Produces something akin to streamlines.
+# Requires vectorplot scikit (http://scikits.appspot.com/vectorplot).
+try:
+    from netCDF4 import Dataset as NetCDFFile
+except ImportError:
+    from mpl_toolkits.basemap import NetCDFFile
+from mpl_toolkits.basemap import Basemap, cm, shiftgrid
+import numpy as np
+import matplotlib.pyplot as plt
+try:
+    from vectorplot import lic_internal
+except ImportError:
+    raise  ImportError('need vectorplot scikit for this example')
+
+date = '2010090100'
+lat0=22.6; lon0=-69.2
+
+ncfile = NetCDFFile('hurrearl.nc')
+u = ncfile.variables['u10m'][:,:]
+v = ncfile.variables['v10m'][:,:]
+lons1 = ncfile.variables['lon'][:]
+lats1 = ncfile.variables['lat'][:]
+lons, lats = np.meshgrid(lons1,lats1)
+ncfile.close()
+
+fig = plt.figure(figsize=(8,8))
+m = 
Basemap(projection='stere',lat_0=lat0,lon_0=lon0,width=1.e6,height=1.e6,resolution='i')
+nxv = 501; nyv = 501
+udat, vdat, xv, yv = m.transform_vector(u,v,lons1,lats1,nxv,nyv,returnxy=True)
+texture = np.random.rand(udat.shape[0],udat.shape[1]).astype(np.float32)
+kernellen=51
+kernel = np.sin(np.arange(kernellen)*np.pi/kernellen).astype(np.float32)
+image = lic_internal.line_integral_convolution(udat.astype(np.float32),\
+        vdat.astype(np.float32), texture, kernel)
+im = m.imshow(image,plt.cm.gist_stern)
+m.drawcoastlines()
+m.drawmeridians(np.arange(0,360,2),labels=[0,0,0,1])
+m.drawparallels(np.arange(-30,30,2),labels=[1,0,0,0])
+plt.title('Hurricane Earl flow field visualized with Line Integral 
Convolution',\
+        fontsize=13)
+plt.show()


Property changes on: trunk/toolkits/basemap/examples/lic_demo.py
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/toolkits/basemap/examples/run_all.py
===================================================================
--- trunk/toolkits/basemap/examples/run_all.py  2011-02-10 07:37:05 UTC (rev 
8969)
+++ trunk/toolkits/basemap/examples/run_all.py  2011-02-11 19:30:12 UTC (rev 
8970)
@@ -10,6 +10,7 @@
 test_files.remove('plotsst.py')
 test_files.remove('embedding_map_in_wx.py') # requires wx
 test_files.remove('plothighsandlows.py') # requires scipy
+test_files.remove('lic_demo.py')
 print test_files
 py_path = os.environ.get('PYTHONPATH')
 if py_path is None:


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to