Index: anuga_core/documentation/user_manual/anuga_user_manual.tex
===================================================================
--- anuga_core/documentation/user_manual/anuga_user_manual.tex	(revision 4704)
+++ anuga_core/documentation/user_manual/anuga_user_manual.tex	(revision 4705)
@@ -2314,5 +2314,56 @@
   \end{funcdesc}
 
-
+  
+  \begin{funcdesc}{set\_quantities\_to\_be\_monitored}{}
+  Module: \module{abstract\_2d\_finite\_volumes.domain}
+
+  Selects quantities and derived quantities for which extrema attained at internal timesteps 
+  will be collected.
+  
+  Information can be tracked in the evolve loop by printing \code{quantity\_statistics} and 
+  collected data will be stored in the sww file.
+
+  Optional parameters \code{polygon} and \code{time\_interval} may be specified to restrict the 
+  extremum computation.
+  \end{funcdesc}  
+    
+  \begin{funcdesc}{quantity\_statistics}{}
+  Module: \module{abstract\_2d\_finite\_volumes.domain}
+
+  Reports on extrema attained by selected quantities.
+  
+  Returns a string of the following type for each
+  timestep:
+
+  \begin{verbatim} 
+  Monitored quantities at time 1.0000:
+    stage-elevation:
+      values since time = 0.00 in [0.00000000, 0.30000000]
+      minimum attained at time = 0.00000000, location = (0.16666667, 0.33333333)
+      maximum attained at time = 0.00000000, location = (0.83333333, 0.16666667)
+    ymomentum:
+      values since time = 0.00 in [0.00000000, 0.06241221]
+      minimum attained at time = 0.00000000, location = (0.33333333, 0.16666667)
+      maximum attained at time = 0.22472667, location = (0.83333333, 0.66666667)
+    xmomentum:
+      values since time = 0.00 in [-0.06062178, 0.47886313]
+      minimum attained at time = 0.00000000, location = (0.16666667, 0.33333333)
+      maximum attained at time = 0.35103646, location = (0.83333333, 0.16666667)
+  \end{verbatim}     
+
+  The quantities (and derived quantities) listed here must be selected at model 
+  initialisation using the method \code{domain.set_quantities_to_be_monitored}.\\
+   
+  The optional keyword argument \code{precision='\%.4f'} will
+  determine the precision used for floating point values in the output.
+  This diagnostics helps track extrema attained by the selected quantities 
+  at every internal timestep.
+
+  These values are also stored in the sww file for post processing.
+
+  \end{funcdesc}
+  
+
+  
   \begin{funcdesc}{get\_values}{location='vertices', indices = None}
   Module: \module{abstract\_2d\_finite\_volumes.quantity}
Index: anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py
===================================================================
--- anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py	(revision 4704)
+++ anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py	(revision 4705)
@@ -498,10 +498,10 @@
             if not segments.has_key(tuple(A)):
                 segments[tuple(A)] = [] # Empty list for candidate points
-		          
+
             segments[tuple(A)].append(B)                
 
 
         # Start with smallest point and follow boundary (counter clock wise)
-        polygon = [p0]      # Storage for final boundary polygon
+        polygon = [list(p0)]# Storage for final boundary polygon
         point_registry = {} # Keep track of storage to avoid multiple runs 
 	                    # around boundary. This will only be the case if 
@@ -599,5 +599,5 @@
                 point_registry[tuple(p1)] = len(point_registry)
             
-            polygon.append(p1)
+            polygon.append(list(p1)) # De-Numeric each point :-)
             p0 = p1
 
Index: anuga_core/source/anuga/shallow_water/data_manager.py
===================================================================
--- anuga_core/source/anuga/shallow_water/data_manager.py	(revision 4704)
+++ anuga_core/source/anuga/shallow_water/data_manager.py	(revision 4705)
@@ -345,4 +345,26 @@
             if domain.quantities_to_be_monitored is not None:
                 fid.createDimension('singleton', 1)
+                fid.createDimension('two', 2)                
+
+                poly = domain.monitor_polygon
+                if poly is not None:
+                    N = len(poly)
+                    fid.createDimension('polygon_length', N)
+                    fid.createVariable('extrema:polygon',
+                                       self.precision,
+                                       ('polygon_length',
+                                        'two'))
+                    fid.variables['extrema:polygon'][:] = poly                                    
+                    
+                interval = domain.monitor_time_interval
+                if interval is not None:
+                    fid.createVariable('extrema:time_interval',
+                                       self.precision,
+                                       ('two',))
+                    fid.variables['extrema:time_interval'][:] = interval
+                    
+                
+
+                
                 for q in domain.quantities_to_be_monitored:
                     #print 'doing', q
Index: anuga_core/source/anuga/shallow_water/test_data_manager.py
===================================================================
--- anuga_core/source/anuga/shallow_water/test_data_manager.py	(revision 4704)
+++ anuga_core/source/anuga/shallow_water/test_data_manager.py	(revision 4705)
@@ -274,4 +274,15 @@
                                                'ymomentum',
                                                'stage-elevation'])
+
+        assert domain.monitor_polygon is None
+        assert domain.monitor_time_interval is None
+
+
+        domain.set_quantities_to_be_monitored(['xmomentum',
+                                               'ymomentum',
+                                               'stage-elevation'],
+                                              polygon=domain.get_boundary_polygon(),
+                                              time_interval=[0,1])
+        
         
         assert len(domain.quantities_to_be_monitored) == 3
@@ -279,6 +290,5 @@
         assert domain.quantities_to_be_monitored.has_key('xmomentum')                
         assert domain.quantities_to_be_monitored.has_key('ymomentum')        
-        assert domain.monitor_polygon is None
-        assert domain.monitor_time_interval is None        
+
         
         sww = get_dataobject(domain)
@@ -287,5 +297,5 @@
             pass
             #print domain.timestepping_statistics()
-            #print domain.quantity_statistics(precision = '%.8f')
+            domain.quantity_statistics(precision = '%.8f') # Silent
 
             
@@ -312,4 +322,9 @@
         assert allclose(extrema,[0.00, 0.06241221])        
 
+        time_interval = fid.variables['extrema:time_interval'][:]
+        assert allclose(time_interval, [0,1])
+        
+        polygon = fid.variables['extrema:polygon'][:]        
+        assert allclose(polygon, domain.get_boundary_polygon())
         
         fid.close()
