Index: trunk/tools/drawing.py
===================================================================
--- trunk/tools/drawing.py	(revision 650)
+++ trunk/tools/drawing.py	(revision 651)
@@ -24,4 +24,6 @@
 ## e.g. # ~/etudes/WRF_LMDZ/svn/LMDZ_WRF/tools/drawing.py -o draw_points -S 'tslist.dat,#,3,2,1:SuperStorm|sfc|stations:cyl,i:legend:auto:None:0:png:stations_loc' -f $HOME'/etudes/domains/WRFdynamicoSENS_SuperStorm/geo_em.d02.nc,XLONG_M,XLAT_M,HGT_M,Time|0,height,0.,3000.,terrain,m'
 ## e.g. # drawing.py -o draw_points -S 'tslist.dat,#,3,2,1:SuperStorm|sfc|stations:cyl,i:labelled,8,black:auto:None:0:png:stations_loc' -f $HOME'/etudes/domains/WRFdynamicoSENS_SuperStorm/geo_em_west_east_B25-E180-I1_south_north_B160-E262-I1.nc,XLONG_M,XLAT_M,HGT_M,Time|0,height,0.,1500.,terrain,m'
+## e.g. # drawing.py -o draw_ptZvals -f geo_v2_2012102123_RR1.nc -S 'pracc:lon,lat:o:80:2,42,7,47,:values!of!values:Blues:cyl,l:pdf' -v pr
+
 main = 'drawing.py'
 
