Index: /trunk/MESOSCALE/LMD_MM_MARS/makemeso
===================================================================
--- /trunk/MESOSCALE/LMD_MM_MARS/makemeso	(revision 239)
+++ /trunk/MESOSCALE/LMD_MM_MARS/makemeso	(revision 240)
@@ -538,6 +538,8 @@
       *) echo not yet supported ; exit ;;
   esac
-  restex=$(expr ${physx}%${divx})   
-  restey=$(expr ${physy}%${divy})
+  physx=$(expr ${lon} - 1)
+  restex=$(expr ${physx} \% ${divx})   
+  physy=$(expr ${lat} - 1)
+  restey=$(expr ${physy} \% ${divy})
   if [[ ${restex} != 0 || ${restey} != 0 ]]
   then
@@ -546,6 +548,6 @@
      exit
   fi
-  physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ ${divx})
-  physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ ${divy})
+  physx=$(expr ${physx} \/ ${divx})
+  physy=$(expr ${physy} \/ ${divy})
   physz=$(expr ${level} - 1)
 
Index: /trunk/MESOSCALE_DEV/PLOT/PYTHON/mylib/myplot.py
===================================================================
--- /trunk/MESOSCALE_DEV/PLOT/PYTHON/mylib/myplot.py	(revision 239)
+++ /trunk/MESOSCALE_DEV/PLOT/PYTHON/mylib/myplot.py	(revision 240)
@@ -100,8 +100,14 @@
                 wlon = [-60.,60.]
         elif area == "North_Pole":
-                wlat = [60.,90.]
+                wlat = [50.,90.]
                 wlon = [-180.,180.]
         elif area == "Close_North_Pole":
                 wlat = [75.,90.]
+                wlon = [-180.,180.]
+        elif area == "South_Pole":
+                wlat = [-90.,-50.]
+                wlon = [-180.,180.]
+        elif area == "Close_South_Pole":
+                wlat = [-90.,-75.]
                 wlon = [-180.,180.]
 	return wlon,wlat
@@ -244,24 +250,25 @@
     return [wlon,wlat]
 
-def makeplotpngres (filename,res,pad_inches_value=0.25,folder='',disp=True):
+def makeplotres (filename,res=None,pad_inches_value=0.25,folder='',disp=True,ext='png',erase=False):
     import  matplotlib.pyplot as plt
-    res = int(res)
-    name = filename+"_"+str(res)+".png"
+    from os import system 
+    addstr = ""
+    if res is not None:
+        res = int(res)
+        addstr = "_"+str(res)
+    name = filename+addstr+"."+ext
     if folder != '':      name = folder+'/'+name
     plt.savefig(name,dpi=res,bbox_inches='tight',pad_inches=pad_inches_value)
-    if disp:              display(name)		
+    if disp:              display(name)
+    if ext in ['eps','ps','svg']:   system("tar czvf "+name+".tar.gz "+name+" ; rm -f "+name)
+    if erase:   system("mv "+name+" to_be_erased")		
     return
 
-def makeplotpng (filename,pad_inches_value=0.25,minres=100.,folder='',disp=True):
-    makeplotpngres(filename,minres,     pad_inches_value=pad_inches_value,folder=folder,disp=disp)
-    makeplotpngres(filename,minres+200.,pad_inches_value=pad_inches_value,folder=folder,disp=False)
-    return
-
-def dumpbdy (field,stag=None):
+def dumpbdy (field,n,stag=None):
     nx = len(field[0,:])-1
     ny = len(field[:,0])-1
     if stag == 'U': nx = nx-1
     if stag == 'V': ny = ny-1
-    return field[5:ny-5,5:nx-5]
+    return field[n:ny-n,n:nx-n]
 
 def getcoorddef ( nc ):   
@@ -270,6 +277,6 @@
     if typefile in ['mesoapi','meso']:
         [lon2d,lat2d] = getcoord2d(nc)
