Index: /trunk/UTIL/PYTHON/README.PP
===================================================================
--- /trunk/UTIL/PYTHON/README.PP	(revision 447)
+++ /trunk/UTIL/PYTHON/README.PP	(revision 448)
@@ -68,5 +68,5 @@
 
 Goal: I want to plot results for two different times in the file next to one another
-pp.py -f diagfi.nc -v tsurf --time 4 -- time 7
+pp.py -f diagfi.nc -v tsurf --time 4 --time 7
 
 Goal: I want to plot averaged results in the file from one time to another time
Index: /trunk/UTIL/PYTHON/myplot.py
===================================================================
--- /trunk/UTIL/PYTHON/myplot.py	(revision 447)
+++ /trunk/UTIL/PYTHON/myplot.py	(revision 448)
@@ -158,5 +158,5 @@
         elif d3 is not None and d1 is not None:  
              output = reduce_zaxis(input[:,d3,:,:],ax=1,yint=yint,vert=alt,indice=d3)
-             output = mean(output[:,:,d1],axis=0)
+             output = mean(output[:,:,d1],axis=2)
         elif d2 is not None and d1 is not None:  
              output = mean(input[:,:,d2,:],axis=2)
@@ -1036,35 +1036,35 @@
     return nlon, nlat, nvert, ntime, mapmode, nslices
 
-# Author: AC
-# Reduce complexity of main script by moving the contour part here. Also allow to call it from elsewhere
-# which can be usefull
-
-def call_contour(what_I_plot,error,x,y,m,lon,lat,vert,time,vertmode,ze_var2,indextime,indexlon,indexlat,indexvert,yintegral,mapmode,typefile,var2,ticks):
-      from matplotlib.pyplot import contour, plot, clabel
-      import numpy as np
-      #what_I_plot = what_I_plot*mult
-      if not error:
-         if mapmode == 1:
-             if typefile in ['mesoapi','meso']:    what_I_plot = dumpbdy(what_I_plot,6)
-         zevmin, zevmax = calculate_bounds(what_I_plot)
-         zelevels = np.linspace(zevmin,zevmax,ticks) #20)
-         if var2 == 'HGT':  zelevels = np.arange(-10000.,30000.,2000.)
-         if mapmode == 0:
-             #if typefile in ['mesoideal']:    what_I_plot = dumpbdy(what_I_plot,0,stag='W')
-             itime=indextime
-             if len(what_I_plot.shape) is 3: itime=[0]
-             what_I_plot, x, y = define_axis(lon,lat,vert,time,indexlon,indexlat,indexvert,\
-                   itime,what_I_plot, len(ze_var2.shape),vertmode)
-         ### If we plot a 2-D field
-         if len(what_I_plot.shape) is 2:
-             #zelevels=[1.]
-             if mapmode == 0:cs = contour(x,y,what_I_plot, zelevels, colors='k', linewidths = 1 ) #0.33 colors='w' )# , alpha=0.5)
-             elif mapmode == 1:cs = m.contour(x,y,what_I_plot, zelevels, colors='k', linewidths = 1 ) #0.33 colors='w' )# , alpha=0.5)
-             #clabel(cs,zelevels,inline=3,fmt='%1.1f',fontsize=7)
-         ### If we plot a 1-D field
-         elif len(what_I_plot.shape) is 1:
-             plot(what_I_plot,x)
-      else:
-         errormess("There is an error in reducing field !")
-      return error 
-
+## Author: AC
+## Reduce complexity of main script by moving the contour part here. Also allow to call it from elsewhere
+## which can be usefull
+#
+#def call_contour(what_I_plot,error,x,y,m,lon,lat,vert,time,vertmode,ze_var2,indextime,indexlon,indexlat,indexvert,yintegral,mapmode,typefile,var2,ticks):
+#      from matplotlib.pyplot import contour, plot, clabel
+#      import numpy as np
+#      #what_I_plot = what_I_plot*mult
+#      if not error:
+#         if mapmode == 1:
+#             if typefile in ['mesoapi','meso']:    what_I_plot = dumpbdy(what_I_plot,6)
+#         zevmin, zevmax = calculate_bounds(what_I_plot)
+#         zelevels = np.linspace(zevmin,zevmax,ticks) #20)
+#         if var2 == 'HGT':  zelevels = np.arange(-10000.,30000.,2000.)
+#         if mapmode == 0:
+#             #if typefile in ['mesoideal']:    what_I_plot = dumpbdy(what_I_plot,0,stag='W')
+#             itime=indextime
+#             if len(what_I_plot.shape) is 3: itime=[0]
+#             what_I_plot, x, y = define_axis(lon,lat,vert,time,indexlon,indexlat,indexvert,\
+#                   itime,what_I_plot, len(ze_var2.shape),vertmode)
+#         ### If we plot a 2-D field
+#         if len(what_I_plot.shape) is 2:
+#             #zelevels=[1.]
+#             if mapmode == 0:cs = contour(x,y,what_I_plot, zelevels, colors='k', linewidths = 1 ) #0.33 colors='w' )# , alpha=0.5)
+#             elif mapmode == 1:cs = m.contour(x,y,what_I_plot, zelevels, colors='k', linewidths = 1 ) #0.33 colors='w' )# , alpha=0.5)
+#             #clabel(cs,zelevels,inline=3,fmt='%1.1f',fontsize=7)
+#         ### If we plot a 1-D field
+#         elif len(what_I_plot.shape) is 1:
+#             plot(what_I_plot,x)
+#      else:
+#         errormess("There is an error in reducing field !")
+#      return error 
+
Index: /trunk/UTIL/PYTHON/planetoplot.py
===================================================================
--- /trunk/UTIL/PYTHON/planetoplot.py	(revision 447)
+++ /trunk/UTIL/PYTHON/planetoplot.py	(revision 448)
@@ -6,5 +6,5 @@
 ### T. Navarro   -- LMD -- 10~11/2011 -- Improved use for GCM and added sections + 1Dplot capabilities 
 ### A. Colaitis  -- LMD --    11/2011 -- Mostly minor improvements and inter-plot operation capabilities + zrecast interpolation for gcm
