Index: /trunk/UTIL/PYTHON/planetoplot_v2/examples/easy_get_field.py
===================================================================
--- /trunk/UTIL/PYTHON/planetoplot_v2/examples/easy_get_field.py	(revision 930)
+++ /trunk/UTIL/PYTHON/planetoplot_v2/examples/easy_get_field.py	(revision 930)
@@ -0,0 +1,41 @@
+#! /usr/bin/env python
+from ppclass import pp
+import numpy as np
+import matplotlib.pyplot as mpl
+
+test = pp()
+test.file = [ \
+  "/planeto/jllmd/Earth/Nmix/F1525/output/diagfi4.nc", \
+  "/planeto/jllmd/Earth/Nmix/F1550/output/diagfi4.nc", \
+  "/planeto/jllmd/Earth/Nmix/F1500/output/diagfi4.nc" ]
+test.var = ["tsurf","ASR"]
+test.x = "-180.,175."
+test.y = "-90.,90."
+test.t = "0,1000"
+#test.verbose = True
+test.compute = "meanarea"
+test.get()
+
+# -----------------------------
+# self.allfield contains data !
+# -----------------------------
+# index ordering: 
+# - file
+# - var
+# - request t
+# - request z
+# - request y
+# - request x
+# - field dimensions
+# -----------------------------
+# ALL DIM == 1 HAVE BEEN SQUEEZED
+# -----------------------------
+
+# for instance here, shape of allfield is (3,2)
+# because the user requested 3 files, 2 vars, 0D values
+
+tsurf = test.allfield[:,0]
+asr = test.allfield[:,1]
+
+mpl.plot(tsurf,asr)
+mpl.show()
Index: /trunk/UTIL/PYTHON/planetoplot_v2/examples/intercompare.py
===================================================================
--- /trunk/UTIL/PYTHON/planetoplot_v2/examples/intercompare.py	(revision 930)
+++ /trunk/UTIL/PYTHON/planetoplot_v2/examples/intercompare.py	(revision 930)
@@ -0,0 +1,128 @@
+#! /usr/bin/env python
+from ppclass import pp
+
+### LMD simulation results
+### ----------------------
+### set object
+lmdu = pp()
+### set file var coord
+lmdu.file = 'LMD/wrfout_d01_2024-09-08_01:00:00_z'
+lmdu.var = 'Um'
+lmdu.x = -6.
+lmdu.y = -2.
+lmdu.t = 0.
+### get data
+lmdu.get()
+
+### MRAMS simulation results
+### ------------------------
+### set object
+mramsu = pp()
+### get attributes from lmd object
+mramsu << lmdu
+### OK just change what changes in MRAMS
+mramsu.file = 'MRAMS/mramsout_d01_2024-09-08_01:00:00_z'
+mramsu.var = 'u_areo'
+### get data
+mramsu.get()
+
+### THE SAME BUT FOR V
+### ------------------
+lmdv = pp()
+lmdv << lmdu
+lmdv.var = 'Vm'
+lmdv.get()
+mramsv = pp()
+mramsv << mramsu
+mramsv.var = 'v_areo'
+mramsv.get()
+
+### COMPUTE WIND SPEED
+### ------------------
+lmd = (lmdu**2+lmdv**2)**0.5
+mrams = (mramsu**2+mramsv**2)**0.5
+
+### NOW PLOT
+### --------
+### define plot for LMD
+### ... and prepare it so that MRAMS will be superimposed
+lmd.superpose = True
+lmd.defineplot(extraplot=1)
+### ... add a few personal settings
+lmd.p[0].title = "LMD (blue) vs. MRAMS (red)"
+lmd.p[0].swaplab = False
+lmd.p[0].xlabel = "Wind speed (m s$^{-1})$"
+lmd.p[0].ylabel = "Altitude above MOLA zero datum (km)"
+lmd.p[0].ycoeff = 1./1000.
+### ... and make plot (no output, wait for extraplot)
+lmd.makeplot()
+### --------
+### define plot for MRAMS
+### ... say we will plot this in lmd figure
+mrams.plotin = lmd
+mrams.superpose = True
+### ... and make plot (now there is an output)
+mrams.out = 'png'
+mrams.filename = 'wind_intercomp'
+mrams.plot()
+
+### COMPUTE REL DIFF in % AND PLOT IT INDEPENDENTLY
+### -----------------------------------------------
+diff = ((lmd-mrams)/(lmd*0.5+mrams*0.5))*100.
+diff.filename = 'wind_intercomp_diff'
+diff.superpose = False
+diff.out = 'png'
+diff.defineplot()
+diff.p[0].title = ""
+diff.p[0].swaplab = False
+diff.p[0].xlabel = "Relative difference in wind LMD vs. MRAMS (%)"
+diff.p[0].ylabel = "Altitude above MOLA zero datum (km)"
+diff.p[0].ycoeff = 1./1000.
+diff.makeplot()
+
+### SAME FOR TEMPERATURE
+### --------------------
+lmdt = pp()
+lmdt << lmdu
+lmdt.var = 'tk'
+lmdt.get()
+mramst = pp()
+mramst << mramsu
+mramst.var = 'tk'
+mramst.get()
+difft = ((lmdt-mramst)/(lmdt*0.5+mramst*0.5))*100.
+difft.defineplot()
+difft.filename = 'temp_intercomp_diff'
+difft.superpose = False
+difft.out = 'png'
+difft.defineplot()
+difft.p[0].title = ""
+difft.p[0].swaplab = False
+difft.p[0].xlabel = "Relative difference in temperature LMD vs. MRAMS (%)"
+difft.p[0].ylabel = "Altitude above MOLA zero datum (km)"
+difft.p[0].ycoeff = 1./1000.
+difft.makeplot()
+
+### TEMPERATURE
+###############
+
+int = pp()
+int.file = ['LMD/wrfout_d01_2024-09-08_01:00:00_z','MRAMS/mramsout_d01_2024-09-08_01:00:00_z']
+int.var = 'tk'
+int.x = -6.
+int.y = -2.
+int.t = 0.
+int.out = 'png'
+int.filename = 'temp_intercomp'
+int.superpose = True
+int.getdefineplot()
+
+int.p[0].title = "LMD (blue) vs. MRAMS (red)"
+int.p[0].swaplab = False
+int.p[0].ylabel = "Altitude above MOLA zero datum (km)"
+int.p[0].ycoeff = 1./1000.
+int.p[0].title = lmd.p[0].title
+int.p[0].xlabel = "Temperature (K)"
+
+int.makeplot()
+
Index: /trunk/UTIL/PYTHON/planetoplot_v2/exapi.py
===================================================================
--- /trunk/UTIL/PYTHON/planetoplot_v2/exapi.py	(revision 930)
+++ /trunk/UTIL/PYTHON/planetoplot_v2/exapi.py	(revision 930)
@@ -0,0 +1,103 @@
+#! /usr/bin/env python
+from api_wrapper import api_onelevel
+from ppclass import separatenames,inspect
+from optparse import OptionParser ### TBR by argparse
+import numpy as np
+# -----------------------------------------------------------------------
+# A simple script to call the API program to interpolate mesoscale files
+# ... NB: API_WRAPPER necessary with api compiled with f2py
+# Author: A. Spiga 04/2013
+# -----------------------------------------------------------------------
+
+# default settings
+# ---------------- 
+defitp = 4
+deflvl = "0.1"
+
+# define parser with version and usage 
+# ------------------------------------
+parser = OptionParser()
+parser.version = \
+'''***********************************************
+******** EXAPI (for help: exapi.py -h) ********
+***********************************************'''
+parser.usage = \
+'''exapi.py [options] netCDF file(s)'''
+parser.print_version()
+
+# define options and get options+arguments
+# ----------------------------------------
+parser.add_option('-v','--var',action='store',dest='var',type="string",default=None,help='Variables processed. Not used means all variables.')
+parser.add_option('-i','--interp',action='store',dest='itp',type="int",default=defitp,help='Mode: 2=press /  3=z-amr / 4=z-als (default)')
+parser.add_option('-l','--level',action='store',dest='lvl',type="string",default=deflvl,help='Levels: start[,stop,step] (-i 2: Pa)(-i 3,4: km)')
+parser.add_option('-o','--output',action='store',dest='output',type="string",default=None,help="name of output files")
+parser.add_option('-d','--directory',action='store',dest='folder',type="string",default=None,help="directory of output files")
+(opt,args) = parser.parse_args()
+
+# get variables
+# if None, take all!
+# ------------------
+if opt.var is None: 
+  ze_process = "all"
+  zevars = None
+else: 
+  ze_process = "list"
+  # (we start by unravelling user input in an array)
+  zevars = separatenames(opt.var)
+  # (we help a little the user about naming certain variables)
+  for i in range(len(zevars)):
+    if zevars[i] in ['t','temp','temperature']: zevars[i] = 'tk'
+    elif zevars[i] in ['T','temppot','theta']: zevars[i] = 'tpot'
+    elif zevars[i] in ['u','v','U','V','Um','Vm','uv','UV','wind']: zevars[i] = 'uvmet'
+  # (we recombine them all for call to api)
+  list = ""
+  for el in zevars: list = list + el + ","
+  zevars = list
+
+# get the kind of interpolation
+# -----------------------------
+inputnvert = separatenames(opt.lvl)
+
+# prepare levels: one-level only
+# ------------------------------
+if len(inputnvert) == 1:
+    zelevel = float(inputnvert[0])
+    ze_interp_levels = [-9999.]
+
+# prepare levels: several levels
+# ------------------------------
+elif len(inputnvert) > 1:
+    # initialize. make number of interp levels to 20 if not given.
+    zelevel = -99.
+    start = float(inputnvert[0])
+    stop = float(inputnvert[1])
+    if len(inputnvert) == 2:  numsample = 20
+    else:                     numsample = float(inputnvert[2])
+    # make the interval. either normal -- or log if pressure.
+    if stop > start:
+        # altitude coordinates
+        ze_interp_levels = np.linspace(start,stop,numsample)
+    else:
+        # pressure coordinates
+        ze_interp_levels = np.logspace(np.log10(start),np.log10(stop),numsample)
+
+# main api call
+# -------------
+for file in args:
+    print "EXAPI: working on file",file 
+    newname = api_onelevel ( \
+        path_to_input = '', \
+        path_to_output = None, \
+        input_name = file, \
+        output_name = opt.output, \
+        fields = zevars, \
+        interp_method = opt.itp, \
+        interp_level = ze_interp_levels, \
+        onelevel = zelevel, \
+        process = ze_process )
+    print "EXAPI: inspect the new file."
+    inspect(newname)
+    print "EXAPI: OK. done with this file."
+    
+
+
Index: /trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py
===================================================================
--- /trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py	(revision 929)
+++ /trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py	(revision 930)
@@ -100,6 +100,7 @@
                 zesaxis[i,1] = float(a[1])          
     return zesaxis