-        lon2d = dumpbdy(lon2d)
-        lat2d = dumpbdy(lat2d)
+        lon2d = dumpbdy(lon2d,6)
+        lat2d = dumpbdy(lat2d,6)
     elif typefile in ['gcm']:
         [lon2d,lat2d] = getcoord2d(nc,nlat="latitude",nlon="longitude",is1d=True)
@@ -376,9 +383,11 @@
     import  numpy                           as np
     import  matplotlib                      as mpl
+    from mymath import max
     meanlon = 0.5*(wlon[0]+wlon[1])
     meanlat = 0.5*(wlat[0]+wlat[1])
     if   wlat[0] >= 80.:   blat =  40. 
-    elif wlat[0] <= -80.:  blat = -40. 
-    else:                  blat = wlat[0]
+    elif wlat[1] <= -80.:  blat = -40. 
+    else:                  blat = max([wlat[0],wlat[1]])
+    print blat
     h = 50.  ## en km
     radius = 3397200.
@@ -482,4 +491,5 @@
              "ICETOT":       "%.1e",\
              "TAU_ICE":      "%.2f",\
+             "anomaly":      "%.1f",\
                     }
     if whichvar not in fmtvar:
@@ -499,5 +509,7 @@
              "ICETOT":       "YlGnBu",\
              "TAU_ICE":      "Blues",\
+             "anomaly":      "RdBu_r",\
                      }
+#spectral BrBG RdBu_r
     if whichone not in whichcolorb:
         whichone = "def"
Index: /trunk/MESOSCALE_DEV/PLOT/PYTHON/scripts/winds.py
===================================================================
--- /trunk/MESOSCALE_DEV/PLOT/PYTHON/scripts/winds.py	(revision 239)
+++ /trunk/MESOSCALE_DEV/PLOT/PYTHON/scripts/winds.py	(revision 240)
@@ -26,5 +26,7 @@
            display=True,\
            itstep=None,\
-           hole=False):
+           hole=False,\
+           save="gui",\
+           anomaly=False):
 
     ####################################################################################################################
@@ -34,16 +36,18 @@
     ### Load librairies and functions
     from netCDF4 import Dataset
-    from myplot import getcoord2d,define_proj,makeplotpng,makeplotpngres,simplinterv,vectorfield,ptitle,latinterv,getproj,wrfinterv,dumpbdy,\
+    from myplot import getcoord2d,define_proj,makeplotres,simplinterv,vectorfield,ptitle,latinterv,getproj,wrfinterv,dumpbdy,\
                        fmtvar,definecolorvec,defcolorb,getprefix,putpoints,calculate_bounds,errormess,definesubplot,\
-                       zoomset,getcoorddef,getwinddef,whatkindfile,reducefield,bounds,getstralt,getfield
+                       zoomset,getcoorddef,getwinddef,whatkindfile,reducefield,bounds,getstralt,getfield,smooth
     from mymath import deg,max,min,mean
-    from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor
+    from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show
     from matplotlib.cm import get_cmap
     import numpy as np
     from numpy.core.defchararray import find
 
+    #rcParams['backend'] = 'PS'
+
     ######################
     ### Load NETCDF object
-    nc  = Dataset(namefile)
+    nc  = Dataset(namefile)  
     
     ##################################
@@ -60,4 +64,5 @@
     ### Define plot boundaries
     if proj == "npstere":             [wlon,wlat] = latinterv("North_Pole")
+    elif proj == "spstere":           [wlon,wlat] = latinterv("South_Pole")
     elif proj in ["lcc","laea"]:      [wlon,wlat] = wrfinterv(lon2d,lat2d)
     else:                             [wlon,wlat] = simplinterv(lon2d,lat2d)
@@ -119,7 +124,13 @@
            what_I_plot, error = reducefield( getfield(nc,var), d4=itime, d3=nvert )
            if not error: 
