Index: trunk/UTIL/PYTHON/README.PP
===================================================================
--- trunk/UTIL/PYTHON/README.PP	(revision 474)
+++ trunk/UTIL/PYTHON/README.PP	(revision 475)
@@ -71,4 +71,10 @@
 Goal: I want to plot averaged results in the file from one time to another time
 pp.py -f diagfi.nc -v tsurf --time 4,7
+
+Goal: I want to plot a globally-averaged 1D temperature profile
+pp.py -f diagfi.nc -v temp --time 4 --lat -90,90 --lon -180,180
+
+Goal: I want to overplot few globally-averaged 1D temperature profiles at different times
+pp.py -f diagfi.nc -v temp --time 4 --time 7 --lat -90,90 --lon -180,180
 
 [only mesoscale for the moment]
Index: trunk/UTIL/PYTHON/myplot.py
===================================================================
--- trunk/UTIL/PYTHON/myplot.py	(revision 474)
+++ trunk/UTIL/PYTHON/myplot.py	(revision 475)
@@ -414,6 +414,4 @@
     if typefile in ['mesoapi','meso']:
         [lon2d,lat2d] = getcoord2d(nc)
-        lon2d = dumpbdy(lon2d,6)
-        lat2d = dumpbdy(lat2d,6)
     elif typefile in ['gcm']: 
         [lon2d,lat2d] = getcoord2d(nc,nlat="latitude",nlon="longitude",is1d=True)
@@ -958,6 +956,7 @@
 
 ## Author: AS
-def bidimfind(lon2d,lat2d,vlon,vlat):
+def bidimfind(lon2d,lat2d,vlon,vlat,file=None):
    import numpy as np
+   import matplotlib.pyplot as mpl
    if vlat is None:    array = (lon2d - vlon)**2
    elif vlon is None:  array = (lat2d - vlat)**2
@@ -965,10 +964,14 @@
    idy,idx = np.unravel_index( np.argmin(array), lon2d.shape )
    if vlon is not None:
-       #print lon2d[idy,idx],vlon
-       if (np.abs(lon2d[idy,idx]-vlon)) > 5: errormess("longitude not found ",printvar=lon2d)
+      if (np.abs(lon2d[idy,idx]-vlon)) > 5: errormess("longitude not found ",printvar=lon2d)
    if vlat is not None:
-       #print lat2d[idy,idx],vlat
-       if (np.abs(lat2d[idy,idx]-vlat)) > 5: errormess("latitude not found ",printvar=lat2d)
-   return idx,idy
+      if (np.abs(lat2d[idy,idx]-vlat)) > 5: errormess("latitude not found ",printvar=lat2d)
+   if file is not None:
+      print idx,idy,lon2d[idy,idx],vlon
+      print idx,idy,lat2d[idy,idx],vlat
+      var = file.variables["HGT"][:,:,:]
+      mpl.contourf(var[0,:,:],30,cmap = mpl.get_cmap(name="Greys_r") ) ; mpl.axis('off') ; mpl.plot(idx,idy,'bo')
+      mpl.show()
+   return idy,idx
 
 ## Author: TN
Index: trunk/UTIL/PYTHON/planetoplot.py
===================================================================
--- trunk/UTIL/PYTHON/planetoplot.py	(revision 474)
+++ trunk/UTIL/PYTHON/planetoplot.py	(revision 475)
@@ -8,5 +8,5 @@
 ### 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]
