Index: trunk/UTIL/PYTHON/README.PP
===================================================================
--- trunk/UTIL/PYTHON/README.PP	(revision 450)
+++ trunk/UTIL/PYTHON/README.PP	(revision 451)
@@ -12,11 +12,7 @@
 **************************************
 
-
-*************************************
-MAPMODE 1 
-MAPPING MODE
-SIMPLE EXAMPLES on a SAMPLE GCM FILE
-*************************************
-
+*****************************************************************
+MAPMODE 1... MAPPING MODE... SIMPLE EXAMPLES on a SAMPLE GCM FILE
+*****************************************************************
 Goal: The simplest, most minimal example. Mapping topography.
 pp.py -f diagfired.nc
@@ -73,10 +69,73 @@
 pp.py -f diagfi.nc -v tsurf --time 4,7
 
---- mesoscale stuff
+[only mesoscale for the moment]
 Goal: I want to plot results for two different LOCAL times in the file next to one another
 pp.py -f wrfout**** -v TSURF --time -4 -- time -7
 
-Goal: The classic mountain GW plot
+***********************************************************************************
+EXAMPLE : The classic mountain GW plot
+***********************************************************************************
 pp.py -f wrfout_d01_9999-09-09_09:00:00 -v W,tpot --lat 60 --time 15 -i 4 -l 30,130,100 --div 50
+***********************************************************************************
+
+***********************************************************************************
+COMMENTED EXAMPLE : The globe with surface temperature and winds
+***********************************************************************************
+pp.py -f diagfired.nc -v tsurf -w phisinit -m 120 -M 320 --div 20 -W -s 1 --vert 0 -p ortho --blat 20 --blon -80 -S html -t $W
+***********************************************************************************
+See results here: http://www.lmd.jussieu.fr/~aslmd/EXAMPLES/LMD_GCM_movie_tsurf_UV/anim.html
+***********************************************************************************
+pp.py -f diagfired.nc
+	OK. You probably get that one.
+-v tsurf -w phisinit
+	Shade surface temperature. Contour topography.
+-m 120 -M 320 --div 20
+	Surface temperature is shown with bounds 120K to 320K. Use 20 levels for shading.
+-W -s 1
+	Include wind vectors. Prescribe a stride of 1: vectors are shown at every grid point.
+--vert 0
+	Show fields in the first (lowermost) level.
+-p ortho --blat 20 --blon -80
+	Use orthographic projection ('whole sphere' view). Center view on lon -80E and lat 20N.
+-S html
+	Make nice webpage with animation and controls.
+-t /u/aslmd/WWW/EXAMPLES
+	Move resulting plot files to the given folder.
+
+***********************************************************************************
+COMMENTED EXAMPLE : The dust storm section movie
+***********************************************************************************
+pp.py -f wrfout_d01_2024-05-30_12:00:00,wrfout_d01_2024-05-30_18:00:00,wrfout_d01_2024-05-31_00\:00\:00 --operation cat -v QDUST --lat -3. -i 3 -l -1,37,100 --div 30 -c Oranges_r -m 0. -M 5.e-5 -t $W --rate 12 --xmin=5 --xmax=115
+***********************************************************************************
+See results here: http://www.lmd.jussieu.fr/~aslmd/EXAMPLES/LMD_MMM_d1_10km_movie_QDUST_-1000m-AMR_lat_-3_Ls134.8/anim.html
+***********************************************************************************
+pp.py 
+	OK. You probably get that one.
+-f wrfout_d01_2024-05-30_12:00:00,wrfout_d01_2024-05-30_18:00:00,wrfout_d01_2024-05-31_00\:00\:00 --operation cat 
+	Mesoscale outputs are splitted in several files. In that case, this was 1 file per 6 simulated hours. 
+	The above options allow to concatenate files along time axis for 1D time series or animated movies 
+	[if --operation cat is omitted, this is a multiplot call, with one subplot per files in -f].
+-v QDUST 
+	Choose to plot dust mass mixing ratio.
+-i 3 -l -1,37,100 
+	Set a call to vertical interpolator [compiled with f2py, thereby being embedded as a Python routine] for each of the files in the -f instance. 
+	-i sets the kind of interpolation, 3 means Above MOLA Reference Altitude. -l sets the range for altitude levels: from -1 km to 37 km with 100 levels.
+--div 30 
+	The number of contours used for shaded plots. Higher value means smoother appearance.
+-c Oranges_r 
+	Choose a colorbar adapted to display a dust storm.
+-m 0. -M 5.e-5 
+	Choose bounds for the plotted field. This one is adapted to show dust mass mixing ratio.
+-t $W
+	Put resulting figure or movie in another destination folder. 
+	Personally I have an environnement variable W which is somewhere in my system where the file automatically appears on the web, 
+		hence is easy to see from a remote place.
+--rate 12 --lat -3.
+	Define prescribed axis. A section in latitude -3°N. A time animation with 12 frame per seconds. 
+	So the displayed field will be an altitude/longitude section. Alternative: "-S avi" instead of "--rate 12" creates a default 8 fps movie. 
+	Alternative II: "-S html" instead of --rate 12 creates a nice webpage.
+--xmin=5 --xmax=115
+	Define limits for the displayed section. Here we just want to get rid of transition rows where atmospheric fields are 
+		relaxed towards prescribed GCM fields.
 
 ***********************************************************************************
