Commit 96e61715 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added new operator ydayvar1 and ydaystd1

parent f61545f5
......@@ -7,6 +7,9 @@
* New operator: ymonvar1 - Multi-year monthly variance [Divisor is (n-1)]
* New operator: ymonstd1 - Multi-year monthly standard deviation [Divisor is(n-1)]
* New operator: ydayvar1 - Multi-year daily variance [Divisor is (n-1)]
* New operator: ydaystd1 - Multi-year daily standard deviation [Divisor is (n-1)]
2013-01-25 Uwe Schulzweida <Uwe.Schulzweida@zmaw.de>
......
......@@ -352,8 +352,10 @@ Operator catalog:
Ydaystat ydaysum Multi-year daily sum
Ydaystat ydaymean Multi-year daily mean
Ydaystat ydayavg Multi-year daily average
Ydaystat ydayvar Multi-year daily variance
Ydaystat ydaystd Multi-year daily standard deviation
Ydaystat ydaystd1 Multi-year daily standard deviation
Ydaystat ydayvar Multi-year daily variance
Ydaystat ydayvar1 Multi-year daily variance
Ydaypctl ydaypctl Multi-year daily percentiles
Ymonstat ymonmin Multi-year monthly minimum
Ymonstat ymonmax Multi-year monthly maximum
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for cdo 1.6.0rc2.
# Generated by GNU Autoconf 2.68 for cdo 1.6.0rc3.
#
# Report bugs to <http://code.zmaw.de/projects/cdo>.
#
......@@ -570,8 +570,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='cdo'
PACKAGE_TARNAME='cdo'
PACKAGE_VERSION='1.6.0rc2'
PACKAGE_STRING='cdo 1.6.0rc2'
PACKAGE_VERSION='1.6.0rc3'
PACKAGE_STRING='cdo 1.6.0rc3'
PACKAGE_BUGREPORT='http://code.zmaw.de/projects/cdo'
PACKAGE_URL=''
 