-               if typefile in ['mesoapi','meso']:    what_I_plot = dumpbdy(what_I_plot)
+               fvar = var
+               ###
+               if anomaly:
+                   what_I_plot = 100. * ((what_I_plot / smooth(what_I_plot,10)) - 1.)
+                   fvar = 'anomaly'
+               ###
+               if typefile in ['mesoapi','meso']:    what_I_plot = dumpbdy(what_I_plot,6)
                zevmin, zevmax = calculate_bounds(what_I_plot,vmin=vmin,vmax=vmax)
-               if colorb is True: colorb = defcolorb(var)
+               if colorb is True: colorb = defcolorb(fvar)
                palette = get_cmap(name=colorb)
                if not tile:
@@ -133,8 +144,8 @@
                elif colorb:              
                          ndiv = 10
-                         colorbar(fraction=0.05,pad=0.1,format=fmtvar(var),\
+                         colorbar(fraction=0.05,pad=0.1,format=fmtvar(fvar),\
                                            ticks=np.linspace(zevmin,zevmax,ndiv+1),\
-                                           extend='max',spacing='proportional')
-                                           # both min max neither
+                                           extend='neither',spacing='proportional')
+                                           # both min max neither 
                   
        ### Vector plot
@@ -144,5 +155,5 @@
            if not error:
                if typefile in ['mesoapi','meso']:    
-                   [vecx,vecy] = [dumpbdy(vecx,stag=uchar), dumpbdy(vecy,stag=vchar)]
+                   [vecx,vecy] = [dumpbdy(vecx,6,stag=uchar), dumpbdy(vecy,6,stag=vchar)]
                    key = True
                elif typefile in ['gcm']:            
@@ -178,6 +189,16 @@
     else:               zeplot = target + "/" + zeplot  
     ###
-    if found_lct:     makeplotpng(zeplot,pad_inches_value=0.35,disp=display)   
-    #if found_lct:     makeplotpngres(zeplot,200,disp=display)
+    if found_lct:     
+        pad_inches_value = 0.35
+        if save == 'png': 
+            makeplotres(zeplot,res=100.,pad_inches_value=pad_inches_value,erase=True)  ## a miniature
+            makeplotres(zeplot,res=200.,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()
+        else: 
+            print "save mode not supported. using gui instead."
+            show()
     else:             print "Local time not found"
 
@@ -210,4 +231,5 @@
     from netCDF4 import Dataset
     from myplot import getlschar
+    from os import system
 
     #############################
@@ -233,4 +255,6 @@
     parser.add_option('-e', action='store',dest='itstep',       type="int",     default=None,  help='stride time (def=4)')
     parser.add_option('-H', action='store_true',dest='hole',                    default=False, help='holes above max and below min')
+    parser.add_option('-S', action='store',dest='save',         type="string",  default="gui", help='save mode (png,eps,svg,pdf or gui)(def=gui)')
+    parser.add_option('-a', action='store_true',dest='anomaly',                 default=False, help='compute and plot relative anomaly in %')
     #parser.add_option('-V', action='store', dest='comb',        type="float",   default=None,  help='a defined combination of variables')
     (opt,args) = parser.parse_args()
@@ -275,5 +299,4 @@
             zefile = api_onelevel (  path_to_input   = '', \
                                      input_name      = zefile, \
-                                     #path_to_output  = opt.target, \
                                      fields          = zefields, \
                                      interp_method   = opt.interp, \
@@ -303,7 +326,9 @@
                 addchar=lschar,interv=[zehour,zehourin],vmin=argvmin,vmax=argvmax,\
                 tile=opt.tile,zoom=opt.zoom,display=opt.display,\
-                itstep=opt.itstep,hole=opt.hole)
+                itstep=opt.itstep,hole=opt.hole,save=opt.save,\
+                anomaly=opt.anomaly)
             print 'Done: '+name
-    
+            system("rm -f to_be_erased")
+  
         #########################################################
         ### Generate a .sh file with the used command saved in it
