Index: trunk/MESOSCALE/PLOT/PYTHON/mylib/api_g95.sh
===================================================================
--- trunk/MESOSCALE/PLOT/PYTHON/mylib/api_g95.sh	(revision 186)
+++ trunk/MESOSCALE/PLOT/PYTHON/mylib/api_g95.sh	(revision 186)
@@ -0,0 +1,3 @@
+#! /bin/bash
+
+f2py -c -m api ~/Science/MODELES/MESOSCALE/LMD_MM_MARS/SRC/POSTPROC/api.F90 --fcompiler=g95 -L$NETCDF/lib -lnetcdf -lm -I$NETCDF/include --f90flags="-Wall -Wno=112,141,137,155 -fno-second-underscore -ffree-form" > ~/logc 2> ~/loge
Index: trunk/MESOSCALE/PLOT/PYTHON/mylib/api_wrapper.py
===================================================================
--- trunk/MESOSCALE/PLOT/PYTHON/mylib/api_wrapper.py	(revision 186)
+++ trunk/MESOSCALE/PLOT/PYTHON/mylib/api_wrapper.py	(revision 186)
@@ -0,0 +1,33 @@
+
+### A. Spiga -- LMD -- 03/07/2011
+
+def api_onelevel (  path_to_input   = './', \
+                    input_name      = 'wrfout_d0?_????-??-??_??:00:00', \
+                    path_to_output  = None, \
+                    output_name     = None, \
+                    process         = 'list', \
+                    fields          = 'tk,W,uvmet,HGT', \
+                    debug           = False, \
+                    bit64           = False, \
+                    oldvar          = True, \
+                    interp_method   = 4, \
+                    extrapolate     = 0, \
+                    unstagger_grid  = False, \
+                    onelevel        = 0.020  ):
+    import api
+    import numpy as np
+
+    if not path_to_output:  path_to_output = path_to_input
+
+    if not output_name:
+        if interp_method <= 2:    output_name = input_name+'_p'
+        if interp_method == 3:    output_name = input_name+'_z'
+        if interp_method == 4:    output_name = input_name+'_zabg'
+
+    print input_name, output_name
+
+    api.api_main ( path_to_input, input_name, path_to_output, output_name, \
+                   process, fields, debug, bit64, oldvar, np.arange(299), \
+                   interp_method, extrapolate, unstagger_grid, onelevel )
+
+    return output_name
Index: trunk/MESOSCALE/PLOT/PYTHON/mylib/myplot.py
===================================================================
--- trunk/MESOSCALE/PLOT/PYTHON/mylib/myplot.py	(revision 184)
+++ trunk/MESOSCALE/PLOT/PYTHON/mylib/myplot.py	(revision 186)
@@ -35,4 +35,26 @@
 	return wlon,wlat
 
+def api_onelevel (  path_to_input   = None, \
+                    input_name      = 'wrfout_d0?_????-??-??_??:00:00', \
+                    path_to_output  = None, \
+                    output_name     = 'output.nc', \
+                    process         = 'list', \
+                    fields          = 'tk,W,uvmet,HGT', \
+                    debug           = False, \
+                    bit64           = False, \
+                    oldvar          = True, \
+                    interp_method   = 4, \
+                    extrapolate     = 0, \
+                    unstagger_grid  = False, \
+                    onelevel        = 0.020  ):
+    import api
+    import numpy as np
+    if not path_to_input:   path_to_input  = './'
+    if not path_to_output:  path_to_output = path_to_input
+    api.api_main ( path_to_input, input_name, path_to_output, output_name, \
+                   process, fields, debug, bit64, oldvar, np.arange (299), \
+                   interp_method, extrapolate, unstagger_grid, onelevel )
+    return
+
 def getproj (nc):
     map_proj = getattr(nc, 'MAP_PROJ')
@@ -51,4 +73,6 @@
         print "mercator projection"
         proj="merc"
+    else:
+        proj="merc"
     return proj    
 
@@ -70,6 +94,6 @@
     import  matplotlib.pyplot as plt
     res = int(res)
-    if folder != '':      name = folder+'/'+filename+str(res)+".png"
-    else:           	  name = filename+str(res)+".png"
+    name = filename+"_"+str(res)+".png"
+    if folder != '':      name = folder+'/'+name
     plt.savefig(name,dpi=res,bbox_inches='tight',pad_inches=pad_inches_value)
     if disp:              display(name)		
Index: trunk/MESOSCALE/PLOT/PYTHON/scripts/winds.py
===================================================================
--- trunk/MESOSCALE/PLOT/PYTHON/scripts/winds.py	(revision 184)
+++ trunk/MESOSCALE/PLOT/PYTHON/scripts/winds.py	(revision 186)
@@ -24,8 +24,4 @@
     import numpy as np
 
