Changed h1_summary/h1_summary2 to write a timestamp that is centered on the time bounds.
authorForrest Hoffman <forrest@climatemodeling.org>
Wed, 03 Oct 2007 11:23:02 -0400
changeset 3d3122367777b
parent 2 978f4510987d
child 4 dd8e6719647b
Changed h1_summary/h1_summary2 to write a timestamp that is centered on the time bounds.

h1_summary and h1_summary2 previously wrote out a timestamp representing the
last time entry in the last file to be summarized. Now, to follow convention,
the timestamp is recomputed as the mean of the first and last time_bounds,
where the first time_bounds value is the first value from the first time
entry in the first file and the last time_bounds is the second value from
the last time entry in the last file.
h1_summary.c
h1_summary2.c
     1.1 --- a/h1_summary.c	Mon Oct 01 15:49:25 2007 -0400
     1.2 +++ b/h1_summary.c	Wed Oct 03 11:23:02 2007 -0400
     1.3 @@ -788,7 +788,7 @@
     1.4  	double *tbounds)
     1.5  {
     1.6  	int i, j;
     1.7 -	float hr[HOURS_PER_DAY];
     1.8 +	float hr[HOURS_PER_DAY], mean_time;
     1.9  	struct var *in_vnode, *out_vnode;
    1.10  	void *val;
    1.11  
    1.12 @@ -823,6 +823,12 @@
    1.13  					val = read_timeslice(in_ncid, in_vnode->ncvarid, in_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, ((input_dim_idx[in_vnode->dimids[0]])->len - 1));
    1.14  					if (!strcmp(in_vnode->name, time_bounds_name))
    1.15  						write_timeslice(out_ncid, out_vnode->ncvarid, out_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, tbounds, 0);
    1.16 +					else if (!strcmp(in_vnode->name, time_name)) {
    1.17 +						/* force the timestamp to be the
    1.18 +						 * mean of the time bounds */
    1.19 +						mean_time = (tbounds[0] + tbounds[1]) / 2.0;
    1.20 +						write_timeslice(out_ncid, out_vnode->ncvarid, out_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, &mean_time, 0);
    1.21 +					}
    1.22  					else
    1.23  						write_timeslice(out_ncid, out_vnode->ncvarid, out_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, val, 0);
    1.24  				}
     2.1 --- a/h1_summary2.c	Mon Oct 01 15:49:25 2007 -0400
     2.2 +++ b/h1_summary2.c	Wed Oct 03 11:23:02 2007 -0400
     2.3 @@ -788,7 +788,7 @@
     2.4  	double *tbounds)
     2.5  {
     2.6  	int i, j;
     2.7 -	float hr[HOURS_PER_DAY];
     2.8 +	float hr[HOURS_PER_DAY], mean_time;
     2.9  	struct var *in_vnode, *out_vnode;
    2.10  	void *val;
    2.11  
    2.12 @@ -823,6 +823,12 @@
    2.13  					val = read_timeslice(in_ncid, in_vnode->ncvarid, in_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, ((input_dim_idx[in_vnode->dimids[0]])->len - 1));
    2.14  					if (!strcmp(in_vnode->name, time_bounds_name))
    2.15  						write_timeslice(out_ncid, out_vnode->ncvarid, out_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, tbounds, 0);
    2.16 +					else if (!strcmp(in_vnode->name, time_name)) {
    2.17 +						/* force the timestamp to be the
    2.18 +						 * mean of the time bounds */
    2.19 +						mean_time = (tbounds[0] + tbounds[1]) / 2.0;
    2.20 +						write_timeslice(out_ncid, out_vnode->ncvarid, out_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, &mean_time, 0);
    2.21 +					}
    2.22  					else
    2.23  						write_timeslice(out_ncid, out_vnode->ncvarid, out_vnode->nctype, in_vnode->ndims, in_vnode->dimids, in_dim_idx, val, 0);
    2.24  				}