[cmor] 109/190: Adding the test cases for clim filename bounds

Alastair McKinstry mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:44 UTC 2015


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch debian/master
in repository cmor.

commit eeed60ea16385f0e6ebee45feb8ee646df816b83
Author: Charles Doutriaux <doutriaux1 at llnl.gov>
Date:   Wed Apr 27 16:15:22 2011 -0700

    Adding the test cases for clim filename bounds
---
 Test/test_python_clim_bounds_02.py | 72 +++++++++++++++++++++++++++++++++++++
 Test/test_python_clim_bounds_03.py | 73 ++++++++++++++++++++++++++++++++++++++
 Test/test_python_clim_bounds_04.py | 72 +++++++++++++++++++++++++++++++++++++
 3 files changed, 217 insertions(+)

diff --git a/Test/test_python_clim_bounds_02.py b/Test/test_python_clim_bounds_02.py
new file mode 100644
index 0000000..228cb37
--- /dev/null
+++ b/Test/test_python_clim_bounds_02.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+import cmor
+import numpy
+
+def main():
+    
+    cmor.setup(inpath='/git/cmip5-cmor-tables/Tables',
+               netcdf_file_action = cmor.CMOR_REPLACE_3)
+    cmor.dataset('pre-industrial control', 'ukmo', 'HadCM3', 'noleap',
+                 institute_id = 'ukmo',
+                 model_id = 'HadCM3',
+                 history = 'some global history',
+                 forcing = 'N/A',
+                 parent_experiment_id = 'N/A',
+                 parent_experiment_rip = 'N/A',
+                 branch_time = 0,
+                 contact = 'brian clough')
+ 
+    table = 'CMIP5_Oclim'
+    cmor.load_table(table)
+    axes = [ {'table_entry': 'time2',
+              'units': 'days since 1861',
+              'coord_vals': [48925.5, 48955, 48984.5, 49015, 49045.5, 49076, 49106.5, 49137.5, 49168, 49198.5, 49229, 49259.5 ],
+              'cell_bounds': [ [ 45625, 52591],
+                               [ 45656, 52619,],
+                               [ 45684, 52650,],
+                               [ 45715, 52680,],
+                               [ 45745, 52711,],
+                               [45776, 52741,],
+                               [45806, 52772,],
+                               [45837, 52803,],
+                               [45868, 52833,],
+                               [45898, 52864,],
+                               [45929, 52894,],
+                               [45959, 52925]],
+              },
+             {'table_entry': 'depth_coord',
+              'units': 'm',
+              'coord_vals': [ 500,1000.],
+              'cell_bounds': [ 0.,750.,1200.]},
+             {'table_entry': 'latitude',
+              'units': 'degrees_north',
+              'coord_vals': [0],
+              'cell_bounds': [-1, 1]},             
+             {'table_entry': 'longitude',
+              'units': 'degrees_east',
+              'coord_vals': [90],
+              'cell_bounds': [89, 91]},
+             ]
+
+    axis_ids = list()
+    for axis in axes:
+        print 'doing:',axis
+        axis_id = cmor.axis(**axis)
+        axis_ids.append(axis_id)
+
+    for var, units, value in (('tnpeot', 'W m-2', 274),):
+        values = numpy.array([value,]*len(axes[1]['coord_vals']), numpy.float32)
+        varid = cmor.variable(var,
+                              units,
+                              axis_ids,
+                              history = 'variable history',
+                              missing_value = -99
+                              )
+        for i in range(12):
+            cmor.write(varid, values, ntimes_passed=1)
+
+    cmor.close()
+    
+if __name__ == '__main__':
+
+    main()
diff --git a/Test/test_python_clim_bounds_03.py b/Test/test_python_clim_bounds_03.py
new file mode 100644
index 0000000..d62f335
--- /dev/null
+++ b/Test/test_python_clim_bounds_03.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+import cmor
+import numpy
+
+def main():
+    
+    cmor.setup(inpath='/git/cmip5-cmor-tables/Tables',
+               netcdf_file_action = cmor.CMOR_REPLACE_3)
+    cmor.dataset('pre-industrial control', 'ukmo', 'HadCM3', 'noleap',
+                 institute_id = 'ukmo',
+                 model_id = 'HadCM3',
+                 history = 'some global history',
+                 forcing = 'N/A',
+                 parent_experiment_id = 'N/A',
+                 parent_experiment_rip = 'N/A',
+                 branch_time = 0,
+                 contact = 'brian clough')
+ 
+    table = 'CMIP5_Oclim'
+    cmor.load_table(table)
+    axes = [ {'table_entry': 'time2',
+              'units': 'days since 1861',
+              'coord_vals': [48925.5, 48955, 48984.5, 49015, 49045.5, 49076, 49106.5, 49137.5, 49168, 49198.5, 49229, 49259.5 ],
+              'cell_bounds': [ [ 45625, 52591],
+                               [ 45656, 52619,],
+                               [ 45684, 52650,],
+                               [ 45715, 52680,],
+                               [ 45745, 52711,],
+                               [45776, 52741,],
+                               [45806, 52772,],
+                               [45837, 52803,],
+                               [45868, 52833,],
+                               [45898, 52864,],
+                               [45929, 52894,],
+                               [45959, 52925]],
+              },
+             {'table_entry': 'depth_coord',
+              'units': 'm',
+              'coord_vals': [ 500,1000.],
+              'cell_bounds': [ 0.,750.,1200.]},
+             {'table_entry': 'latitude',
+              'units': 'degrees_north',
+              'coord_vals': [0],
+              'cell_bounds': [-1, 1]},             
+             {'table_entry': 'longitude',
+              'units': 'degrees_east',
+              'coord_vals': [90],
+              'cell_bounds': [89, 91]},
+             ]
+
+    axis_ids = list()
+    for axis in axes:
+        print 'doing:',axis
+        axis_id = cmor.axis(**axis)
+        axis_ids.append(axis_id)
+
+    for var, units, value in (('tnpeot', 'W m-2', 274),):
+        values = numpy.ones((len(axes[0]['coord_vals']),len(axes[1]['coord_vals'])))*value
+        varid = cmor.variable(var,
+                              units,
+                              axis_ids,
+                              history = 'variable history',
+                              missing_value = -99
+                              )
+        print values.shape
+        
+        cmor.write(varid, values)#, ntimes_passed=1)
+
+    cmor.close()
+    
+if __name__ == '__main__':
+
+    main()
diff --git a/Test/test_python_clim_bounds_04.py b/Test/test_python_clim_bounds_04.py
new file mode 100644
index 0000000..5049db6
--- /dev/null
+++ b/Test/test_python_clim_bounds_04.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+import cmor
+import numpy
+
+def main():
+    
+    cmor.setup(inpath='/git/cmip5-cmor-tables/Tables',
+               netcdf_file_action = cmor.CMOR_REPLACE_3)
+    cmor.dataset('pre-industrial control', 'ukmo', 'HadCM3', 'noleap',
+                 institute_id = 'ukmo',
+                 model_id = 'HadCM3',
+                 history = 'some global history',
+                 forcing = 'N/A',
+                 parent_experiment_id = 'N/A',
+                 parent_experiment_rip = 'N/A',
+                 branch_time = 0,
+                 contact = 'brian clough')
+ 
+    table = 'CMIP5_Oclim'
+    cmor.load_table(table)
+    axes = [ {'table_entry': 'time2',
+              'units': 'days since 1861',
+              },
+             {'table_entry': 'depth_coord',
+              'units': 'm',
+              'coord_vals': [ 500,1000.],
+              'cell_bounds': [ 0.,750.,1200.]},
+             {'table_entry': 'latitude',
+              'units': 'degrees_north',
+              'coord_vals': [0],
+              'cell_bounds': [-1, 1]},             
+             {'table_entry': 'longitude',
+              'units': 'degrees_east',
+              'coord_vals': [90],
+              'cell_bounds': [89, 91]},
+             ]
+
+    axes2={'coord_vals': [48925.5, 48955, 48984.5, 49015, 49045.5, 49076, 49106.5, 49137.5, 49168, 49198.5, 49229, 49259.5 ],
+              'cell_bounds': [ [ 45625, 52591],
+                               [ 45656, 52619,],
+                               [ 45684, 52650,],
+                               [ 45715, 52680,],
+                               [ 45745, 52711,],
+                               [45776, 52741,],
+                               [45806, 52772,],
+                               [45837, 52803,],
+                               [45868, 52833,],
+                               [45898, 52864,],
+                               [45929, 52894,],
+                               [45959, 52925]],}
+    axis_ids = list()
+    for axis in axes:
+        print 'doing:',axis
+        axis_id = cmor.axis(**axis)
+        axis_ids.append(axis_id)
+
+    for var, units, value in (('tnpeot', 'W m-2', 274),):
+        values = numpy.array([value,]*len(axes[1]['coord_vals']), numpy.float32)
+        varid = cmor.variable(var,
+                              units,
+                              axis_ids,
+                              history = 'variable history',
+                              missing_value = -99
+                              )
+        for i in range(12):
+            cmor.write(varid, values, time_vals=axes2["coord_vals"][i],time_bnds=axes2["cell_bounds"][i])
+
+    cmor.close()
+    
+if __name__ == '__main__':
+
+    main()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cmor.git



More information about the debian-science-commits mailing list