+
+# look for comas in the input name to separate different names (files, variables,etc ..)
 # (needed by readslices)
-# look for comas in the input name to separate different names (files, variables,etc ..)
 def separatenames (name):
     if name is None: names = None
@@ -141,4 +142,5 @@
                       filename="myplot",\
                       folder="./",\
+                      includedate=True,\
                       xlabel=None,ylabel=None,\
                       xcoeff=None,ycoeff=None,\
@@ -162,4 +164,5 @@
         self.p = None
         self.customplot = False
+        self.allfield = None
         ## what could be defined by the user
         self.file = file
@@ -180,4 +183,5 @@
         self.filename = filename
         self.folder = folder
+        self.includedate = includedate
         ## here are user-defined plot settings 
         ## -- if not None, valid on all plots in the pp() objects
@@ -238,4 +242,5 @@
             self.label = other.label
             self.title = other.title
+            self.includedate = other.includedate
         else:
             print "!! ERROR !! argument must be a pp object." ; exit()
@@ -560,4 +565,11 @@
         # check if things were done OK before
         if self.status != "defined": print "!! ERROR !! Please use .define() to define your pp object." ; exit()
+        # create the list of allfield() objects
+        # --> so that the user can easily access values
+        self.allfield = [[[[[[ \
+                        [] \
+                        for x in range(self.nplotx)] for y in range(self.nploty)] \
+                        for z in range(self.nplotz)] for t in range(self.nplott)] \
+                        for j in range(self.nvin)]   for i in range(self.nfin)]
         ## first get fields
         ## ... only what is needed is extracted from the files
