Index: trunk/tools/drawing.py
===================================================================
--- trunk/tools/drawing.py	(revision 780)
+++ trunk/tools/drawing.py	(revision 781)
@@ -3333,4 +3333,82 @@
 
 def draw_basins(ncfile, values, varns):
+    """ Function to plot wind basins
+      values= [lonlatbox]:[mapres]:[cbarname]:[xtrmbasin]:[mapdraw]:[veclength]:[freq]:
+        [ifreq]:[gtit]:[kindfig]:[figuren]
+        [lonlatbox]= [lonSW],[lonNE],[latSW],[latNE] coordinates of the lon/lat box
+        [xtrmbasin]= pminbasin],[maxbasin]
+        gtit= title of the graph ('|', for spaces)
+        kindfig= kind of figure
+        figuren= name of the figure
+      ncfile= file to use
+    """
+    fname = 'draw_basins'
+
+    if values == 'h':
+        print fname + '_____________________________________________________________'
+        print draw_vectors.__doc__
+        quit()
+
+    expectargs = '[lonlatbox]:[mapres]:[cbarname]:[xtrmbasin]:[mapdraw]:' +          \
+      '[veclength]:[freq]:[ifreq]:[gtit]:[kindfig]:[figuren]'
+ 
+    drw.check_arguments(fname,values,expectargs,':')
+
+    varn='basins'
+    lonname = 'nav_lon'
+    latname = 'nav_lat'
+    flowname = 'trip'
+
+    lonlims =[]
+    latlims =[]
+
+    lonlims.append(np.float(values.split(':')[0].split(',')[0]))
+    lonlims.append(np.float(values.split(':')[0].split(',')[1]))
+    latlims.append(np.float(values.split(':')[0].split(',')[2]))
+    latlims.append(np.float(values.split(':')[0].split(',')[3]))
+    map_res = values.split(':')[1]
+    cbarname = values.split(':')[2]
+    vtit = 'basins'
+    minbasin = np.int(values.split(':')[3].split(',')[0])
+    maxbasin = np.int(values.split(':')[3].split(',')[1])
+    mapdraw0 = gen.Str_Bool(values.split(':')[4])
+    veclength = np.float(values.split(':')[5])
+    freq0 = values.split(':')[6]
+    ifreq = int(values.split(':')[7])
+    gtit = values.split(':')[8].replace('|',' ')
+    kindfig = values.split(':')[9]
+    figuren = values.split(':')[10]
+
+    if freq0 == 'None': freq = None
+
+    ofile = NetCDFFile(ncfile, 'r')
+
+    obasins = ofile.variables[varn]
+    olon = ofile.variables[lonname]
+    olat = ofile.variables[latname]
+    oflow = ofile.variables[flowname]
+
+    lons = olon[:]
+    lats = olat[:]
+
+    lon, lat = drw.lonlat2D(lons, lats)
+
+    nlon = lonlims[0]
+    xlon = lonlims[1]
+    nlat = latlims[0]
+    xlat = latlims[1]
+
+    imin, imax, jmin, jmax = gen.ijlonlat(lon, lat, nlon, xlon, nlat, xlat)
+
+    drw.plot_basins(lon[jmin:jmax,imin:imax], lat[jmin:jmax,imin:imax],              \
+      oflow[jmin:jmax,imin:imax], freq, cbarname+'@basin@-',                         \
+      obasins[jmin:jmax,imin:imax], veclength, minbasin, maxbasin, 'outflow', '-',   \
+      'cyl,'+map_res, gtit, kindfig, figuren)
+
+    ofile.close()
+
+    return
+
+def draw_basinsold(ncfile, values, varns):
     """ Function to plot wind basins
       values= [dimname]|[vardimname]|[value]:[vecvals]:[windlabs]:[mapvalues]:
Index: trunk/tools/drawing_tools.py
===================================================================
--- trunk/tools/drawing_tools.py	(revision 780)
+++ trunk/tools/drawing_tools.py	(revision 781)
@@ -6214,5 +6214,5 @@
     return
 
-def plot_basins(xvals,yvals,fvals,vecfreq,vecoln,veccolor,veclength,windn,wuts,\
+def plot_basins(xvals,yvals,fvals,vecfreq,vecoln,veccolor,veclength,vcolmin,vcolmax,windn,wuts,\
   mapv,graphtit,kfig,figname):
     """ Function to plot vectors
@@ -6283,8 +6283,8 @@
 #   From: http://stackoverflow.com/questions/15235630/matplotlib-pick-up-one-color-associated-to-one-value-in-a-colorbar
     my_cmap = plt.cm.get_cmap(vcolor)
-    vcolmin = np.min(veccolor[::yfreq,::xfreq])
-    vcolmax = np.max(veccolor[::yfreq,::xfreq])
-    vcolmin = 0.
-    vcolmax = 2500.
+#    vcolmin = np.min(veccolor[::yfreq,::xfreq])
+#    vcolmax = np.max(veccolor[::yfreq,::xfreq])
+#    vcolmin = 0.
+#    vcolmax = 2500.
     norm = mpl.colors.Normalize(vcolmin, vcolmax)
     print 'min col:',vcolmin,'max col:',vcolmax
@@ -6354,6 +6354,13 @@
         vvals = np.float(veclength)*vvals/wind
 
+    vecolorvals = veccolor[::yfreq,::xfreq]
+    vecolorvals = np.where(vecolorvals < vcolmin, vcolmin - 1, vecolorvals)
+    vecolorvals = np.where(vecolorvals > vcolmax, vcolmax + 1, vecolorvals)
+
+#    plt.quiver(xvals[::yfreq,::xfreq], yvals[::yfreq,::xfreq],                       \
+#      uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq], veccolor[::yfreq,::xfreq],     \
+#       cmap=plt.get_cmap(vcolor), pivot='middle')
     plt.quiver(xvals[::yfreq,::xfreq], yvals[::yfreq,::xfreq],                       \
-      uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq], veccolor[::yfreq,::xfreq],     \
+      uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq], vecolorvals,                   \
        cmap=plt.get_cmap(vcolor), pivot='middle')
     cbar = plt.colorbar()