-### A. Spiga     -- LMD --    11/2011 -- Extended multivar subplot capabilities + cosmetic changes + general cleaning and tests
+### A. Spiga     -- LMD -- 11~12/2011 -- Extended multivar subplot capabilities + cosmetic changes + general cleaning and tests
 ### A. Colaitis  -- LMD --    12/2011 -- Added movie capability [mencoder must be installed]
 
@@ -65,6 +65,5 @@
                        fmtvar,definecolorvec,defcolorb,getprefix,putpoints,calculate_bounds,errormess,definesubplot,\
                        zoomset,getcoorddef,getwinddef,whatkindfile,reducefield,bounds,getstralt,getfield,smooth,nolow,\
-                       getname,localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar,hole_bounds,\
-                       call_contour
+                       getname,localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar,hole_bounds
     from mymath import deg,max,min,mean,get_tsat,writeascii,fig2data,fig2img
     import matplotlib as mpl
@@ -243,5 +242,5 @@
     #################################
     ### Time loop for plotting device
-    nplot = 1 ; error = False
+    nplot = 1 ; error = False 
     print "********************************************"
     while error is False:
@@ -253,9 +252,6 @@
 
        ### Map projection                    
-       if mapmode == 1:
-           m = define_proj(proj,wlon,wlat,back=back,blat=blat)
-           x, y = m(lon2d, lat2d)
-       elif mapmode ==0:
-           m = None ; x = None ; y = None
+       if mapmode == 1:     m = define_proj(proj,wlon,wlat,back=back,blat=blat) ; x, y = m(lon2d, lat2d)
+       elif mapmode ==0:    m = None ; x = None ; y = None
 
        ####################################################################
@@ -282,19 +278,17 @@
        print "********** index lon, lat, vert, time ",indexlon,indexlat,indexvert,indextime
        ####################################################################
