[cmor] 105/190: 2011-04-07 : only adding extra time precision in file names if it is < 6hr instead of 1 day 2011-04-05 : not overwriting user time values in climatology case
Alastair McKinstry
mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:43 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 66700aa762afe32a8bce629097f2d1be978933bd
Author: Charles Doutriaux <doutriaux1 at llnl.gov>
Date: Mon Apr 11 12:15:13 2011 -0700
2011-04-07 : only adding extra time precision in file names if it is < 6hr instead of 1 day
2011-04-05 : not overwriting user time values in climatology case
---
RELEASE-NOTES | 1 +
Src/cmor.c | 44 +++++++++++++++++-------------
Src/cmor_variables.c | 38 +++++++++++++-------------
Test/test_python_clim_bounds.py | 59 +++++++++++++++++++++++++++++++++++++++++
configure | 18 ++++++-------
configure.ac | 2 +-
include/cmor.h | 4 +--
7 files changed, 116 insertions(+), 50 deletions(-)
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 687e2b5..abb9edb 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -1,3 +1,4 @@
+2011-04-07 : only adding extra time precision in file names if it is < 6hr instead of 1 day
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
diff --git a/Src/cmor.c b/Src/cmor.c
index 4aea269..17b1950 100644
--- a/Src/cmor.c
+++ b/Src/cmor.c
@@ -530,8 +530,8 @@ void cmor_reset_variable(int var_id) {
cmor_vars[var_id].values = NULL;
cmor_vars[var_id].first_time=-999.;
cmor_vars[var_id].last_time=-999.;
- /* cmor_vars[var_id].first_bound=1.e20; */
- /* cmor_vars[var_id].last_bound=1.e20; */
+ cmor_vars[var_id].first_bound=1.e20;
+ cmor_vars[var_id].last_bound=1.e20;
cmor_vars[var_id].base_path[0]='\0';
cmor_vars[var_id].current_path[0]='\0';
cmor_vars[var_id].suffix[0]='\0';
@@ -3690,12 +3690,15 @@ int cmor_close_variable(int var_id, char *file_name, int *preserve)
}
/* ok makes a comptime out of input */
- /* if (cmor_vars[var_id].first_bound!=1.e20) { */
- /* cdRel2Comp(icalo,msg,cmor_vars[var_id].first_bound,&comptime); */
- /* } */
- /* else { */
+ i = cmor_vars[var_id].axes_ids[0];
+ j=cmor_axes[i].ref_table_id;
+ i=cmor_axes[i].ref_axis_id;
+ if ((cmor_tables[j].axes[i].climatology==1)&&(cmor_vars[var_id].first_bound!=1.e20)) {
+ cdRel2Comp(icalo,msg,cmor_vars[var_id].first_bound,&comptime);
+ }
+ else {
cdRel2Comp(icalo,msg,cmor_vars[var_id].first_time,&comptime);
- /* } */
+ }
/* need to figure out the approximate interval */
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);
@@ -3716,6 +3719,9 @@ int cmor_close_variable(int var_id, char *file_name, int *preserve)
/* from now on add 1 more level of precision since that frequency */
snprintf(msg2,CMOR_MAX_STRING,"%.2i",(int)comptime.hour);
strncat(outname,msg2,CMOR_MAX_STRING-strlen(outname));
+ }
+ if (interval<21000) { /* less than 6hr */
+ /* from now on add 1 more level of precision since that frequency */
snprintf(msg2,CMOR_MAX_STRING,"%.2i",(int)((comptime.hour-(int)(comptime.hour))*60.));
strncat(outname,msg2,CMOR_MAX_STRING-strlen(outname));
}
@@ -3725,20 +3731,20 @@ int cmor_close_variable(int var_id, char *file_name, int *preserve)
}
- /* if (cmor_vars[var_id].last_bound!=1.e20) { */
- /* cdRel2Comp(icalo,msg,cmor_vars[var_id].last_bound,&comptime); */
- /* } */
- /* else { */
+ if ((cmor_tables[j].axes[i].climatology==1) && (cmor_vars[var_id].last_bound!=1.e20)) {
+ cdRel2Comp(icalo,msg,cmor_vars[var_id].last_bound,&comptime);
+ /* ok apparently we don't like the new time format if it's ending at midnight exactly so I'm removing one second...*/
+ if (icalo==cdMixed) {
+ cdCompAddMixed(comptime,-1./3600.,&comptime);
+ }
+ else{
+ cdCompAdd(comptime,-1./3600.,icalo,&comptime);
+ }
+ }
+ else {
cdRel2Comp(icalo,msg,cmor_vars[var_id].last_time,&comptime);
- /* } */
+ }
- /* /\* ok apparently we don't like the new time format if it's ending at midnight exactly so I'm removing one second...*\/ */
- /* if (icalo==cdMixed) { */
- /* cdCompAddMixed(comptime,-1./3600.,&comptime); */
- /* } */
- /* else{ */
- /* cdCompAdd(comptime,-1./3600.,icalo,&comptime); */
- /* } */
/* separator between first and last time */
strncat(outname,"-",CMOR_MAX_STRING-strlen(outname));
diff --git a/Src/cmor_variables.c b/Src/cmor_variables.c
index a27f867..f8d8e22 100644
--- a/Src/cmor_variables.c
+++ b/Src/cmor_variables.c
@@ -1648,11 +1648,11 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
ierr = nc_put_vara_double(ncid,avar->time_bnds_nc_id,starts,counts2,tmp_vals);
if (ierr != NC_NOERR) {snprintf(msg,CMOR_MAX_STRING,"NetCDF error (%i) writing time bounds for variable '%s', already written in file: %i",ierr,avar->id,avar->ntimes_written);cmor_handle_error(msg,CMOR_CRITICAL);}
/* /\* ok first time around the we need to store bounds *\/ */
- /* if (avar->ntimes_written == 0) { */
- /* /\* ok first time we're putting data in *\/ */
- /* avar->first_bound = tmp_vals[0]; */
- /* } */
- /* avar->last_bound = tmp_vals[ntimes_passed*2-1]; */
+ if (avar->ntimes_written == 0) {
+ /* ok first time we're putting data in */
+ avar->first_bound = tmp_vals[0];
+ }
+ avar->last_bound = tmp_vals[ntimes_passed*2-1];
/* ok since we have bounds we need to set time in the middle */
@@ -1700,8 +1700,8 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
snprintf(msg,CMOR_MAX_STRING,"time axis must have bounds, please pass them to cmor_write along with time values, variable %s, table %s",avar->id,cmor_tables[avar->ref_table_id].table_id);
cmor_handle_error(msg,CMOR_CRITICAL);
}
- /* avar->first_bound=1.e20; */
- /* avar->last_bound=1.e20; */
+ avar->first_bound=1.e20;
+ avar->last_bound=1.e20;
cmor_get_axis_attribute(avar->axes_ids[0],"units",'c',&msg);
cmor_get_cur_dataset_attribute("calendar",msg2);
tmp_vals = malloc(ntimes_passed*sizeof(double));
@@ -1734,11 +1734,11 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
starts[1]=0;
ierr = nc_put_vara_double(ncid,avar->time_bnds_nc_id,starts,counts2,&cmor_axes[avar->axes_ids[0]].bounds[starts[0]*2]);
if (ierr != NC_NOERR) {snprintf(msg,CMOR_MAX_STRING,"NCError (%i: %s) writting time bounds values for variable '%s' (table: %s)",ierr,nc_strerror(ierr),avar->id,cmor_tables[avar->ref_table_id].table_id);cmor_handle_error(msg,CMOR_CRITICAL);}
- /* /\* ok we need to store first and last bounds *\/ */
- /* if (avar->ntimes_written==0) { */
- /* avar->first_bound=cmor_axes[avar->axes_ids[0]].bounds[starts[0]*2]; */
- /* } */
- /* avar->last_bound=cmor_axes[avar->axes_ids[0]].bounds[(starts[0]+counts[0])*2]; */
+ /* ok we need to store first and last bounds */
+ if (avar->ntimes_written==0) {
+ avar->first_bound=cmor_axes[avar->axes_ids[0]].bounds[starts[0]*2];
+ }
+ avar->last_bound=cmor_axes[avar->axes_ids[0]].bounds[(starts[0]+counts[0])*2];
}
else {
/* checks wether you need bounds or not */
@@ -1746,12 +1746,12 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
snprintf(msg,CMOR_MAX_STRING,"time axis must have bounds, you defined it w/o any for variable %s (table: %s)",avar->id,cmor_tables[avar->ref_table_id].table_id);
cmor_handle_error(msg,CMOR_CRITICAL);
}
- /* avar->first_bound=1.e20; */
- /* avar->last_bound=1.e20; */
+ avar->first_bound=1.e20;
+ avar->last_bound=1.e20;
}
ierr = nc_put_vara_double(ncid,avar->time_nc_id,starts,counts,&cmor_axes[avar->axes_ids[0]].values[starts[0]]);
if (ierr != NC_NOERR) {snprintf(msg,CMOR_MAX_STRING,"NCError (%i: %s) writting time values for variable '%s' (table: %s)",ierr,nc_strerror(ierr),avar->id,cmor_tables[avar->ref_table_id].table_id);cmor_handle_error(msg,CMOR_CRITICAL);}
- /* ok now we need to stroe first and last stuff */
+ /* ok now we need to store first and last stuff */
if (avar->ntimes_written==0) {
avar->first_time = cmor_axes[avar->axes_ids[0]].values[starts[0]];
}
@@ -1773,8 +1773,8 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
snprintf(msg,CMOR_MAX_STRING,"variable '%s' (table: %s) you are passing %i times but no values and you did not define them via cmor_axis",avar->id,cmor_tables[avar->ref_table_id].table_id,ntimes_passed);
cmor_handle_error(msg,CMOR_CRITICAL);
}
- /* avar->first_bound=1.e20; */
- /* avar->last_bound=1.e20; */
+ avar->first_bound=1.e20;
+ avar->last_bound=1.e20;
if (cmor_axes[avar->axes_ids[ierr]].bounds!=NULL) {
/* ok at that stage the recentering must already be done so we just need to write the bounds */
counts2[0]=counts[0];
@@ -1783,8 +1783,8 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
starts[1]=0;
ierr = nc_put_vara_double(ncid,avar->time_bnds_nc_id,starts,counts2,&cmor_axes[avar->axes_ids[0]].bounds[starts[0]*2]);
if (ierr != NC_NOERR) {snprintf(msg,CMOR_MAX_STRING,"NCError (%i: %s) writting time bounds values for variable '%s' (table: %s)",ierr,nc_strerror(ierr),avar->id,cmor_tables[avar->ref_table_id].table_id);cmor_handle_error(msg,CMOR_CRITICAL);}
- /* avar->first_bound=cmor_axes[avar->axes_ids[0]].bounds[0]; */
- /* avar->last_bound=cmor_axes[avar->axes_ids[0]].bounds[counts[0]*2]; */
+ avar->first_bound=cmor_axes[avar->axes_ids[0]].bounds[0];
+ avar->last_bound=cmor_axes[avar->axes_ids[0]].bounds[counts[0]*2];
}
ierr = nc_put_vara_double(ncid,avar->time_nc_id,starts,counts,&cmor_axes[avar->axes_ids[0]].values[starts[0]]);
if (ierr != NC_NOERR) {snprintf(msg,CMOR_MAX_STRING,"NCError (%i: %s) writting time values for variable '%s' (table: %s)",ierr,nc_strerror(ierr),avar->id,cmor_tables[avar->ref_table_id].table_id);cmor_handle_error(msg,CMOR_CRITICAL);}
diff --git a/Test/test_python_clim_bounds.py b/Test/test_python_clim_bounds.py
new file mode 100644
index 0000000..19cba4c
--- /dev/null
+++ b/Test/test_python_clim_bounds.py
@@ -0,0 +1,59 @@
+#!/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 2000-01-01 00:00:00',
+ },
+ {'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, time_vals = [30*i+15], time_bnds = [ [30*i,360+30*(i+1)] ])
+
+ cmor.close()
+
+if __name__ == '__main__':
+
+ main()
diff --git a/configure b/configure
index 8e511d1..825770c 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for cmor 2.5.7.
+# Generated by GNU Autoconf 2.61 for cmor 2.5.8.
#
# Report bugs to <doutriaux1 at llnl.gov>.
#
@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='cmor'
PACKAGE_TARNAME='cmor'
-PACKAGE_VERSION='2.5.7'
-PACKAGE_STRING='cmor 2.5.7'
+PACKAGE_VERSION='2.5.8'
+PACKAGE_STRING='cmor 2.5.8'
PACKAGE_BUGREPORT='doutriaux1 at llnl.gov'
ac_default_prefix=/usr/local/cmor
@@ -1185,7 +1185,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures cmor 2.5.7 to adapt to many kinds of systems.
+\`configure' configures cmor 2.5.8 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1251,7 +1251,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of cmor 2.5.7:";;
+ short | recursive ) echo "Configuration of cmor 2.5.8:";;
esac
cat <<\_ACEOF
@@ -1350,7 +1350,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-cmor configure 2.5.7
+cmor configure 2.5.8
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1364,7 +1364,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by cmor $as_me 2.5.7, which was
+It was created by cmor $as_me 2.5.8, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -4989,7 +4989,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by cmor $as_me 2.5.7, which was
+This file was extended by cmor $as_me 2.5.8, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -5032,7 +5032,7 @@ Report bugs to <bug-autoconf at gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-cmor config.status 2.5.7
+cmor config.status 2.5.8
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/configure.ac b/configure.ac
index 4f07e05..0ae2abd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ dnl -*- Autoconf -*-
dnl Process this file with autoconf to produce a configure script.
dnl AC_PREREQ(2.59)
-AC_INIT(cmor, 2.5.7, doutriaux1 at llnl.gov)
+AC_INIT(cmor, 2.5.8, doutriaux1 at llnl.gov)
GIT_TAG=`./get_git_version.sh`
diff --git a/include/cmor.h b/include/cmor.h
index 0b1790e..82312ae 100644
--- a/include/cmor.h
+++ b/include/cmor.h
@@ -220,8 +220,8 @@ typedef struct cmor_var_ {
double *values;
double first_time;
double last_time;
- /* double first_bound; */
- /* double last_bound; */
+ double first_bound;
+ double last_bound;
char base_path[CMOR_MAX_STRING];
char current_path[CMOR_MAX_STRING];
char suffix[CMOR_MAX_STRING];
--
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