[cmor] 97/190: 2011-04-05 : not overwriting user time values in climatology case

Alastair McKinstry mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:42 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 a2cda9cffbe1d4179046ee0e649abf50a3c049ca
Author: Charles Doutriaux <doutriaux1 at llnl.gov>
Date:   Thu Apr 7 11:06:23 2011 -0700

    2011-04-05 : not overwriting user time values in climatology case
---
 RELEASE-NOTES                                 |  1 +
 Src/cmor.c                                    |  1 -
 Src/cmor_axes.c                               |  2 +-
 Test/test_python_joerg_tim2_clim.py           | 61 +++++++++++++++++++++++++++
 Test/test_python_stephanie_6hrPlev_minutes.py | 58 +++++++++++++++++++++++++
 5 files changed, 121 insertions(+), 2 deletions(-)

diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index e25ae6e..687e2b5 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -1,3 +1,4 @@
+2011-04-05 : not overwriting user time values in climatology case
 2011-02-25 : releasing 2.5.7
 2011-02-25 : fixed bug for dims of length one where bounds needed to be flliped, it used to raise an unwarranted error
 2011-02-23 : releasing 2.5.6
diff --git a/Src/cmor.c b/Src/cmor.c
index 9cc4709..4aea269 100644
--- a/Src/cmor.c
+++ b/Src/cmor.c
@@ -3700,7 +3700,6 @@ int cmor_close_variable(int var_id, char *file_name, int *preserve)
       interval  = cmor_convert_interval_to_seconds(cmor_tables[cmor_axes[cmor_vars[var_id].axes_ids[0]].ref_table_id].interval,cmor_tables[cmor_axes[cmor_vars[var_id].axes_ids[0]].ref_table_id].axes[cmor_axes[cmor_vars[var_id].axes_ids[0]].ref_axis_id].units);
       
       
-      /*       printf("interval: %lf\n",interval); */
       /* first time point */
       strncat(outname,"_",CMOR_MAX_STRING-strlen(outname));
       snprintf(msg2,CMOR_MAX_STRING,"%.4ld",comptime.year);
diff --git a/Src/cmor_axes.c b/Src/cmor_axes.c
index 325052f..e62180c 100644
--- a/Src/cmor_axes.c
+++ b/Src/cmor_axes.c
@@ -1295,7 +1295,7 @@ int cmor_axis(int *axis_id, char *name,char *units, int length,void *coord_vals,
       /* At this point we are checking that the axis values are within bounds */
       /* for (i=0;i<length;i++) printf("check bounds: %i -> %lf,%lf,%lf\n",i,cmor_axes[cmor_naxes].bounds[2*i],cmor_axes[cmor_naxes].values[i],cmor_axes[cmor_naxes].bounds[2*i+1]); */
       ierr = cmor_check_values_inside_bounds(&cmor_axes[cmor_naxes].values[0],&cmor_axes[cmor_naxes].bounds[0], length, name);
-      if (refaxis.axis=='T') {
+      if ((refaxis.axis=='T')&&(refaxis.climatology==0)) {
 	/* ok now we need to overwrite the time values with mid point */
 	for (i=0;i<length;i++) cmor_axes[cmor_naxes].values[i]=(cmor_axes[cmor_naxes].bounds[2*i]+cmor_axes[cmor_naxes].bounds[2*i+1])/2.;
       }
diff --git a/Test/test_python_joerg_tim2_clim.py b/Test/test_python_joerg_tim2_clim.py
new file mode 100644
index 0000000..c81037e
--- /dev/null
+++ b/Test/test_python_joerg_tim2_clim.py
@@ -0,0 +1,61 @@
+#!/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', '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 = 'brian clough')
+ 
+    table = 'CMIP5_Oclim'
+    cmor.load_table(table)
+    axes = [ {'table_entry': 'time2',
+              'units': 'days since 1850-01-01 00:00:00',
+              'coord_vals' : [15.5, 45, 74.5, 105, 135.5, 166, 196.5, 227.5, 258, 288.5, 319, 349.5],
+              'cell_bounds':[0,31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365],
+              },
+             {'table_entry': 'depth_coord',
+              'units': 'm',
+              'coord_vals': [5000., 3000., 2000., 1000.],
+              'cell_bounds': [ 5000., 3000., 2000., 1000.,0]},
+             {'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 (('difvso', 'm2 s-1', 274.),):
+        values = numpy.ones(map(lambda x: len(x["coord_vals"]),axes))*value
+        varid = cmor.variable(var,
+                              units,
+                              axis_ids,
+                              history = 'variable history',
+                              missing_value = -99
+                              )
+        cmor.write(varid, values)
+
+    cmor.close()
+    
+if __name__ == '__main__':
+
+    main()
diff --git a/Test/test_python_stephanie_6hrPlev_minutes.py b/Test/test_python_stephanie_6hrPlev_minutes.py
new file mode 100644
index 0000000..74d7cc3
--- /dev/null
+++ b/Test/test_python_stephanie_6hrPlev_minutes.py
@@ -0,0 +1,58 @@
+#!/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', '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 = 'brian clough')
+ 
+    table = 'CMIP5_6hrPlev'
+    cmor.load_table(table)
+    axes = [ {'table_entry': 'time1',
+              'units': 'hours since 2000-01-01 00:00:00',
+              },
+             {'table_entry': 'plev3',
+              'units': 'Pa',
+              'coord_vals': [100000., 92500., 85000., 70000., 60000., 50000., 40000., 30000., 25000., 20000., 15000., 10000., 7000., 5000., 3000., 2000., 1000.]},
+             {'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 (('ta', 'K', 274), ('ua', 'm s-1', 10)):
+        values = numpy.array([value,]*len(axes[1]['coord_vals']), numpy.float32)
+        varid = cmor.variable(var,
+                              units,
+                              axis_ids,
+                              history = 'variable history',
+                              missing_value = -99
+                              )
+        cmor.write(varid, values, time_vals = [0], time_bnds = [ [0,6] ])
+
+    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