-
-       ticks = ndiv + 1
-
-       #### Contour plot. TBD: var2 could be just another instance of all_var
-       if var2:  what_I_plot_contour, error = reducefield( all_var2[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert, \
-                                                           yint=yintegral, alt=vert )
-
-       #### Shaded plot
+       error = False
        varname = all_varname[index_f]
-       if varname:
+       if varname:   ### what is shaded.
            what_I_plot, error = reducefield( all_var[index_f], d4=indextime, d1=indexlon, d2=indexlat, d3=indexvert, \
                                              yint=yintegral, alt=vert, anomaly=anomaly )
            what_I_plot = what_I_plot*mult
-#           if typefile in ['mesoideal']:    what_I_plot = dumpbdy(what_I_plot,0,stag='W')
-           if not error: 
+       if var2:      ### what is contoured
+           what_I_plot_contour, error = reducefield( all_var2[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert, \
+                                             yint=yintegral, alt=vert )
+       ####################################################################
+
+       if not error:
+               ticks = ndiv + 1 
                fvar = varname 
                if anomaly: fvar = 'anomaly'
@@ -317,16 +311,23 @@
                elif (fileref is not None) and (index_f is numplot-1):  palette = get_cmap(name="RdBu_r")
                else:                                                   palette = get_cmap(name=colorb)
+
                ##### simple 2D field and movies of 2D fields
                if len(what_I_plot.shape) >= 2:
                  if (len(what_I_plot.shape) is 3 and mrate is None):  errormess("3D field. Use --rate RATE for movie or specify --time TIME. Exit.")
-                 istart=0 
                  if mrate is not None: iend=len(time)-1
-                 else:                 iend=istart
-                 imov=istart
+                 else:                 iend=0
+                 imov = 0 
+                 if var2:  which = "contour" ## have to start with contours rather than shading
+                 else:     which = "regular"
                  while imov <= iend:
-                    what_I_plot_frame = what_I_plot
-                    if mrate is not None:      
-                        what_I_plot_frame = what_I_plot[imov,:,:] ; print "-> frame ",imov+1
-                        if mapmode == 1:
+                    print "-> frame ",imov+1, which
+                    if which == "regular":   
+                        if mrate is None:                                   what_I_plot_frame = what_I_plot
+                        else:                                               what_I_plot_frame = what_I_plot[imov,:,:]
+                    elif which == "contour":  
+                        if mrate is None or what_I_plot_contour.ndim < 3:   what_I_plot_frame = what_I_plot_contour
+                        else:                                               what_I_plot_frame = what_I_plot_contour[imov,:,:]
+                    if mrate is not None:     
+                        if mapmode == 1: 
                             m = define_proj(proj,wlon,wlat,back=back,blat=blat)  ## this is dirty, defined above but out of imov loop
                             x, y = m(lon2d, lat2d)                               ## this is dirty, defined above but out of imov loop
@@ -334,53 +335,59 @@
                     if typefile in ['mesoideal']:    what_I_plot_frame = dumpbdy(what_I_plot_frame,0,stag='W',condition=dumped_vert_stag)
 
-                    if hole:         what_I_plot_frame = hole_bounds(what_I_plot_frame,zevmin,zevmax)
-                    else:            what_I_plot_frame = bounds(what_I_plot_frame,zevmin,zevmax)
-                    if flagnolow:    what_I_plot_frame = nolow(what_I_plot_frame)
-
                     if imov >= 0:
-                       # Renew axis directives for movie frames which are not the first one.
-                       zxmin, zxmax = xaxis ; zymin, zymax = yaxis
-                       if zxmin is not None: mpl.pyplot.xlim(xmin=zxmin)
-                       if zxmax is not None: mpl.pyplot.xlim(xmax=zxmax)
-                       if zymin is not None: mpl.pyplot.ylim(ymin=zymin)
-                       if zymax is not None: mpl.pyplot.ylim(ymax=zymax)
-                       if invert_y:     lima,limb = mpl.pyplot.ylim() ; mpl.pyplot.ylim(limb,lima)
-                       if ylog:         mpl.pyplot.semilogy()
-                    # Renew contours for movie frames which are not the first one
-                    if var2:
-                         what_I_plot_contour_frame = what_I_plot_contour
-                         if mrate is not None: what_I_plot_contour_frame = what_I_plot_contour[imov,:,:]
-                         call_contour( what_I_plot_contour_frame,error,x,y,m,lon,lat,vert,time,vertmode,\
-                                       all_var2[index_f],imov,indexlon,indexlat,indexvert,yintegral,mapmode,typefile, var2, ticks )
-                    if not tile:
-                        #zelevels = np.linspace(zevmin*(1. + 1.e-7),zevmax*(1. - 1.e-7)) #,num=20)
-                        zelevels = np.linspace(zevmin,zevmax,num=ticks)
-                        if imov is 0:          print np.array(x).shape, np.array(y).shape, np.array(what_I_plot_frame).shape
-                        if mapmode == 1:       m.contourf( x, y, what_I_plot_frame, zelevels, cmap = palette)
-                        elif mapmode == 0:     contourf( x, y, what_I_plot_frame, zelevels, cmap = palette)
-                    else:
-                        if mapmode == 1:       m.pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax )
-                        elif mapmode == 0:     pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax )
-                    if colorb != 'nobar':        
-                        if (fileref is not None) and (index_f is numplot-1):   daformat = "%.3f"
-                        else:                                                  daformat = fmtvar(fvar.upper())
-                        colorbar( fraction=0.05,pad=0.03,format=daformat,\
-                                  ticks=np.linspace(zevmin,zevmax,num=min([ticks/2+1,20])),extend='neither',spacing='proportional' ) 
-                    ### movie stuff
-                    figframe=mpl.pyplot.gcf()
-                    if mrate is not None:
-                       if mquality: figframe.set_dpi(600.)
-                       else: figframe.set_dpi(200.)
-                    mframe=fig2img(figframe)
-                    if ((mrate is not None) and (imov is 0)):
-                        moviename='test'
-                        W,H = figframe.canvas.get_width_height()
-                        video = VideoSink((H,W), moviename, rate=mrate, byteorder="rgba")
-                    if mrate is not None: 
-                        video.run(mframe)
-                        mpl.pyplot.close()
-                    ### movie stuff
-                    imov=imov+1
+                        # Renew axis directives for movie frames which are not the first one.
+                        zxmin, zxmax = xaxis ; zymin, zymax = yaxis
+                        if zxmin is not None: mpl.pyplot.xlim(xmin=zxmin)
+                        if zxmax is not None: mpl.pyplot.xlim(xmax=zxmax)
+                        if zymin is not None: mpl.pyplot.ylim(ymin=zymin)
+                        if zymax is not None: mpl.pyplot.ylim(ymax=zymax)
+                        if invert_y:     lima,limb = mpl.pyplot.ylim() ; mpl.pyplot.ylim(limb,lima)
+                        if ylog:         mpl.pyplot.semilogy()
+                    
+                    if which == "regular": 
+                        if hole:         what_I_plot_frame = hole_bounds(what_I_plot_frame,zevmin,zevmax)
+                        else:            what_I_plot_frame = bounds(what_I_plot_frame,zevmin,zevmax)
+                        if flagnolow:    what_I_plot_frame = nolow(what_I_plot_frame)
+                        if not tile:
+                            #zelevels = np.linspace(zevmin*(1. + 1.e-7),zevmax*(1. - 1.e-7)) #,num=20)
+                            zelevels = np.linspace(zevmin,zevmax,num=ticks)
+                            if mapmode == 1:       m.contourf( x, y, what_I_plot_frame, zelevels, cmap = palette)
+                            elif mapmode == 0:     contourf( x, y, what_I_plot_frame, zelevels, cmap = palette)
+                        else:
+                            if mapmode == 1:       m.pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax )
+                            elif mapmode == 0:     pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax )
+                        if colorb != 'nobar':        
+                            if (fileref is not None) and (index_f is numplot-1):   daformat = "%.3f"
+                            else:                                                  daformat = fmtvar(fvar.upper())
+                            colorbar( fraction=0.05,pad=0.03,format=daformat,\
+                                      ticks=np.linspace(zevmin,zevmax,num=min([ticks/2+1,20])),extend='neither',spacing='proportional' ) 
+                    elif which == "contour":
+                        zevminc, zevmaxc = calculate_bounds(what_I_plot_frame)
+                        zelevels = np.linspace(zevminc,zevmaxc,ticks/2) #20)
+                        if var2 == 'HGT': zelevels = np.arange(-10000.,30000.,2000.)
+                        if mapmode == 0:    
+                            what_I_plot_frame, x, y = define_axis( lon,lat,vert,time,indexlon,indexlat,indexvert,\
+                                                              itime,what_I_plot_frame, len(all_var2[index_f].shape),vertmode )
+                            cs = contour( x,y,what_I_plot_frame, zelevels, colors='k', linewidths = 1 ) #0.33 colors='w' )# , alpha=0.5)
+                        elif mapmode == 1:  cs = m.contour( x,y,what_I_plot_frame, zelevels, colors='k', linewidths = 1 ) #0.33 colors='w' )# , alpha=0.5)
+
+
+                    if which == "regular":
+                        if mrate is not None:
+                           figframe=mpl.pyplot.gcf()
+                           if mquality:   figframe.set_dpi(600.)
+                           else:          figframe.set_dpi(200.)
+                           mframe=fig2img(figframe)
+                           if ((mrate is not None) and (imov is 0)):
+                              moviename='test' ;W,H = figframe.canvas.get_width_height()
+                              video = VideoSink((H,W), moviename, rate=mrate, byteorder="rgba")
+                           video.run(mframe) ; mpl.pyplot.close()
+                        if var2:  which = "contour"
+                        imov = imov+1
+                    elif which == "contour":
+                        which = "regular"
+
                  if mrate is not None: video.close()
+
                ##### 1D field
                elif len(what_I_plot.shape) is 1:
@@ -392,5 +399,5 @@
                  print "WARNING!!! ",len(what_I_plot.shape),"-D PLOT NOT SUPPORTED !!! dimensions: ",what_I_plot.shape
                  errormess("Are you sure you did not forget to prescribe a dimension ?")
-           else:
+       else:
                errormess("There is an error in reducing field !")
 
Index: /trunk/UTIL/PYTHON/videosink.py
===================================================================
--- /trunk/UTIL/PYTHON/videosink.py	(revision 447)
+++ /trunk/UTIL/PYTHON/videosink.py	(revision 448)
@@ -14,4 +14,5 @@
                     '-nosound',
                     '-ovc', 'x264',
+                    '-msglevel', 'all=-1'
 #                    '-ovc', 'lavc',
                     )
