Index: trunk/UTIL/PYTHON/myplot.py
===================================================================
--- trunk/UTIL/PYTHON/myplot.py	(revision 893)
+++ trunk/UTIL/PYTHON/myplot.py	(revision 896)
@@ -98,4 +98,5 @@
     ## this allows to get much faster and use much less memory esp. with large datasets
     print "   Opening variable",var," with", dimension, "dimensions ..."
+    print indextime, indexlon, indexlat, indexvert
     if dimension == 2:    
         field = nc.variables[var][indextime,indexlon]
@@ -1610,2 +1611,15 @@
     idx=idxsub[0]+np.min(idxs) ; idy=idysub[0]+np.min(idys)
     return np.int(idx),np.int(idy)
+
+# Author : A.S.
+# This is temporary. An object formulation would solve this kind of inelegant approach.
+def alltransfer(zeto,zefrom,all_varname,all_time,all_vert,all_lat,all_lon,all_namefile,all_var2,all_colorb,all_var):
+    all_varname[zeto] 	= all_varname[zefrom] 
+    all_time[zeto] 	= all_time[zefrom] 
+    all_vert[zeto] 	= all_vert[zefrom] 
+    all_lat[zeto] 	= all_lat[zefrom] 
+    all_lon[zeto] 	= all_lon[zefrom] 
+    all_namefile[zeto] 	= all_namefile[zefrom] 
+    all_var2[zeto] 	= all_var2[zefrom] 
+    all_colorb[zeto] 	= all_colorb[zefrom] 
+    all_var[zeto] 	= all_var[zefrom]
Index: trunk/UTIL/PYTHON/planetoplot.py
===================================================================
--- trunk/UTIL/PYTHON/planetoplot.py	(revision 893)
+++ trunk/UTIL/PYTHON/planetoplot.py	(revision 896)
@@ -118,7 +118,12 @@
         print "********* SPEED MODE. EXPERIMENTAL. ********"
         print "********************************************"
-### we ensure namefiles and var are arrays
+### we ensure namefiles and var are arrays and we get their size
     if not isinstance(namefiles, np.ndarray): namefiles = [namefiles]
     if not isinstance(var, np.ndarray):       var = [var]
+    zelenfile = len(namefiles) ; zelenvar = len(var)
+### we check colorbars options (including trycol i.e. the user wants to try a set of colorbars)
+    if trycol: clb = ["Greys","Blues","YlOrRd","jet","spectral","hot","RdBu","RdYlBu","Paired"] ; zetitle = clb ; var = [var[0]]*9 ; zelenvar = len(var)
+    if clb is None:            clb = ["def"]*zelenvar
+    elif len(clb) < zelenvar:  clb = [clb[0]]*zelenvar ; print "WARNING: less color than vars! setting all to 1st value."
 ### we initialize a few variables
     initime=-1 ; sslon = None ; sslat = None
@@ -127,15 +132,11 @@
     if slon is not None: sslon = np.zeros([1,2])
     if slat is not None: sslat = np.zeros([1,2])
-    if clb is None:            clb = ["def"]*len(var)
-    elif len(clb) < len(var):  clb = [clb[0]]*len(var) ; print "WARNING: less color than vars! setting all to 1st value."
     if redope is not None and winds: winds=False ; print "WARNING: no winds with redope. setting winds to False."
-### we set option trycol i.e. the user wants to try a set of colorbars
-    if trycol: clb = ["Greys","Blues","YlOrRd","jet","spectral","hot","RdBu","RdYlBu","Paired"] ; zetitle = clb ; var = [var[0]]*9
 ### we avoid specific cases not yet implemented
-    if mrate is not None and len(var) > 1: myplot.errormess("multivar not allowed in movies. should be fixed soon!")
+    if mrate is not None and zelenvar > 1: myplot.errormess("multivar not allowed in movies. should be fixed soon!")
 ### we prepare number of plot fields [zelen] and number of plot instances [numplot] according to user choices
 ### --> we support multifile and multivar plots : files + vars separated by commas are on the same figure
     nlon, nlat, nvert, ntime, mapmode, nslices = myplot.determineplot(slon, slat, svert, stime, redope)