-### A. Spiga     -- LMD --    12/2011 -- Added HTML animated page capability + general tests of consistency [winds, etc...]
+### A. Spiga     -- LMD --    12/2011 -- Added HTML animated page capability + general tests of consistency [winds, etc...] + consistent generic movie loop
 
 def planetoplot (namefiles,\
@@ -154,7 +154,10 @@
       elif typefile in ['meso','mesoapi','geo','mesoideal']:
           ### the following lines are kind of dirty... not possible to ask for several lats and lons
-          if vlon is not None or vlat is not None:   indices = bidimfind(lon2d,lat2d,vlon,vlat) 
-          if slon is not None: slon[0][0] = indices[0] ; slon[0][1] = indices[0]
-          if slat is not None: slat[0][0] = indices[1] ; slat[0][1] = indices[1]
+          if vlon is not None or vlat is not None:   
+              indices = bidimfind(lon2d,lat2d,vlon,vlat) #,file=nc)  #placer un point sur carte
+              lonp,latp = ( lon2d[indices[0],indices[1]] , lat2d[indices[0],indices[1]] )
+          if typefile in ['mesoapi','meso'] and mapmode == 1: lon2d = dumpbdy(lon2d,6) ; lat2d = dumpbdy(lat2d,6)  ### important to do that now and not before
+          if slon is not None: slon[0][0] = indices[1] ; slon[0][1] = indices[1]  #...this is idx
+          if slat is not None: slat[0][0] = indices[0] ; slat[0][1] = indices[0]  #...this is idy
           if varname in ['PHTOT','W']:    vertdim='BOTTOM-TOP_PATCH_END_STAG'
           else:                           vertdim='BOTTOM-TOP_PATCH_END_UNSTAG'
@@ -236,5 +239,5 @@
                 tabtime = all_time[0];tab = all_var[0];k = 1
                 if var2: tab2 = all_var2[0]
-                while k != len(namefiles):
+                while k != len(namefiles) and len(all_time[k]) != 0:
                     if var2: tab2 = np.append(tab2,all_var2[k],axis=0) 
                     tabtime = np.append(tabtime,all_time[k]) ; tab = np.append(tab,all_var[k],axis=0) ; k += 1
@@ -292,4 +295,6 @@
        print "********** INDEX LON:",indexlon," LAT:",indexlat," VERT:",indexvert," TIME:",indextime
        ####################################################################
+       ########## REDUCE FIELDS
+       ####################################################################
        error = False
        varname = all_varname[index_f]
@@ -308,40 +313,44 @@
        changesubplot = (numplot > 1) and (len(what_I_plot.shape) != 1)  ## default for 1D plots: superimposed. to be reworked for better flexibility.
        if changesubplot: subplot(subv,subh,nplot)
-       ### Map projection                    
-       if mapmode == 1:     m = define_proj(proj,wlon,wlat,back=back,blat=blat,blon=blon) ; x, y = m(lon2d, lat2d)
-       elif mapmode ==0:    m = None ; x = None ; y = None
        ####################################################################
-
-       if not error:
+       if error:
+               errormess("There is an error in reducing field !")
+       else:
                ticks = ndiv + 1 
                fvar = varname 
                if anomaly: fvar = 'anomaly'
-               if mapmode == 0:
+               ###
+               if mapmode == 0:    ### could this be moved inside imov loop ?
                    itime=indextime
                    if len(what_I_plot.shape) is 3:itime=[0]
+                   m = None ; x = None ; y = None
                    what_I_plot, x, y = define_axis(lon,lat,vert,time,indexlon,indexlat,indexvert,\
                          itime,what_I_plot, len(all_var[index_f].shape),vertmode)
-                   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 (fileref is not None) and (index_f is numplot-1):    zevmin, zevmax = calculate_bounds(what_I_plot,vmin=minop,vmax=maxop)
+               ###
+               if (fileref is not None) and (index_f == numplot-1):    zevmin, zevmax = calculate_bounds(what_I_plot,vmin=minop,vmax=maxop)
                else:                                                   zevmin, zevmax = calculate_bounds(what_I_plot,vmin=vmin,vmax=vmax)
+               if (fileref is not None) and (index_f == numplot-1):    colorb = "RdBu_r"
                if colorb in ["def","nobar"]:                           palette = get_cmap(name=defcolorb(fvar.upper()))
-               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.")
+               ##### 1. ELIMINATE >3D CASES
+               if len(what_I_plot.shape) >= 4:
+                 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 ?")
+               ##### 2. HANDLE simple 1D/2D field and movies of 1D/2D fields
+               else:
                  if mrate is not None: iend=len(time)-1
                  else:                 iend=0
                  imov = 0 
-                 if var2:  which = "contour" ## have to start with contours rather than shading
-                 else:     which = "regular"
+                 if len(what_I_plot.shape) == 3:
+                    if var2:               which = "contour" ## have to start with contours rather than shading
+                    else:                  which = "regular"
+                    if mrate is None:      errormess("3D field. Use --rate RATE for movie or specify --time TIME. Exit.")
+                 elif len(what_I_plot.shape) == 2:
+                    if var2:               which = "contour" ## have to start with contours rather than shading
+                    else:                  which = "regular"
+                    if mrate is not None:  which = "unidim"
+                 elif len(what_I_plot.shape) == 1:
+                    which = "unidim"
+                 ##### IMOV LOOP #### IMOV LOOP
                  while imov <= iend:
                     print "-> frame ",imov+1, which
@@ -355,6 +364,9 @@
                         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: 
+                    elif which == "unidim":
+                        if mrate is None:                                   what_I_plot_frame = what_I_plot
+                        else:                                               what_I_plot_frame = what_I_plot[:,imov]  ## because swapaxes 
+                    #if mrate is not None:     
+                    if mapmode == 1: 
                             m = define_proj(proj,wlon,wlat,back=back,blat=blat,blon=blon)  ## 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
@@ -362,15 +374,18 @@
 #                   if typefile in ['mesoideal']:    what_I_plot_frame = dumpbdy(what_I_plot_frame,0,stag='W',condition=dumped_vert_stag)
 
-                    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()
-                    
-                    if which == "regular": 
+                    if which == "unidim":
+                        lbl = ""
+                        if indexlat is not None:  lbl = lbl + " ix" + str(indexlat[0])
+                        if indexlon is not None:  lbl = lbl + " iy" + str(indexlon[0])
+                        if indexvert is not None: lbl = lbl + " iz" + str(indexvert[0])
+                        if indextime is not None: lbl = lbl + " it" + str(indextime[0])
+                        if mrate is not None: x = y  ## because swapaxes...
+                        if indexvert is not None or indextime is None:    plot(x,what_I_plot_frame,label=lbl)  ## regular plot
+                        else:                                             plot(what_I_plot_frame,x,label=lbl)  ## vertical profile
+                        if nplot > 1: legend(loc='best')
+                        if indextime is None and axtime is not None:      xlabel(axtime.upper()) ## define the right label
+                        if save == 'txt':  writeascii(np.transpose(what_I_plot),'profile'+str(nplot*1000+imov)+'.txt')
+
+                    elif 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)
@@ -384,6 +399,7 @@
                             if mapmode == 1:       m.pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax, alpha=trans)
                             elif mapmode == 0:     pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax, alpha=trans)