-    #############################
-    ### Lower a bit the font size
-    rcParams['font.size'] = int( rcParams['font.size'] * 2. / 3. )
-
     ######################
     ### Load NETCDF object
@@ -50,8 +46,8 @@
                                     ## pb avec les autres (de trace derriere la sphere ?)
 
-    ###################################################################
-    ### For mesoscale results plot the underlying topography by default 
+    ####################################################################
+    #### For mesoscale results plot the underlying topography by default 
     if typefile in ['mesoapi','meso']: 
-        if var == None: var = 'HGT'
+        if var == None: back="mola" #var = 'HGT'
 
     ####################################################
@@ -83,4 +79,5 @@
         [u,v] = getwinds(nc,charu='U',charv='V')
         metwind = False ## geometrical (wrt grid)
+        print "Beware ! Not using meteorological winds. You trust numerical grid as being (x,y)."
 
     ####################################################
@@ -95,45 +92,74 @@
             elif dimension == 3:   field = nc.variables[var][:,:,:]
             elif dimension == 4:   field = nc.variables[var][:,nvert,:,:]  
+    nt = len(u[:,0,0,0])
+
+    #########################################
+    ### Name for title and graphics save file
+    basename = "WINDS"
+    if var:
+        basename = basename + "_" + var
+    basename = basename + "_z" + str(nvert)
 
     ##################################
     ### Open a figure and set subplots
     fig = figure()
-    if   numplot == 4: 
-        sub = 221
-        fig.subplots_adjust(wspace = 0.1, hspace = 0.3)
-    elif numplot == 2: 
-        sub = 121
-        fig.subplots_adjust(wspace = 0.3)
-    elif numplot == 3: 
-        sub = 131
-        fig.subplots_adjust(wspace = 0.3)
-    elif numplot == 6: 
-        sub = 231
-        fig.subplots_adjust(wspace = 0.4, hspace = 0.0)
-    elif numplot == 8: 
-        sub = 331 #241
-        fig.subplots_adjust(wspace = 0.1, hspace = 0.3)
-    else:
-        print "supported: 1,2,3,4,6,8"
-        exit()
-
-    #####################
-    ### Prepare time loop
-    nt = len(u[:,0,0,0])
-    if nt <= numplot or numplot == 1:  
-        print "I am plotting only one map ",nt,numplot
-        tabrange = [0]
-    else:                          
-        tabrange = range(0,nt-1,int(nt/numplot))
+    if   numplot > 0:    
+        if   numplot == 4: 
+            sub = 221
+            fig.subplots_adjust(wspace = 0.1, hspace = 0.3)
+            rcParams['font.size'] = int( rcParams['font.size'] * 2. / 3. )
+        elif numplot == 2: 
+            sub = 121
+            fig.subplots_adjust(wspace = 0.3)
+            rcParams['font.size'] = int( rcParams['font.size'] * 3. / 4. )
+        elif numplot == 3: 
+            sub = 131
+            fig.subplots_adjust(wspace = 0.3)
+            rcParams['font.size'] = int( rcParams['font.size'] * 2. / 3. )
+        elif numplot == 6: 
+            sub = 231
+            fig.subplots_adjust(wspace = 0.4, hspace = 0.0)
+            rcParams['font.size'] = int( rcParams['font.size'] * 2. / 3. )
+        elif numplot == 8: 
+            sub = 331 #241
+            fig.subplots_adjust(wspace = 0.1, hspace = 0.3)
+            rcParams['font.size'] = int( rcParams['font.size'] * 1. / 2. )
+        elif numplot == 9:
+            sub = 331 
+            fig.subplots_adjust(wspace = 0.1, hspace = 0.3)
+            rcParams['font.size'] = int( rcParams['font.size'] * 1. / 2. )
+        elif numplot == 1:
+            pass
+        else:
+            print "supported: 1,2,3,4,6,8"
+            exit()
+        ### Prepare time loop
+        if nt <= numplot or numplot == 1:  
+            tabrange = [0]
+            numplot = 1
+        else:                          
+            tabrange = range(0,nt,int(nt/numplot))  #nt-1
+            tabrange = tabrange[0:numplot]
+    else: 
+        tabrange = range(0,nt,1)
+        sub = 99999
+    print tabrange
 
     #################################
     ### Time loop for plotting device
+    found_lct = False
     for i in tabrange:
 
-       print i
-
        ### General plot settings
