Index: /anuga_work/production/perth/export_results_all.py
===================================================================
--- /anuga_work/production/perth/export_results_all.py	(revision 5818)
+++ /anuga_work/production/perth/export_results_all.py	(revision 5819)
@@ -11,106 +11,85 @@
 """
 
-import project_250m, os
+import project, os
 import sys
 from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
-
 from anuga.shallow_water.data_manager import sww2dem
 from os import sep
 
-directory = project_250m.output_dir
 
-#time_dir = '20080526_104946_run_final_0.6_test_kvanputt'
-#time_dir = '20080530_170833_run_final_0.6_exmouth_kvanputt'
-#time_dir1 = '20080815_103442_run_final_0.0_polyline_alpha0.1_kvanputt'
-time_dir = '20080924_123601_run_final_0_27283_250m_none_kvanputt'
+directory = project.output_dir
+
+time_dir1 = '20080815_103336_run_final_0.6_polyline_alpha0.1_kvanputt'
+time_dirs = [time_dir1]
 
 #cellsize = 20
-cellsize = 30
-timestep = 0
-#area = ['Geordie', 'Sorrento', 'Fremantle', 'Rockingham']
-#area = ['All']
-which_area = 'all'
-#var = [1,2] # Absolute momentum and depth
-#var = [2] # depth
-var = [4] #stage and elevation
+cellsize = 25
 
-name1 = directory+time_dir+sep+project_250m.scenario_name
-#name2 = directory+time_dir+sep+'sww2'+sep+project.scenario_name+'_time_39900_0' #need to get assistance on how to make this into anything
+timestep = None    # None means no timestep!
+#timestep = 0
 
-names = [name1]
-for name in names:
+######
+# Set the special areas of interest.  If none, do: area='All'
+######
+area = ['Fremantle']  # strings must match keys in var_equations below
+#area = ['All']      # 'All' means no special areas - the whole thing
 
-##        for which_area in area:
-##            if which_area == 'All':
-##            
-##            if which_area == 'Geordie':
-##                easting_min = project.xminGeordie
-##                easting_max = project.xmaxGeordie
-##                northing_min = project.yminGeordie
-##                northing_max = project.ymaxGeordie
-##
-##            if which_area == 'Sorrento':
-##                easting_min = project.xminSorrento
-##                easting_max = project.xmaxSorrento
-##                northing_min = project.yminSorrento
-##                northing_max = project.ymaxSorrento
-##
-##            if which_area == 'Fremantle':
-##                easting_min = project.xminFremantle
-##                easting_max = project.xmaxFremantle
-##                northing_min = project.yminFremantle
-##                northing_max = project.ymaxFremantle
-##
-##            if which_area == 'Rockingham':
-##                easting_min = project.xminRockingham
-##                easting_max = project.xmaxRockingham
-##                northing_min = project.yminRockingham
-##                northing_max = project.ymaxRockingham
+######
+# Define allowed variable names and associated equations to generate values.
+# This would not normally change.
+######
+var_equations = {'stage':     'stage',
+                 'momentum':  '(xmomentum**2 + ymomentum**2)**0.5',
+                 'depth':     'stage-elevation',
+                 'speed':     '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)',
+                 'elevation': 'elevation' }
 
-          
-        for which_var in var:
-            if which_var == 0:  # Stage
-                outname = name + which_area + '_stage' 
-                quantityname = 'stage'
+# one or more key strings from var_equations above
+var = ['momentum']
 
-            if which_var == 1:  # Absolute Momentum
-                outname = name + which_area + '_momentum' 
-                quantityname = '(xmomentum**2 + ymomentum**2)**0.5'  
+######
+# Start running the various conversions we require.
+######
+for time_dir in time_dirs:
+    name1 = directory+time_dir+sep+project.scenario_name
+    name2 = directory+time_dir+sep+project.scenario_name+'_time_39900_0' #need to get assistance on how to make this into anything
+    names = [name1,name2]
+    
+    for name in names:
+        for which_area in area:
+            if which_area == 'All':
+                easting_min = None
+                easting_max = None
+                northing_min = None
+                northing_max = None
+            else:
+                try:
+                    easting_min = eval('project.xmin%s' % which_area)
+                    easting_max = eval('project.xmax%s' % which_area)
+                    northing_min = eval('project.ymin%s' % which_area)
+                    northing_max = eval('project.ymax%s' % which_area)
+                except AttributeError:
+                    print 'Unrecognized area name: %s' % which_area
+                    break
+              
+            for which_var in var:
+                if which_var not in var_equations:
+                    print 'Unrecognized variable name: %s' % which_var
+                    break
 
-            if which_var == 2:  # Depth
-                outname = name + which_area + '_depth'
-                quantityname = 'stage-elevation'  
+                outname = name + which_area + '_' + which_var
+                quantityname = var_equations[which_var]
 
-            if which_var == 3:  # Speed
-                outname = name + which_area + '_speed'
-                #quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6/(stage-elevation))'  #Speed
-                quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)'  #Speed
+                print 'start sww2dem: time_dir=%s' % time_dir
                 
-            if which_var == 4:  # Elevation
-                outname = name + which_area + '_elevation'
-                quantityname = 'elevation'  #Elevation
-
-            else: 
-                print 'start sww2dem',which_area
                 sww2dem(name, basename_out = outname,
                             quantity = quantityname,
                             timestep = timestep,
                             cellsize = cellsize,      
+                            easting_min = easting_min,
+                            easting_max = easting_max,
+                            northing_min = northing_min,
+                            northing_max = northing_max,        
                             reduction = max, 
                             verbose = True,
                             format = 'asc')
-##
-##                else:
-##                    print 'start sww2dem',which_area, easting_min
-##                    sww2dem(name, basename_out = outname,
-##                                quantity = quantityname,
-##                                #timestep = timestep,
-##                                cellsize = cellsize,      
-##                                easting_min = easting_min,
-##                                easting_max = easting_max,
-##                                northing_min = northing_min,
-##                                northing_max = northing_max,        
-##                                reduction = max, 
-##                                verbose = True,
-##                                format = 'asc')
-##