Index: trunk/UTIL/PYTHON/body.html
===================================================================
--- trunk/UTIL/PYTHON/body.html	(revision 451)
+++ trunk/UTIL/PYTHON/body.html	(revision 451)
@@ -0,0 +1,369 @@
+//**************************************************************************
+ 
+//=== THE CODE STARTS HERE - no need to change anything below ===
+ 
+//=== global variables ====
+theImages = new Array();      //holds the images
+imageNum = new Array();       //keeps track of which images to omit from loop
+normal_delay = 1000;
+delay = normal_delay;         //delay between frames in 1/100 seconds
+delay_step = 50;
+delay_max = 6000;
+delay_min = 50;
+dwell_multipler = 3;
+dwell_step = 1;
+end_dwell_multipler   = dwell_multipler;
+start_dwell_multipler = dwell_multipler;
+current_image = first_image;     //number of the current image
+timeID = null;
+status = 0;                      // 0-stopped, 1-playing
+play_mode = 0;                   // 0-normal, 1-loop, 2-sweep
+size_valid = 0;
+ 
+//===> Make sure the first image number is not bigger than the last image number
+if (first_image > last_image)
+{
+   var help = last_image;
+   last_image = first_image;
+   first_image = help;
+}
+ 
+//===> Preload the first image (while page is downloading)
+   theImages[0] = new Image();
+   theImages[0].src = modImages[0];
+   imageNum[0] = true;
+ 
+//==============================================================
+//== All previous statements are performed as the page loads. ==
+//== The following functions are also defined at this time.   ==
+//==============================================================
+ 
+//===> Stop the animation
+function stop()
+{
+   //== cancel animation (timeID holds the expression which calls the fwd or bkwd function) ==
+   if (status == 1)
+      clearTimeout (timeID);
+   status = 0;
+}
+ 
+ 
+//===> Display animation in fwd direction in either loop or sweep mode
+function animate_fwd()
+{
+   current_image++;                      //increment image number
+ 
+   //== check if current image has exceeded loop bound ==
+   if (current_image > last_image) {
+      if (play_mode == 1) {              //fwd loop mode - skip to first image
+         current_image = first_image;
+      }
+      if (play_mode == 2) {              //sweep mode - change directions (go bkwd)
+         current_image = last_image;
+         animate_rev();
+         return;
+      }
+   }
+ 
+   //== check to ensure that current image has not been deselected from the loop ==
+   //== if it has, then find the next image that hasn't been ==
+   while (imageNum[current_image-first_image] == false) {
+         current_image++;
+         if (current_image > last_image) {
+            if (play_mode == 1)
+               current_image = first_image;
+            if (play_mode == 2) {
+               current_image = last_image;
+               animate_rev();
+               return;
+            }
+         }
+   }
+ 
+   document.animation.src = theImages[current_image-first_image].src;   //display image onto screen
+   document.control_form.frame_nr.value = current_image;                //display image number
+
+   delay_time = delay;
+   if ( current_image == first_image) delay_time = start_dwell_multipler*delay;
+   if (current_image == last_image)   delay_time = end_dwell_multipler*delay;
+ 
+   //== call "animate_fwd()" again after a set time (delay_time) has elapsed ==
+   timeID = setTimeout("animate_fwd()", delay_time);
+}
+ 
+ 
+//===> Display animation in reverse direction
+function animate_rev()
+{
+   current_image--;                      //decrement image number
+ 
+   //== check if image number is before lower loop bound ==
+   if (current_image < first_image) {
+     if (play_mode == 1) {               //rev loop mode - skip to last image
+        current_image = last_image;
+     }
+     if (play_mode == 2) {
+        current_image = first_image;     //sweep mode - change directions (go fwd)
+        animate_fwd();
+        return;
+     }
+   }
+ 
+   //== check to ensure that current image has not been deselected from the loop ==
+   //== if it has, then find the next image that hasn't been ==
+   while (imageNum[current_image-first_image] == false) {
+         current_image--;
+         if (current_image < first_image) {
+            if (play_mode == 1)
+               current_image = last_image;
+            if (play_mode == 2) {
+               current_image = first_image;
+               animate_fwd();
+               return;
+            }
+         }
+   }
+ 
+   document.animation.src = theImages[current_image-first_image].src;   //display image onto screen
+   document.control_form.frame_nr.value = current_image;                //display image number
+
+   delay_time = delay;
+   if ( current_image == first_image) delay_time = start_dwell_multipler*delay;
+   if (current_image == last_image)   delay_time = end_dwell_multipler*delay;
+ 
+   //== call "animate_rev()" again after a set amount of time (delay_time) has elapsed ==
+   timeID = setTimeout("animate_rev()", delay_time);
+}
+ 
+ 
+//===> Changes playing speed by adding to or substracting from the delay between frames
+function change_speed(dv)
+{
+   delay+=dv;
+   //== check to ensure max and min delay constraints have not been crossed ==
+   if(delay > delay_max) delay = delay_max;
+   if(delay < delay_min) delay = delay_min;
+}
+ 
+//===> functions that changed the dwell rates.
+function change_end_dwell(dv) {
+   end_dwell_multipler+=dv;
+   if ( end_dwell_multipler < 1 ) end_dwell_multipler = 0;
+   }
+ 
+function change_start_dwell(dv) {
+   start_dwell_multipler+=dv;
+   if ( start_dwell_multipler < 1 ) start_dwell_multipler = 0;
+   }
+ 
+//===> Increment to next image
+function incrementImage(number)
+{
+   stop();
+ 
+   //== if image is last in loop, increment to first image ==
+   if (number > last_image) number = first_image;
+ 
+   //== check to ensure that image has not been deselected from loop ==
+   while (imageNum[number-first_image] == false) {
+         number++;
+         if (number > last_image) number = first_image;
+   }
+ 
+   current_image = number;
+   document.animation.src = theImages[current_image-first_image].src;   //display image
+   document.control_form.frame_nr.value = current_image;                //display image number
+}
+ 
+//===> Decrement to next image
+function decrementImage(number)
+{
+   stop();
+ 
+   //== if image is first in loop, decrement to last image ==
+   if (number < first_image) number = last_image;
+ 
+   //== check to ensure that image has not been deselected from loop ==
+   while (imageNum[number-first_image] == false) {
+         number--;
+         if (number < first_image) number = last_image;
+   }
+ 
+   current_image = number;
+   document.animation.src = theImages[current_image-first_image].src;   //display image
+   document.control_form.frame_nr.value = current_image;                //display image number
+}
+ 
+//===> "Play forward"
+function fwd()
+{
+   stop();
+   status = 1;
+   play_mode = 1;
+   animate_fwd();
+}
+ 
+//===> "Play reverse"
+function rev()
+{
+   stop();
+   status = 1;
+   play_mode = 1;
+   animate_rev();
+}
+
+//===> "play sweep"
+function sweep() {
+   stop();
+   status = 1;
+   play_mode = 2;
+   animate_fwd();
+   }
+ 
+//===> Change play mode (normal, loop, swing)
+function change_mode(mode)
+{
+   play_mode = mode;
+}
+ 
+//===> Load and initialize everything once page is downloaded (called from 'onLoad' in <BODY>)
+function launch()
+{
+   for (var i = first_image + 1; i <= last_image; i++)
+   {
+      theImages[i-first_image] = new Image();
+      theImages[i-first_image].src = modImages[i-first_image];
+      imageNum[i-first_image] = true;
+      document.animation.src = theImages[i-first_image].src;
+      document.control_form.frame_nr.value = i;
+   }
+ 
+   // this needs to be done to set the right mode when the page is manually reloaded
+   change_mode (1);
+   fwd();
+}
+ 
+//===> Check selection status of image in animation loop
+function checkImage(status,i)
+{
+   if (status == true)
+      imageNum[i] = false;
+   else imageNum[i] = true;
+}
+ 
+//==> Empty function - used to deal with image buttons rather than HTML buttons
+function func()
+{
+}
+ 
+//===> Sets up interface - this is the one function called from the HTML body
+function animation()
+{
+  count = first_image;
+}
+ 
+// -->
+
+function MM_jumpMenu(targ,selObj,restore){ //v3.0
+  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
+  if (restore) selObj.selectedIndex=0;
+}
+//-->
+</SCRIPT>
+
+<link href="animate_styles.css" rel="stylesheet" type="text/css">
+</head>
+
+<body bgcolor="#FFFFFF" onLoad="launch()">
+
+
+
+<table border=1 align=center cellpadding=3 cellspacing=0 id="frame">
+
+<tr>
+
+<td valign="top" id="leftnav">
+    
+<!--
+
+	<h1>Frame Controls</h1>
+     <p>Choose another forecast:</p>
+                   
+		<form name="form1" method="post" action="">
+     <p>
+        <select name="menu1" onChange="MM_jumpMenu('parent',this,1)">
+
+<option value="none.html" selected>  </option>
+<option value="none.html">  </option>
+
+</select>                                           
+</p>
+</form>
+
+--!>
+
+Results from LMD meteorological models.<br> 
+All rights reserved. Copy forbidden.<br>
+Contact us for external use (site, publication)<br>
+
+Plots made with Python [EPD distribution]<br>
+
+<p>Play Mode:<br><br>
+    <a href="JavaScript: func()" onClick="change_mode(1);rev()">
+    <img border=0 hspace=0 vspace=0 width=29 height=24 src="http://www.lmd.jussieu.fr/~aslmd/images/button_rev.png" alt="+1"></a>
+    <a href="JavaScript: func()" onClick="stop()">
+    <img border=0 hspace=0 vspace=0 width=29 height=24 src="http://www.lmd.jussieu.fr/~aslmd/images/button_stop.png" alt="+1"></a>
+
+    <a href="JavaScript: func()" onClick="change_mode(1);fwd()">
+    <img border=0 hspace=0 vspace=0 width=29 height=24 src="http://www.lmd.jussieu.fr/~aslmd/images/button_fwd.png" alt="+1"></a>
+		</p>
+				     					
+		<p>Adjust Speed:<br><br>
+    <a href="JavaScript: func()" onClick="change_speed(delay_step)">
+    <img border=0 hspace=0 vspace=0 width=29 height=24 src="http://www.lmd.jussieu.fr/~aslmd/images/button_slow.png" alt="+1"></a>
+	  <a href="JavaScript: func()" onClick="change_speed(-delay_step)">
+		<img border=0 hspace=0 vspace=0 width=29 height=24 src="http://www.lmd.jussieu.fr/~aslmd/images/button_fast.png" alt="+1"></a>
+
+    </p>
+
+
+		<p>Advance One Frame:<br><br>
+		<a href="JavaScript: func()" onClick="decrementImage(--current_image)">
+		<img border=0 hspace=0 vspace=0 width=29 height=24 src="http://www.lmd.jussieu.fr/~aslmd/images/button_rev1.png" alt="+1"></a>
+		<a href="JavaScript: func()" onClick="incrementImage(++current_image)">
+		<img border=0 hspace=0 vspace=0 width=29 height=24 src="http://www.lmd.jussieu.fr/~aslmd/images/button_fwd1.png" alt="+1"></a>
+		</p>
+
+
+		<form method="post" name="control_form">
+
+    <p>Frame No:</p>
+    <p>
+       <input type="text" name="frame_nr" value="9" size="2" onFocus="this.select()" onChange="go2image(this.value)"></input>
+       <br /> &#160; <br />
+    </p>
+
+    </form>   				     
+   <p>
+      <A HREF="http://www-mars.lmd.jussieu.fr/mars/publi/jgr99_gcm.pdf">About LMD Mars Global Circulation Model</A></a><br /><br />
+      <A HREF="http://dl.dropbox.com/u/11078310/my_papers/spiga_jgr_SF09.pdf">About LMD Mars Mesoscale Model</A></a><br /><br />
+      <A HREF="http://www-mars.lmd.jussieu.fr">About the Mars Climate Database</A></a><br /><br />
+   </p>
+</td>
+
+						<td valign="top" id="content">
+<!--
+						<h1>LMD Planetary Atmospheres Team</h1>
+-->
+
+
+             <!--<p><img WIDTH="525" name="animation" border="0" src="images/loading.gif" ALT="model image">--!>
+             <p><img WIDTH="600" name="animation" border="0" src="images/loading.gif" ALT="model image">
+</p>
+</tr>
+</table>
+
+
+</body>
+</html>
+
Index: trunk/UTIL/PYTHON/header.html
===================================================================
--- trunk/UTIL/PYTHON/header.html	(revision 451)
+++ trunk/UTIL/PYTHON/header.html	(revision 451)
@@ -0,0 +1,35 @@
+<html>
+<head>
+<meta http-equiv="Pragma" content="no-cache">
+<title>LMD Planetary Atmospheres Team</title>
+
+<SCRIPT LANGUAGE="JavaScript">
+<!--
+// <!--
+
+//============================================================
+//                >> jsImagePlayer 1.0 <<
+//            for Netscape3.0+, September 1996
+//============================================================
+//                  by (c)BASTaRT 1996
+//             Praha, Czech Republic, Europe
+//
+// feel free to copy and use as long as the credits are given
+//          by having this header in the code
+//
+//          contact: xholecko@sgi.felk.cvut.cz
+//          http://sgi.felk.cvut.cz/~xholecko
+//
+//============================================================
+// Thanx to Karel & Martin for beta testing and suggestions!
+//============================================================
+//
+//     modified by D. Watson and A. Earnhart (CIRA/CSU), 7/30/97
+//     and Greg Thompson (NCAR/RAP) May 07, 2000
+//	   graphic & php enhancement, Kristin Conrad (NCAR/MMM) Dec 2004
+//
+//============================================================
+ 
+//********* SET UP THESE VARIABLES - MUST BE CORRECT!!!*********************
+modImages = new Array(); 
+
Index: trunk/UTIL/PYTHON/myplot.py
===================================================================
--- trunk/UTIL/PYTHON/myplot.py	(revision 450)
+++ trunk/UTIL/PYTHON/myplot.py	(revision 451)
@@ -376,5 +376,5 @@
 
 ## Author: AS + AC