+
                         if colorb != 'nobar':        
-                            if (fileref is not None) and (index_f is numplot-1):   daformat = "%.3f"
+                            if (fileref is not None) and (index_f == numplot-1):   daformat = "%.3f" 
                             elif mult != 1:                                        daformat = "%.1f"
                             else:                                                  daformat = fmtvar(fvar.upper())
@@ -413,6 +429,18 @@
                         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 which in ["regular","unidim"]:
+
+                        if nplot > 1 and which == "unidim":
+                           pass  ## because we superimpose nplot instances
+                        else:
+                           # Axis directives for movie frames [including 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 ylog:      mpl.pyplot.semilogy()
+                           if invert_y:  ax = mpl.pyplot.gca() ; ax.set_ylim(ax.get_ylim()[::-1])
+
                         if mrate is not None:
                            ### THIS IS A MENCODER MOVIE
@@ -437,29 +465,8 @@
                                  myfile.write("last_image = "+str(iend)+";"+ '\n')
                                  myfile.close()
-                        if var2:  which = "contour"
+                        if var2 and which == "regular":  which = "contour"
                         imov = imov+1
                     elif which == "contour":
                         which = "regular"
-
-               ##### 1D field
-               elif len(what_I_plot.shape) is 1:
-                 lbl = ""
-                 if indexlat is not None:  lbl = lbl + " ix" + str(indexlat)
-                 if indexlon is not None:  lbl = lbl + " iy" + str(indexlon)
-                 if indexvert is not None: lbl = lbl + " iz" + str(indexvert)
-                 if indextime is not None: lbl = lbl + " it" + str(indextime)
-
-                 if indexvert is not None or indextime is None:    plot(x,what_I_plot,label=lbl)  ## regular plot
-                 else:                                             plot(what_I_plot,x,label=lbl)  ## vertical profile
-                 if nplot > 1: legend(loc='best')
-                 if indextime is None and axtime is not None:      xlabel(axtime.upper()) ## define the right label
-                 if save == 'txt':  writeascii(np.transpose(what_I_plot),'profile'+str(nplot)+'.txt')
-
-               #### Other cases: (maybe plot 3-D field one day ??)
-               else:
-                 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:
-               errormess("There is an error in reducing field !")
 
        ### Next subplot