-    zelen = len(namefiles)*len(var)
+    zelen = zelenfile*zelenvar
     if (nslices > 1 and monster): myplot.errormess("multislice + monster not supported yet. to be done soon")
 ### we have a special mode obtained by -p noproj in which lat/lon plots are just flat 2D plots
@@ -143,8 +144,8 @@
 ### we correct number of plot fields for possible operation (substract, etc...)
     if ope is not None:
-        if fileref is not None:       zelen = 3*len(var)*len(namefiles)
+        if fileref is not None:       zelen = 3*zelenvar*zelenfile
         elif "var" in ope:            zelen = zelen + 1
     numplot = zelen*nslices
-    print "********** FILES, SLICES, VARS, TOTAL PLOTS: ", len(namefiles), nslices, len(var), numplot
+    print "********** FILES, SLICES, VARS, TOTAL PLOTS: ", zelenfile, nslices, zelenvar, numplot
     print "********** MAPMODE: ", mapmode
 ### we define the arrays for plot fields -- which will be placed within multiplot loops
@@ -160,6 +161,6 @@
 #############################
    
-    for nnn in range(len(namefiles)):
-     for vvv in range(len(var)): 
+    for nnn in range(zelenfile):
+     for vvv in range(zelenvar): 
 
     ### we load each NETCDF objects in namefiles
@@ -362,12 +363,12 @@
         ## We plot 1) all lon slices 2) all lat slices 3) all vert slices 4) all time slices and then go to the next slice
         if ope is not None:
