Commit 08a98270 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Fldstat: added parameter noweights to use constant grid cell area weights

parent 051c2db4
2015-09-26 Uwe Schulzweida
2015-03-27 Uwe Schulzweida
* Fldstat: added parameter noweights to use constant grid cell area weights
* expr: added support for operator ?:,&&,||
2015-03-26 Uwe Schulzweida
......
......@@ -126,10 +126,26 @@ void *Fldstat(void *argument)
cdoAbort("Illegal argument: percentile number %d is not in the range 1..99!", pn);
}
int useweights = TRUE;
if ( operfunc == func_mean || operfunc == func_avg ||
operfunc == func_var || operfunc == func_std ||
operfunc == func_var1 || operfunc == func_std1 )
needWeights = TRUE;
{
needWeights = TRUE;
unsigned npar = operatorArgc();
if ( npar > 0 )
{
char **parnames = operatorArgv();
if ( cdoVerbose )
for ( unsigned i = 0; i < npar; i++ )
cdoPrint("key %u = %s", i+1, parnames[i]);
if ( strcmp(parnames[0], "noweights") == 0 ) useweights = FALSE;
else cdoAbort("Parameter >%s< unsupported! Supported parameter are: noweights", parnames[0]);
}
}
int streamID1 = streamOpenRead(cdoStreamName(0));
......@@ -163,7 +179,14 @@ void *Fldstat(void *argument)
field.ptr = (double*) malloc(lim*sizeof(double));
field.weight = NULL;
if ( needWeights )
field.weight = (double*) malloc(lim*sizeof(double));
{
field.weight = (double*) malloc(lim*sizeof(double));
if ( !useweights )
{
cdoPrint("Using constant grid cell area weights!");
for ( int i = 0; i < lim; ++i ) field.weight[i] = 1;
}
}
int tsID = 0;
while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
......@@ -194,14 +217,14 @@ void *Fldstat(void *argument)
{
lastgrid = field.grid;
field.weight[0] = 1;
if ( field.size > 1 )
if ( useweights && field.size > 1 )
{
int wstatus = gridWeights(field.grid, field.weight);
int wstatus = wstatus = gridWeights(field.grid, field.weight);
if ( wstatus != 0 && tsID == 0 && levelID == 0 )
{
char varname[CDI_MAX_NAME];
vlistInqVarName(vlistID1, varID, varname);
cdoWarning("Using constant grid cell area weights for variable %s!", varname);
cdoWarning("Grid cell bounds not available, using constant grid cell area weights for variable %s!", varname);
}
}
}
......
......@@ -203,13 +203,13 @@ void *Vertstat(void *argument)
if ( needWeights )
{
int genbounds = FALSE;
int npar = operatorArgc();
unsigned npar = operatorArgc();
if ( npar > 0 )
{
char **parnames = operatorArgv();
if ( cdoVerbose )
for ( i = 0; i < npar; i++ )
for ( unsigned i = 0; i < npar; i++ )
cdoPrint("key %d = %s", i+1, parnames[i]);
if ( strcmp(parnames[0], "genbounds") == 0 ) genbounds = TRUE;
......
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