Index: /trunk/UTIL/PYTHON/myscript.py
===================================================================
--- /trunk/UTIL/PYTHON/myscript.py	(revision 401)
+++ /trunk/UTIL/PYTHON/myscript.py	(revision 402)
@@ -4,5 +4,5 @@
     parser.add_option('-f', '--file',   action='append',dest='file',     type="string",  default=None,  help='[NEEDED] filename. Append: different figures. Comma-separated: same figure (+ possible --operation). Regex tip: -f `echo foo* | sed s+" "+","+g`')
     parser.add_option('-t', '--target', action='store',dest='tgt',       type="string",  default=None,  help='destination folder')
-    parser.add_option('-S', '--save',   action='store',dest='save',      type="string",  default="gui", help='save mode (png,eps,svg,pdf or gui) [gui]')
+    parser.add_option('-S', '--save',   action='store',dest='save',      type="string",  default="gui", help='save mode (png,eps,svg,pdf,txt or gui) [gui]')
     parser.add_option('-d', '--display',action='store_false',dest='display',             default=True,  help='do not pop up created images')
     parser.add_option('-O','--output',  action='store',dest='out',       type="string",  default=None,  help='output file name')
Index: /trunk/UTIL/PYTHON/planetoplot.py
===================================================================
--- /trunk/UTIL/PYTHON/planetoplot.py	(revision 401)
+++ /trunk/UTIL/PYTHON/planetoplot.py	(revision 402)
@@ -65,5 +65,5 @@
                        zoomset,getcoorddef,getwinddef,whatkindfile,reducefield,bounds,getstralt,getfield,smooth,nolow,\
                        getname,localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar
-    from mymath import deg,max,min,mean,get_tsat
+    from mymath import deg,max,min,mean,get_tsat,writeascii
     import matplotlib as mpl
     from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title
@@ -135,13 +135,8 @@
 ##########################################################
       if typefile == "gcm":
-          lat = nc.variables["latitude"][:] 
-          lon = nc.variables["longitude"][:]
-          if "Time" in nc.variables:
-             time = nc.variables["Time"][:]
-          elif "time" in nc.variables:
-             time = nc.variables["time"][:]
-          else:
-             print "no time axis found."
-             exit()
+          lat = nc.variables["latitude"][:] ; lon = nc.variables["longitude"][:]
+          if "Time" in nc.variables:      time = nc.variables["Time"][:]
+          elif "time" in nc.variables:    time = nc.variables["time"][:]
+          else:                           errormess("no time axis found.")
           vert = nc.variables["altitude"][:]
       elif typefile in ['meso','mesoapi']:
@@ -155,6 +150,5 @@
           if varname in ['U']:  londim='WEST-EAST_PATCH_END_STAG'
           else:                 londim='WEST-EAST_PATCH_END_UNSTAG'
-          lon = np.arange(0,getattr(nc,londim),1)
-          lat = np.arange(0,getattr(nc,latdim),1)
+          lon = np.arange(0,getattr(nc,londim),1) ; lat = np.arange(0,getattr(nc,latdim),1)
           if vertmode is None:  vertmode=0
           if vertmode == 0:     vert = np.arange(0,getattr(nc,vertdim),1)
@@ -179,4 +173,7 @@
          if zoom:                          [wlon,wlat] = zoomset(wlon,wlat,zoom) 
 
+      all_varname[k] = varname
+      all_namefile[k] = namefile
+      if var2: all_var2[k] = getfield(nc,var2)
       ##### SPECIFIC
       if varname in ["temp","t","T_nadir_nit","T_nadir_day","temp_day","temp_night"] and tsat:
@@ -188,8 +185,4 @@
       ##### GENERAL STUFF HERE
           all_var[k] = getfield(nc,varname)
-      all_varname[k] = varname
-      all_namefile[k] = namefile
-      if var2: all_var2[k] = getfield(nc,var2)
-      
       print "********** all_var[k].shape", all_var[k].shape
       k += 1
@@ -207,13 +200,11 @@
                 if ope == "-":     all_var[k+1]= all_var[k-1] - all_var[k]
                 elif ope == "+":   all_var[k+1]= all_var[k-1] + all_var[k]
-                all_varname[k+1] = all_varname[k]
-                numplot = numplot+2
+                all_varname[k+1] = all_varname[k] ; numplot = numplot+2
              elif ope in ["cat"]:
                 tab = all_var[0];k = 1
                 while k != len(namefiles)-1: 
-                    tab = np.append(tab,all_var[k],axis=0)
-                    k += 1
-                time = np.arange(0,len(tab),1) ### AS: time reference is simple, should be better
-                all_var[0] = np.array(tab);numplot = 1
+                    tab = np.append(tab,all_var[k],axis=0) ; k += 1
+                time = np.arange(0,len(tab),1) ### AS: time reference is too simplistic, should be better
+                all_var[0] = np.array(tab) ; numplot = 1
              elif ope is not None:
                 errormess(ope+" : non-implemented operation. Available op. are + and -.")
@@ -229,5 +220,4 @@
     if itstep is None and numplot > 0: itstep = int(24./numplot)
     elif numplot <= 0:                 itstep = 1 
-    
     print "********************************************"
     while error is False:
@@ -270,14 +260,6 @@
            indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time)  
 
-       if fileref is not None:
-           index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%(len(namefiles)+2)  ## OK only 1 var, see test in the beginning
-       else:
-           yeah = len(namefiles)*len(var)
-           index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah
-       #print nlon, nlat, nvert, ntime  
-       #print slon, slat, svert, stime       
-       #print index_f
-       #print "index lon,lat,vert,time", indexlon, indexlat, indexvert, indextime
-       #if varname != all_varname[index_f]:  indextime = first
+       if fileref is not None:      index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%(len(namefiles)+2)  ## OK only 1 var, see test in the beginning
+       else:                        yeah = len(namefiles)*len(var) ; index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah
 ####################################################################
 
@@ -341,11 +323,8 @@
                      #contourf(what_I_plot, zelevels, cmap = palette )
 
-                     if mapmode == 1:
-                       m.contourf( x, y, what_I_plot, zelevels, cmap = palette)
-                     elif mapmode == 0:
-                       contourf( x, y, what_I_plot, zelevels, cmap = palette)
-
-                     zxmin, zxmax = xaxis
-                     zymin, zymax = yaxis
+                     if mapmode == 1:       m.contourf( x, y, what_I_plot, zelevels, cmap = palette)
+                     elif mapmode == 0:     contourf( x, y, what_I_plot, zelevels, cmap = palette)
+
+                     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)
@@ -376,4 +355,6 @@
                elif len(what_I_plot.shape) is 1:
                  plot(x,what_I_plot)
+                 if save == 'txt':  writeascii(np.transpose(what_I_plot),'profile'+str(nplot)+'.txt')
+
                #### Other cases: (maybe plot 3-D field one day or movie ??)
                else:
@@ -418,34 +399,22 @@
        else:
             if fileref is not None:
-                if index_f is numplot-1:
-                   plottitle = basename+' '+"fig(1) "+ope+" fig(2)"
-                elif index_f is numplot-2:
-                   plottitle = basename+' '+fileref
-                else:
-                   plottitle = basename+' '+namefiles[0]#index_f]
-            else:
-                plottitle = basename+' '+namefiles[0]#index_f]
-       if mult != 1:           plottitle = str(mult) + "*" + plottitle
-       if zetitle != "fill":   
+                if index_f is numplot-1:     plottitle = basename+' '+"fig(1) "+ope+" fig(2)"
+                elif index_f is numplot-2:   plottitle = basename+' '+fileref
+                else:                        plottitle = basename+' '+namefiles[0]#index_f]
+            else:                            plottitle = basename+' '+namefiles[0]#index_f]
+       if mult != 1:                         plottitle = str(mult) + "*" + plottitle
+       if zetitle != "fill":                 
           plottitle = zetitle
-          if titleref is "fill":
-             titleref=zetitle
+          if titleref is "fill":             titleref=zetitle
           if fileref is not None:
-             if index_f is numplot-2:
-                plottitle = titleref
-             if index_f is numplot-1:
-                plottitle = "fig(1) "+ope+" fig(2)"
-#       if indexlon is not None:
-#         plottitle = plottitle + " lon: " + str(min(lon[indexlon])) +" "+ str(max(lon[indexlon]))
-#       if indexlat is not None:
-#         plottitle = plottitle + " lat: " + str(min(lat[indexlat])) +" "+ str(max(lat[indexlat]))
-#       if indexvert is not None:
-#         plottitle = plottitle + " vert: " + str(min(vert[indexvert])) +" "+ str(max(vert[indexvert]))
-#       if indextime is not None:
-#         plottitle = plottitle + " time: " + str(min(time[indextime])) +" "+ str(max(time[indextime]))
+             if index_f is numplot-2:        plottitle = titleref
+             if index_f is numplot-1:        plottitle = "fig(1) "+ope+" fig(2)"
+#       if indexlon is not None:      plottitle = plottitle + " lon: " + str(min(lon[indexlon])) +" "+ str(max(lon[indexlon]))
+#       if indexlat is not None:      plottitle = plottitle + " lat: " + str(min(lat[indexlat])) +" "+ str(max(lat[indexlat]))
+#       if indexvert is not None:     plottitle = plottitle + " vert: " + str(min(vert[indexvert])) +" "+ str(max(vert[indexvert]))
+#       if indextime is not None:     plottitle = plottitle + " time: " + str(min(time[indextime])) +" "+ str(max(time[indextime]))
        title( plottitle )
        itime += itstep
-       if nplot >= numplot:
-          error = True
+       if nplot >= numplot: error = True
        nplot += 1
 
@@ -480,8 +449,7 @@
             if display: makeplotres(zeplot,res=100.,pad_inches_value=pad_inches_value) #,erase=True)  ## a miniature
             makeplotres(zeplot,res=resolution,pad_inches_value=pad_inches_value,disp=False)
-        elif save in ['eps','svg','pdf']:
-            makeplotres(zeplot,         pad_inches_value=pad_inches_value,disp=False,ext=save)
-        elif save == 'gui':
-            show()
+        elif save in ['eps','svg','pdf']:     makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save)
+        elif save == 'gui':                   show()
+        elif save == 'txt':                   print "Saved results in txt file." 
         else: 
             print "INFO: save mode not supported. using gui instead."