-def dumpbdy (field,n,stag=None,condition=False):
+def dumpbdy (field,n,stag=None,condition=False,onlyx=False,onlyy=False):
     nx = len(field[0,:])-1
     ny = len(field[:,0])-1
@@ -383,5 +383,8 @@
       if stag == 'V': ny = ny-1
       if stag == 'W': nx = nx+1 #special les case when we dump stag on W
-    return field[n:ny-n,n:nx-n]
+    if onlyx:    result = field[:,n:nx-n]
+    elif onlyy:  result = field[n:ny-n,:]
+    else:        result = field[n:ny-n,n:nx-n]
+    return result
 
 ## Author: AS + AC
@@ -547,5 +550,5 @@
 
 ## Author: AS
-def define_proj (char,wlon,wlat,back=None,blat=None):
+def define_proj (char,wlon,wlat,back=None,blat=None,blon=None):
     from    mpl_toolkits.basemap            import Basemap
     import  numpy                           as np
@@ -561,5 +564,6 @@
         elif wlat[0] <= 0.:    blat = wlat[1]
     else:  ortholat=blat
-    #print "blat ", blat
+    if blon is None:  ortholon=meanlon
+    else:             ortholon=blon
     h = 50.  ## en km
     radius = 3397200.
@@ -567,5 +571,5 @@
                               llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1])
     elif char == "moll":    m = Basemap(rsphere=radius,projection='moll',lon_0=meanlon)