-       if tabrange != [0]: subplot(sub)
-       zetitle = "WINDS" + "_"
+       if numplot > 1: 
+           subplot(sub)
+           found_lct = True
+       elif numplot == 1:
+           found_lct = True 
+        ### If only one local time is requested (numplot < 0)
+       elif numplot <= 0: 
+           #print (ltst+i)%24, numplot, (ltst+i)%24+numplot
+           if (ltst+i)%24 + numplot != 0:   continue
+           else:                            found_lct = True
 
        ### Map projection
@@ -143,5 +169,4 @@
        #### Contour plot
        if var:
-           zetitle = zetitle + var + "_"
            if typefile in ['mesoapi','meso']:    what_I_plot = dumpbdy(field[i,:,:])
            elif typefile in ['gcm']:             
@@ -158,19 +183,20 @@
            key = False
        if metwind:  [vecx,vecy] = m.rotate_vector(vecx, vecy, lon2d, lat2d)
-       else:        print "Beware ! Not using meteorological winds. You trust numerical grid as being (x,y)."
        vectorfield(vecx, vecy,\
-                      x, y, stride=stride, csmooth=2,\
+                      x, y, stride=stride, csmooth=stride,\
                       scale=15., factor=200., color='k', key=key)
+                                                   ## or csmooth=2
        
        ### Next subplot
-       zetitle = zetitle + "LT"+str((ltst+i)%24)
-       ptitle(zetitle)
+       ptitle( basename + "_LT"+str((ltst+i)%24) )
        sub += 1
 
     ##########################################################################
     ### Save the figure in a file in the data folder or an user-defined folder
-    if not target:   zeplot = namefile+zetitle
-    else:            zeplot = target+"/"+zetitle
-    makeplotpng(zeplot,pad_inches_value=0.35)   
+    if not target:    zeplot = namefile+"_"+basename
+    else:             zeplot = target+"/"+basename
+    if numplot <= 0:  zeplot = zeplot + "_LT"+str(abs(numplot))
+    if found_lct:     makeplotpng(zeplot,pad_inches_value=0.35)   
+    else:             print "Local time not found"
 
 
@@ -196,13 +222,15 @@
     import sys
     from optparse import OptionParser    ### to be replaced by argparse
+    from api_wrapper import api_onelevel
     parser = OptionParser()
     parser.add_option('-f', action='store', dest='namefile',    type="string",  default=None,  help='name of WRF file [NEEDED]')
-    parser.add_option('-l', action='store', dest='nvert',       type="int",     default=0,     help='subscript for vertical level')
+    parser.add_option('-l', action='store', dest='nvert',       type="float",   default=0,     help='vertical level (def=0)')
     parser.add_option('-p', action='store', dest='proj',        type="string",  default=None,  help='projection')
     parser.add_option('-b', action='store', dest='back',        type="string",  default=None,  help='background')
     parser.add_option('-t', action='store', dest='target',      type="string",  default=None,  help='destination folder')
-    parser.add_option('-s', action='store', dest='stride',      type="int",     default=3,     help='stride vectors')
+    parser.add_option('-s', action='store', dest='stride',      type="int",     default=3,     help='stride vectors (def=3)')
     parser.add_option('-v', action='store', dest='var',         type="string",  default=None,  help='variable contoured')
-    parser.add_option('-n', action='store', dest='numplot',     type="int",     default=4,     help='number of plots')
+    parser.add_option('-n', action='store', dest='numplot',     type="int",     default=4,     help='number of plots (def=1)(if <0: 1 plot of LT -*numplot*)')
+    parser.add_option('-i', action='store', dest='interp',      type="int",     default=None,  help='interpolation method (done at level *nvert* km)')
     (opt,args) = parser.parse_args()
     if opt.namefile is None: 
@@ -210,8 +238,18 @@
         exit()
     print "Options:", opt
-    winds (opt.namefile,opt.nvert,proj=opt.proj,back=opt.back,target=opt.target,stride=opt.stride,var=opt.var,numplot=opt.numplot)
-
-#    if typefile in ['gcm']:
-#        if var == 'HGT':    var = 'phisinit'  ## default choice for GCM
-
-
+
+    zefile = opt.namefile    
+    zelevel = opt.nvert   
+    if opt.nvert is 0 and opt.interp:   zelevel = 0.020 
+    if opt.interp is not None:
+        if   opt.var is None    :  zefields = 'uvmet'
+        else                    :  zefields = 'uvmet,'+opt.var
+        zefile = api_onelevel (  path_to_input   = '', \
+                                 input_name      = zefile, \
+                                 path_to_output  = opt.target, \
+                                 fields          = zefields, \
+                                 interp_method   = opt.interp, \
+                                 onelevel        = zelevel )
+        zelevel = 0
+
+    winds (zefile,int(zelevel),proj=opt.proj,back=opt.back,target=opt.target,stride=opt.stride,var=opt.var,numplot=opt.numplot)