-            if fileref is not None:      index_f = (k//(nlon*nlat*nvert*ntime))%(3*len(namefiles))  ## OK only 1 var,  see test in the beginning
-            elif "var" in ope:           index_f = (k//(nlon*nlat*nvert*ntime))%(len(var)+1)        ## OK only 1 file, see test in the beginning
+            if fileref is not None:      index_f = (k//(nlon*nlat*nvert*ntime))%(3*zelenfile)  ## OK only 1 var,  see test in the beginning
+            elif "var" in ope:           index_f = (k//(nlon*nlat*nvert*ntime))%(zelenvar+1)        ## OK only 1 file, see test in the beginning
             elif "cat" in ope:           index_f = 0
         elif not (k == 0):
-           #if len(namefiles) > 1 and len(var) == 1 and which == "unidim": pass ## TROUVER UN MOYEN POUR unidim
-           if len(namefiles) > 1 and len(var) == 1: pass
-           else: yeah = len(namefiles)*len(var) ; index_f = (k//(nlon*nlat*nvert*ntime))%yeah
-        else: yeah = len(namefiles)*len(var) ; index_f = (k//(nlon*nlat*nvert*ntime))%yeah
+           #if zelenfile > 1 and zelenvar == 1 and which == "unidim": pass ## TROUVER UN MOYEN POUR unidim
+           if zelenfile > 1 and zelenvar == 1: pass
+           else: yeah = zelenfile*zelenvar ; index_f = (k//(nlon*nlat*nvert*ntime))%yeah
+        else: yeah = zelenfile*zelenvar ; index_f = (k//(nlon*nlat*nvert*ntime))%yeah
 
         ilon  = myplot.getsindex(sslon,k%nlon,lon)
@@ -424,6 +425,6 @@
     if ope is not None and "var" in ope:
          print "********** OPERATION: ",ope
-         if len(namefiles) > 1: myplot.errormess("for this operation... please set only one file !")
-         if len(var) > 2:       myplot.errormess("not sure this works for more than 2 vars... please check.")
+         if zelenfile > 1: myplot.errormess("for this operation... please set only one file !")
+         if zelenvar > 2:       myplot.errormess("not sure this works for more than 2 vars... please check.")
          if   "div_var" in ope: all_var[k] = all_var[k-2] / all_var[k-1] ; insert = '_div_'
          elif "mul_var" in ope: all_var[k] = all_var[k-2] * all_var[k-1] ; insert = '_mul_'
@@ -442,24 +443,23 @@
              all_varname[0] = all_varname[k-2] + insert + all_varname[k-1]
 
-
-    ##################################
-    ### Operation on files (II) without _var
-    # we re-iterate on the plots to set operation subplots to make it compatible with multifile (using the same ref file)
-    # (k+1)%3==0 is the index of operation plots
-    # (k+2)%3==0 is the index of reference plots
-    # (k+3)%3==0 is the index of first plots
-    opefirstpass=True
     if ope is not None and "var" not in ope:
        print "********** OPERATION: ",ope
+       if zelenvar > 1: myplot.errormess("for this operation... please set only one var !")
+       if fileref is None and ope not in ['cat']: myplot.errormess("fileref is missing!")
+       ################################## this is terribly complex for the main program file. got to do something about this
+       ### Operation on files (II) without _var
+       # we re-iterate on the plots to set operation subplots to make it compatible with multifile (using the same ref file)
+       # (k+1)%3==0 is the index of operation plots
+       # (k+2)%3==0 is the index of reference plots
+       # (k+3)%3==0 is the index of first plots
+       opefirstpass=True
        for k in np.arange(zelen):
-               if len(var) > 1: myplot.errormess("for this operation... please set only one var !")
                if ope in ["-","+","-%","-_only","+_only","-%_only","-_histo"]:
-                  if fileref is None: myplot.errormess("fileref is missing!")
-                  else:ncref = Dataset(fileref)
+                  ncref = netCDF4.Dataset(fileref)
 
                   if opefirstpass: ## first plots
-                     for ll in np.arange(len(namefiles)):
+                     for ll in np.arange(zelenfile):
                         print "SETTING FIRST PLOT"
-                        all_varname[3*ll] = all_varname[ll] ; all_time[3*ll] = all_time[ll] ; all_vert[3*ll] = all_vert[ll] ; all_lat[3*ll] = all_lat[ll] ; all_lon[3*ll] = all_lon[ll] ; all_namefile[3*ll] = all_namefile[ll] ; all_var2[3*ll] = all_var2[ll] ; all_colorb[3*ll] = all_colorb[ll] ; all_var[3*ll] = all_var[ll]
+                        myplot.alltransfer(3*ll,ll,all_varname,all_time,all_vert,all_lat,all_lon,all_namefile,all_var2,all_colorb,all_var)
                         if plot_y[ll] is not None: plot_y[3*ll] = plot_y[ll] ; plot_x[3*ll] = plot_x[ll]
                         else: plot_y[3*ll] = None ; plot_x[3*ll] = None
@@ -468,5 +468,6 @@
                   if (k+2)%3==0: ## reference plots
                         print "SETTING REFERENCE PLOT"
-                        all_varname[k] = all_varname[k-1] ; all_time[k] = all_time[k-1] ; all_vert[k] = all_vert[k-1] ; all_lat[k] = all_lat[k-1] ; all_lon[k] = all_lon[k-1] ; all_namefile[k] = all_namefile[k-1] ; all_var2[k] = all_var2[k-1] ; all_colorb[k] = all_colorb[k-1]
+                        myplot.alltransfer(k,k-1,all_varname,all_time,all_vert,all_lat,all_lon,all_namefile,all_var2,all_colorb,all_var)
+                        ### all_var is actually overwritten here
                         all_var[k], plot_x[k], plot_y[k] = myplot.select_getfield(zvarname=all_varname[k-1],znc=ncref,ztypefile=typefile,mode='getvar',ztsat=tsat,ylon=all_lon[k],ylat=all_lat[k],yalt=all_vert[k],ytime=all_time[k],analysis=analysis)
                         if winds: all_windu[k] = myplot.getfield(ncref,uchar) ; all_windv[k] = myplot.getfield(ncref,vchar)
@@ -499,5 +500,5 @@
                   tabtime = all_time[0];tab = all_var[0];k = 1
                   if var2: tab2 = all_var2[0]
-                  while k != len(namefiles) and len(all_time[k]) != 0:
+                  while k != zelenfile 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
@@ -514,6 +515,6 @@
     fig = mpl.pyplot.figure()
     subv,subh = myplot.definesubplot( numplot, fig, ipreferline = (mapmode == 1) ) 
-    if ope in ['-','-%','-_histo'] and len(namefiles) ==1 : subv,subh = 2,2
-    elif ope in ['-','-%'] and len(namefiles)>1 : subv, subh = len(namefiles), 3
+    if ope in ['-','-%','-_histo'] and zelenfile ==1 : subv,subh = 2,2
+    elif ope in ['-','-%'] and zelenfile>1 : subv, subh = zelenfile, 3
  
     #################################
@@ -532,11 +533,11 @@
        ## We plot 1) all lon slices 2) all lat slices 3) all vert slices 4) all time slices and then go to the next slice
        if ope is not None:
-           if fileref is not None:      index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%(3*len(namefiles))  ## OK only 1 var,  see test in the beginning
-           elif "var" in ope:           index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%(len(var)+1)        ## OK only 1 file, see test in the beginning
+           if fileref is not None:      index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%(3*zelenfile)  ## OK only 1 var,  see test in the beginning
+           elif "var" in ope:           index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%(zelenvar+1)        ## OK only 1 file, see test in the beginning
            elif "cat" in ope:           index_f = 0
        elif not firstpass:
-          if len(namefiles) > 1 and len(var) == 1 and which == "unidim": pass
-          else: yeah = len(namefiles)*len(var) ; index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah
-       else: yeah = len(namefiles)*len(var) ; index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah
+          if zelenfile > 1 and zelenvar == 1 and which == "unidim": pass
+          else: yeah = zelenfile*zelenvar ; index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah
+       else: yeah = zelenfile*zelenvar ; index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah
        time = all_time[index_f] ; vert = all_vert[index_f] ; lat = all_lat[index_f] ; lon = all_lon[index_f]
        indexlon  = myplot.getsindex(sslon,(nplot-1)%nlon,lon)
@@ -669,5 +670,5 @@
                     which = "unidim"
                     if what_I_plot.shape[-1] == 1:      print "VALUE VALUE VALUE VALUE ::: ", what_I_plot[0] ; save = 'donothing'
-##                 if which == "unidim" and len(namefiles) > 1: numplot = 1 # this case is similar to several vars from one file 
+##                 if which == "unidim" and zelenfile > 1: numplot = 1 # this case is similar to several vars from one file 
                  ##### IMOV LOOP #### IMOV LOOP
                  while imov <= iend:
@@ -780,5 +781,5 @@
                              if teststream:
                                 print 'INFO: Using stream file',streamfile, 'for stream lines'
-                                ncstream = Dataset(streamfile)
+                                ncstream = netCDF4.Dataset(streamfile)
                                 psi = myplot.getfield(ncstream,'psi')
                                 psi = psi[0,:,:,0] # time and longitude are dummy dimensions
@@ -871,5 +872,5 @@
                             
                     elif which == "contour":
-                        mpl.pyplot.rcParams['contour.negative_linestyle'] = 'solid' # no dashed line for negative values
+                        #mpl.pyplot.rcParams['contour.negative_linestyle'] = 'solid' # no dashed line for negative values
                         zevminc, zevmaxc = myplot.calculate_bounds(what_I_plot_frame, vmin=min(what_I_plot_frame), vmax=max(what_I_plot_frame))
                         zelevels = np.linspace(zevminc,zevmaxc,ticks/2) #20)
@@ -880,5 +881,5 @@
                         elif var2 == 'wstar':    zelevels = np.arange(0,10,1.0)
                         elif var2 == 'zmax_th':  zelevels = np.arange(0,10,2.0) ; what_I_plot_frame = what_I_plot_frame / 1000.
-                        elif var2 in ['u']:      zelevels = np.arange(-400.,400.,10.)
+                        elif var2 in ['u']:      zelevels = np.arange(-400.,400.,5.)
                         ###
                         if mapmode == 0:   
@@ -901,4 +902,7 @@
                            if zxmin is not None: mpl.pyplot.xlim(xmin=zxmin)
                            if zxmax is not None: mpl.pyplot.xlim(xmax=zxmax)
+                           if zxmin is not None and zxmax is not None:
+                               ax = mpl.pyplot.gca()
+                               ax.get_xaxis().set_ticks(np.linspace(xaxis[0],xaxis[1],ticks/2+1)) 
                            if zymin is not None: mpl.pyplot.ylim(ymin=zymin)
                            if zymax is not None: mpl.pyplot.ylim(ymax=zymax)
@@ -976,5 +980,5 @@
        nplot += 1
 
-       if len(namefiles) > 1 and len(var) == 1 and which == "unidim": index_f=index_f+1
+       if zelenfile > 1 and zelenvar == 1 and which == "unidim": index_f=index_f+1
        firstpass=False
 