@@ -572,4 +584,7 @@
               obj.getfield()
               obj.computations()
+              self.allfield[i][j][t][z][y][x] = obj.field
+        # get rid of useless dimensions in allfield
+        self.allfield = np.squeeze(self.allfield)
         # change status
         self.status = "retrieved"
@@ -860,5 +875,5 @@
         print "**** PPCLASS. Done step: makeplot"
         if (self.n == self.howmanyplots):
-            ppplot.save(mode=self.out,filename=self.filename,folder=self.folder,custom=self.customplot)
+            ppplot.save(mode=self.out,filename=self.filename,folder=self.folder,custom=self.customplot,includedate=self.includedate)
             mpl.close()
         # SAVE A PICKLE FILE WITH THE self.p ARRAY OF OBJECTS
@@ -1380,5 +1395,5 @@
           pass
         elif test in ["fixedfree","fixedcomp"] or test in ["freefixed","compfixed"]: 
-          time0 = timelib.time()  
+          time0 = timelib.time()
           # now have to obtain the new indexes which correspond to the extracted self.field
           # for it to work with unique index, ensure that any index_* is a numpy array
@@ -1518,4 +1533,5 @@
                 totarea = np.tile(totarea,(1,self.index_x.size))
         elif self.method_x == "comp" and self.method_y == "comp":
+            aire.field = aire.field[np.ix_(self.index_y, self.index_x)] # reduce to requested indexes only
             totarea = ppcompute.sum(ppcompute.sum(aire.field,axis=1),axis=0)
         else:
@@ -1527,5 +1543,6 @@
         aire.field = np.tile(aire.field,(self.index_t.size,self.index_z.size,1,1))
         if self.field.shape != aire.field.shape:
-            print "!! ERROR !! Problem in area(). Check array shapes." ; exit()
+            print "!! ERROR !! Problem in area(). Check array shapes."
+            print "Field vs. aire:",self.field.shape,aire.field.shape ; exit()
         else:
             self.field = self.field*aire.field
Index: /trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py
===================================================================
--- /trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py	(revision 929)
+++ /trunk/UTIL/PYTHON/planetoplot_v2/ppplot.py	(revision 930)
@@ -418,8 +418,10 @@
                 mpl.legend(loc="best",fancybox=True)
         ## TBD: set with .div the number of ticks
-        ## TBD: be able to control plot limits
         #ticks = self.div + 1
         #ax = mpl.gca()
         #ax.get_xaxis().set_ticks(np.linspace(ppcompute.min(x),ppcompute.max(x),ticks/2+1))
+        # control plot limits (TBD: be able to control those)
+        ax = mpl.gca() ; ax.set_xbound(lower=ppcompute.min(x), upper=ppcompute.max(x))
+
 
 ################################
@@ -660,7 +662,7 @@
                               angles='xy',color=self.colorvec,pivot='middle',\
                               scale=zescale*reducevec,width=widthvec )
-                # make vector key. default is on upper left corner.
-                keyh = 1.025 ; keyv = 1.05
-                #keyh = -0.03 ; keyv = 1.08
+                # make vector key.
+                keyh = 1.025 ; keyv = 1.05 # upper right corner over colorbar
+                #keyh = -0.03 ; keyv = 1.08 # upper left corner
                 p = mpl.quiverkey(q,keyh,keyv,\
                                   zescale,str(int(zescale)),\
Index: /trunk/UTIL/PYTHON/planetoplot_v2/set_area.txt
===================================================================
--- /trunk/UTIL/PYTHON/planetoplot_v2/set_area.txt	(revision 929)
+++ /trunk/UTIL/PYTHON/planetoplot_v2/set_area.txt	(revision 930)
@@ -24,3 +24,4 @@
 Xanadu ; -40 ; 20 ; 40 ; 120
 Hyperboreae ; 80 ; 87 ; -70 ; -10
+VM ; -15 ; 0 ; -90 ; -60
 VM_alt ; -15 ; 0 ; 270 ; 300
