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

Added operator yseasrange.

parent 002a1d1c
......@@ -103,11 +103,11 @@ void *Seasstat(void *argument)
dtlist_set_stat(dtlist, timestat_date);
dtlist_set_calendar(dtlist, taxisInqCalendar(taxisID1));
int gridsize = vlistGridsizeMax(vlistID1);
int gridsizemax = vlistGridsizeMax(vlistID1);
field_type field;
field_init(&field);
field.ptr = (double*) Malloc(gridsize*sizeof(double));
field.ptr = (double*) Malloc(gridsizemax*sizeof(double));
field_type **samp1 = field_malloc(vlistID1, FIELD_NONE);
field_type **vars1 = field_malloc(vlistID1, FIELD_PTR);
......@@ -162,7 +162,7 @@ void *Seasstat(void *argument)
field_type *pvars1 = &vars1[varID][levelID];
field_type *pvars2 = vars2 ? &vars2[varID][levelID] : NULL;
gridsize = pvars1->size;
int gridsize = pvars1->size;
if ( nsets == 0 )
{
......
......@@ -18,6 +18,7 @@
/*
This module contains the following operators:
Yseasstat yseasrange Multi-year seasonally range
Yseasstat yseasmin Multi-year seasonally minimum
Yseasstat yseasmax Multi-year seasonally maximum
Yseasstat yseassum Multi-year seasonally sum
......@@ -77,15 +78,16 @@ void *Yseasstat(void *argument)
cdoInitialize(argument);
cdoOperatorAdd("yseasmin", func_min, 0, NULL);
cdoOperatorAdd("yseasmax", func_max, 0, NULL);
cdoOperatorAdd("yseassum", func_sum, 0, NULL);
cdoOperatorAdd("yseasmean", func_mean, 0, NULL);
cdoOperatorAdd("yseasavg", func_avg, 0, NULL);
cdoOperatorAdd("yseasvar", func_var, 0, NULL);
cdoOperatorAdd("yseasvar1", func_var1, 0, NULL);
cdoOperatorAdd("yseasstd", func_std, 0, NULL);
cdoOperatorAdd("yseasstd1", func_std1, 0, NULL);
cdoOperatorAdd("yseasrange", func_range, 0, NULL);
cdoOperatorAdd("yseasmin", func_min, 0, NULL);
cdoOperatorAdd("yseasmax", func_max, 0, NULL);
cdoOperatorAdd("yseassum", func_sum, 0, NULL);
cdoOperatorAdd("yseasmean", func_mean, 0, NULL);
cdoOperatorAdd("yseasavg", func_avg, 0, NULL);
cdoOperatorAdd("yseasvar", func_var, 0, NULL);
cdoOperatorAdd("yseasvar1", func_var1, 0, NULL);
cdoOperatorAdd("yseasstd", func_std, 0, NULL);
cdoOperatorAdd("yseasstd1", func_std1, 0, NULL);
int operatorID = cdoOperatorID();
int operfunc = cdoOperatorF1(operatorID);
......@@ -100,10 +102,11 @@ void *Yseasstat(void *argument)
datetime[seas].vtime = 0;
}
bool lrange = operfunc == func_range;
bool lmean = operfunc == func_mean || operfunc == func_avg;
bool lstd = operfunc == func_std || operfunc == func_std1;
bool lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
int divisor = operfunc == func_std1 || operfunc == func_var1;
int divisor = operfunc == func_std1 || operfunc == func_var1;
int streamID1 = streamOpenRead(cdoStreamName(0));
......@@ -123,11 +126,11 @@ void *Yseasstat(void *argument)
recinfo_t *recinfo = (recinfo_t *) Malloc(maxrecs*sizeof(recinfo_t));
int gridsize = vlistGridsizeMax(vlistID1);
int gridsizemax = vlistGridsizeMax(vlistID1);
field_type field;
field_init(&field);
field.ptr = (double*) Malloc(gridsize*sizeof(double));
field.ptr = (double*) Malloc(gridsizemax*sizeof(double));
int tsID = 0;
int otsID = 0;
......@@ -145,7 +148,7 @@ void *Yseasstat(void *argument)
{
vars1[seas] = field_malloc(vlistID1, FIELD_PTR);
samp1[seas] = field_malloc(vlistID1, FIELD_NONE);
if ( lvarstd )
if ( lvarstd || lrange )
vars2[seas] = field_malloc(vlistID1, FIELD_PTR);
}
......@@ -162,12 +165,18 @@ void *Yseasstat(void *argument)
field_type *pvars1 = &vars1[seas][varID][levelID];
field_type *pvars2 = vars2[seas] ? &vars2[seas][varID][levelID] : NULL;
gridsize = pvars1->size;
int gridsize = pvars1->size;
if ( nsets[seas] == 0 )
{
streamReadRecord(streamID1, pvars1->ptr, &nmiss);
pvars1->nmiss = (size_t)nmiss;
if ( lrange )
{
pvars2->nmiss = pvars1->nmiss;
for ( int i = 0; i < gridsize; i++ )
pvars2->ptr[i] = pvars1->ptr[i];
}
if ( nmiss > 0 || samp1[seas][varID][levelID].ptr )
{
......@@ -204,6 +213,11 @@ void *Yseasstat(void *argument)
farsumq(pvars2, field);
farsum(pvars1, field);
}
else if ( lrange )
{
farmin(pvars2, field);
farmax(pvars1, field);
}
else
{
farfun(pvars1, field, operfunc);
......@@ -266,6 +280,18 @@ void *Yseasstat(void *argument)
else farvar(pvars1, *pvars2, samp1[seas][varID][levelID], divisor);
}
}
else if ( lrange )
for ( int recID = 0; recID < maxrecs; recID++ )
{
int varID = recinfo[recID].varID;
int levelID = recinfo[recID].levelID;
field_type *pvars1 = &vars1[seas][varID][levelID];
field_type *pvars2 = &vars2[seas][varID][levelID];
if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
farsub(pvars1, *pvars2);
}
taxisDefVdate(taxisID2, datetime[seas].vdate);
taxisDefVtime(taxisID2, datetime[seas].vtime);
......
......@@ -509,7 +509,7 @@ void *Samplegrid(void *argument); // "samplegrid", "subgrid"
#define YmonpctlOperators {"ymonpctl"}
#define YmonstatOperators {"ymonmin", "ymonmax", "ymonsum", "ymonmean", "ymonavg", "ymonstd", "ymonstd1", "ymonvar", "ymonvar1"}
#define YseaspctlOperators {"yseaspctl"}
#define YseasstatOperators {"yseasmin", "yseasmax", "yseassum", "yseasmean", "yseasavg", "yseasstd", "yseasstd1", "yseasvar", "yseasvar1"}
#define YseasstatOperators {"yseasrange", "yseasmin", "yseasmax", "yseassum", "yseasmean", "yseasavg", "yseasstd", "yseasstd1", "yseasvar", "yseasvar1"}
#define ZonstatOperators {"zonrange", "zonmin", "zonmax", "zonsum", "zonmean", "zonavg", "zonstd", "zonstd1", "zonvar", "zonvar1", "zonpctl"}
#define EcaCfdOperators {"eca_cfd"}
......
......@@ -9,7 +9,7 @@ COMP_REF = comp_eqc_ref comp_gec_ref comp_gtc_ref comp_lec_ref comp_ltc_ref
EOF_REF = eval_ref eof_ref pcoeff00000
YDRUNSTAT_REF = ydrunmin_ref ydrunmax_ref ydrunsum_ref ydrunavg_ref ydrunmean_ref ydrunstd_ref ydrunstd1_ref ydrunvar_ref ydrunvar1_ref
YMONSTAT_REF = ymonmin_ref ymonmax_ref ymonsum_ref ymonavg_ref ymonmean_ref ymonstd_ref ymonstd1_ref ymonvar_ref ymonvar1_ref
YSEASSTAT_REF = yseasmin_ref yseasmax_ref yseassum_ref yseasavg_ref yseasmean_ref yseasstd_ref yseasstd1_ref yseasvar_ref yseasvar1_ref
YSEASSTAT_REF = yseasmin_ref yseasmax_ref yseassum_ref yseasavg_ref yseasmean_ref yseasstd_ref yseasstd1_ref yseasvar_ref yseasvar1_ref yseasrange_ref
SEASSTAT_REF = seasmin_ref seasmax_ref seassum_ref seasavg_ref seasmean_ref seasstd_ref seasstd1_ref seasvar_ref seasvar1_ref seasrange_ref
RUNSTAT_REF = runmin_ref runmax_ref runsum_ref runavg_ref runmean_ref runstd_ref runstd1_ref runvar_ref runvar1_ref runrange_ref
TIMSTAT_REF = timmin_ref timmax_ref timsum_ref timavg_ref timmean_ref timstd_ref timstd1_ref timvar_ref timvar1_ref timrange_ref
......
......@@ -299,7 +299,7 @@ COMP_REF = comp_eqc_ref comp_gec_ref comp_gtc_ref comp_lec_ref comp_ltc_ref comp
EOF_REF = eval_ref eof_ref pcoeff00000
YDRUNSTAT_REF = ydrunmin_ref ydrunmax_ref ydrunsum_ref ydrunavg_ref ydrunmean_ref ydrunstd_ref ydrunstd1_ref ydrunvar_ref ydrunvar1_ref
YMONSTAT_REF = ymonmin_ref ymonmax_ref ymonsum_ref ymonavg_ref ymonmean_ref ymonstd_ref ymonstd1_ref ymonvar_ref ymonvar1_ref
YSEASSTAT_REF = yseasmin_ref yseasmax_ref yseassum_ref yseasavg_ref yseasmean_ref yseasstd_ref yseasstd1_ref yseasvar_ref yseasvar1_ref
YSEASSTAT_REF = yseasmin_ref yseasmax_ref yseassum_ref yseasavg_ref yseasmean_ref yseasstd_ref yseasstd1_ref yseasvar_ref yseasvar1_ref yseasrange_ref
SEASSTAT_REF = seasmin_ref seasmax_ref seassum_ref seasavg_ref seasmean_ref seasstd_ref seasstd1_ref seasvar_ref seasvar1_ref seasrange_ref
RUNSTAT_REF = runmin_ref runmax_ref runsum_ref runavg_ref runmean_ref runstd_ref runstd1_ref runvar_ref runvar1_ref runrange_ref
TIMSTAT_REF = timmin_ref timmax_ref timsum_ref timavg_ref timmean_ref timstd_ref timstd1_ref timvar_ref timvar1_ref timrange_ref
......
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