[cmor] 128/190: Adding Jamie's time gap tests
Alastair McKinstry
mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:46 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 01320008fc41be14f2e5dcebb141c35ad4aa9178
Author: Charles Doutriaux <doutriaux1 at llnl.gov>
Date: Fri May 17 10:13:17 2013 -0700
Adding Jamie's time gap tests
---
Test/test_time_gap_multi_write.py | 69 ++++++++++++++++++++++++++++++++++++
Test/test_time_gap_single_write1.py | 69 ++++++++++++++++++++++++++++++++++++
Test/test_time_gap_single_write2.py | 70 +++++++++++++++++++++++++++++++++++++
3 files changed, 208 insertions(+)
diff --git a/Test/test_time_gap_multi_write.py b/Test/test_time_gap_multi_write.py
new file mode 100644
index 0000000..ba7ce3a
--- /dev/null
+++ b/Test/test_time_gap_multi_write.py
@@ -0,0 +1,69 @@
+import cmor
+import numpy
+
+def cmor_initialisation():
+ cmor.setup(inpath='/net/home/h03/hadju/Projects/MipTables/cmip5-cmor-tables/Tables',
+ netcdf_file_action = cmor.CMOR_REPLACE_3,
+ create_subdirectories = 0)
+ cmor.dataset('pre-industrial control', 'ukmo', 'HadCM3', '360_day',
+ 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 = 'bob',
+ outpath = '/data/local/hadju/test')
+
+def setup_data():
+ axes = [ {'table_entry': 'time',
+ 'units': 'days since 2000-01-01 00:00:00'
+ },
+ {'table_entry': 'latitude',
+ 'units': 'degrees',
+ 'coord_vals': [0],
+ 'cell_bounds': [-0.5, 0.5]},
+ {'table_entry': 'longitude',
+ 'units': 'degrees',
+ 'coord_vals': [1],
+ 'cell_bounds': [0.5, 1.5]},
+ ]
+
+ values = numpy.array([215.], numpy.float32)
+ return values, axes
+
+def cmor_define_and_write(values, axes):
+ table = 'CMIP5_day'
+ cmor.load_table(table)
+
+ axis_ids = list()
+ for axis in axes:
+ axis_ids.append(cmor.axis(**axis))
+
+ varid = cmor.variable('rlut',
+ 'W m-2',
+ axis_ids,
+ history = 'variable history',
+ missing_value = -99,
+ positive = 'up'
+ )
+
+ for time in (15, 17):
+ cmor.write(varid, values, time_vals = [time], time_bnds = [time - 0.5, time + 0.5])
+
+def version(cmor):
+ return '%s.%s.%s' % (cmor.CMOR_VERSION_MAJOR,
+ cmor.CMOR_VERSION_MINOR,
+ cmor.CMOR_VERSION_PATCH)
+
+def main():
+ assert version(cmor) == '2.8.3'
+ cmor_initialisation()
+ values, axes = setup_data()
+ cmor_define_and_write(values, axes)
+ cmor.close()
+
+if __name__ == '__main__':
+
+ main()
diff --git a/Test/test_time_gap_single_write1.py b/Test/test_time_gap_single_write1.py
new file mode 100644
index 0000000..c98096d
--- /dev/null
+++ b/Test/test_time_gap_single_write1.py
@@ -0,0 +1,69 @@
+import cmor
+import numpy
+
+def cmor_initialisation():
+ cmor.setup(inpath='/net/home/h03/hadju/Projects/MipTables/cmip5-cmor-tables/Tables',
+ netcdf_file_action = cmor.CMOR_REPLACE_3,
+ create_subdirectories = 0)
+ cmor.dataset('pre-industrial control', 'ukmo', 'HadCM3', '360_day',
+ 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 = 'bob',
+ outpath = '/data/local/hadju/test')
+
+def setup_data():
+ axes = [ {'table_entry': 'time',
+ 'units': 'days since 2000-01-01 00:00:00'
+ },
+ {'table_entry': 'latitude',
+ 'units': 'degrees',
+ 'coord_vals': [0],
+ 'cell_bounds': [-0.5, 0.5]},
+ {'table_entry': 'longitude',
+ 'units': 'degrees',
+ 'coord_vals': [1],
+ 'cell_bounds': [0.5, 1.5]},
+ ]
+
+ values = numpy.array([215., 215.], numpy.float32)
+ return values, axes
+
+def cmor_define_and_write(values, axes):
+ table = 'CMIP5_day'
+ cmor.load_table(table)
+
+ axis_ids = list()
+ for axis in axes:
+ axis_ids.append(cmor.axis(**axis))
+
+ varid = cmor.variable('rlut',
+ 'W m-2',
+ axis_ids,
+ history = 'variable history',
+ missing_value = -99,
+ positive = 'up'
+ )
+
+ time = [15, 17]
+ cmor.write(varid, values, time_vals = time, time_bnds = [[15 - 0.5, 15 +0.5], [17 - 0.5, 17 + 0.5]])
+
+def version(cmor):
+ return '%s.%s.%s' % (cmor.CMOR_VERSION_MAJOR,
+ cmor.CMOR_VERSION_MINOR,
+ cmor.CMOR_VERSION_PATCH)
+
+def main():
+ assert version(cmor) == '2.8.3'
+ cmor_initialisation()
+ values, axes = setup_data()
+ cmor_define_and_write(values, axes)
+ cmor.close()
+
+if __name__ == '__main__':
+
+ main()
diff --git a/Test/test_time_gap_single_write2.py b/Test/test_time_gap_single_write2.py
new file mode 100644
index 0000000..f4c54de
--- /dev/null
+++ b/Test/test_time_gap_single_write2.py
@@ -0,0 +1,70 @@
+
+import cmor
+import numpy
+
+def cmor_initialisation():
+ cmor.setup(inpath='/net/home/h03/hadju/Projects/MipTables/cmip5-cmor-tables/Tables',
+ netcdf_file_action = cmor.CMOR_REPLACE_3,
+ create_subdirectories = 0)
+ cmor.dataset('pre-industrial control', 'ukmo', 'HadCM3', '360_day',
+ 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 = 'bob',
+ outpath = '/data/local/hadju/test')
+
+def setup_data():
+ axes = [ {'table_entry': 'time1',
+ 'units': 'days since 2000-01-01 00:00:00'
+ },
+ {'table_entry': 'latitude',
+ 'units': 'degrees',
+ 'coord_vals': [0],
+ 'cell_bounds': [-0.5, 0.5]},
+ {'table_entry': 'longitude',
+ 'units': 'degrees',
+ 'coord_vals': [1],
+ 'cell_bounds': [0.5, 1.5]},
+ ]
+
+ values = numpy.array([215., 215.], numpy.float32)
+ return values, axes
+
+def cmor_define_and_write(values, axes):
+ table = 'CMIP5_3hr'
+ cmor.load_table(table)
+
+ axis_ids = list()
+ for axis in axes:
+ axis_ids.append(cmor.axis(**axis))
+
+ varid = cmor.variable('tas',
+ 'K',
+ axis_ids,
+ history = 'variable history',
+ missing_value = -99,
+ positive = ''
+ )
+
+ time = [15, 25]
+ cmor.write(varid, values, time_vals = time)
+
+def version(cmor):
+ return '%s.%s.%s' % (cmor.CMOR_VERSION_MAJOR,
+ cmor.CMOR_VERSION_MINOR,
+ cmor.CMOR_VERSION_PATCH)
+
+def main():
+ assert version(cmor) == '2.8.3'
+ cmor_initialisation()
+ values, axes = setup_data()
+ cmor_define_and_write(values, axes)
+ 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