<p><b>dwj07@fsu.edu</b> 2012-03-01 15:38:43 -0700 (Thu, 01 Mar 2012)</p><p><br>
        -- BRANCH COMMIT --<br>
<br>
        Adding a python script to compute the RMS error of a field in two mpas files.<br>
</p><hr noshade><pre><font color="gray">Added: branches/ocean_projects/ocean_test_cases_staging/ocean/baroclinic_channel/field_rms_errors.py
===================================================================
--- branches/ocean_projects/ocean_test_cases_staging/ocean/baroclinic_channel/field_rms_errors.py                                (rev 0)
+++ branches/ocean_projects/ocean_test_cases_staging/ocean/baroclinic_channel/field_rms_errors.py        2012-03-01 22:38:43 UTC (rev 1566)
@@ -0,0 +1,81 @@
+#!/usr/bin/python
+import sys, os, glob, shutil, numpy
+
+sys.path.append('/home/douglasj/softwares/python/lib/python2.7/site-packages')
+
+from netCDF4 import *
+from netCDF4 import Dataset as NetCDFFile
+from pylab import *
+
+from optparse import OptionParser
+
+parser = OptionParser()
+parser.add_option(&quot;-1&quot;, &quot;--file1&quot;, dest=&quot;filename1&quot;, help=&quot;first input file&quot;, metavar=&quot;FILE&quot;)
+parser.add_option(&quot;-2&quot;, &quot;--file2&quot;, dest=&quot;filename2&quot;, help=&quot;second 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.filename1:
+        parser.error(&quot;Two filenames are required inputs.&quot;)
+
+if not options.filename2:
+        parser.error(&quot;Two filenames are required inputs.&quot;)
+
+if not options.variable:
+        parser.error(&quot;Variable is a required input.&quot;)
+
+f1 = NetCDFFile(options.filename1,'r')
+f2 = NetCDFFile(options.filename2,'r')
+
+nCells = len(f1.dimensions['nCells'])
+nEdges = len(f1.dimensions['nEdges'])
+nVertices = len(f1.dimensions['nVertices'])
+vert_levs = len(f1.dimensions['nVertLevels'])
+
+times = f1.variables['xtime']
+dcedge = f1.variables['dcEdge']
+
+field1 = f1.variables[options.variable][:]
+field2 = f2.variables[options.variable][:]
+
+print f1.variables[options.variable]
+
+junk = dcedge[:]
+resolution = junk.max()
+
+del dcedge
+del junk
+
+time_length = times.shape[0]
+
+del times
+
+field_size = size(field1)
+
+if field_size == nCells * vert_levs * time_length:
+        second_dim = nCells * vert_levs
+
+elif field_size == nEdges * vert_levs * time_length:
+        second_dim = nEdges * vert_levs
+
+elif field_size == nVertices * vert_levs * time_length:
+        second_dim = nVertices * vert_levs
+
+else:
+        print &quot;Field doesn't have the right dimensions. Quitting.&quot;
+        quit()
+
+field1_reshaped = field1.reshape(time_length, second_dim)
+field2_reshaped = field2.reshape(time_length, second_dim)
+
+for t in range( 0, time_length):
+        diff = field1_reshaped[t,:] - field2_reshaped[t,:]
+        diff = diff * diff
+        rms = sum(diff)
+        rms = rms/(second_dim)
+        rms = math.sqrt(rms)
+
+        print &quot;Error at time &quot;,t,rms
+        del rms
+        del diff


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

</font>
</pre>