@@ -32,6 +34,7 @@
 namegraphics = ['create_movie', 'draw_2D_shad', 'draw_2D_shad_time',                 \
   'draw_2D_shad_cont', 'draw_2D_shad_cont_time', 'draw_2D_shad_line',                \
-  'draw_2D_shad_line_time', 'draw_barbs', 'draw_points', 'draw_timeSeries',          \
-   'draw_topo_geogrid',                                                              \
+  'draw_2D_shad_line_time', 'draw_barbs', 'draw_points', 'draw_ptZvals',             \
+   'draw_timeSeries',                                                                \
+  'draw_topo_geogrid',                                                               \
   'draw_topo_geogrid_boxes', 'draw_trajectories', 'draw_vals_trajectories',          \
   'draw_lines', 'draw_lines_time', 'draw_Neighbourghood_evol', 'list_graphics',      \
@@ -2846,4 +2849,126 @@
     return
 
+def draw_ptZvals(ncfile, values, variable):
+    """ Function to plot a given list of points and values 
+      ncfile= netCDF file to use
+      values= [fvname]:[XYvar]:[pointype]:[pointsize]:[graphlimits]:[nxtype]:
+        [figuretitle]:[colorbar]:[mapvalue]:[kindfig]
+        fvname: name of the variable in the graph
+        XYvar: [lon],[lat] variable names
+        ptype: type of the point
+        ptsize: size of the point
+        graphlimits: minLON,minLAT,maxLON,maxLAT limits of the graph 'None' for the full size
+        nxtype: minimum and maximum type
+          'auto': values taken from the extrems of the data
+          [min],[max]: given minimum and maximum values
+        figtitle: title of the figure
+        cbar: color bar
+        mapv: map characteristics: [proj],[res]
+          see full documentation: http://matplotlib.org/basemap/
+          [proj]: projection
+            * 'cyl', cilindric
+            * 'lcc', lambert-conformal
+          [res]: resolution:
+            * 'c', crude
+            * 'l', low
+            * 'i', intermediate
+            * 'h', high
+            * 'f', full
+        kfig: kind of figure
+      variable= name of the variable to plot
+    """
+    fname = 'draw_ptZvals'
+    import numpy.ma as ma
+
+    if values == 'h':
+        print fname + '_____________________________________________________________'
+        print draw_ptZvals.__doc__
+        quit()
+
+    expectargs = '[fvname]:[XYvar]:[pointype]:[pointsize]:[graphlmits]:[nxtype]:' +  \
+      '[figuretit]:[colorbar]:[mapvalue]:[kindfig]'
+ 
+    drw.check_arguments(fname,len(expectargs.split(':')),values,':',expectargs)
+
+    fvname = values.split(':')[0]
+    XYvar = values.split(':')[1]
+    pointype = values.split(':')[2]
+    pointsize = int(values.split(':')[3])
+    graphlimits = values.split(':')[4]
+    nxtype = values.split(':')[5]
+    figuretitle = values.split(':')[6].replace('!',' ')
+    colorbar = values.split(':')[7]
+    mapvalue = values.split(':')[8]
+    kindfig = values.split(':')[9]
+
+    onc = NetCDFFile(ncfile, 'r')
+    
+    if not onc.variables.has_key(variable):
+        print errormsg
+        print '  ' + fname + ": file '" + ncfile + "' does not have variable '" +    \
+          variable + "' !!"
+        quit(-1)
+
+# points
+    lonvarn = XYvar.split(',')[0]
+    latvarn = XYvar.split(',')[1]
+
+    if not onc.variables.has_key(lonvarn):
+        print errormsg
+        print '  ' + fname + ": file '" + ncfile + "' does not have longitude " +    \
+          "variable '" + lonvarn + "' !!"
+        quit(-1)
+    
+    if not onc.variables.has_key(latvarn):
+        print errormsg
+        print '  ' + fname + ": file '" + ncfile + "' does not have latitude " +    \
+          "variable '" + latvarn + "' !!"
+        quit(-1)
+
+    olonvar = onc.variables[lonvarn]
+    olatvar = onc.variables[latvarn]
+    ovarvar = onc.variables[variable]
+
+    Lpts = len(olonvar[:].flatten())
+
+    pointvalues = ma.masked_array(np.zeros((Lpts,3), dtype=np.float))
+    pointvalues[:,0] = olonvar[:]
+    pointvalues[:,1] = olatvar[:]
+    pointvalues[:,2] = ovarvar[:]
+
+    varattrs = ovarvar.ncattrs()
+    if drw.searchInlist(varattrs, 'units'):
+        fvunits = ovarvar.getncattr('units')
+    else:
+        fvunits = drw.variables_values(variable)[5]
+
+# map value
+    if mapvalue == 'None': mapvalue = None
+
+# Graph limits
+    if graphlimits != 'None':
+        graphlts = np.zeros((4), dtype=np.float)
+        for il in range(4): graphlts[il] = np.float(graphlimits.split(',')[il])
+        pointvalues[:,0] = ma.masked_outside(pointvalues[:,0], graphlts[0],          \
+          graphlts[2])
+        pointvalues[:,1] = ma.masked_outside(pointvalues[:,1], graphlts[3],          \
+          graphlts[2])
+
+#        for ip in range(Lpts):  
+#            if pointvalues[ip,0] < graphlts[0] or pointvalues[ip,0] > graphlts[2]    \
+#              or pointvalues[ip,1] < graphlts[1] or pointvalues[ip,1] > graphlts[3]:
+#                print ip,pointvalues[ip,0:2], graphlts
+#                pointvalues[ip,2] = None
+    else:
+        graphlts = None
+
+    drw.plot_ptZvals(fvname,fvunits,pointvalues,pointype,pointsize,graphlts, nxtype, \
+      figuretitle,colorbar,mapvalue,kindfig)
+
+    return
+
+#draw_ptZvals('OBSnetcdf.nc', 'pracc:lon,lat:o:80:2,42,7,47,:values!of!values:Blues:cyl,l:pdf', 'pr')
+#quit()
+
 ####### ###### ##### #### ### ## #
 
@@ -2922,4 +3047,6 @@
 elif oper == 'draw_points':
     draw_points(opts.ncfile, opts.values)
+elif oper == 'draw_ptZvals':
+    draw_ptZvals(opts.ncfile, opts.values, opts.varname)
 elif oper == 'draw_timeSeries':
     draw_timeSeries(opts.ncfile, opts.values, opts.varname)
