Commit e28e8b92 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

New operator: seasstd1 - Seasonal standard deviation [Divisor is (n-1)]

parent 8fc4869f
......@@ -3,6 +3,11 @@
* using CDI library version 1.7.0
* Version 1.7.0 released
2015-05-22 Uwe Schulzweida
* New operator: seasvar1 - Seasonal variance [Divisor is (n-1)]
* New operator: seasstd1 - Seasonal standard deviation [Divisor is (n-1)]
2015-05-21 Uwe Schulzweida
* after: extent incomming GEOPOTHEIGHT on full 3d hybrid levels to half 3d hybrid levels (bug fix)
......
......@@ -3,6 +3,9 @@ CDO NEWS
Version 1.7.0 (28 October 2015):
New operators:
* seasvar1: Seasonal variance [Divisor is (n-1)]
* seasstd1: Seasonal standard deviation [Divisor is (n-1)]
Fixed bugs:
* env. CDO_TIMESTAT_DATE does not work [Bug #5758]
* splityear*: support for constant fields is missing [Bug #5759]
......
......@@ -24,7 +24,9 @@
Seasstat seasmean Seasonal mean
Seasstat seasavg Seasonal average
Seasstat seasvar Seasonal variance
Seasstat seasvar1 Seasonal variance [Divisor is (n-1)]
Seasstat seasstd Seasonal standard deviation
Seasstat seasstd1 Seasonal standard deviation [Divisor is (n-1)]
*/
......@@ -44,8 +46,6 @@ void *Seasstat(void *argument)
int vdate1 = 0, vtime1 = 0;
int nrecs;
int varID, levelID, recID;
int tsID;
int otsID;
long nsets;
int i;
int year, month, day, seas, seas0 = 0;
......@@ -53,9 +53,6 @@ void *Seasstat(void *argument)
int nlevel;
int newseas, oldmon = 0, newmon;
int nseason = 0;
field_t **vars1 = NULL, **vars2 = NULL, **samp1 = NULL;
field_t field;
int season_start;
const char *seas_name[4];
cdoInitialize(argument);
......@@ -66,14 +63,21 @@ void *Seasstat(void *argument)
cdoOperatorAdd("seasmean", func_mean, 0, NULL);
cdoOperatorAdd("seasavg", func_avg, 0, NULL);
cdoOperatorAdd("seasvar", func_var, 0, NULL);
cdoOperatorAdd("seasvar1", func_var1, 0, NULL);
cdoOperatorAdd("seasstd", func_std, 0, NULL);
cdoOperatorAdd("seasstd1", func_std1, 0, NULL);
int operatorID = cdoOperatorID();
int operfunc = cdoOperatorF1(operatorID);
season_start = get_season_start();
int season_start = get_season_start();
get_season_name(seas_name);
int lmean = operfunc == func_mean || operfunc == func_avg;
int lstd = operfunc == func_std || operfunc == func_std1;
int lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
double divisor = operfunc == func_std1 || operfunc == func_var1;
int streamID1 = streamOpenRead(cdoStreamName(0));
int vlistID1 = streamInqVlist(streamID1);
......@@ -100,16 +104,17 @@ void *Seasstat(void *argument)
gridsize = vlistGridsizeMax(vlistID1);
field_t field;
field_init(&field);
field.ptr = (double*) malloc(gridsize*sizeof(double));
vars1 = field_malloc(vlistID1, FIELD_PTR);
samp1 = field_malloc(vlistID1, FIELD_NONE);
if ( operfunc == func_std || operfunc == func_var )
vars2 = field_malloc(vlistID1, FIELD_PTR);
field_t **samp1 = field_malloc(vlistID1, FIELD_NONE);
field_t **vars1 = field_malloc(vlistID1, FIELD_PTR);
field_t **vars2 = NULL;
if ( lvarstd ) vars2 = field_malloc(vlistID1, FIELD_PTR);
tsID = 0;
otsID = 0;
int tsID = 0;
int otsID = 0;
while ( TRUE )
{
nsets = 0;
......@@ -211,7 +216,7 @@ void *Seasstat(void *argument)
samp1[varID][levelID].ptr[i]++;
}
if ( operfunc == func_std || operfunc == func_var )
if ( lvarstd )
{
farsumq(&vars2[varID][levelID], field);
farsum(&vars1[varID][levelID], field);
......@@ -223,7 +228,7 @@ void *Seasstat(void *argument)
}
}
if ( nsets == 0 && (operfunc == func_std || operfunc == func_var) )
if ( nsets == 0 && lvarstd )
for ( varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
......@@ -240,7 +245,7 @@ void *Seasstat(void *argument)
if ( nrecs == 0 && nsets == 0 ) break;
if ( operfunc == func_mean || operfunc == func_avg )
if ( lmean )
for ( varID = 0; varID < nvars; varID++ )
{
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
......@@ -253,7 +258,7 @@ void *Seasstat(void *argument)
fardiv(&vars1[varID][levelID], samp1[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;
......@@ -262,18 +267,17 @@ void *Seasstat(void *argument)
{
if ( samp1[varID][levelID].ptr == NULL )
{
if ( operfunc == func_std )
farcstd(&vars1[varID][levelID], vars2[varID][levelID], 1.0/nsets);
if ( lstd )
farcstdx(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
else
farcvar(&vars1[varID][levelID], vars2[varID][levelID], 1.0/nsets);
farcvarx(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
}
else
{
farinv(&samp1[varID][levelID]);
if ( operfunc == func_std )
farstd(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID]);
if ( lstd )
farstdx(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
else
farvar(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID]);
farvarx(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
}
}
}
......@@ -287,8 +291,7 @@ void *Seasstat(void *argument)
date2str(vdate1, vdatestr1, sizeof(vdatestr1));
time2str(vtime1, vtimestr1, sizeof(vtimestr1));
cdoPrint("season %3d %3s start %s %s end %s %s ntimesteps %d",
nseason, seas_name[seas0],
vdatestr0, vtimestr0, vdatestr1, vtimestr1, nsets);
nseason, seas_name[seas0], vdatestr0, vtimestr0, vdatestr1, vtimestr1, nsets);
}
dtlist_stat_taxisDefTimestep(dtlist, taxisID2, nsets);
......@@ -320,7 +323,7 @@ void *Seasstat(void *argument)
field_free(vars1, vlistID1);
field_free(samp1, vlistID1);
if ( operfunc == func_std || operfunc == func_var ) field_free(vars2, vlistID1);
if ( lvarstd ) field_free(vars2, vlistID1);
if ( field.ptr ) free(field.ptr);
......
......@@ -39,7 +39,6 @@
void *Timselstat(void *argument)
{
int timestat_date = TIMESTAT_MEAN;
int gridsize;
int nrecs = 0;
int varID, levelID, recID;
int tsID;
......@@ -47,8 +46,6 @@ void *Timselstat(void *argument)
int i;
int nmiss;
int nlevel;
field_t **vars1 = NULL, **vars2 = NULL, **samp1 = NULL;
field_t field;
cdoInitialize(argument);
......@@ -103,15 +100,16 @@ void *Timselstat(void *argument)
dtlist_set_stat(dtlist, timestat_date);
dtlist_set_calendar(dtlist, taxisInqCalendar(taxisID1));
gridsize = vlistGridsizeMax(vlistID1);
int gridsize = vlistGridsizeMax(vlistID1);
field_t field;
field_init(&field);
field.ptr = (double*) malloc(gridsize*sizeof(double));
vars1 = field_malloc(vlistID1, FIELD_PTR);
samp1 = field_malloc(vlistID1, FIELD_NONE);
if ( lvarstd )
vars2 = field_malloc(vlistID1, FIELD_PTR);
field_t **samp1 = field_malloc(vlistID1, FIELD_NONE);
field_t **vars1 = field_malloc(vlistID1, FIELD_PTR);
field_t **vars2 = NULL;
if ( lvarstd ) vars2 = field_malloc(vlistID1, FIELD_PTR);
for ( tsID = 0; tsID < noffset; tsID++ )
{
......
......@@ -382,10 +382,10 @@ void *Maggraph(void *argument);
#define RhopotOperators {"rhopot"}
#define RotuvOperators {"rotuvb"}
#define RunpctlOperators {"runpctl"}
#define RunstatOperators {"runmin", "runmax", "runsum", "runmean", "runavg", "runstd", "runstd1", "runvar", "runvar1"}
#define RunstatOperators {"runmin", "runmax", "runsum", "runmean", "runavg", "runstd", "runstd1", "runvar", "runvar1"}
#define SeascountOperators {"seascount"}
#define SeaspctlOperators {"seaspctl"}
#define SeasstatOperators {"seasmin", "seasmax", "seassum", "seasmean", "seasavg", "seasvar", "seasstd"}
#define SeasstatOperators {"seasmin", "seasmax", "seassum", "seasmean", "seasavg", "seasstd", "seasstd1", "seasvar", "seasvar1"}
#define SelboxOperators {"sellonlatbox", "selindexbox"}
#define SelectOperators {"select", "delete"}
#define SelvarOperators {"selparam", "selcode", "selname", "selstdname", "sellevel", "sellevidx", "selgrid", \
......
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