<p><b>dwj07@fsu.edu</b> 2012-03-16 10:57:55 -0600 (Fri, 16 Mar 2012)</p><p><br>
        -- BRANCH COMMIT --<br>
<br>
        Adding python script for error computation<br>
        Adding bash script for spatial convergence study.<br>
</p><hr noshade><pre><font color="gray">Added: branches/ocean_projects/ocean_test_cases_staging/ocean/advective_transport/getErrors.sh
===================================================================
--- branches/ocean_projects/ocean_test_cases_staging/ocean/advective_transport/getErrors.sh                                (rev 0)
+++ branches/ocean_projects/ocean_test_cases_staging/ocean/advective_transport/getErrors.sh        2012-03-16 16:57:55 UTC (rev 1661)
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+RUNS=`cat run_paths`
+OUTPUT_NAME=output.0000-01-01_00:00:00.nc
+
+rm -f *.errors
+
+for RUN in ${RUNS}
+do
+
+        RESOLUTION=${RUN%%levs/*}
+        RESOLUTION=${RESOLUTION##*/}
+        RESOLUTION=${RESOLUTION%m_*}
+        ADVECTION_ROUTINE=${RUN##*levs/}
+        ADVECTION_ROUTINE=${ADVECTION_ROUTINE%/*}
+        ADVECTION_ROUTINE=${ADVECTION_ROUTINE##*_}
+
+        ERROR=`./rms_error_from_ic.py -f ${RUN}/${OUTPUT_NAME} -v tracer1 | tail -n 1 | awk '{print $2}'`
+
+        echo &quot;${RESOLUTION} ${ERROR}&quot; &gt;&gt; ${ADVECTION_ROUTINE}.errors
+done
+
+ERROR_FILES=`ls *.errors`
+
+for ERROR_FILE in ${ERROR_FILES}
+do
+        sort -n ${ERROR_FILE} &gt; temp
+        mv temp ${ERROR_FILE}
+done


Property changes on: branches/ocean_projects/ocean_test_cases_staging/ocean/advective_transport/getErrors.sh
___________________________________________________________________
Added: svn:executable
   + *

Added: branches/ocean_projects/ocean_test_cases_staging/ocean/advective_transport/rms_error_from_ic.py
===================================================================
--- branches/ocean_projects/ocean_test_cases_staging/ocean/advective_transport/rms_error_from_ic.py                                (rev 0)
+++ branches/ocean_projects/ocean_test_cases_staging/ocean/advective_transport/rms_error_from_ic.py        2012-03-16 16:57:55 UTC (rev 1661)
@@ -0,0 +1,71 @@
+#!/usr/bin/python
+import sys, os, glob, shutil, numpy
+
+sys.path.append('PATH_TO_NETCDF4')
+
+from netCDF4 import *
+from netCDF4 import Dataset as NetCDFFile
+from pylab import *
+
+from optparse import OptionParser
+
+parser = OptionParser()
+parser.add_option(&quot;-f&quot;, &quot;--file&quot;, dest=&quot;filename&quot;, help=&quot;first input file&quot;, metavar=&quot;FILE&quot;)
+parser.add_option(&quot;-v&quot;, &quot;--var&quot;, dest=&quot;variable&quot;, help=&quot;variable to compute error with&quot;, metavar=&quot;VAR&quot;)
+
+options, args = parser.parse_args()
+
+if not options.filename:
+        parser.error(&quot;Filename is a required input.&quot;)
+
+if not options.variable:
+        parser.error(&quot;Variable is a required input.&quot;)
+
+f = NetCDFFile(options.filename,'r')
+
+nCells = len(f.dimensions['nCells'])
+nEdges = len(f.dimensions['nEdges'])
+nVertices = len(f.dimensions['nVertices'])
+vert_levs = len(f.dimensions['nVertLevels'])
+
+times = f.variables['xtime']
+
+field = f.variables[options.variable][:]
+dim = f.variables[options.variable].dimensions[1]
+
+time_length = times.shape[0]
+
+field_size = size(field)
+
+if field_size == nCells * vert_levs * time_length:
+        second_dim = nCells
+        area = f.variables['areaCell'][:]
+
+elif field_size == nEdges * vert_levs * time_length:
+        second_dim = nEdges
+        area = f.variables['areaEdge'][:]
+
+elif field_size == nVertices * vert_levs * time_length:
+        second_dim = nVertices
+        area = f.variables['areaTriangle'][:]
+
+else:
+        print &quot;Field doesn't have the right dimensions. Quitting.&quot;
+        quit()
+
+field_reshaped = field.reshape(time_length, second_dim, vert_levs)
+
+for t in range( 0, time_length):
+        rms = 0
+        for v in range(0, vert_levs):
+                diff = field_reshaped[t,:,v] - field_reshaped[0,:,v]
+                #diff = diff * diff * area
+                diff = diff * diff
+                rms = rms + sum(diff)
+
+#         rms = math.sqrt(rms) / (sum(area) * vert_levs)
+         rms = math.sqrt(rms) / (second_dim * vert_levs)
+
+        print t, rms
+        del rms
+        del diff


Property changes on: branches/ocean_projects/ocean_test_cases_staging/ocean/advective_transport/rms_error_from_ic.py
___________________________________________________________________
Added: svn:executable
   + *

</font>
</pre>