-    elif char == "ortho":   m = Basemap(rsphere=radius,projection='ortho',lon_0=meanlon,lat_0=ortholat)
+    elif char == "ortho":   m = Basemap(rsphere=radius,projection='ortho',lon_0=ortholon,lat_0=ortholat)
     elif char == "lcc":     m = Basemap(rsphere=radius,projection='lcc',lat_1=meanlat,lat_0=meanlat,lon_0=meanlon,\
                               llcrnrlat=wlat[0],urcrnrlat=wlat[1],llcrnrlon=wlon[0],urcrnrlon=wlon[1])
@@ -645,8 +649,8 @@
     if zevmin < 0: what_I_plot[ what_I_plot < zevmin*(1. - 1.e-7) ] = zevmin*(1. - 1.e-7)
     else:          what_I_plot[ what_I_plot < zevmin*(1. + 1.e-7) ] = zevmin*(1. + 1.e-7)
-    print "NEW MIN ", min(what_I_plot)
+    #print "NEW MIN ", min(what_I_plot)
     what_I_plot[ what_I_plot > 9e+35  ] = -9e+35
     what_I_plot[ what_I_plot > zevmax ] = zevmax
-    print "NEW MAX ", max(what_I_plot)
+    #print "NEW MAX ", max(what_I_plot)
     return what_I_plot
 
@@ -707,4 +711,5 @@
              "ICETOT":       "%.1e",\
              "TAU_ICE":      "%.2f",\
+             "TAUICE":       "%.2f",\
              "VMR_ICE":      "%.1e",\
              "MTOT":         "%.1f",\
@@ -751,4 +756,5 @@
              "TEMP":         "Jet",\
              "TAU_ICE":      "Blues",\
+             "TAUICE":       "Blues",\
              "VMR_ICE":      "Blues",\
              "W":            "jet",\
Index: trunk/UTIL/PYTHON/myscript.py
===================================================================
--- trunk/UTIL/PYTHON/myscript.py	(revision 450)
+++ trunk/UTIL/PYTHON/myscript.py	(revision 451)
@@ -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,txt or gui) [gui]')
+    parser.add_option('-S', '--save',   action='store',dest='save',      type="string",  default="gui", help='save mode (gui,png,eps,svg,pdf,txt,html,avi) [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')
@@ -37,5 +37,6 @@
     parser.add_option('-W', '--winds',  action='store_true',dest='winds',                default=False, help='wind vectors [False]')
     parser.add_option('-z', '--zoom',   action='store',dest='zoom',      type="float",   default=None,  help='zoom factor in %')
-    parser.add_option('--blat',         action='store',dest='blat',      type="int",     default=None,  help='bounding latitude for stereographic plots [computed]')
+    parser.add_option('--blat',         action='store',dest='blat',      type="int",     default=None,  help='reference lat (or bounding lat for stere) [computed]')
+    parser.add_option('--blon',         action='store',dest='blon',      type="int",     default=None,  help='reference lon [computed]')
 
     ### SPECIFIC FOR SLICING [MAPMODE 0]
Index: trunk/UTIL/PYTHON/planetoplot.py
===================================================================
--- trunk/UTIL/PYTHON/planetoplot.py	(revision 450)
+++ trunk/UTIL/PYTHON/planetoplot.py	(revision 451)
@@ -8,4 +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...]
 
 def planetoplot (namefiles,\
@@ -50,4 +51,5 @@
            yintegral=False,\
            blat=None,\
+           blon=None,\
            tsat=False,\
            flagnolow=False,\
@@ -68,5 +70,5 @@
     from mymath import deg,max,min,mean,get_tsat,writeascii,fig2data,fig2img
     import matplotlib as mpl
-    from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title
+    from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title, close
     from matplotlib.cm import get_cmap
     import numpy as np
@@ -97,4 +99,5 @@
            stime = readslices(str(0)) ; ntime=1 ## this is a default choice
            print "WELL... nothing about time axis. I took default: first time reference stored in file."
+    if mrate is not None and len(var) > 1: errormess("multivar not allowed in movies. should be fixed soon!")
     zelen = len(namefiles)*len(var)
     numplot = zelen*nslices
@@ -103,5 +106,5 @@
         if fileref is not None:       zelen = zelen + 2
         elif "var" in ope:            zelen = zelen + 1
-    all_var  = [[]]*zelen ; all_var2  = [[]]*zelen ; all_title = [[]]*zelen ; all_varname = [[]]*zelen ; all_namefile = [[]]*zelen ; all_time = [[]]*zelen
+    all_var  = [[]]*zelen ; all_var2  = [[]]*zelen ; all_title = [[]]*zelen ; all_varname = [[]]*zelen ; all_namefile = [[]]*zelen ; all_time = [[]]*zelen ; all_windu = [[]]*zelen ; all_windv = [[]]*zelen
  
     #################################################################################################
@@ -191,4 +194,5 @@
       all_time[k] = time
       if var2: all_var2[k] = getfield(nc,var2)
+      if winds: all_windu[k] = getfield(nc,uchar) ; all_windv[k] = getfield(nc,vchar)
       ##### SPECIFIC
       if varname in ["temp","t","T_nadir_nit","T_nadir_day","temp_day","temp_night"] and tsat:
@@ -219,5 +223,5 @@
              elif ope in ["cat"]:
                 tab = all_var[0];k = 1
-                while k != len(namefiles)-1: 
+                while k != len(namefiles):
                     tab = np.append(tab,all_var[k],axis=0) ; k += 1
                 all_time[0] = np.arange(0,len(tab),1) ### AS: time reference is too simplistic, should be better
@@ -252,5 +256,5 @@
 
        ### Map projection                    
-       if mapmode == 1:     m = define_proj(proj,wlon,wlat,back=back,blat=blat) ; x, y = m(lon2d, lat2d)
+       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
 
@@ -264,4 +268,5 @@
            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
            elif "var" in ope:           index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%(len(var)+1)        ## OK only 1 file, see test in the beginning
+           elif "cat" in ope:           index_f = 0
        else:                            yeah = len(namefiles)*len(var) ; index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah
        time = all_time[index_f]
@@ -284,7 +289,10 @@
                                              yint=yintegral, alt=vert, anomaly=anomaly )
            what_I_plot = what_I_plot*mult
-       if var2:      ### what is contoured
+       if var2:      ### what is contoured.
            what_I_plot_contour, error = reducefield( all_var2[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert, \
                                              yint=yintegral, alt=vert )
+       if winds:     ### what is plot as vectors.
+           vecx, error = reducefield( all_windu[index_f], d4=indextime, d3=indexvert, yint=yintegral, alt=vert)
+           vecy, error = reducefield( all_windv[index_f], d4=indextime, d3=indexvert, yint=yintegral, alt=vert)
        ####################################################################
 
@@ -325,4 +333,7 @@
                         if mrate is None:                                   what_I_plot_frame = what_I_plot
                         else:                                               what_I_plot_frame = what_I_plot[imov,:,:]
+                        if winds:
+                            if mrate is None:                                   vecx_frame = vecx ; vecy_frame = vecy
+                            else:                                               vecx_frame = vecx[imov,:,:] ; vecy_frame = vecy[imov,:,:]
                     elif which == "contour":  
                         if mrate is None or what_I_plot_contour.ndim < 3:   what_I_plot_frame = what_I_plot_contour
@@ -330,6 +341,6 @@
                     if mrate is not None:     
                         if mapmode == 1: 
-                            m = define_proj(proj,wlon,wlat,back=back,blat=blat)  ## 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
+                            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
                     if typefile in ['mesoapi','meso'] and mapmode == 1:   what_I_plot_frame = dumpbdy(what_I_plot_frame,6,condition=True)
                     if typefile in ['mesoideal']:    what_I_plot_frame = dumpbdy(what_I_plot_frame,0,stag='W',condition=dumped_vert_stag)
@@ -362,4 +373,17 @@
                             colorbar( fraction=0.05,pad=0.03,format=daformat,\
                                       ticks=np.linspace(zevmin,zevmax,num=min([ticks/2+1,20])),extend='neither',spacing='proportional' ) 
+                        if winds:
+                            if typefile in ['mesoapi','meso']:
+                                [vecx_frame,vecy_frame] = [dumpbdy(vecx_frame,6,stag=uchar,condition=True), dumpbdy(vecy_frame,6,stag=vchar,condition=True)]
+                                key = True
+                            elif typefile in ['gcm']:
+                                key = False
+                            if metwind:  [vecx_frame,vecy_frame] = m.rotate_vector(vecx_frame, vecy_frame, lon2d, lat2d)
+                            if var:       colorvec = definecolorvec(back)
+                            else:         colorvec = definecolorvec(colorb)
+                            vectorfield(vecx_frame, vecy_frame, x, y, stride=stride, csmooth=2,\
+                                             #scale=15., factor=300., color=colorvec, key=key)
+                                             scale=20., factor=250., color=colorvec, key=key)
+                                                              #200.         ## or csmooth=stride
                     elif which == "contour":
                         zevminc, zevmaxc = calculate_bounds(what_I_plot_frame)
@@ -375,12 +399,25 @@
                     if which == "regular":
                         if mrate is not None:
-                           figframe=mpl.pyplot.gcf()
-                           if mquality:   figframe.set_dpi(600.)
-                           else:          figframe.set_dpi(200.)
-                           mframe=fig2img(figframe)
-                           if ((mrate is not None) and (imov is 0)):
-                              moviename='test' ;W,H = figframe.canvas.get_width_height()
-                              video = VideoSink((H,W), moviename, rate=mrate, byteorder="rgba")
-                           video.run(mframe) ; mpl.pyplot.close()
+                           ### THIS IS A MENCODER MOVIE
+                           if mrate > 0:
+                             figframe=mpl.pyplot.gcf()
+                             if mquality:   figframe.set_dpi(600.)
+                             else:          figframe.set_dpi(200.)
+                             mframe=fig2img(figframe)
+                             if imov == 0:
+                                moviename='movie' ;W,H = figframe.canvas.get_width_height()
+                                video = VideoSink((H,W), moviename, rate=mrate, byteorder="rgba")
+                             video.run(mframe) ; close()
+                             if imov == iend: video.close()                            
+                           ### THIS IS A WEBPAGE MOVIE 
+                           else:
+                             nameframe = "image"+str(1000+imov)
+                             makeplotres(nameframe,res=100.,disp=False) ; close()
+                             if imov == 0: myfile = open("zepics", 'w')
+                             myfile.write("modImages["+str(imov)+"] = '"+nameframe+"_100.png';"+ '\n')
+                             if imov == iend:
+                                 myfile.write("first_image = 0;"+ '\n')
+                                 myfile.write("last_image = "+str(iend)+";"+ '\n')
+                                 myfile.close()
                         if var2:  which = "contour"
                         imov = imov+1
@@ -388,6 +425,4 @@
                         which = "regular"
 
-                 if mrate is not None: video.close()
-
                ##### 1D field
                elif len(what_I_plot.shape) is 1:
@@ -395,5 +430,5 @@
                  if save == 'txt':  writeascii(np.transpose(what_I_plot),'profile'+str(nplot)+'.txt')
 
-               #### Other cases: (maybe plot 3-D field one day or movie ??)
+               #### 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
@@ -402,27 +437,8 @@
                errormess("There is an error in reducing field !")
 
-       ### Vector plot --- a adapter
-       if winds:
-           vecx, error = reducefield( getfield(nc,uchar), d4=indextime, d3=indexvert , yint=yintegral , alt=vert)
-           vecy, error = reducefield( getfield(nc,vchar), d4=indextime, d3=indexvert , yint=yintegral , alt=vert)
-           #what_I_plot, error = reducefield(all_var[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert )
-           if not error:
-               if typefile in ['mesoapi','meso']:    
-                   [vecx,vecy] = [dumpbdy(vecx,6,stag=uchar,condition=True), dumpbdy(vecy,6,stag=vchar,condition=True)]
-                   key = True
-               elif typefile in ['gcm']:            
-                   key = False
-               if metwind:  [vecx,vecy] = m.rotate_vector(vecx, vecy, lon2d, lat2d)
-               if varname == False:       colorvec = definecolorvec(back)
-               else:                  colorvec = definecolorvec(colorb)
-               vectorfield(vecx, vecy,\
-                          x, y, stride=stride, csmooth=2,\
-                          #scale=15., factor=300., color=colorvec, key=key)
-                          scale=20., factor=250., color=colorvec, key=key)
-                                            #200.         ## or csmooth=stride
-    
        ### Next subplot
        basename = getname(var=varname,winds=winds,anomaly=anomaly)
-       basename = basename + getstralt(nc,level)  
+       basename = basename + getstralt(nc,level) 
+       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]]))
Index: trunk/UTIL/PYTHON/pp.py
===================================================================
--- trunk/UTIL/PYTHON/pp.py	(revision 450)
+++ trunk/UTIL/PYTHON/pp.py	(revision 451)
@@ -27,4 +27,7 @@
     if opt.fref is not None and opt.operat is not None and opt.itp is not None: interpref=True
     else:   interpref=False