@@ -469,6 +476,6 @@
        if mrate is not None: basename = "movie_" + basename 
        if typefile in ['mesoapi','meso']:
-            if slon is not None: basename = basename + "_lon_" + str(int(lon2d[indices[1],indices[0]]))
-            if slat is not None: basename = basename + "_lat_" + str(int(lat2d[indices[1],indices[0]]))
+            if slon is not None: basename = basename + "_lon_" + str(int(round(lonp)))
+            if slat is not None: basename = basename + "_lat_" + str(int(round(latp)))
             plottitle = basename
             ### dans le nouveau systeme time=ls,sol,lt cette ligne pourrait ne servir a rien (ou deplacer au dessus)
Index: trunk/UTIL/PYTHON/pp.py
===================================================================
--- trunk/UTIL/PYTHON/pp.py	(revision 474)
+++ trunk/UTIL/PYTHON/pp.py	(revision 475)
@@ -107,8 +107,10 @@
           #####
           elif typefile == "gcm":
+            inputvar = zevars
+            if opt.var2 is not None : inputvar = np.append(inputvar,opt.var2)
             interpolated_files=""
             interpolated_files=call_zrecast(interp_mode=opt.itp,\
                     input_name=zefiles,\
-                    fields=zevars,\
+                    fields=inputvar,\
                     predefined=opt.intas)
 
Index: trunk/UTIL/farm_tour
===================================================================
--- trunk/UTIL/farm_tour	(revision 474)
+++ trunk/UTIL/farm_tour	(revision 475)
@@ -17,5 +17,5 @@
 machine='levan'
 #####################
-ssh $machine -t "ps --sort=-pcpu -e -o '%C %u %c %x %p' -G lmdjus r | grep -v ps | grep -v root >> ~/log1" > /dev/null 2> /dev/null
+ssh $machine -t "ps --sort=-pcpu -e -o '%C %u %c %x %p' -G lmdjus r | grep -v ps | grep -v root | grep -v grep | grep -v bash >> ~/log1" > /dev/null 2> /dev/null
 echo "*********************************************************" >> ~/log
 echo " $machine ... "`head -n -1 ~/log1 | wc -l`" processeurs utilises sur 8"  >> ~/log
@@ -27,5 +27,5 @@
 machine='penn'
 #####################
-ssh $machine -t "ps --sort=-pcpu -e -o '%C %u %c %x %p' -G lmdjus r | grep -v ps | grep -v root >> ~/log2" > /dev/null 2> /dev/null
+ssh $machine -t "ps --sort=-pcpu -e -o '%C %u %c %x %p' -G lmdjus r | grep -v ps | grep -v root | grep -v grep | grep -v bash >> ~/log2" > /dev/null 2> /dev/null
 echo "*********************************************************" >> ~/log
 echo " $machine ... "`head -n -1 ~/log2 | wc -l`" processeurs utilises sur 8"  >> ~/log
@@ -37,5 +37,5 @@
 machine='viccaro'
 #####################
-ssh $machine -t "ps --sort=-pcpu -e -o '%C %u %c %x %p' -G lmdjus r | grep -v ps | grep -v root >> ~/log3" > /dev/null 2> /dev/null
+ssh $machine -t "ps --sort=-pcpu -e -o '%C %u %c %x %p' -G lmdjus r | grep -v ps | grep -v root | grep -v grep | grep -v bash >> ~/log3" > /dev/null 2> /dev/null
 echo "*********************************************************" >> ~/log 
 echo " $machine ... "`head -n -1 ~/log3 | wc -l`" processeurs utilises sur 8"  >> ~/log
