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

Vertstat: cleanup

parent dc76f561
......@@ -93,7 +93,6 @@ void *Fldstat(void *argument)
int index;
int recID, nrecs;
int varID, levelID;
int needWeights = FALSE;
int nmiss;
double sglval;
field_t field;
......@@ -104,16 +103,17 @@ void *Fldstat(void *argument)
cdoOperatorAdd("fldmin", func_min, 0, NULL);
cdoOperatorAdd("fldmax", func_max, 0, NULL);
cdoOperatorAdd("fldsum", func_sum, 0, NULL);
cdoOperatorAdd("fldmean", func_mean, 0, NULL);
cdoOperatorAdd("fldavg", func_avg, 0, NULL);
cdoOperatorAdd("fldstd", func_std, 0, NULL);
cdoOperatorAdd("fldstd1", func_std1, 0, NULL);
cdoOperatorAdd("fldvar", func_var, 0, NULL);
cdoOperatorAdd("fldvar1", func_var1, 0, NULL);
cdoOperatorAdd("fldmean", func_mean, 1, NULL);
cdoOperatorAdd("fldavg", func_avg, 1, NULL);
cdoOperatorAdd("fldstd", func_std, 1, NULL);
cdoOperatorAdd("fldstd1", func_std1, 1, NULL);
cdoOperatorAdd("fldvar", func_var, 1, NULL);
cdoOperatorAdd("fldvar1", func_var1, 1, NULL);
cdoOperatorAdd("fldpctl", func_pctl, 0, NULL);
int operatorID = cdoOperatorID();
int operfunc = cdoOperatorF1(operatorID);
int needWeights = cdoOperatorF2(operatorID);
if ( operfunc == func_pctl )
{
......@@ -126,11 +126,8 @@ void *Fldstat(void *argument)
int useweights = TRUE;
if ( operfunc == func_mean || operfunc == func_avg ||
operfunc == func_var || operfunc == func_std ||
operfunc == func_var1 || operfunc == func_std1 )
if ( needWeights )
{
needWeights = TRUE;
unsigned npar = operatorArgc();
if ( npar > 0 )
{
......
......@@ -177,8 +177,8 @@ void *Vertstat(void *argument)
cdoOperatorAdd("vertmax", func_max, 0, NULL);
cdoOperatorAdd("vertsum", func_sum, 0, NULL);
int VERTINT = cdoOperatorAdd("vertint", func_sum, 1, NULL);
int VERTMEAN = cdoOperatorAdd("vertmean", func_mean, 1, NULL);
int VERTAVG = cdoOperatorAdd("vertavg", func_avg, 1, NULL);
cdoOperatorAdd("vertmean", func_mean, 1, NULL);
cdoOperatorAdd("vertavg", func_avg, 1, NULL);
cdoOperatorAdd("vertvar", func_var, 0, NULL);
cdoOperatorAdd("vertvar1", func_var1, 0, NULL);
cdoOperatorAdd("vertstd", func_std, 0, NULL);
......@@ -193,6 +193,8 @@ void *Vertstat(void *argument)
int lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
double divisor = operfunc == func_std1 || operfunc == func_var1;
int applyWeights = lmean;
int streamID1 = streamOpenRead(cdoStreamName(0));
int vlistID1 = streamInqVlist(streamID1);
......@@ -338,8 +340,7 @@ void *Vertstat(void *argument)
vars1[varID].nmiss = nmiss;
if ( operatorID == VERTINT && IS_NOT_EQUAL(layer_thickness, 1.0) ) farcmul(&vars1[varID], layer_thickness);
if ( (operatorID == VERTMEAN || operatorID == VERTAVG) && IS_NOT_EQUAL(layer_weight, 1.0) )
farcmul(&vars1[varID], layer_weight);
if ( applyWeights && IS_NOT_EQUAL(layer_weight, 1.0) ) farcmul(&vars1[varID], layer_weight);
if ( lvarstd )
farmoq(&vars2[varID], vars1[varID]);
......@@ -363,8 +364,7 @@ void *Vertstat(void *argument)
field.missval = vars1[varID].missval;
if ( operatorID == VERTINT && IS_NOT_EQUAL(layer_thickness, 1.0) ) farcmul(&field, layer_thickness);
if ( (operatorID == VERTMEAN || operatorID == VERTAVG) && IS_NOT_EQUAL(layer_weight, 1.0) )
farcmul(&field, layer_weight);
if ( applyWeights && IS_NOT_EQUAL(layer_weight, 1.0) ) farcmul(&field, layer_weight);
if ( field.nmiss > 0 || samp1[varID].ptr )
{
......
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