+    if opt.rate is not None:      opt.save = "avi"
+    elif opt.save == "avi":       opt.rate = 8   ## this is a default value for -S avi
+    if opt.save == "html":        opt.rate = -1  ## this is convenient because everything is done in planetoplot with mrate
 
     #############################
@@ -137,5 +140,5 @@
                 ope=opt.operat,fileref=reffile,minop=opt.vminope,maxop=opt.vmaxope,titleref=opt.titref,\
                 invert_y=opt.inverty,xaxis=zexaxis,yaxis=zeyaxis,ylog=opt.logy,yintegral=opt.column,\
-                blat=opt.blat,tsat=opt.tsat,flagnolow=opt.nolow,mrate=opt.rate,mquality=opt.quality)
+                blat=opt.blat,blon=opt.blon,tsat=opt.tsat,flagnolow=opt.nolow,mrate=opt.rate,mquality=opt.quality)
         print 'DONE: '+name
         system("rm -f to_be_erased")
@@ -146,5 +149,7 @@
     for arg in sys.argv: command = command + arg + ' '
     #if typefile not in ["meso","mesoapi"]: name = 'pycommand'
-    if opt.save is "gui": name = 'pycommand'
+    if opt.save == "gui":    name = 'pycommand'
+    elif opt.save == "avi":  system("mv -f movie*.avi "+name+".avi")
+    elif opt.save == "html": system("cat $PYTHONPATH/header.html > anim.html ; cat zepics >> anim.html ; cat $PYTHONPATH/body.html >> anim.html ; rm -rf zepics "+name+" ; mkdir "+name+" ; mv anim.html image*png "+name) 
     f = open(name+'.sh', 'w')
     f.write(command)