......@@ -1370,7 +1370,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 cdo 1.6.0rc2 to adapt to many kinds of systems.
\`configure' configures cdo 1.6.0rc3 to adapt to many kinds of systems.
 
Usage: $0 [OPTION]... [VAR=VALUE]...
 
......@@ -1440,7 +1440,7 @@ fi
 
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of cdo 1.6.0rc2:";;
short | recursive ) echo "Configuration of cdo 1.6.0rc3:";;
esac
cat <<\_ACEOF
 
......@@ -1584,7 +1584,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
cdo configure 1.6.0rc2
cdo configure 1.6.0rc3
generated by GNU Autoconf 2.68
 
Copyright (C) 2010 Free Software Foundation, Inc.
......@@ -2177,7 +2177,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 cdo $as_me 1.6.0rc2, which was
It was created by cdo $as_me 1.6.0rc3, which was
generated by GNU Autoconf 2.68. Invocation command line was
 
$ $0 $@
......@@ -3071,7 +3071,7 @@ fi
 
# Define the identity of the package.
PACKAGE='cdo'
VERSION='1.6.0rc2'
VERSION='1.6.0rc3'
 
 
cat >>confdefs.h <<_ACEOF
......@@ -19736,7 +19736,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by cdo $as_me 1.6.0rc2, which was
This file was extended by cdo $as_me 1.6.0rc3, which was
generated by GNU Autoconf 2.68. Invocation command line was
 
CONFIG_FILES = $CONFIG_FILES
......@@ -19802,7 +19802,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
cdo config.status 1.6.0rc2
cdo config.status 1.6.0rc3
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
 
......
# Process this file with autoconf to produce a configure script.
AC_INIT([cdo], [1.6.0rc2], [http://code.zmaw.de/projects/cdo])
AC_INIT([cdo], [1.6.0rc3], [http://code.zmaw.de/projects/cdo])
CONFIG_ABORT=yes
AC_CONFIG_AUX_DIR(config)
......
@BeginModule
@NewPage
@Name = Ydaypctl
@Title = Multi-year daily percentile values
@Section = Statistical values
......
......@@ -5,7 +5,7 @@
@Section = Statistical values
@Class = Statistic
@Arguments = ifile ofile
@Operators = ydaymin ydaymax ydaysum ydaymean ydayavg ydayvar ydaystd
@Operators = ydaymin ydaymax ydaysum ydaymean ydayavg ydaystd ydaystd1 ydayvar ydayvar1
@BeginDescription
This module computes statistical values of each day of year.
......@@ -129,6 +129,8 @@ o(\mbox{366},x) = \mbox{\bf avg}\{i(t,x), \mbox{day}(i(t)) = \mbox{366}\} \\
@Title = Multi-year daily variance
@BeginDescription
Divisor is n.
@IfMan
o(001,x) = var{i(t,x), day(i(t)) = 001}
...
......@@ -147,10 +149,36 @@ o(\mbox{366},x) = \mbox{\bf var}\{i(t,x), \mbox{day}(i(t)) = \mbox{366}\} \\
@EndOperator
@BeginOperator_ydayvar1
@Title = Multi-year daily variance
@BeginDescription
Divisor is (n-1).
@IfMan
o(001,x) = var1{i(t,x), day(i(t)) = 001}
...
o(366,x) = var1{i(t,x), day(i(t)) = 366}
@EndifMan
@IfDoc
@BeginMath
\begin{array}{c}
o(\mbox{001},x) = \mbox{\bf var1}\{i(t,x), \mbox{day}(i(t)) = \mbox{001}\} \\
\vdots \\
o(\mbox{366},x) = \mbox{\bf var1}\{i(t,x), \mbox{day}(i(t)) = \mbox{366}\} \\
\end{array}
@EndMath
@EndifDoc
@EndDescription
@EndOperator
@BeginOperator_ydaystd
@Title = Multi-year daily standard deviation
@BeginDescription
Divisor is n.
@IfMan
o(001,x) = std{i(t,x), day(i(t)) = 001}
...
......@@ -169,6 +197,30 @@ o(\mbox{366},x) = \mbox{\bf std}\{i(t,x), \mbox{day}(i(t)) = \mbox{366}\} \\
@EndOperator
@BeginOperator_ydaystd1
@Title = Multi-year daily standard deviation
@BeginDescription
Divisor is (n-1).
@IfMan
o(001,x) = std1{i(t,x), day(i(t)) = 001}
...
o(366,x) = std1{i(t,x), day(i(t)) = 366}
@EndifMan
@IfDoc
@BeginMath
\begin{array}{c}
o(\mbox{001},x) = \mbox{\bf std1}\{i(t,x), \mbox{day}(i(t)) = \mbox{001}\} \\
\vdots \\
o(\mbox{366},x) = \mbox{\bf std1}\{i(t,x), \mbox{day}(i(t)) = \mbox{366}\} \\
\end{array}
@EndMath
@EndifDoc
@EndDescription
@EndOperator
@BeginExample
To compute the daily mean over all input years use:
@BeginVerbatim
......
......@@ -467,8 +467,7 @@ void *Timstat(void *argument)
field_free(vars1, vlistID1);
field_free(samp1, vlistID1);
if ( lvarstd )
field_free(vars2, vlistID1);
if ( lvarstd ) field_free(vars2, vlistID1);
if ( cdoDiag ) streamClose(streamID3);
streamClose(streamID2);
......
......@@ -24,7 +24,9 @@
Ydaystat ydaymean Multi-year daily mean
Ydaystat ydayavg Multi-year daily average
Ydaystat ydayvar Multi-year daily variance
Ydaystat ydayvar1 Multi-year daily variance [Divisor is (n-1)]
Ydaystat ydaystd Multi-year daily standard deviation
Ydaystat ydaystd1 Multi-year daily standard deviation [Divisor is (n-1)]
*/
#include <cdi.h>
......@@ -44,7 +46,6 @@ void *Ydaystat(void *argument)
int i;
int varID;
int recID;
int gridID;
int vdate, vtime;
int year, month, day, dayoy;
int nrecs, nrecords;
......@@ -58,7 +59,8 @@ void *Ydaystat(void *argument)
int nvars, nlevel;
int *recVarID, *recLevelID;
int vdates[NDAY], vtimes[NDAY];
double missval;
int lmean = FALSE, lvarstd = FALSE, lstd = FALSE;
double divisor;
field_t **vars1[NDAY], **vars2[NDAY], **samp1[NDAY];
field_t field;
......@@ -70,11 +72,18 @@ void *Ydaystat(void *argument)
cdoOperatorAdd("ydaymean", func_mean, 0, NULL);
cdoOperatorAdd("ydayavg", func_avg, 0, NULL);
cdoOperatorAdd("ydayvar", func_var, 0, NULL);
cdoOperatorAdd("ydayvar1", func_var1, 0, NULL);
cdoOperatorAdd("ydaystd", func_std, 0, NULL);
cdoOperatorAdd("ydaystd1", func_std1, 0, NULL);
operatorID = cdoOperatorID();
operfunc = cdoOperatorF1(operatorID);
lmean = operfunc == func_mean || operfunc == func_avg;
lstd = operfunc == func_std || operfunc == func_std1;
lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
divisor = operfunc == func_std1 || operfunc == func_var1;
for ( dayoy = 0; dayoy < NDAY; dayoy++ )
{
vars1[dayoy] = NULL;
......@@ -130,42 +139,10 @@ void *Ydaystat(void *argument)
if ( vars1[dayoy] == NULL )
{
vars1[dayoy] = (field_t **) malloc(nvars*sizeof(field_t *));
samp1[dayoy] = (field_t **) malloc(nvars*sizeof(field_t *));
if ( operfunc == func_std || operfunc == func_var )
vars2[dayoy] = (field_t **) malloc(nvars*sizeof(field_t *));
for ( varID = 0; varID < nvars; varID++ )
{
gridID = vlistInqVarGrid(vlistID1, varID);
gridsize = gridInqSize(gridID);
nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
missval = vlistInqVarMissval(vlistID1, varID);
vars1[dayoy][varID] = (field_t *) malloc(nlevel*sizeof(field_t));
samp1[dayoy][varID] = (field_t *) malloc(nlevel*sizeof(field_t));
if ( operfunc == func_std || operfunc == func_var )
vars2[dayoy][varID] = (field_t *) malloc(nlevel*sizeof(field_t));
for ( levelID = 0; levelID < nlevel; levelID++ )
{
vars1[dayoy][varID][levelID].grid = gridID;
vars1[dayoy][varID][levelID].nmiss = 0;
vars1[dayoy][varID][levelID].missval = missval;
vars1[dayoy][varID][levelID].ptr = (double *) malloc(gridsize*sizeof(double));
samp1[dayoy][varID][levelID].grid = gridID;
samp1[dayoy][varID][levelID].nmiss = 0;
samp1[dayoy][varID][levelID].missval = missval;
samp1[dayoy][varID][levelID].ptr = NULL;
if ( operfunc == func_std || operfunc == func_var )
{
vars2[dayoy][varID][levelID].grid = gridID;
vars2[dayoy][varID][levelID].nmiss = 0;
vars2[dayoy][varID][levelID].missval = missval;
vars2[dayoy][varID][levelID].ptr = (double *) malloc(gridsize*sizeof(double));
}
}
}
vars1[dayoy] = field_malloc(vlistID1, FIELD_PTR);
samp1[dayoy] = field_malloc(vlistID1, FIELD_NONE);
if ( lvarstd )
vars2[dayoy] = field_malloc(vlistID1, FIELD_PTR);
}
for ( recID = 0; recID < nrecs; recID++ )
......@@ -218,7 +195,7 @@ void *Ydaystat(void *argument)
samp1[dayoy][varID][levelID].ptr[i]++;
}
if ( operfunc == func_std || operfunc == func_var )
if ( lvarstd )
{
farsumq(&vars2[dayoy][varID][levelID], field);
farsum(&vars1[dayoy][varID][levelID], field);
......@@ -230,7 +207,7 @@ void *Ydaystat(void *argument)
}
}
if ( nsets[dayoy] == 0 && (operfunc == func_std || operfunc == func_var) )
if ( nsets[dayoy] == 0 && lvarstd )
for ( varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
......@@ -247,7 +224,7 @@ void *Ydaystat(void *argument)
for ( dayoy = 0; dayoy < NDAY; dayoy++ )
if ( nsets[dayoy] )
{
if ( operfunc == func_mean || operfunc == func_avg )
if ( lmean )
for ( varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
......@@ -260,7 +237,7 @@ void *Ydaystat(void *argument)
fardiv(&vars1[dayoy][varID][levelID], samp1[dayoy][varID][levelID]);
}
}
else if ( operfunc == func_std || operfunc == func_var )
else if ( lvarstd )
for ( varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
......@@ -269,18 +246,17 @@ void *Ydaystat(void *argument)
{
if ( samp1[dayoy][varID][levelID].ptr == NULL )
{
if ( operfunc == func_std )
farcstd(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], 1.0/nsets[dayoy]);
if ( lstd )
farcstdx(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], nsets[dayoy], divisor);
else
farcvar(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], 1.0/nsets[dayoy]);
farcvarx(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], nsets[dayoy], divisor);
}
else
{
farinv(&samp1[dayoy][varID][levelID]);
if ( operfunc == func_std )
farstd(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], samp1[dayoy][varID][levelID]);
if ( lstd )
farstdx(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], samp1[dayoy][varID][levelID], divisor);
else
farvar(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], samp1[dayoy][varID][levelID]);
farvarx(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], samp1[dayoy][varID][levelID], divisor);
}
}
}
......@@ -308,24 +284,9 @@ void *Ydaystat(void *argument)
{
if ( vars1[dayoy] != NULL )
{
for ( varID = 0; varID < nvars; varID++ )
{
nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
for ( levelID = 0; levelID < nlevel; levelID++ )
{
free(vars1[dayoy][varID][levelID].ptr);
if ( samp1[dayoy][varID][levelID].ptr ) free(samp1[dayoy][varID][levelID].ptr);
if ( operfunc == func_std || operfunc == func_var ) free(vars2[dayoy][varID][levelID].ptr);
}
free(vars1[dayoy][varID]);
free(samp1[dayoy][varID]);
if ( operfunc == func_std || operfunc == func_var ) free(vars2[dayoy][varID]);
}
free(vars1[dayoy]);
free(samp1[dayoy]);
if ( operfunc == func_std || operfunc == func_var ) free(vars2[dayoy]);
field_free(vars1[dayoy], vlistID1);
field_free(samp1[dayoy], vlistID1);
if ( lvarstd ) field_free(vars2[dayoy], vlistID1);
}
}
......
......@@ -462,7 +462,7 @@ void *Maggraph(void *argument);
#define YAROperators {"yarbil", "yarnn", "yarcon"}
#define YdayarithOperators {"ydayadd", "ydaysub", "ydaymul", "ydaydiv"}
#define YdaypctlOperators {"ydaypctl"}
#define YdaystatOperators {"ydaymin", "ydaymax", "ydaysum", "ydaymean", "ydayavg", "ydayvar", "ydaystd"}
#define YdaystatOperators {"ydaymin", "ydaymax", "ydaysum", "ydaymean", "ydayavg", "ydaystd", "ydaystd1", "ydayvar", "ydayvar1"}
#define YdrunpctlOperators {"ydrunpctl"}
#define YdrunstatOperators {"ydrunmin", "ydrunmax", "ydrunsum", "ydrunmean", "ydrunavg", "ydrunvar", "ydrunstd"}
#define YhourarithOperators {"yhouradd", "yhoursub", "yhourmul", "yhourdiv"}
......
......@@ -2504,8 +2504,8 @@ static char *YhourstatHelp[] = {
static char *YdaystatHelp[] = {
"NAME",
" ydaymin, ydaymax, ydaysum, ydaymean, ydayavg, ydayvar, ydaystd - ",
" Multi-year daily statistical values",
" ydaymin, ydaymax, ydaysum, ydaymean, ydayavg, ydaystd, ydaystd1, ydayvar, ",
" ydayvar1 - Multi-year daily statistical values",
"",
"SYNOPSIS",
" <operator> ifile ofile",
......@@ -2537,14 +2537,30 @@ static char *YdaystatHelp[] = {
" o(001,x) = avg{i(t,x), day(i(t)) = 001}",
" ...",
" o(366,x) = avg{i(t,x), day(i(t)) = 366}",
" ydaystd Multi-year daily standard deviation",
" Divisor is n. ",
" ",
" o(001,x) = std{i(t,x), day(i(t)) = 001}",
" ...",
" o(366,x) = std{i(t,x), day(i(t)) = 366}",
" ydaystd1 Multi-year daily standard deviation",
" Divisor is (n-1). ",
" ",
" o(001,x) = std1{i(t,x), day(i(t)) = 001}",
" ...",
" o(366,x) = std1{i(t,x), day(i(t)) = 366}",
" ydayvar Multi-year daily variance",
" Divisor is n. ",
" ",
" o(001,x) = var{i(t,x), day(i(t)) = 001}",
" ...",
" o(366,x) = var{i(t,x), day(i(t)) = 366}",
" ydaystd Multi-year daily standard deviation",
" o(001,x) = std{i(t,x), day(i(t)) = 001}",
" ydayvar1 Multi-year daily variance",
" Divisor is (n-1). ",
" ",
" o(001,x) = var1{i(t,x), day(i(t)) = 001}",
" ...",
" o(366,x) = std{i(t,x), day(i(t)) = 366}",
" o(366,x) = var1{i(t,x), day(i(t)) = 366}",
NULL
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment